forked from aws-amplify/amplify-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs update for table primitive, use theme values, use exampleCode co… (
aws-amplify#1202) * docs update for table primitive, use theme values, use exampleCode component * remove old DemoBox component and replace it with the Demo component * remove demobox from TablePropControls, rename example files to PascalCase * remove field labeller in favor of the built in label prop * update file reference * update to file references Co-authored-by: Jacob Logan <[email protected]>
- Loading branch information
1 parent
1f5e696
commit 8a3e919
Showing
14 changed files
with
395 additions
and
283 deletions.
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
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
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 |
---|---|---|
@@ -1,26 +1,67 @@ | ||
import * as React from 'react'; | ||
|
||
import { Flex } from '@aws-amplify/ui-react'; | ||
import { Demo } from '@/components/Demo'; | ||
|
||
import { Example } from '@/components/Example'; | ||
import { TablePropControls } from '@/components/TablePropControls'; | ||
import { useTableProps } from '@/components/useTableProps'; | ||
import { TablePropControls } from './TablePropControls'; | ||
import { useTableProps } from './useTableProps'; | ||
import { BasicExample } from './examples'; | ||
|
||
const propsToCode = (props) => { | ||
const { caption, highlightOnHover, size, variation } = props; | ||
return ` | ||
<Table | ||
caption={${caption}} | ||
highlightOnHover={${highlightOnHover}} | ||
size={${size}} | ||
variation={${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> | ||
`; | ||
}; | ||
|
||
const initialValues = { | ||
caption: '', | ||
highlightOnHover: false, | ||
}; | ||
|
||
export const TableDemo = () => { | ||
const tableProps = useTableProps({}); | ||
const tableProps = useTableProps(initialValues); | ||
|
||
return ( | ||
<Flex direction="column" gap="0.5rem"> | ||
<TablePropControls {...tableProps} /> | ||
<Example> | ||
<BasicExample | ||
caption={tableProps.caption} | ||
highlightOnHover={tableProps.highlightOnHover} | ||
size={tableProps.size} | ||
variation={tableProps.variation} | ||
/> | ||
</Example> | ||
</Flex> | ||
<Demo | ||
code={propsToCode(tableProps)} | ||
propControls={<TablePropControls {...tableProps} />} | ||
> | ||
<BasicExample | ||
caption={tableProps.caption} | ||
highlightOnHover={tableProps.highlightOnHover} | ||
size={tableProps.size} | ||
variation={tableProps.variation} | ||
/> | ||
</Demo> | ||
); | ||
}; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
25 changes: 25 additions & 0 deletions
25
docs/src/pages/components/table/examples/TableFontSizePropExample.tsx
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,25 @@ | ||
import { | ||
Table, | ||
TableBody, | ||
TableRow, | ||
TableCell, | ||
useTheme, | ||
} from '@aws-amplify/ui-react'; | ||
|
||
export const TableFontSizePropExample = () => { | ||
const { tokens } = useTheme(); | ||
return ( | ||
<Table> | ||
<TableBody> | ||
<TableRow> | ||
<TableCell fontSize={`${tokens.fontSizes.xs}`}> | ||
Smaller Text | ||
</TableCell> | ||
<TableCell fontSize={`${tokens.fontSizes.xs}`}> | ||
Smaller Text | ||
</TableCell> | ||
</TableRow> | ||
</TableBody> | ||
</Table> | ||
); | ||
}; |
25 changes: 25 additions & 0 deletions
25
docs/src/pages/components/table/examples/TableStylePropExample.tsx
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,25 @@ | ||
import { | ||
Table, | ||
TableBody, | ||
TableRow, | ||
TableCell, | ||
useTheme, | ||
} from '@aws-amplify/ui-react'; | ||
|
||
export const TableStylePropExample = () => { | ||
const { tokens } = useTheme(); | ||
return ( | ||
<Table> | ||
<TableBody> | ||
<TableRow> | ||
<TableCell style={{ fontSize: `${tokens.fontSizes.xs}` }}> | ||
Smaller Text | ||
</TableCell> | ||
<TableCell style={{ fontSize: `${tokens.fontSizes.xs}` }}> | ||
Smaller Text | ||
</TableCell> | ||
</TableRow> | ||
</TableBody> | ||
</Table> | ||
); | ||
}; |
File renamed without changes.
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 |
---|---|---|
@@ -1,5 +1,7 @@ | ||
export { BasicExample } from './basicExample'; | ||
export { HighlightExample } from './highlightExample'; | ||
export { SizeExample } from './sizeExample'; | ||
export { SpanExample } from './spanExample'; | ||
export { VariationExample } from './variationExample'; | ||
export { BasicExample } from './BasicExample'; | ||
export { HighlightExample } from './HighlightExample'; | ||
export { SizeExample } from './SizeExample'; | ||
export { SpanExample } from './SpanExample'; | ||
export { TableFontSizePropExample } from './TableFontSizePropExample'; | ||
export { TableStylePropExample } from './TableStylePropExample'; | ||
export { VariationExample } from './VariationExample'; |
Oops, something went wrong.