Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic Table Primitive, styling, and docs #568

Merged
merged 50 commits into from
Nov 16, 2021
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
2810f22
Add docs files
slaymance Oct 19, 2021
3231556
Add table demo to docs
slaymance Oct 20, 2021
02d4d57
More primitive and docs updates
slaymance Oct 22, 2021
672add4
Update Table tests
slaymance Oct 22, 2021
2f9f2e6
Add nonStyleProps to table components
slaymance Oct 22, 2021
21c2eee
Update demo with header
slaymance Oct 22, 2021
4af875b
Add other table components
slaymance Oct 22, 2021
5d10732
Update docs and demo
slaymance Oct 23, 2021
7e0fee2
Update stylings to use class names
slaymance Oct 23, 2021
19ab269
Add default styling to table
slaymance Oct 31, 2021
8a1028f
Add data attributes for styling
slaymance Nov 1, 2021
dfba7b3
Add css styling for data attributes
slaymance Nov 1, 2021
45768f0
Update demo with new props controls
slaymance Nov 1, 2021
53f1cba
Minor style corrections
slaymance Nov 1, 2021
59ffee7
Add data-attribute unit tests
slaymance Nov 1, 2021
d443a41
More table styling
slaymance Nov 1, 2021
acf9a3a
Add styling examples for table docs
slaymance Nov 1, 2021
d4ec5c2
Merge remote-tracking branch 'origin/main' into table-primitive
slaymance Nov 1, 2021
3e1e2dd
Add changeset
slaymance Nov 1, 2021
07551ac
Add style prop to Table
slaymance Nov 2, 2021
2237755
Update ui snapshots
slaymance Nov 4, 2021
b712425
Merge remote-tracking branch 'origin/main' into table-primitive
slaymance Nov 4, 2021
ab54148
Update js snapshot
slaymance Nov 4, 2021
3d510c7
Update docs/src/styles/tableStyles.css
slaymance Nov 9, 2021
ff5741f
Update packages/ui/src/theme/css/component/table.scss
slaymance Nov 9, 2021
b3d42c9
Add subcomponent specific style tokens
slaymance Nov 9, 2021
6f55052
Add tokens for all table styles
slaymance Nov 10, 2021
7f18314
Remove text-indent property
slaymance Nov 10, 2021
847730b
Update primitive types
slaymance Nov 10, 2021
8aa92d1
Remove label prop from table
slaymance Nov 10, 2021
45bf32e
Update caption render and style
slaymance Nov 11, 2021
11a36fc
Add hideCaption prop
slaymance Nov 11, 2021
a87d3b0
Remove summary class name
slaymance Nov 11, 2021
f415d66
Update unit tests
slaymance Nov 11, 2021
e021a2f
Remove summary style tokens
slaymance Nov 11, 2021
0dbdbc6
Merge remote-tracking branch 'origin/main' into table-primitive
slaymance Nov 11, 2021
ad6cf63
Remove hideCaption prop
slaymance Nov 11, 2021
cfc9a22
Remove summary prop from docs
slaymance Nov 11, 2021
5505965
Make caption bottom of table by default
slaymance Nov 11, 2021
ec3c059
Explicit file imports
slaymance Nov 11, 2021
9f082aa
Some more component and test updates
slaymance Nov 11, 2021
b99912e
Merge remote-tracking branch 'origin/main' into table-primitive
slaymance Nov 11, 2021
72c083a
Update ui snapshots
slaymance Nov 12, 2021
3290b84
Break out docs examples
slaymance Nov 15, 2021
72d7104
Apply variation styles to non-header components
slaymance Nov 15, 2021
70a4c4c
Correct span props
slaymance Nov 15, 2021
4722ad2
Merge remote-tracking branch 'origin/main' into table-primitive
slaymance Nov 15, 2021
76033f4
Update unit test snapshot
slaymance Nov 15, 2021
c3a14e1
Explicitly include rowspan and colspan props
slaymance Nov 15, 2021
3d98f71
Update react unit test snapshot
slaymance Nov 15, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/polite-rings-roll.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@aws-amplify/ui-react': patch
---

Adds React Table primitive
Comment on lines +1 to +5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😍

95 changes: 95 additions & 0 deletions docs/src/components/TablePropControls.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import React from 'react';
slaymance marked this conversation as resolved.
Show resolved Hide resolved

import {
CheckboxField,
SelectField,
TableProps,
TextField,
} from '@aws-amplify/ui-react';

import { DemoBox } from './DemoBox';
import { FieldLabeler } from './FieldLabeler';

export interface TablePropControlsProps extends TableProps {
setCaption: (value: React.SetStateAction<TableProps['caption']>) => void;
setHighlightOnHover: (
value: React.SetStateAction<TableProps['highlightOnHover']>
) => void;
setSize: (value: React.SetStateAction<TableProps['size']>) => void;
setSummary: (value: React.SetStateAction<TableProps['summary']>) => void;
setVariation: (value: React.SetStateAction<TableProps['variation']>) => void;
}

