-
Notifications
You must be signed in to change notification settings - Fork 237
feat: add automatic skeleton rows to Table #4772
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
11 commits
Select commit
Hold shift + click to select a range
670f11c
feat(table): add automatic skeleton rows
gethinwebster 7fcc3cb
fix(table): prevent auto skeleton overflow
gethinwebster 6978122
test(table): cover auto skeleton layout features and add dev pages
gethinwebster 7ccb252
test(table): update documenter snapshot for auto skeleton rows
gethinwebster e6780dc
test(table): cover auto skeleton document overflow fallback
gethinwebster c7ecd28
test(table): fix a11y violations on auto skeleton dev page
gethinwebster 8fa5da2
test(table): keep single wrapped AppLayout skeleton demo
gethinwebster 95c275f
refactor(table): reuse shared getScrollableParents for auto skeleton …
gethinwebster 4b75451
feat: add minAutoRows to Table auto skeleton; name SkeletonConfig uni…
gethinwebster c740ae0
fix: clamp minAutoRows to >=1 and clarify auto skeleton row docs
gethinwebster c8e171c
fix: clamp minAutoRows to maxAutoRows and sanitize maxAutoRows to >=1
gethinwebster 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| import React from 'react'; | ||
|
|
||
| import AppLayout from '~components/app-layout'; | ||
| import Button from '~components/button'; | ||
| import Header from '~components/header'; | ||
| import Table, { TableProps } from '~components/table'; | ||
|
|
||
| import ScreenshotArea from '../utils/screenshot-area'; | ||
| import { Breadcrumbs, Footer, Navigation, Notifications } from './utils/content-blocks'; | ||
| import labels from './utils/labels'; | ||
|
|
||
| interface Item { | ||
| id: string; | ||
| name: string; | ||
| owner: string; | ||
| } | ||
|
|
||
| const columnDefinitions: TableProps.ColumnDefinition<Item>[] = [ | ||
| { | ||
| id: 'id', | ||
| header: 'Resource identifier used to locate the item in the inventory', | ||
| cell: item => item.id, | ||
| }, | ||
| { | ||
| id: 'name', | ||
| header: 'Resource name shown to customers in the management console', | ||
| cell: item => item.name, | ||
| }, | ||
| { | ||
| id: 'owner', | ||
| header: 'Owning team responsible for operating this resource', | ||
| cell: item => item.owner, | ||
| }, | ||
| ]; | ||
|
|
||
| const scenarioId = 'auto-skeleton-app-layout'; | ||
|
|
||
| export default function AutoSkeletonTablePage() { | ||
| return ( | ||
| <ScreenshotArea gutters={false}> | ||
| <div id={scenarioId}> | ||
| <AppLayout | ||
| ariaLabels={labels} | ||
| breadcrumbs={<Breadcrumbs />} | ||
| contentType="table" | ||
| footerSelector="#f" | ||
| headerSelector="#h" | ||
| navigation={<Navigation />} | ||
| notifications={<Notifications />} | ||
| content={ | ||
| <Table<Item> | ||
| columnDefinitions={columnDefinitions} | ||
| footer={<div id={`${scenarioId}-table-footer`}>Table footer</div>} | ||
| header={ | ||
| <Header | ||
| actions={<Button variant="primary">Create resource</Button>} | ||
| description="Automatic skeleton rows fill the AppLayout content viewport." | ||
| variant="awsui-h1-sticky" | ||
| > | ||
| Resources | ||
| </Header> | ||
| } | ||
| items={[]} | ||
| loading={true} | ||
| loadingText="Loading resources" | ||
| skeleton={{ totalRows: 'auto' }} | ||
| stickyHeader={true} | ||
| variant="full-page" | ||
| wrapLines={true} | ||
| /> | ||
| } | ||
| /> | ||
| <Footer legacyConsoleNav={false} /> | ||
| </div> | ||
| </ScreenshotArea> | ||
| ); | ||
| } |
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,124 @@ | ||
| // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| import React from 'react'; | ||
|
|
||
| import Header from '~components/header'; | ||
| import SpaceBetween from '~components/space-between'; | ||
| import Table, { TableProps } from '~components/table'; | ||
|
|
||
| interface Item { | ||
| id: string; | ||
| name: string; | ||
| owner: string; | ||
| } | ||
|
|
||
| const columnDefinitions: TableProps.ColumnDefinition<Item>[] = [ | ||
| { id: 'id', header: 'ID', cell: item => item.id }, | ||
| { id: 'name', header: 'Name', cell: item => item.name }, | ||
| ]; | ||
|
|
||
| const longHeaderColumnDefinitions: TableProps.ColumnDefinition<Item>[] = [ | ||
| { | ||
| id: 'id', | ||
| header: 'Resource identifier used to locate the item in the inventory', | ||
| cell: item => item.id, | ||
| }, | ||
| { | ||
| id: 'name', | ||
| header: 'Resource name shown to customers in the management console', | ||
| cell: item => item.name, | ||
| }, | ||
| { | ||
| id: 'owner', | ||
| header: 'Owning team responsible for operating this resource', | ||
| cell: item => item.owner, | ||
| }, | ||
| ]; | ||
|
|
||
| const partialItems: Item[] = [ | ||
| { id: '1', name: 'First resource', owner: 'Team A' }, | ||
| { id: '2', name: 'Second resource', owner: 'Team B' }, | ||
| { id: '3', name: 'Third resource', owner: 'Team C' }, | ||
| ]; | ||
|
|
||
| interface SkeletonScenarioProps { | ||
| footer?: boolean; | ||
| id: string; | ||
| items?: readonly Item[]; | ||
| longHeaders?: boolean; | ||
| stickyHeader?: boolean; | ||
| title: string; | ||
| wrapLines?: boolean; | ||
| } | ||
|
|
||
| function SkeletonScenario({ | ||
| footer, | ||
| id, | ||
| items = [], | ||
| longHeaders, | ||
| stickyHeader, | ||
| title, | ||
| wrapLines, | ||
| }: SkeletonScenarioProps) { | ||
| return ( | ||
| <div id={id} style={{ blockSize: '320px', inlineSize: longHeaders ? '360px' : undefined, overflowY: 'auto' }}> | ||
| <Table | ||
| columnDefinitions={longHeaders ? longHeaderColumnDefinitions : columnDefinitions} | ||
| items={items} | ||
| loading={true} | ||
| loadingText="Loading items" | ||
| skeleton={{ totalRows: 'auto' }} | ||
| stickyHeader={stickyHeader} | ||
| wrapLines={wrapLines} | ||
| footer={footer ? <div id={`${id}-footer`}>Footer content</div> : undefined} | ||
| header={<Header description="Skeleton rows fill the visible scroll viewport.">{title}</Header>} | ||
| /> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| export default function AutoSkeletonRowsPage() { | ||
| return ( | ||
| <SpaceBetween size="l"> | ||
| <Header variant="h1">Automatic skeleton rows</Header> | ||
| <div id="auto-skeleton-scroll-container" style={{ blockSize: '400px', overflowY: 'auto' }}> | ||
| <div style={{ blockSize: '64px' }} /> | ||
| <div id="auto-skeleton-inner-scroll-container" style={{ blockSize: '320px', overflowY: 'auto' }}> | ||
| <Table | ||
| columnDefinitions={columnDefinitions} | ||
| items={[]} | ||
| loading={true} | ||
| loadingText="Loading items" | ||
| skeleton={{ totalRows: 'auto' }} | ||
| header={ | ||
| <Header description="Skeleton rows fill the visible scroll viewport.">Nested scroll viewport</Header> | ||
| } | ||
| /> | ||
| </div> | ||
| </div> | ||
| <SkeletonScenario id="auto-skeleton-sticky-header" stickyHeader={true} title="Sticky header" /> | ||
| <SkeletonScenario footer={true} id="auto-skeleton-footer" title="Footer" /> | ||
| <SkeletonScenario | ||
| id="auto-skeleton-long-headers-nowrap" | ||
| longHeaders={true} | ||
| title="Long headers without wrapping" | ||
| wrapLines={false} | ||
| /> | ||
| <SkeletonScenario | ||
| id="auto-skeleton-long-headers-wrap" | ||
| longHeaders={true} | ||
| title="Long headers with wrapping" | ||
| wrapLines={true} | ||
| /> | ||
| <SkeletonScenario id="auto-skeleton-mixed-rows" items={partialItems} title="Mixed data and skeleton rows" /> | ||
| <SkeletonScenario | ||
| footer={true} | ||
| id="auto-skeleton-all-features" | ||
| longHeaders={true} | ||
| stickyHeader={true} | ||
| title="Combined features" | ||
| wrapLines={true} | ||
| /> | ||
| </SpaceBetween> | ||
| ); | ||
| } |
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
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
Oops, something went wrong.
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.
Do we have a test for this?
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.
implicitly, but now added an explicit test too