-
Notifications
You must be signed in to change notification settings - Fork 12
feat(PageLayout): support function type for topAlert prop #491
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
Changes from 3 commits
49f36c9
39874ec
176b39f
5884ffe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| import React from 'react'; | ||
|
|
||
| import {Xmark} from '@gravity-ui/icons'; | ||
| import {Button, Flex, Icon, Text, spacing} from '@gravity-ui/uikit'; | ||
| import type {Meta, StoryFn} from '@storybook/react'; | ||
|
|
||
|
|
@@ -8,7 +9,7 @@ | |
| import {PageLayout} from '../components/PageLayout/PageLayout'; | ||
| import {PageLayoutAside} from '../components/PageLayout/PageLayoutAside'; | ||
|
|
||
| import {AsideHeaderShowcase} from './AsideHeaderShowcase'; | ||
| import {AsideHeaderShowcase, AsideHeaderShowcaseProps} from './AsideHeaderShowcase'; | ||
| import {DEFAULT_LOGO, menuItemsClamped, menuItemsShowcase} from './moc'; | ||
|
|
||
| import logoIcon from '../../../../.storybook/assets/logo.svg'; | ||
|
|
@@ -126,7 +127,9 @@ | |
| initialCompact: true, | ||
| }; | ||
|
|
||
| const TopAlertTemplate: StoryFn = (args) => <AsideHeaderShowcase {...args} />; | ||
| const TopAlertTemplate: StoryFn<AsideHeaderShowcaseProps> = (args) => ( | ||
| <AsideHeaderShowcase {...args} /> | ||
| ); | ||
| export const HeaderAlert = TopAlertTemplate.bind({}); | ||
| HeaderAlert.args = { | ||
| topAlert: { | ||
|
|
@@ -148,6 +151,45 @@ | |
| }, | ||
| }; | ||
|
|
||
| export const HeaderAlertCustom = TopAlertTemplate.bind({}); | ||
| HeaderAlertCustom.args = { | ||
| topAlert: { | ||
| message: "We've got something new for you to try!", | ||
| render: ({message, handleClose}) => ( | ||
| <Flex | ||
| direction="row" | ||
| justifyContent="center" | ||
| alignItems="center" | ||
| gap={4} | ||
| style={{ | ||
| position: 'relative', | ||
| padding: '8px', | ||
| background: | ||
| ' linear-gradient(120deg, #191654, #43cea2 40%, #185a9d 70%, #f857a6 100%)', | ||
| }} | ||
| > | ||
| <Text variant="subheader-2" style={{color: 'var(--g-color-text-light-primary)'}}> | ||
| {message} | ||
| </Text> | ||
| <Button view="normal-contrast" size="m"> | ||
| Try Now | ||
| </Button> | ||
| <Button view="outlined-contrast" size="m"> | ||
| Learn More | ||
| </Button> | ||
| <Button | ||
| style={{position: 'absolute', right: '8px'}} | ||
| view="flat-contrast" | ||
| aria-label="Close" | ||
| onClick={handleClose} | ||
| > | ||
| <Icon data={Xmark} size={18} /> | ||
| </Button> | ||
| </Flex> | ||
| ), | ||
| }, | ||
| }; | ||
|
|
||
| const fallbackArgs = { | ||
| headerDecoration: true, | ||
| subheaderItemsCount: 2, | ||
|
|
@@ -179,7 +221,7 @@ | |
| export const Fallback = FallbackTemplate.bind({}); | ||
| Fallback.args = fallbackArgs; | ||
|
|
||
| /** @type {StoryFn} */ | ||
|
Check warning on line 224 in src/components/AsideHeader/__stories__/AsideHeader.stories.tsx
|
||
| export function LineClamp() { | ||
| const [compact, setCompact] = React.useState(false); | ||
| return ( | ||
|
|
@@ -204,7 +246,7 @@ | |
| menuItems={menuItemsShowcase} | ||
| logo={DEFAULT_LOGO} | ||
| onChangeCompact={setCompact} | ||
| collapseButtonWrapper={(defaultButton, {compact}) => ( | ||
| <React.Fragment> | ||
| {defaultButton} | ||
| <div | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -77,7 +77,7 @@ export interface LogoProps { | |
| 'aria-labelledby'?: string; | ||
| } | ||
|
|
||
| export interface TopAlertProps { | ||
| interface TopAlertBaseProps { | ||
| align?: AlertProps['align']; | ||
| message: AlertProps['message']; | ||
| title?: AlertProps['title']; | ||
|
|
@@ -90,3 +90,7 @@ export interface TopAlertProps { | |
| dense?: boolean; | ||
| onCloseTopAlert?: () => void; | ||
| } | ||
|
|
||
| export interface TopAlertProps extends TopAlertBaseProps { | ||
|
||
| render?: (params: TopAlertBaseProps & {handleClose: () => void}) => React.ReactElement; | ||
| } | ||
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.
It seems better to make
messageoptional if therenderis set.