Skip to content
97 changes: 97 additions & 0 deletions pages/theming/themed-components.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import React, { useLayoutEffect, useState } from 'react';
import {
AppLayoutToolbar,
Autosuggest,
Box,
Button,
ButtonGroup,
Cards,
Container,
DatePicker,
Grid,
Expand All @@ -19,6 +21,8 @@ import {
SideNavigation,
SpaceBetween,
StatusIndicator,
Table,
Tiles,
ToggleButton,
} from '~components';
import { MultiselectProps } from '~components/multiselect';
Expand Down Expand Up @@ -292,6 +296,95 @@ const generateDropdownOptions = (count = 25): SelectProps.Options | MultiselectP
});
};

interface ItemType {
name: string;
type: string;
size: string;
status: string;
statusType: 'success' | 'error' | 'warning';
}

function TableCardsAndTiles() {
const [selectedItems, setSelectedItems] = useState<ItemType[]>([
{ name: 'Item 2', type: 'Type B', size: '25 KB', status: 'Inactive', statusType: 'error' },
]);
const [selectedTile, setSelectedTile] = useState<string | null>('tile-1');

return (
<SpaceBetween size="l">
<Table
selectionType="multi"
selectedItems={selectedItems}
onSelectionChange={({ detail }) => setSelectedItems(detail.selectedItems)}
trackBy="name"
ariaLabels={{
selectionGroupLabel: 'Items selection',
allItemsSelectionLabel: () => 'select all',
itemSelectionLabel: (_selection, item) => item.name,
}}
columnDefinitions={[
{ id: 'name', header: 'Name', cell: item => item.name },
{ id: 'type', header: 'Type', cell: item => item.type },
{ id: 'size', header: 'Size', cell: item => item.size },
{
id: 'status',
header: 'Status',
cell: item => <StatusIndicator type={item.statusType}>{item.status}</StatusIndicator>,
},
]}
items={[
{ name: 'Item 1', type: 'Type A', size: '10 KB', status: 'Active', statusType: 'success' as const },
{ name: 'Item 2', type: 'Type B', size: '25 KB', status: 'Inactive', statusType: 'error' as const },
{ name: 'Item 3', type: 'Type A', size: '15 KB', status: 'Pending', statusType: 'warning' as const },
]}
header={<Box variant="h3">Table</Box>}
sortingDisabled={true}
/>

<Cards
selectionType="multi"
selectedItems={selectedItems}
onSelectionChange={({ detail }) => setSelectedItems(detail.selectedItems)}
trackBy="name"
ariaLabels={{
selectionGroupLabel: 'Items selection',
itemSelectionLabel: (_selection, item) => item.name,
}}
cardDefinition={{
header: item => item.name,
sections: [
{ id: 'type', header: 'Type', content: item => item.type },
{ id: 'size', header: 'Size', content: item => item.size },
{
id: 'status',
header: 'Status',
content: item => <StatusIndicator type={item.statusType}>{item.status}</StatusIndicator>,
},
],
}}
items={[
{ name: 'Card 1', type: 'Type A', size: '10 KB', status: 'Active', statusType: 'success' as const },
{ name: 'Card 2', type: 'Type B', size: '25 KB', status: 'Inactive', statusType: 'error' as const },
{ name: 'Card 3', type: 'Type A', size: '15 KB', status: 'Pending', statusType: 'warning' as const },
]}
header={<Box variant="h3">Cards</Box>}
cardsPerRow={[{ cards: 3 }]}
/>

<Tiles
value={selectedTile}
onChange={({ detail }) => setSelectedTile(detail.value)}
items={[
{ value: 'tile-1', label: 'Option A', description: 'Description for option A' },
{ value: 'tile-2', label: 'Option B', description: 'Description for option B' },
{ value: 'tile-3', label: 'Option C', description: 'Description for option C' },
]}
columns={3}
/>
</SpaceBetween>
);
}

function AppLayoutToolbarWithDrawers() {
const [activeDrawerId, setActiveDrawerId] = useState<string | null>(null);

Expand Down Expand Up @@ -330,6 +423,8 @@ export default function ThemedComponentsPage() {
borderRadiusButton: '8px',
borderWidthButton: '1px',
borderWidthToken: '1px',
borderWidthItemSelected: '1px',
borderWidthCardSelected: '1px',
},
};

