Skip to content

Commit 1fd8cf7

Browse files
author
Juli Ovechkina
authored
feat(Title): add size xs (#207)
1 parent f514757 commit 1fd8cf7

File tree

9 files changed

+61
-18
lines changed

9 files changed

+61
-18
lines changed

src/components/BlockHeader/BlockHeader.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ $block: '.#{$ns}block-header';
1111

1212
margin-top: $indentXXS;
1313

14-
&_titleSize_s {
14+
&_titleSize_s,
15+
&_titleSize_xs {
1516
margin-top: $indentXXXS;
1617

1718
.yfm {

src/components/BlockHeader/__stories__/BlockHeader.stories.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ const SizesTemplate: Story<BlockHeaderProps & ClassNameProps> = (args) => (
2828
<div style={{paddingBottom: '64px'}}>
2929
<BlockHeader {...args} title={data.sizes.s as TitleProps} />
3030
</div>
31+
<div style={{paddingBottom: '64px'}}>
32+
<BlockHeader {...args} title={data.sizes.xs as TitleProps} />
33+
</div>
3134
</div>
3235
);
3336

src/components/BlockHeader/__stories__/data.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
}
2424
},
2525
"sizes": {
26+
"xs": {
27+
"text": "Size XS",
28+
"textSize": "xs"
29+
},
2630
"s": {
2731
"text": "Size S",
2832
"textSize": "s"

src/components/Title/Title.scss

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@ $block: '.#{$ns}title-block';
77
@include justify();
88
$root: &;
99

10+
&_size_xs {
11+
@include heading5();
12+
}
13+
1014
&_size_s {
1115
@include heading4();
12-
1316
margin-top: $indentM;
1417
}
1518

@@ -24,10 +27,14 @@ $block: '.#{$ns}title-block';
2427
}
2528

2629
&__arrow {
27-
margin: 8px 0 0 4px;
30+
margin-top: 10px;
31+
32+
&_size_xs {
33+
margin-top: 7px;
34+
}
2835

2936
&_size_s {
30-
margin: 4px 0 0 4px;
37+
margin-top: 5px;
3138
}
3239
}
3340

@@ -41,7 +48,11 @@ $block: '.#{$ns}title-block';
4148
cursor: pointer;
4249

4350
#{$root}__arrow {
44-
margin-left: 12px;
51+
margin-left: 10px;
52+
53+
&_size_xs {
54+
margin-left: 6px;
55+
}
4556

4657
&_size_s {
4758
margin-left: 8px;
@@ -66,8 +77,15 @@ $block: '.#{$ns}title-block';
6677
}
6778

6879
@media (max-width: map-get($gridBreakpoints, 'sm')) {
69-
&_size_l {
80+
&_size_l:not(#{$root}_reset-margin) {
7081
margin-top: $indentL;
7182
}
83+
84+
&__arrow {
85+
&_size_m,
86+
&_size_l {
87+
margin-top: 9px;
88+
}
89+
}
7290
}
7391
}

src/components/Title/Title.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@ const b = block('title-block');
1313

1414
export function getArrowSize(size: TextSize, isMobile: boolean) {
1515
switch (size) {
16+
case 'xs':
17+
return 13;
1618
case 's':
1719
return 16;
1820
case 'm':
19-
return isMobile ? 20 : 24;
21+
return isMobile ? 22 : 24;
2022
case 'l':
21-
return isMobile ? 20 : 24;
23+
return isMobile ? 26 : 38;
2224
default:
2325
return 20;
2426
}

src/components/Title/__stories__/Title.stories.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {Meta, Story} from '@storybook/react/types-6-0';
2-
import React from 'react';
2+
import React, {Fragment} from 'react';
33

44
import Title, {TitleFullProps} from '../Title';
55
import {COMPONENTS} from '../../../demo/constants';
@@ -14,10 +14,21 @@ export default {
1414

1515
const DefaultTemplate: Story<TitleFullProps> = (args) => <Title {...args} />;
1616

17+
const SizeTemplate: Story<TitleFullProps> = (args) => (
18+
<Fragment>
19+
<Title {...args} textSize="xs" />
20+
<Title {...args} textSize="s" />
21+
<Title {...args} textSize="m" />
22+
<Title {...args} textSize="l" resetMargin={true} />
23+
</Fragment>
24+
);
25+
1726
export const Default = DefaultTemplate.bind({});
18-
export const WithLink = DefaultTemplate.bind({});
27+
export const WithLink = SizeTemplate.bind({});
1928
export const ResetMargin = DefaultTemplate.bind({});
29+
export const Size = SizeTemplate.bind({});
2030

2131
Default.args = data.default.content as TitleProps;
2232
WithLink.args = data.withLink.content as TitleProps;
2333
ResetMargin.args = data.resetMargin.content as TitleProps;
34+
Size.args = data.default.content as TitleProps;

src/models/constructor-items/common.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export enum MediaVideoControlsType {
5050

5151
// types
5252
export type TextTheme = 'light' | 'dark';
53-
export type TextSize = 's' | 'm' | 'l';
53+
export type TextSize = 'xs' | 's' | 'm' | 'l';
5454
export type DividerSize = '0' | 'xxs' | 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl' | 'xxxl';
5555
export type HeaderWidth = 's' | 'm' | 'l';
5656
export type HeaderImageSize = 's' | 'm';

src/utils/blocks.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ export function getHeaderTag(size: TextSize) {
88
return 'h1';
99
case 's':
1010
return 'h4';
11+
case 'xs':
12+
return 'h5';
1113
case 'm':
1214
default:
1315
return 'h2';

styles/mixins.scss

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -141,15 +141,17 @@
141141
}
142142

143143
@mixin label($size: m) {
144-
@include text-size(body-1);
144+
@if $size == m {
145+
@include text-size(body-1);
145146

146-
$label-height: 20px;
147+
$label-height: 20px;
147148

148-
display: inline-block;
149-
padding: 0 8px;
150-
border-radius: 2px;
151-
height: $label-height;
152-
line-height: $label-height;
149+
display: inline-block;
150+
padding: 0 8px;
151+
border-radius: 2px;
152+
height: $label-height;
153+
line-height: $label-height;
154+
}
153155

154156
@if $size == s {
155157
@include text-size(caption-2);

0 commit comments

Comments
 (0)