interface TablePropControlsInterface {
(props: TablePropControlsProps): JSX.Element;
}

export const TablePropControls: TablePropControlsInterface = ({
highlightOnHover,
setCaption,
setHighlightOnHover,
setSize,
setSummary,
setVariation,
size,
variation,
}) => (
<DemoBox primitiveName="Table">
<TextField
id="caption-control"
label="caption"
name="caption-control"
placeholder="Table Caption"
onChange={(event) =>
setCaption(event.target.value as TableProps['caption'])
}
/>
<TextField
id="summary-control"
label="summary"
name="summary-control"
placeholder="Table Summary"
onChange={(event) =>
setSummary(event.target.value as TableProps['summary'])
}
/>
<CheckboxField
name="highlightonhover"
value="false"
checked={highlightOnHover}
onChange={(e) => setHighlightOnHover(e.target.checked)}
>
highlightOnHover
</CheckboxField>
<FieldLabeler id="size">
<SelectField
id="size"
name="size"
label="size"
labelHidden
placeholder="(default)"
value={size}
onChange={(e) => setSize(e.target.value as TableProps['size'])}
>
<option value="small">small</option>
<option value="large">large</option>
</SelectField>
</FieldLabeler>
<FieldLabeler id="variation">
<SelectField
id="variation"
name="variation"
label="variation"
labelHidden
placeholder="(default)"
value={variation}
onChange={(e) =>
setVariation(e.target.value as TableProps['variation'])
}
>
<option value="bordered">bordered</option>
<option value="striped">striped</option>
</SelectField>
</FieldLabeler>
</DemoBox>
);
42 changes: 42 additions & 0 deletions docs/src/components/useTableProps.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { useState } from 'react';
slaymance marked this conversation as resolved.
Show resolved Hide resolved

import { TableProps } from '@aws-amplify/ui-react';

import { TablePropControlsProps } from './TablePropControls';

interface UseTableProps {
(initialValues?: TableProps): TablePropControlsProps;
}

export const useTableProps: UseTableProps = (initialValues) => {
const [caption, setCaption] = useState<TableProps['caption']>(
initialValues.caption
);

const [highlightOnHover, setHighlightOnHover] = useState<
TableProps['highlightOnHover']
>(initialValues.highlightOnHover);

const [size, setSize] = useState<TableProps['size']>(initialValues.size);

const [summary, setSummary] = useState<TableProps['summary']>(
initialValues.summary
);

const [variation, setVariation] = useState<TableProps['variation']>(
initialValues.variation
);

return {
caption,
highlightOnHover,
setCaption,
setHighlightOnHover,
setSize,
setSummary,
setVariation,
size,
summary,
variation,
};
};
64 changes: 64 additions & 0 deletions docs/src/pages/ui/primitives/table/demo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import * as React from 'react';

import {
Flex,
Table,
TableBody,
TableCell,
TableHead,
TableRow,
} from '@aws-amplify/ui-react';

import { Example } from '@/components/Example';
import { TablePropControls } from '@/components/TablePropControls';
import { useTableProps } from '@/components/useTableProps';

export const TableDemo = () => {
const tableProps = useTableProps({
caption: '',
highlightOnHover: false,
size: '',
summary: '',
variation: '',
});

return (
<Flex direction="column" gap="0.5rem">
<TablePropControls {...tableProps} />
<Example>
<Table
caption={tableProps.caption}
highlightOnHover={tableProps.highlightOnHover}
size={tableProps.size}
summary={tableProps.summary}
variation={tableProps.variation}
>
<TableHead>
<TableRow>
<TableCell as="th">Citrus</TableCell>
<TableCell as="th">Stone Fruit</TableCell>
<TableCell as="th">Berry</TableCell>
</TableRow>
</TableHead>
<TableBody>
<TableRow>
<TableCell>Orange</TableCell>
<TableCell>Nectarine</TableCell>
<TableCell>Raspberry</TableCell>
</TableRow>
<TableRow>
<TableCell>Grapefruit</TableCell>
<TableCell>Apricot</TableCell>
<TableCell>Blueberry</TableCell>
</TableRow>
<TableRow>
<TableCell>Lime</TableCell>
<TableCell>Peach</TableCell>
<TableCell>Strawberry</TableCell>
</TableRow>
</TableBody>
</Table>
</Example>
</Flex>
);
};
7 changes: 7 additions & 0 deletions docs/src/pages/ui/primitives/table/index.page.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title: Table
---

import { Fragment } from '@/components/Fragment';

<Fragment>{({ platform }) => import(`./${platform}.mdx`)}</Fragment>
Loading