Expand Down Expand Up @@ -373,6 +468,8 @@ export default function ThemedComponentsPage() {
<StatusIndicator type="info">Info</StatusIndicator>
</SpaceBetween>

<TableCardsAndTiles />

<AppLayoutToolbarWithDrawers />
</SpaceBetween>
</div>
Expand Down
6 changes: 6 additions & 0 deletions pages/theming/themed-stroke-width.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ export default function ThemedStrokeWidthPage() {
borderWidthIconMedium: strokeMedium ? `${strokeMedium}px` : '1px',
borderWidthIconBig: strokeBig ? `${strokeBig}px` : '1.5px',
borderWidthIconLarge: strokeLarge ? `${strokeLarge}px` : '2px',
borderRadiusButton: '8px',
fontSizeTabs: '14px',
lineHeightTabs: '16px',
fontWeightTabs: '700',
fontWeightTabsDisabled: '700',
spaceTabsVertical: { comfortable: '2px', compact: '0px' },
},
};

Expand Down
32 changes: 16 additions & 16 deletions src/__integ__/__snapshots__/themes.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ exports[`CSS Custom Properties match previous snapshot for mode "compact" 1`] =
"border-width-alert-inline-start": "1px",
"border-width-button": "1px",
"border-width-card": "0px",
"border-width-card-highlighted": "1px",
"border-width-card-selected": "1px",
"border-width-dropdown": "1px",
"border-width-field": "1px",
"border-width-icon-big": "3px",
Expand All @@ -61,7 +61,7 @@ exports[`CSS Custom Properties match previous snapshot for mode "compact" 1`] =
"border-width-icon-normal": "2px",
"border-width-icon-small": "2px",
"border-width-item-card": "0px",
"border-width-item-card-highlighted": "1px",
"border-width-item-selected": "2px",
"border-width-popover": "1px",
"border-width-token": "1px",
"color-aws-squid-ink": "#232f3e",
Expand Down Expand Up @@ -861,7 +861,7 @@ exports[`CSS Custom Properties match previous snapshot for mode "dark" 1`] = `
"border-width-alert-inline-start": "1px",
"border-width-button": "1px",
"border-width-card": "0px",
"border-width-card-highlighted": "1px",
"border-width-card-selected": "1px",
"border-width-dropdown": "1px",
"border-width-field": "1px",
"border-width-icon-big": "3px",
Expand All @@ -870,7 +870,7 @@ exports[`CSS Custom Properties match previous snapshot for mode "dark" 1`] = `
"border-width-icon-normal": "2px",
"border-width-icon-small": "2px",
"border-width-item-card": "0px",
"border-width-item-card-highlighted": "1px",
"border-width-item-selected": "2px",
"border-width-popover": "1px",
"border-width-token": "1px",
"color-aws-squid-ink": "#232f3e",
Expand Down Expand Up @@ -1670,7 +1670,7 @@ exports[`CSS Custom Properties match previous snapshot for mode "light" 1`] = `
"border-width-alert-inline-start": "1px",
"border-width-button": "1px",
"border-width-card": "0px",
"border-width-card-highlighted": "1px",
"border-width-card-selected": "1px",
"border-width-dropdown": "1px",
"border-width-field": "1px",
"border-width-icon-big": "3px",
Expand All @@ -1679,7 +1679,7 @@ exports[`CSS Custom Properties match previous snapshot for mode "light" 1`] = `
"border-width-icon-normal": "2px",
"border-width-icon-small": "2px",
"border-width-item-card": "0px",
"border-width-item-card-highlighted": "1px",
"border-width-item-selected": "2px",
"border-width-popover": "1px",
"border-width-token": "1px",
"color-aws-squid-ink": "#232f3e",
Expand Down Expand Up @@ -2479,7 +2479,7 @@ exports[`CSS Custom Properties match previous snapshot for mode "reduced-motion"
"border-width-alert-inline-start": "1px",
"border-width-button": "1px",
"border-width-card": "0px",
"border-width-card-highlighted": "1px",
"border-width-card-selected": "1px",
"border-width-dropdown": "1px",
"border-width-field": "1px",
"border-width-icon-big": "3px",
Expand All @@ -2488,7 +2488,7 @@ exports[`CSS Custom Properties match previous snapshot for mode "reduced-motion"
"border-width-icon-normal": "2px",
"border-width-icon-small": "2px",
"border-width-item-card": "0px",
"border-width-item-card-highlighted": "1px",
"border-width-item-selected": "2px",
"border-width-popover": "1px",
"border-width-token": "1px",
"color-aws-squid-ink": "#232f3e",
Expand Down Expand Up @@ -3288,7 +3288,7 @@ exports[`CSS Custom Properties match previous snapshot for mode "visual-refresh"
"border-width-alert-inline-start": "2px",
"border-width-button": "2px",
"border-width-card": "1px",
"border-width-card-highlighted": "2px",
"border-width-card-selected": "2px",
"border-width-dropdown": "2px",
"border-width-field": "1px",
"border-width-icon-big": "3px",
Expand All @@ -3297,7 +3297,7 @@ exports[`CSS Custom Properties match previous snapshot for mode "visual-refresh"
"border-width-icon-normal": "2px",
"border-width-icon-small": "2px",
"border-width-item-card": "1px",
"border-width-item-card-highlighted": "2px",
"border-width-item-selected": "2px",
"border-width-popover": "2px",
"border-width-token": "2px",
"color-aws-squid-ink": "#232f3e",
Expand Down Expand Up @@ -4097,7 +4097,7 @@ exports[`CSS Custom Properties match previous snapshot for mode "visual-refresh-
"border-width-alert-inline-start": "2px",
"border-width-button": "2px",
"border-width-card": "1px",
"border-width-card-highlighted": "2px",
"border-width-card-selected": "2px",
"border-width-dropdown": "2px",
"border-width-field": "1px",
"border-width-icon-big": "3px",
Expand All @@ -4106,7 +4106,7 @@ exports[`CSS Custom Properties match previous snapshot for mode "visual-refresh-
"border-width-icon-normal": "2px",
"border-width-icon-small": "2px",
"border-width-item-card": "1px",
"border-width-item-card-highlighted": "2px",
"border-width-item-selected": "2px",
"border-width-popover": "2px",
"border-width-token": "2px",
"color-aws-squid-ink": "#232f3e",
Expand Down Expand Up @@ -4906,7 +4906,7 @@ exports[`CSS Custom Properties match previous snapshot for mode "visual-refresh-
"border-width-alert-inline-start": "2px",
"border-width-button": "2px",
"border-width-card": "1px",
"border-width-card-highlighted": "2px",
"border-width-card-selected": "2px",
"border-width-dropdown": "2px",
"border-width-field": "1px",
"border-width-icon-big": "3px",
Expand All @@ -4915,7 +4915,7 @@ exports[`CSS Custom Properties match previous snapshot for mode "visual-refresh-
"border-width-icon-normal": "2px",
"border-width-icon-small": "2px",
"border-width-item-card": "1px",
"border-width-item-card-highlighted": "2px",
"border-width-item-selected": "2px",
"border-width-popover": "2px",
"border-width-token": "2px",
"color-aws-squid-ink": "#232f3e",
Expand Down Expand Up @@ -5715,7 +5715,7 @@ exports[`CSS Custom Properties match previous snapshot for mode "visual-refresh-
"border-width-alert-inline-start": "2px",
"border-width-button": "2px",
"border-width-card": "1px",
"border-width-card-highlighted": "2px",
"border-width-card-selected": "2px",
"border-width-dropdown": "2px",
"border-width-field": "1px",
"border-width-icon-big": "3px",
Expand All @@ -5724,7 +5724,7 @@ exports[`CSS Custom Properties match previous snapshot for mode "visual-refresh-
"border-width-icon-normal": "2px",
"border-width-icon-small": "2px",
"border-width-item-card": "1px",
"border-width-item-card-highlighted": "2px",
"border-width-item-selected": "2px",
"border-width-popover": "2px",
"border-width-token": "2px",
"color-aws-squid-ink": "#232f3e",
Expand Down
Loading
Loading