Skip to content

Commit

Permalink
feat: add border prop to tabs media item (#835)
Browse files Browse the repository at this point in the history
  • Loading branch information
qradle-yndx authored Feb 28, 2024
1 parent b70f80d commit 50e3621
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/blocks/Tabs/Tabs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ $block: '.#{$ns}tabs-block';

&__image,
&__media {
@include image-shadow();
@include media-border();
}

&__caption {
Expand Down
5 changes: 3 additions & 2 deletions src/blocks/Tabs/Tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export const TabsBlock = ({

const showMedia = Boolean(activeTabData?.media || imageProps);
const showText = Boolean(activeTabData?.text);
const border = activeTabData?.border || 'shadow';

const textContent = activeTabData && showText && (
<TabsTextContent
Expand Down Expand Up @@ -107,7 +108,7 @@ export const TabsBlock = ({
<Media
{...getThemedValue(activeTabData.media, theme)}
key={activeTab}
className={b('media')}
className={b('media', {border})}
playVideo={play}
height={mediaVideoHeight || undefined}
onImageLoad={handleImageHeight}
Expand All @@ -117,7 +118,7 @@ export const TabsBlock = ({
</div>
{imageProps && (
<Fragment>
<FullscreenImage {...imageProps} imageClassName={b('image')} />
<FullscreenImage {...imageProps} imageClassName={b('image', {border})} />
</Fragment>
)}
{activeTabData?.caption && (
Expand Down
1 change: 1 addition & 0 deletions src/blocks/Tabs/__stories__/Tabs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ import * as TabsStories from './Tabs.stories.tsx';
- `image?: string | ImageObjectProps` — Image.
- [`media: Media` — Media description](?path=/docs/documentation-types#media--imagevideodatalensyoutube)
- `caption?: string` — Image caption (with YFM support)
- `border?: 'shadow' | 'line' | 'none` — Select border of the media.

</StoryTemplate>
9 changes: 9 additions & 0 deletions src/blocks/Tabs/__stories__/Tabs.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export const TabsButtonsColSizes = ButtonsColSizesTemplate.bind({});
export const Centered = DefaultTemplate.bind({});
export const Direction = DirectionTemplate.bind({});
export const Caption = DefaultTemplate.bind({});
export const MediaBorder = DefaultTemplate.bind({});

const DefaultArgs = {
...data.default.content,
Expand Down Expand Up @@ -115,3 +116,11 @@ Caption.args = {
...item,
})),
} as TabsBlockModel;

MediaBorder.args = {
...DefaultArgs,
items: DefaultArgs.items.map((item, index) => ({
...item,
border: ['line', 'none', 'shadow'][index % 3],
})),
} as TabsBlockModel;
15 changes: 10 additions & 5 deletions src/blocks/Tabs/__stories__/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
"dark": {
"image": "/story-assets/img_8-12_dark.png"
}
}
},
"border": "shadow"
},
{
"tabName": "Lorem ipsum",
Expand Down Expand Up @@ -69,7 +70,8 @@
"theme": "normal",
"arrow": true
}
]
],
"border": "shadow"
},
{
"tabName": "Ut enim",
Expand Down Expand Up @@ -111,7 +113,8 @@
"theme": "normal",
"arrow": true
}
]
],
"border": "shadow"
},
{
"tabName": "Consectetur adipiscing elit",
Expand All @@ -128,7 +131,8 @@
}
},
"caption": "Consectetur adipiscing elit",
"text": "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."
"text": "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.",
"border": "shadow"
},
{
"tabName": "minim veniam",
Expand All @@ -150,7 +154,8 @@
"theme": "normal",
"arrow": true
}
]
],
"border": "shadow"
}
]
}
Expand Down
4 changes: 4 additions & 0 deletions src/blocks/Tabs/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ export const tabsItem = {
//TODO deprecated
link: LinkProps,
image: withTheme(ImageProps),
border: {
type: 'string',
enum: ['shadow', 'line', 'none'],
},
},
};

Expand Down
3 changes: 2 additions & 1 deletion src/models/constructor-items/blocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,8 @@ export interface TableBlockProps {
}

export interface TabsBlockItem
extends Omit<ContentBlockProps, 'size' | 'colSizes' | 'centered' | 'theme'> {
extends Omit<ContentBlockProps, 'size' | 'colSizes' | 'centered' | 'theme'>,
WithBorder {
tabName: string;
/**
* @deprecated Use array links from ContentBlockProps instead
Expand Down

0 comments on commit 50e3621

Please sign in to comment.