-
Notifications
You must be signed in to change notification settings - Fork 317
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
Changes from 20 commits
Commits
Show all changes
50 commits
Select commit
Hold shift + click to select a range
2810f22
Add docs files
slaymance 3231556
Add table demo to docs
slaymance 02d4d57
More primitive and docs updates
slaymance 672add4
Update Table tests
slaymance 2f9f2e6
Add nonStyleProps to table components
slaymance 21c2eee
Update demo with header
slaymance 4af875b
Add other table components
slaymance 5d10732
Update docs and demo
slaymance 7e0fee2
Update stylings to use class names
slaymance 19ab269
Add default styling to table
slaymance 8a1028f
Add data attributes for styling
slaymance dfba7b3
Add css styling for data attributes
slaymance 45768f0
Update demo with new props controls
slaymance 53f1cba
Minor style corrections
slaymance 59ffee7
Add data-attribute unit tests
slaymance d443a41
More table styling
slaymance acf9a3a
Add styling examples for table docs
slaymance d4ec5c2
Merge remote-tracking branch 'origin/main' into table-primitive
slaymance 3e1e2dd
Add changeset
slaymance 07551ac
Add style prop to Table
slaymance 2237755
Update ui snapshots
slaymance b712425
Merge remote-tracking branch 'origin/main' into table-primitive
slaymance ab54148
Update js snapshot
slaymance 3d510c7
Update docs/src/styles/tableStyles.css
slaymance ff5741f
Update packages/ui/src/theme/css/component/table.scss
slaymance b3d42c9
Add subcomponent specific style tokens
slaymance 6f55052
Add tokens for all table styles
slaymance 7f18314
Remove text-indent property
slaymance 847730b
Update primitive types
slaymance 8aa92d1
Remove label prop from table
slaymance 45bf32e
Update caption render and style
slaymance 11a36fc
Add hideCaption prop
slaymance a87d3b0
Remove summary class name
slaymance f415d66
Update unit tests
slaymance e021a2f
Remove summary style tokens
slaymance 0dbdbc6
Merge remote-tracking branch 'origin/main' into table-primitive
slaymance ad6cf63
Remove hideCaption prop
slaymance cfc9a22
Remove summary prop from docs
slaymance 5505965
Make caption bottom of table by default
slaymance ec3c059
Explicit file imports
slaymance 9f082aa
Some more component and test updates
slaymance b99912e
Merge remote-tracking branch 'origin/main' into table-primitive
slaymance 72c083a
Update ui snapshots
slaymance 3290b84
Break out docs examples
slaymance 72d7104
Apply variation styles to non-header components
slaymance 70a4c4c
Correct span props
slaymance 4722ad2
Merge remote-tracking branch 'origin/main' into table-primitive
slaymance 76033f4
Update unit test snapshot
slaymance c3a14e1
Explicitly include rowspan and colspan props
slaymance 3d98f71
Update react unit test snapshot
slaymance File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@aws-amplify/ui-react': patch | ||
--- | ||
|
||
Adds React Table primitive | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😍