@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.
Files changed (118) hide show
  1. package/colors.css +21 -21
  2. package/colors.module-75d911c2.js +6 -0
  3. package/common.module-23cd82b6.js +6 -0
  4. package/cssm/text/alfasans-index.module.css +16 -0
  5. package/cssm/text/component.d.ts +2 -1
  6. package/cssm/text/component.js +2 -2
  7. package/cssm/title/alfasans-index.module.css +0 -10
  8. package/cssm/title/component.d.ts +1 -1
  9. package/cssm/title/component.js +2 -2
  10. package/cssm/title/index.d.ts +1 -1
  11. package/cssm/title-mobile/component.d.ts +1 -1
  12. package/cssm/title-responsive/component.d.ts +1 -1
  13. package/cssm/types.d.ts +1 -20
  14. package/esm/colors.css +21 -21
  15. package/esm/colors.module-4059b326.js +4 -0
  16. package/esm/common.module-6cbe43bf.js +4 -0
  17. package/esm/text/alfasans-index.css +30 -30
  18. package/esm/text/component.d.ts +2 -1
  19. package/esm/text/component.js +4 -4
  20. package/esm/text/index.css +22 -22
  21. package/esm/title/alfasans-index.css +11 -11
  22. package/esm/title/common.css +9 -9
  23. package/esm/title/component.d.ts +1 -1
  24. package/esm/title/component.js +2 -2
  25. package/esm/title/index.css +17 -17
  26. package/esm/title/index.d.ts +1 -1
  27. package/esm/title/index.js +3 -3
  28. package/esm/title-mobile/alfasans-index.css +11 -11
  29. package/esm/title-mobile/component.d.ts +1 -1
  30. package/esm/title-mobile/component.js +3 -3
  31. package/esm/title-mobile/index.css +16 -16
  32. package/esm/title-responsive/component.d.ts +1 -1
  33. package/esm/types.d.ts +1 -20
  34. package/modern/colors.css +21 -21
  35. package/modern/colors.module-fb170d72.js +4 -0
  36. package/modern/common.module-82ebec0f.js +4 -0
  37. package/modern/text/alfasans-index.css +30 -30
  38. package/modern/text/component.d.ts +2 -1
  39. package/modern/text/component.js +4 -4
  40. package/modern/text/index.css +22 -22
  41. package/modern/title/alfasans-index.css +11 -11
  42. package/modern/title/common.css +9 -9
  43. package/modern/title/component.d.ts +1 -1
  44. package/modern/title/component.js +2 -2
  45. package/modern/title/index.css +17 -17
  46. package/modern/title/index.d.ts +1 -1
  47. package/modern/title/index.js +3 -3
  48. package/modern/title-mobile/alfasans-index.css +11 -11
  49. package/modern/title-mobile/component.d.ts +1 -1
  50. package/modern/title-mobile/component.js +3 -3
  51. package/modern/title-mobile/index.css +16 -16
  52. package/modern/title-responsive/component.d.ts +1 -1
  53. package/modern/types.d.ts +1 -20
  54. package/moderncssm/text/alfasans-index.module.css +16 -0
  55. package/moderncssm/text/component.d.ts +2 -1
  56. package/moderncssm/text/component.js +1 -1
  57. package/moderncssm/title/alfasans-index.module.css +0 -10
  58. package/moderncssm/title/component.d.ts +1 -1
  59. package/moderncssm/title/component.js +1 -1
  60. package/moderncssm/title/index.d.ts +1 -1
  61. package/moderncssm/title-mobile/component.d.ts +1 -1
  62. package/moderncssm/title-responsive/component.d.ts +1 -1
  63. package/moderncssm/types.d.ts +1 -20
  64. package/package.json +2 -2
  65. package/src/text/component.tsx +3 -2
  66. package/src/title/component.tsx +1 -2
  67. package/src/types.ts +0 -24
  68. package/text/alfasans-index.css +30 -30
  69. package/text/component.d.ts +2 -1
  70. package/text/component.js +5 -5
  71. package/text/index.css +22 -22
  72. package/title/alfasans-index.css +11 -11
  73. package/title/common.css +9 -9
  74. package/title/component.d.ts +1 -1
  75. package/title/component.js +3 -3
  76. package/title/index.css +17 -17
  77. package/title/index.d.ts +1 -1
  78. package/title/index.js +3 -3
  79. package/title-mobile/alfasans-index.css +11 -11
  80. package/title-mobile/component.d.ts +1 -1
  81. package/title-mobile/component.js +3 -3
  82. package/title-mobile/index.css +16 -16
  83. package/title-responsive/component.d.ts +1 -1
  84. package/types.d.ts +1 -20
  85. package/colors.module-94b64d8e.js +0 -6
  86. package/common.module-38b50dd1.js +0 -6
  87. package/cssm/hooks/index.d.ts +0 -1
  88. package/cssm/hooks/index.js +0 -9
  89. package/cssm/hooks/use-skeleton.d.ts +0 -12
  90. package/cssm/hooks/use-skeleton.js +0 -61
  91. package/cssm/hooks/use-skeleton.module.css +0 -33
  92. package/esm/colors.module-5fa27b46.js +0 -4
  93. package/esm/common.module-7645bb09.js +0 -4
  94. package/esm/hooks/index.d.ts +0 -1
  95. package/esm/hooks/index.js +0 -1
  96. package/esm/hooks/use-skeleton.css +0 -34
  97. package/esm/hooks/use-skeleton.d.ts +0 -12
  98. package/esm/hooks/use-skeleton.js +0 -53
  99. package/hooks/index.d.ts +0 -1
  100. package/hooks/index.js +0 -9
  101. package/hooks/use-skeleton.css +0 -34
  102. package/hooks/use-skeleton.d.ts +0 -12
  103. package/hooks/use-skeleton.js +0 -62
  104. package/modern/colors.module-3cedc3fb.js +0 -4
  105. package/modern/common.module-d04ff6fc.js +0 -4
  106. package/modern/hooks/index.d.ts +0 -1
  107. package/modern/hooks/index.js +0 -1
  108. package/modern/hooks/use-skeleton.css +0 -34
  109. package/modern/hooks/use-skeleton.d.ts +0 -12
  110. package/modern/hooks/use-skeleton.js +0 -52
  111. package/moderncssm/hooks/index.d.ts +0 -1
  112. package/moderncssm/hooks/index.js +0 -1
  113. package/moderncssm/hooks/use-skeleton.d.ts +0 -12
  114. package/moderncssm/hooks/use-skeleton.js +0 -50
  115. package/moderncssm/hooks/use-skeleton.module.css +0 -17
  116. package/src/hooks/index.ts +0 -1
  117. package/src/hooks/use-skeleton.module.css +0 -17
  118. 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 };
@@ -1,17 +0,0 @@
1
- /* */
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 +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
- }