@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 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
- export type SkeletonTextProps = WithSupportProps<Omit<SkeletonProps, 'height'> & {
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, borderRadius, ...restProps }: SkeletonTextProps): import("react/jsx-runtime").JSX.Element;
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
- borderRadius = '0.4em'
35
+ typography = 'body-m'
36
36
  } = _a,
37
- restProps = __rest(_a, ["width", "className", "rowClassName", "lineClassName", "children", "loading", "lines", "borderRadius"]);
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
- borderRadius: borderRadius,
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, borderRadius, rowClassName, lineClassName, lineTestId]);
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
+ };
@@ -0,0 +1,6 @@
1
+ import { ValueOf } from '@snack-uikit/utils';
2
+ import { PURPOSE, SIZE } from './constants';
3
+ type Purpose = ValueOf<typeof PURPOSE>;
4
+ type Size = ValueOf<typeof SIZE>;
5
+ export type Variant = `${Purpose}-${Size}`;
6
+ export {};
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -1,11 +1,14 @@
1
1
  import { WithSupportProps } from '@snack-uikit/utils';
2
2
  import { SkeletonProps } from '../Skeleton';
3
- export type SkeletonTextProps = WithSupportProps<Omit<SkeletonProps, 'height'> & {
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, borderRadius, ...restProps }: SkeletonTextProps): import("react/jsx-runtime").JSX.Element;
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, borderRadius = '0.4em' } = _a, restProps = __rest(_a, ["width", "className", "rowClassName", "lineClassName", "children", "loading", "lines", "borderRadius"]);
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), children: _jsx(Skeleton, { "data-test-id": lineTestId, loading: true, borderRadius: borderRadius, className: cn(styles.skeletonTextLine, lineClassName) }) }, index))), [lines, borderRadius, rowClassName, lineClassName, lineTestId]);
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, { style: { width }, className: cn(className, styles.skeletonText), children: rows })));
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,12 @@
1
+ export const PURPOSE = {
2
+ Display: 'display',
3
+ Headline: 'headline',
4
+ Title: 'title',
5
+ Label: 'label',
6
+ Body: 'body',
7
+ };
8
+ export const SIZE = {
9
+ L: 'l',
10
+ M: 'm',
11
+ S: 's',
12
+ };
@@ -0,0 +1,6 @@
1
+ import { ValueOf } from '@snack-uikit/utils';
2
+ import { PURPOSE, SIZE } from './constants';
3
+ type Purpose = ValueOf<typeof PURPOSE>;
4
+ type Size = ValueOf<typeof SIZE>;
5
+ export type Variant = `${Purpose}-${Size}`;
6
+ export {};
@@ -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.5.1",
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": "b9670e68c6af5fdd5dfceeae29ef3af8c89e5e6b"
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
- borderRadius = '0.4em',
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 key={index} className={cn(styles.skeletonTextRow, rowClassName)}>
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
- borderRadius={borderRadius}
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, borderRadius, rowClassName, lineClassName, lineTestId],
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} style={{ width }} className={cn(className, styles.skeletonText)}>
65
+ <div {...restProps} className={cn(className, styles.skeletonText)} style={{ width }}>
56
66
  {rows}
57
67
  </div>
58
68
  );
@@ -0,0 +1,13 @@
1
+ export const PURPOSE = {
2
+ Display: 'display',
3
+ Headline: 'headline',
4
+ Title: 'title',
5
+ Label: 'label',
6
+ Body: 'body',
7
+ } as const;
8
+
9
+ export const SIZE = {
10
+ L: 'l',
11
+ M: 'm',
12
+ S: 's',
13
+ } as const;
@@ -1,3 +1,5 @@
1
+ @use '@snack-uikit/figma-tokens/build/scss/components/styles-tokens-skeleton';
2
+
1
3
  .skeletonText {
2
4
  position: relative;
3
5
  }
@@ -0,0 +1,8 @@
1
+ import { ValueOf } from '@snack-uikit/utils';
2
+
3
+ import { PURPOSE, SIZE } from './constants';
4
+
5
+ type Purpose = ValueOf<typeof PURPOSE>;
6
+ type Size = ValueOf<typeof SIZE>;
7
+
8
+ export type Variant = `${Purpose}-${Size}`;