-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add price-card * feat: made content-list a separate component
- Loading branch information
1 parent
77286c5
commit 527a335
Showing
22 changed files
with
632 additions
and
38 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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import React from 'react'; | ||
|
||
import {useTheme} from '../../context/theme'; | ||
import {ClassNameProps, ImageProps, QAProps, SVGIcon} from '../../models'; | ||
import {ThemeSupporting, getThemedValue} from '../../utils'; | ||
import Image from '../Image/Image'; | ||
import {getMediaImage} from '../Media/Image/utils'; | ||
|
||
interface ListItemProps extends QAProps, ClassNameProps { | ||
icon: ThemeSupporting<ImageProps | SVGIcon>; | ||
} | ||
|
||
function isIconSvg(icon: ImageProps | SVGIcon): icon is SVGIcon { | ||
return typeof icon === 'function'; | ||
} | ||
|
||
const ContentListItemIcon = ({icon, className, qa}: ListItemProps) => { | ||
const theme = useTheme(); | ||
const iconThemed = getThemedValue(icon, theme); | ||
|
||
if (isIconSvg(iconThemed)) { | ||
const Icon = iconThemed; | ||
return ( | ||
<div> | ||
<Icon className={className} /> | ||
</div> | ||
); | ||
} | ||
const iconData = getMediaImage(iconThemed); | ||
return <Image {...iconData} className={className} qa={qa} />; | ||
}; | ||
|
||
export default ContentListItemIcon; |
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,16 @@ | ||
import {Meta} from '@storybook/blocks'; | ||
|
||
import {StoryTemplate} from '../../../demo/StoryTemplate.mdx'; | ||
import * as ContentListStories from './ContentList.stories.tsx'; | ||
|
||
<Meta of={ContentListStories} /> | ||
<StoryTemplate> | ||
## Parameters | ||
|
||
- `size?: 's' | 'l'` — Component's size that defines font sizes ('l' by default) | ||
|
||
`list: Array` - An Array of items with icon | ||
- [`icon: string | ImageObjectProps | ReactNode` — Icon](?path=/docs/documentation-types--docs#imageobjectprops---image-property). | ||
- `title?: string` — Title. | ||
- `text?: string` — Text (with YFM support) | ||
</StoryTemplate> |
37 changes: 37 additions & 0 deletions
37
src/components/ContentList/__stories__/ContentList.stories.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,37 @@ | ||
import React from 'react'; | ||
|
||
import {Meta, StoryFn} from '@storybook/react'; | ||
|
||
import {yfmTransform} from '../../../../.storybook/utils'; | ||
import {ContentItemProps, ContentListProps} from '../../../models'; | ||
import ContentList from '../ContentList'; | ||
|
||
import data from './data.json'; | ||
|
||
const transformList = (item: ContentItemProps) => ({ | ||
...item, | ||
text: item?.text && yfmTransform(item.text), | ||
}); | ||
|
||
export default { | ||
args: {list: data.default.content.map(transformList), size: 'l'}, | ||
component: ContentList, | ||
title: 'Components/ContentList', | ||
} as Meta; | ||
|
||
const DefaultTemplate: StoryFn<ContentListProps> = (args) => ( | ||
<div style={{paddingBottom: '64px'}}> | ||
<ContentList {...args} /> | ||
</div> | ||
); | ||
|
||
const DifferentSizeTemplate: StoryFn<ContentListProps> = (args) => ( | ||
<div> | ||
<h2>Size L</h2> | ||
<DefaultTemplate {...args} size="l" /> | ||
<h2>Size S</h2> | ||
<DefaultTemplate {...args} size="s" /> | ||
</div> | ||
); | ||
export const Default = DefaultTemplate.bind({}); | ||
export const Size = DifferentSizeTemplate.bind({}); |
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,33 @@ | ||
{ | ||
"centered": { | ||
"content": { | ||
"centered": true | ||
} | ||
}, | ||
"default": { | ||
"content": [ | ||
{ | ||
"icon": { | ||
"light": "https://storage.yandexcloud.net/cloud-www-assets/constructor/storybook/images/icon_1_light.svg", | ||
"dark": "https://storage.yandexcloud.net/cloud-www-assets/constructor/storybook/images/icon_1_dark.svg" | ||
}, | ||
"title": "Default", | ||
"text": "**Ut enim ad minim veniam** [quis nostrud](https://example.com) exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." | ||
}, | ||
{ | ||
"icon": { | ||
"light": "https://storage.yandexcloud.net/cloud-www-assets/constructor/storybook/images/icon_3_light.svg", | ||
"dark": "https://storage.yandexcloud.net/cloud-www-assets/constructor/storybook/images/icon_3_dark.svg" | ||
}, | ||
"title": "With title only" | ||
}, | ||
{ | ||
"icon": { | ||
"light": "https://storage.yandexcloud.net/cloud-www-assets/constructor/storybook/images/icon_2_light.svg", | ||
"dark": "https://storage.yandexcloud.net/cloud-www-assets/constructor/storybook/images/icon_2_dark.svg" | ||
}, | ||
"text": "With text only. **Ut enim ad minim veniam** [quis nostrud](https://example.com) exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." | ||
} | ||
] | ||
} | ||
} |
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
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
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
Oops, something went wrong.