@snack-uikit/card 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/dist/components/Header/Header.d.ts +13 -1
- package/dist/components/Header/Header.js +4 -3
- package/dist/components/Header/constants.d.ts +5 -0
- package/dist/components/Header/constants.js +5 -0
- package/package.json +2 -2
- package/src/components/Header/Header.tsx +38 -5
- package/src/components/Header/constants.ts +6 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# 0.8.0 (2024-01-22)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **FF-4133:** add truncate props to Card.Header ([e2f86c1](https://github.com/cloud-ru-tech/snack-uikit/commit/e2f86c170d1e419edc0bc88fc1776616d08b366d))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# 0.7.0 (2023-12-28)
|
|
7
18
|
|
|
8
19
|
|
|
@@ -8,6 +8,18 @@ export type HeaderProps = WithSupportProps<{
|
|
|
8
8
|
description?: string;
|
|
9
9
|
/** Метаинформация */
|
|
10
10
|
metadata?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Максимальное кол-во строк
|
|
13
|
+
* <br> - `title` - в заголовке
|
|
14
|
+
* <br> - `description` - в описании
|
|
15
|
+
* <br> - `metadata` - в подзаголовке
|
|
16
|
+
* @default '{ <br>title: 1; <br>description: 2; <br>metadata: 1; }'
|
|
17
|
+
*/
|
|
18
|
+
truncate?: {
|
|
19
|
+
title?: number;
|
|
20
|
+
description?: number;
|
|
21
|
+
metadata?: number;
|
|
22
|
+
};
|
|
11
23
|
/** Эмблема иконка/картинка */
|
|
12
24
|
emblem?: EmblemProps;
|
|
13
25
|
/** CSS-класс для элемента с контентом */
|
|
@@ -15,4 +27,4 @@ export type HeaderProps = WithSupportProps<{
|
|
|
15
27
|
/** Размер */
|
|
16
28
|
size?: Size;
|
|
17
29
|
}>;
|
|
18
|
-
export declare function Header({ title, description, metadata, emblem, className, size: sizeProp, ...rest }: HeaderProps): import("react/jsx-runtime").JSX.Element;
|
|
30
|
+
export declare function Header({ title, description, metadata, truncate, emblem, className, size: sizeProp, ...rest }: HeaderProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -17,11 +17,12 @@ import { excludeSupportProps } from '@snack-uikit/utils';
|
|
|
17
17
|
import { TEST_IDS } from '../../constants';
|
|
18
18
|
import { useCardContext } from '../../context';
|
|
19
19
|
import { Emblem } from '../../helperComponents';
|
|
20
|
-
import { DESCRIPTION_SIZE_MAP, TITLE_SIZE_MAP } from './constants';
|
|
20
|
+
import { DESCRIPTION_SIZE_MAP, TITLE_SIZE_MAP, TRUNCATE_DEFAULTS } from './constants';
|
|
21
21
|
import styles from './styles.module.css';
|
|
22
22
|
export function Header(_a) {
|
|
23
|
-
var { title, description, metadata, emblem, className, size: sizeProp } = _a, rest = __rest(_a, ["title", "description", "metadata", "emblem", "className", "size"]);
|
|
23
|
+
var { title, description, metadata, truncate, emblem, className, size: sizeProp } = _a, rest = __rest(_a, ["title", "description", "metadata", "truncate", "emblem", "className", "size"]);
|
|
24
24
|
const { size: sizeContext } = useCardContext();
|
|
25
25
|
const size = sizeProp || sizeContext;
|
|
26
|
-
|
|
26
|
+
const truncateStrings = Object.assign(Object.assign({}, TRUNCATE_DEFAULTS), truncate);
|
|
27
|
+
return (_jsxs("div", Object.assign({ className: cn(styles.titleLayout, className) }, excludeSupportProps(rest), { "data-size": size, children: [emblem && _jsx(Emblem, Object.assign({}, emblem)), _jsxs("div", { className: styles.contentLayout, children: [_jsx(Typography, { family: 'sans', size: TITLE_SIZE_MAP[size], purpose: 'title', className: styles.title, "data-test-id": TEST_IDS.title, children: _jsx(TruncateString, { variant: 'end', maxLines: truncateStrings.title, text: title }) }), metadata && (_jsx(Typography.SansBodyS, { className: styles.metadata, children: _jsx(TruncateString, { variant: 'end', maxLines: truncateStrings.metadata, text: metadata, "data-test-id": TEST_IDS.metadata }) })), description && (_jsx(Typography, { family: 'sans', size: DESCRIPTION_SIZE_MAP[size], purpose: 'body', className: styles.description, children: _jsx(TruncateString, { variant: 'end', maxLines: truncateStrings.description, text: description, "data-test-id": TEST_IDS.description }) }))] })] })));
|
|
27
28
|
}
|
|
@@ -2,3 +2,8 @@ import { TypographyProps } from '@snack-uikit/typography';
|
|
|
2
2
|
import { Size } from '../../types';
|
|
3
3
|
export declare const TITLE_SIZE_MAP: Record<Size, TypographyProps['size']>;
|
|
4
4
|
export declare const DESCRIPTION_SIZE_MAP: Record<Size, TypographyProps['size']>;
|
|
5
|
+
export declare const TRUNCATE_DEFAULTS: {
|
|
6
|
+
title: number;
|
|
7
|
+
description: number;
|
|
8
|
+
metadata: number;
|
|
9
|
+
};
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"title": "Card",
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.8.0",
|
|
8
8
|
"sideEffects": [
|
|
9
9
|
"*.css",
|
|
10
10
|
"*.woff",
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"@snack-uikit/utils": "3.2.0",
|
|
43
43
|
"classnames": "2.3.2"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "2d8416044420dd6c97436f74077e94dcae00cad7"
|
|
46
46
|
}
|
|
@@ -8,7 +8,7 @@ import { TEST_IDS } from '../../constants';
|
|
|
8
8
|
import { useCardContext } from '../../context';
|
|
9
9
|
import { Emblem, EmblemProps } from '../../helperComponents';
|
|
10
10
|
import { Size } from '../../types';
|
|
11
|
-
import { DESCRIPTION_SIZE_MAP, TITLE_SIZE_MAP } from './constants';
|
|
11
|
+
import { DESCRIPTION_SIZE_MAP, TITLE_SIZE_MAP, TRUNCATE_DEFAULTS } from './constants';
|
|
12
12
|
import styles from './styles.module.scss';
|
|
13
13
|
|
|
14
14
|
export type HeaderProps = WithSupportProps<{
|
|
@@ -18,6 +18,18 @@ export type HeaderProps = WithSupportProps<{
|
|
|
18
18
|
description?: string;
|
|
19
19
|
/** Метаинформация */
|
|
20
20
|
metadata?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Максимальное кол-во строк
|
|
23
|
+
* <br> - `title` - в заголовке
|
|
24
|
+
* <br> - `description` - в описании
|
|
25
|
+
* <br> - `metadata` - в подзаголовке
|
|
26
|
+
* @default '{ <br>title: 1; <br>description: 2; <br>metadata: 1; }'
|
|
27
|
+
*/
|
|
28
|
+
truncate?: {
|
|
29
|
+
title?: number;
|
|
30
|
+
description?: number;
|
|
31
|
+
metadata?: number;
|
|
32
|
+
};
|
|
21
33
|
/** Эмблема иконка/картинка */
|
|
22
34
|
emblem?: EmblemProps;
|
|
23
35
|
/** CSS-класс для элемента с контентом */
|
|
@@ -26,11 +38,22 @@ export type HeaderProps = WithSupportProps<{
|
|
|
26
38
|
size?: Size;
|
|
27
39
|
}>;
|
|
28
40
|
|
|
29
|
-
export function Header({
|
|
41
|
+
export function Header({
|
|
42
|
+
title,
|
|
43
|
+
description,
|
|
44
|
+
metadata,
|
|
45
|
+
truncate,
|
|
46
|
+
emblem,
|
|
47
|
+
className,
|
|
48
|
+
size: sizeProp,
|
|
49
|
+
...rest
|
|
50
|
+
}: HeaderProps) {
|
|
30
51
|
const { size: sizeContext } = useCardContext();
|
|
31
52
|
|
|
32
53
|
const size = sizeProp || sizeContext;
|
|
33
54
|
|
|
55
|
+
const truncateStrings = { ...TRUNCATE_DEFAULTS, ...truncate };
|
|
56
|
+
|
|
34
57
|
return (
|
|
35
58
|
<div className={cn(styles.titleLayout, className)} {...excludeSupportProps(rest)} data-size={size}>
|
|
36
59
|
{emblem && <Emblem {...emblem} />}
|
|
@@ -43,18 +66,28 @@ export function Header({ title, description, metadata, emblem, className, size:
|
|
|
43
66
|
className={styles.title}
|
|
44
67
|
data-test-id={TEST_IDS.title}
|
|
45
68
|
>
|
|
46
|
-
<TruncateString variant='end' maxLines={
|
|
69
|
+
<TruncateString variant='end' maxLines={truncateStrings.title} text={title} />
|
|
47
70
|
</Typography>
|
|
48
71
|
|
|
49
72
|
{metadata && (
|
|
50
73
|
<Typography.SansBodyS className={styles.metadata}>
|
|
51
|
-
<TruncateString
|
|
74
|
+
<TruncateString
|
|
75
|
+
variant='end'
|
|
76
|
+
maxLines={truncateStrings.metadata}
|
|
77
|
+
text={metadata}
|
|
78
|
+
data-test-id={TEST_IDS.metadata}
|
|
79
|
+
/>
|
|
52
80
|
</Typography.SansBodyS>
|
|
53
81
|
)}
|
|
54
82
|
|
|
55
83
|
{description && (
|
|
56
84
|
<Typography family='sans' size={DESCRIPTION_SIZE_MAP[size]} purpose='body' className={styles.description}>
|
|
57
|
-
<TruncateString
|
|
85
|
+
<TruncateString
|
|
86
|
+
variant='end'
|
|
87
|
+
maxLines={truncateStrings.description}
|
|
88
|
+
text={description}
|
|
89
|
+
data-test-id={TEST_IDS.description}
|
|
90
|
+
/>
|
|
58
91
|
</Typography>
|
|
59
92
|
)}
|
|
60
93
|
</div>
|