Skip to content

Commit f17b426

Browse files
authored
feat: added text components instead of spans/divs in dynamic forms (#158)
Authored-by: Aleksei <[email protected]>
1 parent 8dc8eaa commit f17b426

File tree

118 files changed

+85
-120
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+85
-120
lines changed

src/lib/kit/components/AccordeonCard/AccordeonCard.scss

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,6 @@
6363
order: -1;
6464
}
6565

66-
&-content-title {
67-
font-weight: 700;
68-
69-
&_size_s {
70-
font-size: 13px;
71-
}
72-
73-
&_size_m {
74-
font-size: 16px;
75-
}
76-
}
77-
7866
&-content-description {
7967
margin-top: 12px;
8068
color: var(--g-color-text-complementary);

src/lib/kit/components/AccordeonCard/AccordeonCard.tsx

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22

33
import {ChevronDown} from '@gravity-ui/icons';
4-
import {Button, Icon} from '@gravity-ui/uikit';
4+
import {Button, Icon, Text} from '@gravity-ui/uikit';
55
import _ from 'lodash';
66

77
import {block} from '../../utils';
@@ -69,6 +69,18 @@ export const AccordeonCard: React.FC<AccordeonCardProps> = ({
6969
}
7070
});
7171

72+
const currentHeaderVariant = React.useMemo(() => {
73+
if (!_.isString(header)) {
74+
return 'body-1';
75+
}
76+
77+
if (titleSize === 'm') {
78+
return 'subheader-2';
79+
}
80+
81+
return 'subheader-1';
82+
}, [titleSize]);
83+
7284
return (
7385
<div ref={accordeonRef} className={b({empty: Boolean(emptyBody)}, className)}>
7486
<div
@@ -79,15 +91,7 @@ export const AccordeonCard: React.FC<AccordeonCardProps> = ({
7991
onClick={!ignoreHeaderToggle && !alwaysOpen ? handleToggle : undefined}
8092
>
8193
<div className={b('header-content')}>
82-
<span
83-
className={
84-
_.isString(header)
85-
? b('header-content-title', {size: titleSize})
86-
: undefined
87-
}
88-
>
89-
{header}
90-
</span>
94+
<Text variant={currentHeaderVariant}>{header}</Text>
9195
{description ? (
9296
<span
9397
className={b('header-content-description')}

src/lib/kit/components/Card/Card.scss

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,6 @@
6464
}
6565

6666
&__title {
67-
font-size: var(--g-text-subheader-2-font-size);
68-
font-weight: var(--g-text-subheader-font-weight);
69-
line-height: var(--g-text-subheader-2-line-height);
70-
white-space: nowrap;
71-
overflow: hidden;
72-
text-overflow: ellipsis;
7367
max-width: 533px;
7468
}
7569

src/lib/kit/components/Card/Card.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22

33
import {HelpPopover} from '@gravity-ui/components';
44
import {ChevronDown} from '@gravity-ui/icons';
5-
import {Button, Card as CardBase, Icon, Popover} from '@gravity-ui/uikit';
5+
import {Button, Card as CardBase, Icon, Popover, Text} from '@gravity-ui/uikit';
66
import _ from 'lodash';
77

88
import {COMMON_POPOVER_PLACEMENT, COMMON_TITLE_MAX_WIDTH} from '../../constants/common';
@@ -79,9 +79,14 @@ export const Card: React.FC<CardProps> = ({
7979
disabled={titlePopoverDisabled}
8080
placement={COMMON_POPOVER_PLACEMENT}
8181
>
82-
<div ref={titleRef} className={b('title')}>
82+
<Text
83+
className={b('title')}
84+
ellipsis={true}
85+
ref={titleRef}
86+
variant="subheader-2"
87+
>
8388
{propsTitle}
84-
</div>
89+
</Text>
8590
</Popover>
8691
{description ? (
8792
<div className={b('note')}>
-204 Bytes
-111 Bytes
-201 Bytes
-117 Bytes
-292 Bytes
7 Bytes

0 commit comments

Comments
 (0)