Skip to content
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

feat: add yfm support for tabs block item caption #785

Merged
merged 1 commit into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading