-
Notifications
You must be signed in to change notification settings - Fork 377
feat: Add plain variants for table and data list. #12112
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
796e695
feat: Added isPlain for data list.
dlabaj 94bfbd7
feat: Added isPlain for data list.
dlabaj bb6c651
fix: Updated code to support isPlain for table.
dlabaj 4c6e252
Update packages/react-core/src/components/DataList/DataList.tsx
dlabaj b1ccca2
Update packages/react-table/src/components/Table/Table.tsx
dlabaj 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 hidden or 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 hidden or 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
32 changes: 32 additions & 0 deletions
32
packages/react-core/src/components/DataList/examples/DataListPlain.tsx
This file contains hidden or 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,32 @@ | ||
| import { DataList, DataListItem, DataListItemRow, DataListItemCells, DataListCell } from '@patternfly/react-core'; | ||
|
|
||
| export const DataListPlain: React.FunctionComponent = () => ( | ||
| <DataList aria-label="Plain data list example" isPlain> | ||
| <DataListItem aria-labelledby="plain-item1"> | ||
| <DataListItemRow> | ||
| <DataListItemCells | ||
| dataListCells={[ | ||
| <DataListCell key="primary content"> | ||
| <span id="plain-item1">Primary content</span> | ||
| </DataListCell>, | ||
| <DataListCell key="secondary content">Secondary content</DataListCell> | ||
| ]} | ||
| /> | ||
| </DataListItemRow> | ||
| </DataListItem> | ||
| <DataListItem aria-labelledby="plain-item2"> | ||
| <DataListItemRow> | ||
| <DataListItemCells | ||
| dataListCells={[ | ||
| <DataListCell isFilled={false} key="secondary content fill"> | ||
| <span id="plain-item2">Secondary content (pf-m-no-fill)</span> | ||
| </DataListCell>, | ||
| <DataListCell isFilled={false} alignRight key="secondary content align"> | ||
| Secondary content (pf-m-align-right pf-m-no-fill) | ||
| </DataListCell> | ||
| ]} | ||
| /> | ||
| </DataListItemRow> | ||
| </DataListItem> | ||
| </DataList> | ||
| ); |
This file contains hidden or 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 hidden or 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
52 changes: 52 additions & 0 deletions
52
packages/react-table/src/components/Table/examples/TablePlain.tsx
This file contains hidden or 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,52 @@ | ||
| import { Table, Caption, Thead, Tr, Th, Tbody, Td } from '@patternfly/react-table'; | ||
|
|
||
| interface Repository { | ||
| name: string; | ||
| branches: string | null; | ||
| prs: string | null; | ||
| workspaces: string; | ||
| lastCommit: string; | ||
| } | ||
|
|
||
| export const TablePlain: React.FunctionComponent = () => { | ||
| // In real usage, this data would come from some external source like an API via props. | ||
| const repositories: Repository[] = [ | ||
| { name: 'one', branches: 'two', prs: 'three', workspaces: 'four', lastCommit: 'five' }, | ||
| { name: 'one - 2', branches: null, prs: null, workspaces: 'four - 2', lastCommit: 'five - 2' }, | ||
| { name: 'one - 3', branches: 'two - 3', prs: 'three - 3', workspaces: 'four - 3', lastCommit: 'five - 3' } | ||
| ]; | ||
|
|
||
| const columnNames = { | ||
| name: 'Repositories', | ||
| branches: 'Branches', | ||
| prs: 'Pull requests', | ||
| workspaces: 'Workspaces', | ||
| lastCommit: 'Last commit' | ||
| }; | ||
|
|
||
| return ( | ||
| <Table aria-label="Plain table" isPlain={true}> | ||
| <Caption>Simple table with plain styling using composable components</Caption> | ||
| <Thead> | ||
| <Tr> | ||
| <Th>{columnNames.name}</Th> | ||
| <Th>{columnNames.branches}</Th> | ||
| <Th>{columnNames.prs}</Th> | ||
| <Th>{columnNames.workspaces}</Th> | ||
| <Th>{columnNames.lastCommit}</Th> | ||
| </Tr> | ||
| </Thead> | ||
| <Tbody> | ||
| {repositories.map((repo) => ( | ||
| <Tr key={repo.name}> | ||
| <Td dataLabel={columnNames.name}>{repo.name}</Td> | ||
| <Td dataLabel={columnNames.branches}>{repo.branches}</Td> | ||
| <Td dataLabel={columnNames.prs}>{repo.prs}</Td> | ||
| <Td dataLabel={columnNames.workspaces}>{repo.workspaces}</Td> | ||
| <Td dataLabel={columnNames.lastCommit}>{repo.lastCommit}</Td> | ||
| </Tr> | ||
| ))} | ||
| </Tbody> | ||
| </Table> | ||
| ); | ||
| }; |
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.
Uh oh!
There was an error while loading. Please reload this page.