@alfalab/core-components-typography 4.13.1 → 4.14.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/colors.css +21 -21
- package/colors.module-75d911c2.js +6 -0
- package/common.module-23cd82b6.js +6 -0
- package/cssm/text/alfasans-index.module.css +16 -0
- package/cssm/text/component.d.ts +2 -1
- package/cssm/text/component.js +2 -2
- package/cssm/title/alfasans-index.module.css +0 -10
- package/cssm/title/component.d.ts +1 -1
- package/cssm/title/component.js +2 -2
- package/cssm/title/index.d.ts +1 -1
- package/cssm/title-mobile/component.d.ts +1 -1
- package/cssm/title-responsive/component.d.ts +1 -1
- package/cssm/types.d.ts +1 -20
- package/esm/colors.css +21 -21
- package/esm/colors.module-4059b326.js +4 -0
- package/esm/common.module-6cbe43bf.js +4 -0
- package/esm/text/alfasans-index.css +30 -30
- package/esm/text/component.d.ts +2 -1
- package/esm/text/component.js +4 -4
- package/esm/text/index.css +22 -22
- package/esm/title/alfasans-index.css +11 -11
- package/esm/title/common.css +9 -9
- package/esm/title/component.d.ts +1 -1
- package/esm/title/component.js +2 -2
- package/esm/title/index.css +17 -17
- package/esm/title/index.d.ts +1 -1
- package/esm/title/index.js +3 -3
- package/esm/title-mobile/alfasans-index.css +11 -11
- package/esm/title-mobile/component.d.ts +1 -1
- package/esm/title-mobile/component.js +3 -3
- package/esm/title-mobile/index.css +16 -16
- package/esm/title-responsive/component.d.ts +1 -1
- package/esm/types.d.ts +1 -20
- package/modern/colors.css +21 -21
- package/modern/colors.module-fb170d72.js +4 -0
- package/modern/common.module-82ebec0f.js +4 -0
- package/modern/text/alfasans-index.css +30 -30
- package/modern/text/component.d.ts +2 -1
- package/modern/text/component.js +4 -4
- package/modern/text/index.css +22 -22
- package/modern/title/alfasans-index.css +11 -11
- package/modern/title/common.css +9 -9
- package/modern/title/component.d.ts +1 -1
- package/modern/title/component.js +2 -2
- package/modern/title/index.css +17 -17
- package/modern/title/index.d.ts +1 -1
- package/modern/title/index.js +3 -3
- package/modern/title-mobile/alfasans-index.css +11 -11
- package/modern/title-mobile/component.d.ts +1 -1
- package/modern/title-mobile/component.js +3 -3
- package/modern/title-mobile/index.css +16 -16
- package/modern/title-responsive/component.d.ts +1 -1
- package/modern/types.d.ts +1 -20
- package/moderncssm/text/alfasans-index.module.css +16 -0
- package/moderncssm/text/component.d.ts +2 -1
- package/moderncssm/text/component.js +1 -1
- package/moderncssm/title/alfasans-index.module.css +0 -10
- package/moderncssm/title/component.d.ts +1 -1
- package/moderncssm/title/component.js +1 -1
- package/moderncssm/title/index.d.ts +1 -1
- package/moderncssm/title-mobile/component.d.ts +1 -1
- package/moderncssm/title-responsive/component.d.ts +1 -1
- package/moderncssm/types.d.ts +1 -20
- package/package.json +2 -2
- package/src/text/component.tsx +3 -2
- package/src/title/component.tsx +1 -2
- package/src/types.ts +0 -24
- package/text/alfasans-index.css +30 -30
- package/text/component.d.ts +2 -1
- package/text/component.js +5 -5
- package/text/index.css +22 -22
- package/title/alfasans-index.css +11 -11
- package/title/common.css +9 -9
- package/title/component.d.ts +1 -1
- package/title/component.js +3 -3
- package/title/index.css +17 -17
- package/title/index.d.ts +1 -1
- package/title/index.js +3 -3
- package/title-mobile/alfasans-index.css +11 -11
- package/title-mobile/component.d.ts +1 -1
- package/title-mobile/component.js +3 -3
- package/title-mobile/index.css +16 -16
- package/title-responsive/component.d.ts +1 -1
- package/types.d.ts +1 -20
- package/colors.module-94b64d8e.js +0 -6
- package/common.module-38b50dd1.js +0 -6
- package/cssm/hooks/index.d.ts +0 -1
- package/cssm/hooks/index.js +0 -9
- package/cssm/hooks/use-skeleton.d.ts +0 -12
- package/cssm/hooks/use-skeleton.js +0 -61
- package/cssm/hooks/use-skeleton.module.css +0 -33
- package/esm/colors.module-5fa27b46.js +0 -4
- package/esm/common.module-7645bb09.js +0 -4
- package/esm/hooks/index.d.ts +0 -1
- package/esm/hooks/index.js +0 -1
- package/esm/hooks/use-skeleton.css +0 -34
- package/esm/hooks/use-skeleton.d.ts +0 -12
- package/esm/hooks/use-skeleton.js +0 -53
- package/hooks/index.d.ts +0 -1
- package/hooks/index.js +0 -9
- package/hooks/use-skeleton.css +0 -34
- package/hooks/use-skeleton.d.ts +0 -12
- package/hooks/use-skeleton.js +0 -62
- package/modern/colors.module-3cedc3fb.js +0 -4
- package/modern/common.module-d04ff6fc.js +0 -4
- package/modern/hooks/index.d.ts +0 -1
- package/modern/hooks/index.js +0 -1
- package/modern/hooks/use-skeleton.css +0 -34
- package/modern/hooks/use-skeleton.d.ts +0 -12
- package/modern/hooks/use-skeleton.js +0 -52
- package/moderncssm/hooks/index.d.ts +0 -1
- package/moderncssm/hooks/index.js +0 -1
- package/moderncssm/hooks/use-skeleton.d.ts +0 -12
- package/moderncssm/hooks/use-skeleton.js +0 -50
- package/moderncssm/hooks/use-skeleton.module.css +0 -17
- package/src/hooks/index.ts +0 -1
- package/src/hooks/use-skeleton.module.css +0 -17
- package/src/hooks/use-skeleton.tsx +0 -86
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import React, { useState, useRef } from 'react';
|
|
2
|
-
import cn from 'classnames';
|
|
3
|
-
import { Skeleton } from '@alfalab/core-components-skeleton/moderncssm';
|
|
4
|
-
import { useLayoutEffect_SAFE_FOR_SSR } from '@alfalab/hooks';
|
|
5
|
-
import styles from './use-skeleton.module.css';
|
|
6
|
-
|
|
7
|
-
function useSkeleton(showSkeleton, skeletonProps) {
|
|
8
|
-
const [skeletonParams, setSkeletonParams] = useState();
|
|
9
|
-
const textRef = useRef(null);
|
|
10
|
-
useLayoutEffect_SAFE_FOR_SSR(() => {
|
|
11
|
-
if (showSkeleton && textRef.current) {
|
|
12
|
-
const style = getComputedStyle(textRef.current);
|
|
13
|
-
const textHeight = textRef.current.offsetHeight;
|
|
14
|
-
const fontSize = parseInt(style.fontSize, 10);
|
|
15
|
-
const lineHeight = parseInt(style.lineHeight, 10);
|
|
16
|
-
const padding = (lineHeight - fontSize) % 2 === 0
|
|
17
|
-
? (lineHeight - fontSize) / 2
|
|
18
|
-
: (lineHeight - fontSize - 1) / 2;
|
|
19
|
-
const rows = skeletonProps?.rows
|
|
20
|
-
? skeletonProps?.rows
|
|
21
|
-
: Math.ceil(textHeight / lineHeight);
|
|
22
|
-
setSkeletonParams({
|
|
23
|
-
height: lineHeight - padding * 2,
|
|
24
|
-
padding: `${padding}px 0`,
|
|
25
|
-
rows,
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
setSkeletonParams(undefined);
|
|
30
|
-
}
|
|
31
|
-
}, [showSkeleton, skeletonProps?.rows]);
|
|
32
|
-
const renderSkeleton = (props) => {
|
|
33
|
-
if (showSkeleton && skeletonParams) {
|
|
34
|
-
return (React.createElement("div", { className: cn(skeletonProps?.wrapperClassName, props.wrapperClassName, skeletonProps?.align && styles[skeletonProps.align]), "data-test-id": props.dataTestId }, [...Array(skeletonParams.rows)].map((_, idx) => {
|
|
35
|
-
const width = Array.isArray(skeletonProps?.width)
|
|
36
|
-
? skeletonProps?.width[idx]
|
|
37
|
-
: skeletonProps?.width;
|
|
38
|
-
return (
|
|
39
|
-
// eslint-disable-next-line react/no-array-index-key
|
|
40
|
-
React.createElement("div", { key: idx, style: { width, padding: skeletonParams.padding } },
|
|
41
|
-
React.createElement(Skeleton, { visible: true, className: styles.skeletonText },
|
|
42
|
-
React.createElement("div", { style: { height: skeletonParams.height } }))));
|
|
43
|
-
})));
|
|
44
|
-
}
|
|
45
|
-
return null;
|
|
46
|
-
};
|
|
47
|
-
return { renderSkeleton, textRef };
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export { useSkeleton };
|
package/src/hooks/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './use-skeleton';
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
@import '@alfalab/core-components-vars/src/index.css';
|
|
2
|
-
|
|
3
|
-
.skeletonText.skeletonText {
|
|
4
|
-
border-radius: var(--border-radius-pill);
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
.left > div {
|
|
8
|
-
margin-right: auto;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
.center > div {
|
|
12
|
-
margin: var(--gap-0) auto;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.right > div {
|
|
16
|
-
margin-left: auto;
|
|
17
|
-
}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import React, { useRef, useState } from 'react';
|
|
2
|
-
import cn from 'classnames';
|
|
3
|
-
|
|
4
|
-
import { Skeleton } from '@alfalab/core-components-skeleton';
|
|
5
|
-
import { useLayoutEffect_SAFE_FOR_SSR } from '@alfalab/hooks';
|
|
6
|
-
|
|
7
|
-
import { TextSkeletonProps } from '../types';
|
|
8
|
-
|
|
9
|
-
import styles from './use-skeleton.module.css';
|
|
10
|
-
|
|
11
|
-
type TextSkeletonParams = {
|
|
12
|
-
height: number;
|
|
13
|
-
padding: string;
|
|
14
|
-
rows: number;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
type SkeletonProps = {
|
|
18
|
-
wrapperClassName?: string;
|
|
19
|
-
dataTestId?: string;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export function useSkeleton(showSkeleton?: boolean, skeletonProps?: TextSkeletonProps) {
|
|
23
|
-
const [skeletonParams, setSkeletonParams] = useState<TextSkeletonParams>();
|
|
24
|
-
const textRef = useRef<HTMLElement>(null);
|
|
25
|
-
|
|
26
|
-
useLayoutEffect_SAFE_FOR_SSR(() => {
|
|
27
|
-
if (showSkeleton && textRef.current) {
|
|
28
|
-
const style = getComputedStyle(textRef.current);
|
|
29
|
-
|
|
30
|
-
const textHeight = textRef.current.offsetHeight;
|
|
31
|
-
const fontSize = parseInt(style.fontSize, 10);
|
|
32
|
-
const lineHeight = parseInt(style.lineHeight, 10);
|
|
33
|
-
|
|
34
|
-
const padding =
|
|
35
|
-
(lineHeight - fontSize) % 2 === 0
|
|
36
|
-
? (lineHeight - fontSize) / 2
|
|
37
|
-
: (lineHeight - fontSize - 1) / 2;
|
|
38
|
-
|
|
39
|
-
const rows = skeletonProps?.rows
|
|
40
|
-
? skeletonProps?.rows
|
|
41
|
-
: Math.ceil(textHeight / lineHeight);
|
|
42
|
-
|
|
43
|
-
setSkeletonParams({
|
|
44
|
-
height: lineHeight - padding * 2,
|
|
45
|
-
padding: `${padding}px 0`,
|
|
46
|
-
rows,
|
|
47
|
-
});
|
|
48
|
-
} else {
|
|
49
|
-
setSkeletonParams(undefined);
|
|
50
|
-
}
|
|
51
|
-
}, [showSkeleton, skeletonProps?.rows]);
|
|
52
|
-
|
|
53
|
-
const renderSkeleton = (props: SkeletonProps) => {
|
|
54
|
-
if (showSkeleton && skeletonParams) {
|
|
55
|
-
return (
|
|
56
|
-
<div
|
|
57
|
-
className={cn(
|
|
58
|
-
skeletonProps?.wrapperClassName,
|
|
59
|
-
props.wrapperClassName,
|
|
60
|
-
skeletonProps?.align && styles[skeletonProps.align],
|
|
61
|
-
)}
|
|
62
|
-
data-test-id={props.dataTestId}
|
|
63
|
-
>
|
|
64
|
-
{[...Array(skeletonParams.rows)].map((_, idx) => {
|
|
65
|
-
const width = Array.isArray(skeletonProps?.width)
|
|
66
|
-
? skeletonProps?.width[idx]
|
|
67
|
-
: skeletonProps?.width;
|
|
68
|
-
|
|
69
|
-
return (
|
|
70
|
-
// eslint-disable-next-line react/no-array-index-key
|
|
71
|
-
<div key={idx} style={{ width, padding: skeletonParams.padding }}>
|
|
72
|
-
<Skeleton visible={true} className={styles.skeletonText}>
|
|
73
|
-
<div style={{ height: skeletonParams.height }} />
|
|
74
|
-
</Skeleton>
|
|
75
|
-
</div>
|
|
76
|
-
);
|
|
77
|
-
})}
|
|
78
|
-
</div>
|
|
79
|
-
);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return null;
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
return { renderSkeleton, textRef };
|
|
86
|
-
}
|