-
Notifications
You must be signed in to change notification settings - Fork 240
chore: refactor alert and flashbar contexts and tokens #4866
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
9 commits
Select commit
Hold shift + click to select a range
3a2d2d4
refactor: decouple flash and alert styling from shared tokens
mxschll 6d1c02b
refactor: remove notification contexts from one theme
mxschll 29c99ac
refactor: restore embedded content styling in one theme notifications
mxschll aac72e1
Revert "refactor: restore embedded content styling in one theme notif…
mxschll d5f2cb0
fix: notification border colors in one theme dark mode
mxschll ce1d147
feat: add notification embedded-content tokens
mxschll e583229
chore: update comment
mxschll be8d13d
chore: remove alert from top-nav context
mxschll 8050750
fix: split inverted link color off colorTextNotificationDefault
mxschll 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
29 changes: 29 additions & 0 deletions
29
pages/visual-contexts/content-header-notifications.page.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,29 @@ | ||
| // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| import React from 'react'; | ||
|
|
||
| import Box from '~components/box'; | ||
| import VisualContext from '~components/internal/components/visual-context'; | ||
| import SpaceBetween from '~components/space-between'; | ||
|
|
||
| import PermutationsView from '../utils/permutations-view'; | ||
| import ScreenshotArea from '../utils/screenshot-area'; | ||
| import { alertPermutations, flashbarPermutations, renderAlert, renderFlashbar } from './notifications-permutations'; | ||
|
|
||
| import styles from './styles.scss'; | ||
|
|
||
| export default function ContentHeaderNotificationsPermutations() { | ||
| return ( | ||
| <ScreenshotArea disableAnimations={true} gutters={false}> | ||
| <VisualContext contextName="content-header"> | ||
| <Box padding="l" className={styles.main}> | ||
| <SpaceBetween size="l"> | ||
| <Box variant="h1">Notifications in content-header visual context</Box> | ||
| <PermutationsView permutations={flashbarPermutations} render={renderFlashbar} /> | ||
| <PermutationsView permutations={alertPermutations} render={renderAlert} /> | ||
| </SpaceBetween> | ||
| </Box> | ||
| </VisualContext> | ||
| </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,69 @@ | ||
| // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| import React from 'react'; | ||
|
|
||
| import Alert, { AlertProps } from '~components/alert'; | ||
| import Box from '~components/box'; | ||
| import Button from '~components/button'; | ||
| import Divider from '~components/divider'; | ||
| import Flashbar, { FlashbarProps } from '~components/flashbar'; | ||
| import Link from '~components/link'; | ||
| import SpaceBetween from '~components/space-between'; | ||
|
|
||
| import createPermutations from '../utils/permutations'; | ||
|
|
||
| const noop = () => void 0; | ||
|
|
||
| const types = ['info', 'success', 'warning', 'error'] as const; | ||
|
|
||
| // Embedded content is rendered by other components, which read the shared body text, | ||
| // link and divider tokens rather than inheriting from the notification. | ||
| function EmbeddedContent({ linkColor }: { linkColor?: 'inverted' }) { | ||
| return ( | ||
| <SpaceBetween size="xs"> | ||
| <span> | ||
| Message with a{' '} | ||
| <Link color={linkColor} variant="primary"> | ||
| link | ||
| </Link>{' '} | ||
| and <Box variant="awsui-inline-code">inline code</Box>. | ||
| </span> | ||
| <Divider /> | ||
| <Box>Body text below a divider.</Box> | ||
| </SpaceBetween> | ||
| ); | ||
| } | ||
|
|
||
| /* eslint-disable react/jsx-key */ | ||
| export const flashbarPermutations = createPermutations<FlashbarProps.MessageDefinition>([ | ||
| { | ||
| type: [...types], | ||
| header: ['Flash header'], | ||
| content: [<EmbeddedContent linkColor="inverted" />], | ||
| action: [<Button>Action</Button>], | ||
| dismissible: [true], | ||
| dismissLabel: ['Dismiss'], | ||
| onDismiss: [noop], | ||
| }, | ||
| ]); | ||
|
|
||
| export const alertPermutations = createPermutations<AlertProps>([ | ||
| { | ||
| type: [...types], | ||
| header: ['Alert header'], | ||
| children: [<EmbeddedContent />], | ||
| action: [<Button>Action</Button>], | ||
| dismissible: [true], | ||
| dismissAriaLabel: ['Dismiss'], | ||
| onDismiss: [noop], | ||
| }, | ||
| ]); | ||
| /* eslint-enable react/jsx-key */ | ||
|
|
||
| export function renderFlashbar(permutation: FlashbarProps.MessageDefinition) { | ||
| return <Flashbar items={[{ ...permutation, statusIconAriaLabel: permutation.type ?? 'info' }]} />; | ||
| } | ||
|
|
||
| export function renderAlert(permutation: AlertProps) { | ||
| return <Alert statusIconAriaLabel={permutation.type} {...permutation} />; | ||
| } | ||
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,24 @@ | ||
| // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| import React from 'react'; | ||
|
|
||
| import Box from '~components/box'; | ||
| import SpaceBetween from '~components/space-between'; | ||
|
|
||
| import PermutationsView from '../utils/permutations-view'; | ||
| import ScreenshotArea from '../utils/screenshot-area'; | ||
| import { alertPermutations, flashbarPermutations, renderAlert, renderFlashbar } from './notifications-permutations'; | ||
|
|
||
| export default function NotificationsPermutations() { | ||
| return ( | ||
| <ScreenshotArea disableAnimations={true} gutters={false}> | ||
| <Box padding="l"> | ||
| <SpaceBetween size="l"> | ||
| <Box variant="h1">Notifications on the page surface</Box> | ||
| <PermutationsView permutations={flashbarPermutations} render={renderFlashbar} /> | ||
| <PermutationsView permutations={alertPermutations} render={renderAlert} /> | ||
| </SpaceBetween> | ||
| </Box> | ||
| </ScreenshotArea> | ||
| ); | ||
| } |
28 changes: 28 additions & 0 deletions
28
pages/visual-contexts/top-navigation-notifications.page.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,28 @@ | ||
| // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| import React from 'react'; | ||
|
|
||
| import Box from '~components/box'; | ||
| import VisualContext from '~components/internal/components/visual-context'; | ||
| import SpaceBetween from '~components/space-between'; | ||
|
|
||
| import PermutationsView from '../utils/permutations-view'; | ||
| import ScreenshotArea from '../utils/screenshot-area'; | ||
| import { flashbarPermutations, renderFlashbar } from './notifications-permutations'; | ||
|
|
||
| import styles from './styles.scss'; | ||
|
|
||
| export default function TopNavigationNotificationsPermutations() { | ||
| return ( | ||
| <ScreenshotArea disableAnimations={true} gutters={false}> | ||
| <VisualContext contextName="top-navigation"> | ||
| <Box padding="l" className={styles['top-nav-dropdown']}> | ||
| <SpaceBetween size="l"> | ||
| <Box variant="h1">Notifications in top-navigation visual context</Box> | ||
| <PermutationsView permutations={flashbarPermutations} render={renderFlashbar} /> | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Only testing flashbars within top-navigation context and not alerts. More context: #4872 |
||
| </SpaceBetween> | ||
| </Box> | ||
| </VisualContext> | ||
| </ScreenshotArea> | ||
| ); | ||
| } | ||
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.
Maybe we should change our linter to exclude /pages for this rule... :) We do this for all permutations.