Skip to content

Commit

Permalink
feat: add yfm support for tabs block item caption (#785)
Browse files Browse the repository at this point in the history
  • Loading branch information
qradle-yndx authored Jan 30, 2024
1 parent 032ca0f commit ff35d41
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 5 deletions.
17 changes: 16 additions & 1 deletion src/blocks/Tabs/Tabs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,22 @@ $block: '.#{$ns}tabs-block';
@include text-size(body-2);

margin: $indentXXS 0 0;
color: var(--g-color-text-secondary);

@include add-specificity(&) {
.yfm,
.yfm > * {
color: var(--g-color-text-secondary);
}

.yfm a {
color: var(--g-color-text-secondary);
text-decoration: underline;

&:hover {
color: var(--g-color-text-primary);
}
}
}
}

&__col {
Expand Down
7 changes: 6 additions & 1 deletion src/blocks/Tabs/Tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {getMediaImage} from '../../components/Media/Image/utils';
import Media from '../../components/Media/Media';
import Title from '../../components/Title/Title';
import {getHeight} from '../../components/VideoBlock/VideoBlock';
import YFMWrapper from '../../components/YFMWrapper/YFMWrapper';
import {useTheme} from '../../context/theme';
import {Col, GridColumnOrderClasses, Row} from '../../grid';
import {TabsBlockProps} from '../../models';
Expand Down Expand Up @@ -121,7 +122,11 @@ export const TabsBlock = ({
)}
{activeTabData?.caption && (
<p className={b('caption')} id={captionId}>
{activeTabData.caption}
<YFMWrapper
content={activeTabData.caption}
modifiers={{constructor: true}}
id={captionId}
/>
</p>
)}
</Col>
Expand Down
2 changes: 1 addition & 1 deletion src/blocks/Tabs/__stories__/Tabs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ import * as TabsStories from './Tabs.stories.tsx';
- `buttons?: Button[]` — An array with button objects (see [Content blocks](?path=/docs/documentation-types--docs))
- `image?: string | ImageObjectProps` — Image.
- [`media: Media` — Media description](?path=/docs/documentation-types#media--imagevideodatalensyoutube)
- `caption?: string` — Image caption.
- `caption?: string` — Image caption (with YFM support)

</StoryTemplate>
2 changes: 1 addition & 1 deletion src/blocks/Tabs/__stories__/Tabs.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ const DefaultArgs = {
...item,
text: yfmTransform(item.text),
additionalInfo: item.additionalInfo && yfmTransform(item.additionalInfo),
caption: item.caption && yfmTransform(item.caption),
})),
};

Expand Down Expand Up @@ -112,6 +113,5 @@ Caption.args = {
...DefaultArgs,
items: DefaultArgs.items.map((item) => ({
...item,
caption: item.title,
})),
} as TabsBlockModel;
2 changes: 1 addition & 1 deletion src/blocks/Tabs/__stories__/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
"image": "/story-assets/img_6-12_dark.png"
}
},
"caption": "Dolor sit amet",
"caption": "Duis aute irure dolor in [reprehenderit](https://example.com) n voluptate velit esse cillum dolore eu fugiat nulla pariatur.",
"text": "* Ut enim ad minim veniam\n* Ut enim ad minim veniam",
"links": [
{
Expand Down

0 comments on commit ff35d41

Please sign in to comment.