@digigov/react-core 2.0.0-rc.10 → 2.0.0-rc.12
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/DateInputItem/index.js +0 -2
- package/Skeleton/__snapshots__/index.test.tsx.snap +296 -0
- package/Skeleton/index.d.ts +49 -0
- package/Skeleton/index.js +36 -0
- package/Skeleton/index.test/index.js +64 -0
- package/Skeleton/index.test/package.json +6 -0
- package/Skeleton/index.test.d.ts +1 -0
- package/Skeleton/package.json +6 -0
- package/Tabs/index.d.ts +1 -2
- package/Tabs/index.js +3 -4
- package/Unpurge/index.js +1 -1
- package/cjs/DateInputItem/index.js +0 -2
- package/cjs/Skeleton/__snapshots__/index.test.tsx.snap +296 -0
- package/cjs/Skeleton/index.js +43 -0
- package/cjs/Skeleton/index.test/index.js +67 -0
- package/cjs/Tabs/index.js +3 -4
- package/cjs/Unpurge/index.js +1 -1
- package/cjs/lazy/index.js +9 -0
- package/cjs/registry/index.js +2 -0
- package/index.js +1 -1
- package/lazy/index.js +7 -0
- package/lazy.d.ts +2 -1
- package/package.json +3 -3
- package/registry/index.js +2 -0
- package/registry.d.ts +1 -0
- package/src/DateInputItem/index.tsx +0 -2
- package/src/Skeleton/__snapshots__/index.test.tsx.snap +296 -0
- package/src/Skeleton/index.test.tsx +35 -0
- package/src/Skeleton/index.tsx +107 -0
- package/src/Tabs/index.tsx +1 -3
- package/src/Unpurge/index.tsx +9 -0
- package/src/lazy.js +1 -0
- package/src/registry.js +2 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import Base, { BaseProps } from '@digigov/react-core/Base';
|
|
4
|
+
|
|
5
|
+
export interface SkeletonProps extends BaseProps<'span'> {
|
|
6
|
+
/**
|
|
7
|
+
* variant prop determines the style of the skeleton element.
|
|
8
|
+
* @value 'circular', it renders a circular skeleton.
|
|
9
|
+
* @value 'rectangular', it renders a rectangular skeleton.
|
|
10
|
+
* @value 'text', it renders a text skeleton.
|
|
11
|
+
* @value 'button', it renders a button skeleton.
|
|
12
|
+
* @default 'text'
|
|
13
|
+
*/
|
|
14
|
+
variant?: 'circular' | 'rectangular' | 'text' | 'button';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* width prop determines the width of the skeleton element.
|
|
18
|
+
* It accepts number in px or string with valid CSS units (e.g. '24px', '1em', '100%').
|
|
19
|
+
* For better responsive experience, avoid using px and use percentage instead.
|
|
20
|
+
* @default undefined
|
|
21
|
+
*/
|
|
22
|
+
width?: number | string;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* height prop determines the height of the skeleton element.
|
|
26
|
+
* It accepts number in px or string with valid CSS units (e.g. '24px', '1em', '100%').
|
|
27
|
+
* @default undefined
|
|
28
|
+
*/
|
|
29
|
+
height?: number | string;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* fontSize is optional. 'sm' is the default value.
|
|
33
|
+
* Use 'xl' when this Skeleton is for a main page title.
|
|
34
|
+
* The fontSize works only for variant 'text'.
|
|
35
|
+
* You don't need fontSize if you wrap Skeleton in a typography component.
|
|
36
|
+
* @value 'xl'
|
|
37
|
+
* @value 'lg'
|
|
38
|
+
* @value 'md'
|
|
39
|
+
* @value 'sm'
|
|
40
|
+
* @value 'xs'
|
|
41
|
+
* @default 'sm'
|
|
42
|
+
*/
|
|
43
|
+
fontSize?: 'xl' | 'lg' | 'md' | 'sm' | 'xs';
|
|
44
|
+
/**
|
|
45
|
+
* animation prop determines if the skeleton should animate or not.
|
|
46
|
+
* @default true
|
|
47
|
+
*/
|
|
48
|
+
animation?: boolean;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Use Skeleton component while a page is loading.
|
|
52
|
+
*/
|
|
53
|
+
export const Skeleton = React.forwardRef<HTMLSpanElement, SkeletonProps>(
|
|
54
|
+
function Skeleton(
|
|
55
|
+
{
|
|
56
|
+
width,
|
|
57
|
+
height,
|
|
58
|
+
fontSize,
|
|
59
|
+
variant = 'text',
|
|
60
|
+
animation = true,
|
|
61
|
+
className,
|
|
62
|
+
children,
|
|
63
|
+
style,
|
|
64
|
+
...props
|
|
65
|
+
},
|
|
66
|
+
ref
|
|
67
|
+
) {
|
|
68
|
+
return (
|
|
69
|
+
<Base
|
|
70
|
+
as="span"
|
|
71
|
+
ref={ref}
|
|
72
|
+
className={clsx(className, {
|
|
73
|
+
'ds-skeleton': true,
|
|
74
|
+
[`ds-skeleton--font-${fontSize}`]:
|
|
75
|
+
fontSize !== undefined && variant === 'text',
|
|
76
|
+
[`ds-skeleton--${variant}`]:
|
|
77
|
+
!!variant && (!children || typeof children === 'string'),
|
|
78
|
+
'ds-skeleton--animate': !!animation,
|
|
79
|
+
'ds-skeleton--width-fit-content': !!children && !width,
|
|
80
|
+
})}
|
|
81
|
+
{...props}
|
|
82
|
+
style={{
|
|
83
|
+
width:
|
|
84
|
+
typeof children === 'string'
|
|
85
|
+
? Math.ceil(children.length * 0.5) + 'em'
|
|
86
|
+
: width,
|
|
87
|
+
maxWidth: !!width ? '100%' : undefined,
|
|
88
|
+
height: height,
|
|
89
|
+
...style,
|
|
90
|
+
}}
|
|
91
|
+
>
|
|
92
|
+
{variant === 'button' && (
|
|
93
|
+
<span
|
|
94
|
+
className={clsx({
|
|
95
|
+
'ds-skeleton__line': true,
|
|
96
|
+
'ds-skeleton__line--size-default':
|
|
97
|
+
width === undefined && height === undefined,
|
|
98
|
+
})}
|
|
99
|
+
></span>
|
|
100
|
+
)}
|
|
101
|
+
{typeof children != 'string' && children}
|
|
102
|
+
</Base>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
export default Skeleton;
|
package/src/Tabs/index.tsx
CHANGED
|
@@ -3,7 +3,6 @@ import clsx from 'clsx';
|
|
|
3
3
|
import Base, { BaseProps } from '@digigov/react-core/Base';
|
|
4
4
|
|
|
5
5
|
export interface TabsProps extends BaseProps<'div'> {
|
|
6
|
-
direction?: 'vertical' | 'horizontal';
|
|
7
6
|
/**
|
|
8
7
|
* dense is optional.
|
|
9
8
|
* @value true Tabs will be dense.
|
|
@@ -17,7 +16,7 @@ export interface TabsProps extends BaseProps<'div'> {
|
|
|
17
16
|
* This component must contain TabsHeading, TabsList, and a list of TabsPanel component.
|
|
18
17
|
*/
|
|
19
18
|
export const Tabs = React.forwardRef<HTMLDivElement, TabsProps>(function Tabs(
|
|
20
|
-
{
|
|
19
|
+
{ className, dense, children, ...props },
|
|
21
20
|
ref
|
|
22
21
|
) {
|
|
23
22
|
return (
|
|
@@ -26,7 +25,6 @@ export const Tabs = React.forwardRef<HTMLDivElement, TabsProps>(function Tabs(
|
|
|
26
25
|
ref={ref}
|
|
27
26
|
className={clsx(className, {
|
|
28
27
|
'ds-tabs': true,
|
|
29
|
-
'ds-tabs--vertical': direction === 'vertical',
|
|
30
28
|
'ds-tabs--dense': dense,
|
|
31
29
|
})}
|
|
32
30
|
{...props}
|
package/src/Unpurge/index.tsx
CHANGED
|
@@ -692,6 +692,15 @@ function Unpurge() {
|
|
|
692
692
|
ds-autocomplete__multi-input-container--1
|
|
693
693
|
ds-autocomplete__multi-input-container--2
|
|
694
694
|
ds-autocomplete__multi-input-container--3
|
|
695
|
+
ds-skeleton--text
|
|
696
|
+
ds-skeleton--circular
|
|
697
|
+
ds-skeleton--rectangular
|
|
698
|
+
ds-skeleton--button
|
|
699
|
+
ds-skeleton--font-xs
|
|
700
|
+
ds-skeleton--font-sm
|
|
701
|
+
ds-skeleton--font-md
|
|
702
|
+
ds-skeleton--font-lg
|
|
703
|
+
ds-skeleton--font-xl
|
|
695
704
|
`}
|
|
696
705
|
></div>
|
|
697
706
|
);
|
package/src/lazy.js
CHANGED
|
@@ -238,5 +238,6 @@ export default {
|
|
|
238
238
|
'KitchenSinkLetterContent': lazy(() => import('@digigov/react-core/KitchenSinkLetterContent').then((module)=> ({default: module['KitchenSinkLetterContent']}))),
|
|
239
239
|
'MastheadLogo': lazy(() => import('@digigov/react-core/MastheadLogo').then((module)=> ({default: module['MastheadLogo']}))),
|
|
240
240
|
'PanelTitle': lazy(() => import('@digigov/react-core/PanelTitle').then((module)=> ({default: module['PanelTitle']}))),
|
|
241
|
+
'Skeleton': lazy(() => import('@digigov/react-core/Skeleton').then((module)=> ({default: module['Skeleton']}))),
|
|
241
242
|
|
|
242
243
|
}
|
package/src/registry.js
CHANGED
|
@@ -192,6 +192,7 @@ import * as _digigov_react_core_SelectContainer from '@digigov/react-core/Select
|
|
|
192
192
|
import * as _digigov_react_core_SelectOption from '@digigov/react-core/SelectOption';
|
|
193
193
|
import * as _digigov_react_core_SingleCharacterInput from '@digigov/react-core/SingleCharacterInput';
|
|
194
194
|
import * as _digigov_react_core_SingleCharacterInputs from '@digigov/react-core/SingleCharacterInputs';
|
|
195
|
+
import * as _digigov_react_core_Skeleton from '@digigov/react-core/Skeleton';
|
|
195
196
|
import * as _digigov_react_core_SkipLink from '@digigov/react-core/SkipLink';
|
|
196
197
|
import * as _digigov_react_core_Stack from '@digigov/react-core/Stack';
|
|
197
198
|
import * as _digigov_react_core_StepNav from '@digigov/react-core/StepNav';
|
|
@@ -457,6 +458,7 @@ export default {
|
|
|
457
458
|
'@digigov/react-core/SelectOption': lazyImport(_digigov_react_core_SelectOption),
|
|
458
459
|
'@digigov/react-core/SingleCharacterInput': lazyImport(_digigov_react_core_SingleCharacterInput),
|
|
459
460
|
'@digigov/react-core/SingleCharacterInputs': lazyImport(_digigov_react_core_SingleCharacterInputs),
|
|
461
|
+
'@digigov/react-core/Skeleton': lazyImport(_digigov_react_core_Skeleton),
|
|
460
462
|
'@digigov/react-core/SkipLink': lazyImport(_digigov_react_core_SkipLink),
|
|
461
463
|
'@digigov/react-core/Stack': lazyImport(_digigov_react_core_Stack),
|
|
462
464
|
'@digigov/react-core/StepNav': lazyImport(_digigov_react_core_StepNav),
|