Skip to content

Commit fc7bf58

Browse files
benax-seqradle-yndx
authored andcommitted
fix: support ContentList theme prop; pass theme prop from Content to ContentList (#1066)
1 parent 75248b9 commit fc7bf58

File tree

8 files changed

+72
-14
lines changed

8 files changed

+72
-14
lines changed

src/components/ContentList/ContentList.scss

+39
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@ $iconSizeS: 20px;
77
$iconSizeXS: 18px;
88
$marginIconSizeS: 2px;
99
$marginIconSizeL: 1px;
10+
$lightPrimary: var(--g-color-text-light-primary);
11+
$darkPrimary: var(--g-color-text-dark-primary);
12+
$darkSecondary: var(--g-color-text-dark-secondary);
13+
14+
@mixin content-link($baseColor: $primary, $hoverColor: $secondary) {
15+
color: $baseColor;
16+
text-decoration: underline;
17+
&:hover {
18+
color: $hoverColor;
19+
}
20+
}
1021

1122
#{$block} {
1223
&_size_l {
@@ -84,6 +95,34 @@ $marginIconSizeL: 1px;
8495
}
8596
}
8697

98+
&_theme_light {
99+
#{$block}__item {
100+
*,
101+
.yfm,
102+
.yfm * {
103+
color: $darkPrimary;
104+
}
105+
106+
.yfm a {
107+
@include content-link($darkPrimary, $darkSecondary);
108+
}
109+
}
110+
}
111+
112+
&_theme_dark {
113+
#{$block}__item {
114+
*,
115+
.yfm,
116+
.yfm * {
117+
color: $lightPrimary;
118+
}
119+
120+
.yfm a {
121+
@include content-link($lightPrimary, $lightSecondary);
122+
}
123+
}
124+
}
125+
87126
&__icon {
88127
display: block;
89128
}

src/components/ContentList/ContentList.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ function getHeadingLevel(size: ContentSize) {
2424
}
2525
}
2626

27-
const ContentList = ({list, size = 'l', qa}: ContentListProps & QAProps) => {
27+
const ContentList = ({list, size = 'l', qa, theme}: ContentListProps & QAProps) => {
2828
const qaAttributes = getQaAttrubutes(qa, ['image', 'title', 'text']);
2929

3030
return (
31-
<div className={b({size})} data-qa={qa}>
31+
<div className={b({size, theme})} data-qa={qa}>
3232
{list?.map((item) => {
3333
const {icon, title, text} = item;
3434
return (

src/sub-blocks/BackgroundCard/__stories__/BackgroundCard.stories.tsx

+13-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ const transformedContentList = data.common.list.map((item) => {
1919
};
2020
}) as ContentItemProps[];
2121

22+
const transformedContentDarkList = data.common.darkList.map((item) => {
23+
return {
24+
...item,
25+
text: item?.text && yfmTransform(item.text),
26+
};
27+
}) as ContentItemProps[];
28+
2229
const getPaddingBottomTitle = (padding: string) =>
2330
data.paddings.title.replace('{{padding}}', padding);
2431

@@ -78,7 +85,12 @@ const CardThemesTemplate: StoryFn<{items: BackgroundCardProps[]}> = (args) => (
7885
<div style={{display: 'flex'}}>
7986
{args.items.map((item, i) => (
8087
<div style={{maxWidth: '400px', padding: '0 8px'}} key={i}>
81-
<BackgroundCard {...item} />
88+
<BackgroundCard
89+
{...item}
90+
list={
91+
item.theme === 'dark' ? transformedContentDarkList : transformedContentList
92+
}
93+
/>
8294
</div>
8395
))}
8496
</div>

src/sub-blocks/BackgroundCard/__stories__/data.json

+15
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,21 @@
3535
"title": "Lorem ipsum ipsum"
3636
}
3737
],
38+
"darkList": [
39+
{
40+
"icon": "/story-assets/icon_1_dark.svg",
41+
"title": "Lorem ipsum",
42+
"text": "**Ut enim ad minim veniam** [quis nostrud](https://example.com) exercitation."
43+
},
44+
{
45+
"icon": "/story-assets/icon_2_dark.svg",
46+
"text": "**Ut enim ad minim veniam** [quis nostrud](https://example.com) exercitation."
47+
},
48+
{
49+
"icon": "/story-assets/icon_3_dark.svg",
50+
"title": "Lorem ipsum ipsum"
51+
}
52+
],
3853
"buttons": [
3954
{
4055
"text": "Button\r",

src/sub-blocks/Content/Content.scss

+2-10
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,6 @@ $darkSecondary: var(--g-color-text-dark-secondary);
130130
#{$block}__title *,
131131
#{$block}__text .yfm,
132132
#{$block}__text .yfm *,
133-
#{$block}__list *,
134-
#{$block}__list .yfm,
135-
#{$block}__list .yfm *,
136133
#{$block}__links a {
137134
color: $lightPrimary;
138135
}
@@ -148,8 +145,7 @@ $darkSecondary: var(--g-color-text-dark-secondary);
148145
}
149146
}
150147

151-
#{$block}__text,
152-
#{$block}__list {
148+
#{$block}__text {
153149
.yfm a {
154150
@include content-link($lightPrimary, $lightSecondary);
155151
}
@@ -167,9 +163,6 @@ $darkSecondary: var(--g-color-text-dark-secondary);
167163
#{$block}__title *,
168164
#{$block}__text .yfm,
169165
#{$block}__text .yfm *,
170-
#{$block}__list *,
171-
#{$block}__list .yfm,
172-
#{$block}__list .yfm *,
173166
#{$block}__links a {
174167
color: $darkPrimary;
175168
}
@@ -185,8 +178,7 @@ $darkSecondary: var(--g-color-text-dark-secondary);
185178
}
186179
}
187180

188-
#{$block}__text,
189-
#{$block}__list {
181+
#{$block}__text {
190182
.yfm a {
191183
@include content-link($darkPrimary, $darkSecondary);
192184
}

src/sub-blocks/Content/Content.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ const Content = (props: ContentProps) => {
8080
)}
8181
{list?.length ? (
8282
<div className={b('list')}>
83-
<ContentList list={list} size={size} qa={qaAttributes.list} />
83+
<ContentList list={list} size={size} qa={qaAttributes.list} theme={theme} />
8484
</div>
8585
) : null}
8686
{additionalInfo && (

0 commit comments

Comments
 (0)