@snack-uikit/skeleton 0.5.1 → 0.6.1-preview-20b0f520.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 +16 -0
- package/README.md +1 -1
- package/dist/cjs/components/SkeletonText/SkeletonText.d.ts +5 -2
- package/dist/cjs/components/SkeletonText/SkeletonText.js +9 -5
- package/dist/cjs/components/SkeletonText/constants.d.ts +12 -0
- package/dist/cjs/components/SkeletonText/constants.js +18 -0
- package/dist/cjs/components/SkeletonText/types.d.ts +6 -0
- package/dist/cjs/components/SkeletonText/types.js +5 -0
- package/dist/esm/components/SkeletonText/SkeletonText.d.ts +5 -2
- package/dist/esm/components/SkeletonText/SkeletonText.js +5 -3
- package/dist/esm/components/SkeletonText/constants.d.ts +12 -0
- package/dist/esm/components/SkeletonText/constants.js +12 -0
- package/dist/esm/components/SkeletonText/types.d.ts +6 -0
- package/dist/esm/components/SkeletonText/types.js +1 -0
- package/package.json +3 -3
- package/src/components/SkeletonText/SkeletonText.tsx +16 -6
- package/src/components/SkeletonText/constants.ts +13 -0
- package/src/components/SkeletonText/styles.module.scss +2 -0
- package/src/components/SkeletonText/types.ts +8 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
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.6.0 (2024-11-29)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **PDS-801:** add typography prop ([b0e8495](https://github.com/cloud-ru-tech/snack-uikit/commit/b0e84950550b866c3a4460b4b31143df498d705b))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### BREAKING CHANGES
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
* **PDS-801:** use skeleton text tokens ([930bcb0](https://github.com/cloud-ru-tech/snack-uikit/commit/930bcb01500e5754457a8d1e8fdf2c0487bc2526))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
6
22
|
## 0.5.1 (2024-11-14)
|
|
7
23
|
|
|
8
24
|
|
package/README.md
CHANGED
|
@@ -37,11 +37,11 @@
|
|
|
37
37
|
|------|------|---------------|-------------|
|
|
38
38
|
| loading | `boolean` | - | Флаг состояния загрузки. Если значение true, будет отрисован блок скелетона, если false - children. |
|
|
39
39
|
| width | `Width<string \| number>` | - | Ширина блока. Можно указать значение допустимое для CSSProperty.width (пример `'60%'`, `'400px'` и т.д) |
|
|
40
|
-
| borderRadius | `BorderRadius<string \| number>` | 0.4em | Радиус скругления. Можно указать значение допустимое для CSSProperty.borderRadius (пример `'10px'`, `'50%'` и т.д) |
|
|
41
40
|
| className | `string` | - | CSS-класс |
|
|
42
41
|
| lines | `number` | 3 | Количество строк. |
|
|
43
42
|
| rowClassName | `string` | - | CSS-класс строки |
|
|
44
43
|
| lineClassName | `string` | - | CSS-класс линии |
|
|
44
|
+
| typography | "display-l" \| "display-m" \| "display-s" \| "headline-l" \| "headline-m" \| "headline-s" \| "title-l" \| "title-m" \| "title-s" \| "label-l" \| "label-m" \| "label-s" \| "body-l" \| "body-m" \| "body-s" | body-m | Типографика |
|
|
45
45
|
## WithSkeleton
|
|
46
46
|
### Props
|
|
47
47
|
| name | type | default value | description |
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { WithSupportProps } from '@snack-uikit/utils';
|
|
2
2
|
import { SkeletonProps } from '../Skeleton';
|
|
3
|
-
|
|
3
|
+
import { Variant } from './types';
|
|
4
|
+
export type SkeletonTextProps = WithSupportProps<Omit<SkeletonProps, 'height' | 'borderRadius'> & {
|
|
4
5
|
/** Количество строк. */
|
|
5
6
|
lines?: number;
|
|
6
7
|
/** CSS-класс строки */
|
|
7
8
|
rowClassName?: string;
|
|
8
9
|
/** CSS-класс линии */
|
|
9
10
|
lineClassName?: string;
|
|
11
|
+
/** Типографика */
|
|
12
|
+
typography?: Variant;
|
|
10
13
|
}>;
|
|
11
|
-
export declare function SkeletonText({ width, className, rowClassName, lineClassName, children, loading, lines,
|
|
14
|
+
export declare function SkeletonText({ width, className, rowClassName, lineClassName, children, loading, lines, typography, ...restProps }: SkeletonTextProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -32,26 +32,30 @@ function SkeletonText(_a) {
|
|
|
32
32
|
children,
|
|
33
33
|
loading,
|
|
34
34
|
lines = 3,
|
|
35
|
-
|
|
35
|
+
typography = 'body-m'
|
|
36
36
|
} = _a,
|
|
37
|
-
restProps = __rest(_a, ["width", "className", "rowClassName", "lineClassName", "children", "loading", "lines", "
|
|
37
|
+
restProps = __rest(_a, ["width", "className", "rowClassName", "lineClassName", "children", "loading", "lines", "typography"]);
|
|
38
38
|
const lineTestId = restProps['data-test-id'] ? `${restProps['data-test-id']}_line` : undefined;
|
|
39
39
|
const rows = (0, react_1.useMemo)(() => Array(lines).fill(true).map((_, index) => (0, jsx_runtime_1.jsx)("div", {
|
|
40
40
|
className: (0, classnames_1.default)(styles_module_scss_1.default.skeletonTextRow, rowClassName),
|
|
41
|
+
style: {
|
|
42
|
+
lineHeight: `var(--size-skeleton-text-line-height-${typography})`
|
|
43
|
+
},
|
|
41
44
|
children: (0, jsx_runtime_1.jsx)(Skeleton_1.Skeleton, {
|
|
42
45
|
"data-test-id": lineTestId,
|
|
43
46
|
loading: true,
|
|
44
|
-
|
|
47
|
+
height: `var(--size-skeleton-text-font-size-${typography})`,
|
|
48
|
+
borderRadius: `var(--radius-skeleton-text-${typography})`,
|
|
45
49
|
className: (0, classnames_1.default)(styles_module_scss_1.default.skeletonTextLine, lineClassName)
|
|
46
50
|
})
|
|
47
|
-
}, index)), [lines,
|
|
51
|
+
}, index)), [lines, rowClassName, lineTestId, typography, lineClassName]);
|
|
48
52
|
const isLoading = (0, hooks_1.useIsLoadingValue)(loading);
|
|
49
53
|
if (isLoading) {
|
|
50
54
|
return (0, jsx_runtime_1.jsx)("div", Object.assign({}, restProps, {
|
|
55
|
+
className: (0, classnames_1.default)(className, styles_module_scss_1.default.skeletonText),
|
|
51
56
|
style: {
|
|
52
57
|
width
|
|
53
58
|
},
|
|
54
|
-
className: (0, classnames_1.default)(className, styles_module_scss_1.default.skeletonText),
|
|
55
59
|
children: rows
|
|
56
60
|
}));
|
|
57
61
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const PURPOSE: {
|
|
2
|
+
readonly Display: "display";
|
|
3
|
+
readonly Headline: "headline";
|
|
4
|
+
readonly Title: "title";
|
|
5
|
+
readonly Label: "label";
|
|
6
|
+
readonly Body: "body";
|
|
7
|
+
};
|
|
8
|
+
export declare const SIZE: {
|
|
9
|
+
readonly L: "l";
|
|
10
|
+
readonly M: "m";
|
|
11
|
+
readonly S: "s";
|
|
12
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.SIZE = exports.PURPOSE = void 0;
|
|
7
|
+
exports.PURPOSE = {
|
|
8
|
+
Display: 'display',
|
|
9
|
+
Headline: 'headline',
|
|
10
|
+
Title: 'title',
|
|
11
|
+
Label: 'label',
|
|
12
|
+
Body: 'body'
|
|
13
|
+
};
|
|
14
|
+
exports.SIZE = {
|
|
15
|
+
L: 'l',
|
|
16
|
+
M: 'm',
|
|
17
|
+
S: 's'
|
|
18
|
+
};
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { WithSupportProps } from '@snack-uikit/utils';
|
|
2
2
|
import { SkeletonProps } from '../Skeleton';
|
|
3
|
-
|
|
3
|
+
import { Variant } from './types';
|
|
4
|
+
export type SkeletonTextProps = WithSupportProps<Omit<SkeletonProps, 'height' | 'borderRadius'> & {
|
|
4
5
|
/** Количество строк. */
|
|
5
6
|
lines?: number;
|
|
6
7
|
/** CSS-класс строки */
|
|
7
8
|
rowClassName?: string;
|
|
8
9
|
/** CSS-класс линии */
|
|
9
10
|
lineClassName?: string;
|
|
11
|
+
/** Типографика */
|
|
12
|
+
typography?: Variant;
|
|
10
13
|
}>;
|
|
11
|
-
export declare function SkeletonText({ width, className, rowClassName, lineClassName, children, loading, lines,
|
|
14
|
+
export declare function SkeletonText({ width, className, rowClassName, lineClassName, children, loading, lines, typography, ...restProps }: SkeletonTextProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -16,14 +16,16 @@ import { useIsLoadingValue } from '../../hooks';
|
|
|
16
16
|
import { Skeleton } from '../Skeleton';
|
|
17
17
|
import styles from './styles.module.css';
|
|
18
18
|
export function SkeletonText(_a) {
|
|
19
|
-
var { width, className, rowClassName, lineClassName, children, loading, lines = 3,
|
|
19
|
+
var { width, className, rowClassName, lineClassName, children, loading, lines = 3, typography = 'body-m' } = _a, restProps = __rest(_a, ["width", "className", "rowClassName", "lineClassName", "children", "loading", "lines", "typography"]);
|
|
20
20
|
const lineTestId = restProps['data-test-id'] ? `${restProps['data-test-id']}_line` : undefined;
|
|
21
21
|
const rows = useMemo(() => Array(lines)
|
|
22
22
|
.fill(true)
|
|
23
|
-
.map((_, index) => (_jsx("div", { className: cn(styles.skeletonTextRow, rowClassName),
|
|
23
|
+
.map((_, index) => (_jsx("div", { className: cn(styles.skeletonTextRow, rowClassName), style: {
|
|
24
|
+
lineHeight: `var(--size-skeleton-text-line-height-${typography})`,
|
|
25
|
+
}, children: _jsx(Skeleton, { "data-test-id": lineTestId, loading: true, height: `var(--size-skeleton-text-font-size-${typography})`, borderRadius: `var(--radius-skeleton-text-${typography})`, className: cn(styles.skeletonTextLine, lineClassName) }) }, index))), [lines, rowClassName, lineTestId, typography, lineClassName]);
|
|
24
26
|
const isLoading = useIsLoadingValue(loading);
|
|
25
27
|
if (isLoading) {
|
|
26
|
-
return (_jsx("div", Object.assign({}, restProps, {
|
|
28
|
+
return (_jsx("div", Object.assign({}, restProps, { className: cn(className, styles.skeletonText), style: { width }, children: rows })));
|
|
27
29
|
}
|
|
28
30
|
return _jsx(_Fragment, { children: children });
|
|
29
31
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const PURPOSE: {
|
|
2
|
+
readonly Display: "display";
|
|
3
|
+
readonly Headline: "headline";
|
|
4
|
+
readonly Title: "title";
|
|
5
|
+
readonly Label: "label";
|
|
6
|
+
readonly Body: "body";
|
|
7
|
+
};
|
|
8
|
+
export declare const SIZE: {
|
|
9
|
+
readonly L: "l";
|
|
10
|
+
readonly M: "m";
|
|
11
|
+
readonly S: "s";
|
|
12
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"title": "Skeleton",
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.6.1-preview-20b0f520.0",
|
|
8
8
|
"sideEffects": [
|
|
9
9
|
"*.css",
|
|
10
10
|
"*.woff",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"license": "Apache-2.0",
|
|
37
37
|
"scripts": {},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@snack-uikit/utils": "3.5.0",
|
|
39
|
+
"@snack-uikit/utils": "3.5.1-preview-20b0f520.0",
|
|
40
40
|
"classnames": "2.5.1"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "3d9f58d349ce6413d2242d7a42b8ba624815dcc0"
|
|
43
43
|
}
|
|
@@ -6,15 +6,18 @@ import { WithSupportProps } from '@snack-uikit/utils';
|
|
|
6
6
|
import { useIsLoadingValue } from '../../hooks';
|
|
7
7
|
import { Skeleton, SkeletonProps } from '../Skeleton';
|
|
8
8
|
import styles from './styles.module.scss';
|
|
9
|
+
import { Variant } from './types';
|
|
9
10
|
|
|
10
11
|
export type SkeletonTextProps = WithSupportProps<
|
|
11
|
-
Omit<SkeletonProps, 'height'> & {
|
|
12
|
+
Omit<SkeletonProps, 'height' | 'borderRadius'> & {
|
|
12
13
|
/** Количество строк. */
|
|
13
14
|
lines?: number;
|
|
14
15
|
/** CSS-класс строки */
|
|
15
16
|
rowClassName?: string;
|
|
16
17
|
/** CSS-класс линии */
|
|
17
18
|
lineClassName?: string;
|
|
19
|
+
/** Типографика */
|
|
20
|
+
typography?: Variant;
|
|
18
21
|
}
|
|
19
22
|
>;
|
|
20
23
|
|
|
@@ -26,7 +29,7 @@ export function SkeletonText({
|
|
|
26
29
|
children,
|
|
27
30
|
loading,
|
|
28
31
|
lines = 3,
|
|
29
|
-
|
|
32
|
+
typography = 'body-m',
|
|
30
33
|
...restProps
|
|
31
34
|
}: SkeletonTextProps) {
|
|
32
35
|
const lineTestId = restProps['data-test-id'] ? `${restProps['data-test-id']}_line` : undefined;
|
|
@@ -36,23 +39,30 @@ export function SkeletonText({
|
|
|
36
39
|
Array(lines)
|
|
37
40
|
.fill(true)
|
|
38
41
|
.map((_, index) => (
|
|
39
|
-
<div
|
|
42
|
+
<div
|
|
43
|
+
key={index}
|
|
44
|
+
className={cn(styles.skeletonTextRow, rowClassName)}
|
|
45
|
+
style={{
|
|
46
|
+
lineHeight: `var(--size-skeleton-text-line-height-${typography})`,
|
|
47
|
+
}}
|
|
48
|
+
>
|
|
40
49
|
<Skeleton
|
|
41
50
|
data-test-id={lineTestId}
|
|
42
51
|
loading
|
|
43
|
-
|
|
52
|
+
height={`var(--size-skeleton-text-font-size-${typography})`}
|
|
53
|
+
borderRadius={`var(--radius-skeleton-text-${typography})`}
|
|
44
54
|
className={cn(styles.skeletonTextLine, lineClassName)}
|
|
45
55
|
/>
|
|
46
56
|
</div>
|
|
47
57
|
)),
|
|
48
|
-
[lines,
|
|
58
|
+
[lines, rowClassName, lineTestId, typography, lineClassName],
|
|
49
59
|
);
|
|
50
60
|
|
|
51
61
|
const isLoading = useIsLoadingValue(loading);
|
|
52
62
|
|
|
53
63
|
if (isLoading) {
|
|
54
64
|
return (
|
|
55
|
-
<div {...restProps}
|
|
65
|
+
<div {...restProps} className={cn(className, styles.skeletonText)} style={{ width }}>
|
|
56
66
|
{rows}
|
|
57
67
|
</div>
|
|
58
68
|
);
|