@nuskin/foundation-ui-components 1.0.0-develop.7 → 1.0.0-develop.9
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/package.json +1 -1
- package/src/common/accordion/NsAccordion.tsx +3 -1
- package/src/common/accordion/NsAccordionHeader.tsx +25 -19
- package/src/common/accordion/NsAccordionItem.tsx +8 -0
- package/src/common/accordion/NsCollapse.tsx +26 -10
- package/src/common/accordion/NsToggleSection.tsx +2 -0
- package/src/common/accordion/ToggleSection.styled.tsx +5 -2
- package/src/common/accordion/enums.ts +0 -7
- package/src/common/accordion/specs/NsAccordion.spec.tsx +1 -0
- package/src/common/accordion/specs/NsAccordionItem.spec.tsx +4 -0
- package/src/common/accordion/specs/NsCollapse.spec.tsx +23 -20
- package/src/common/accordion/specs/NsToggleSection.spec.tsx +4 -0
- package/src/common/accordion/stories/NsAccordion.stories.tsx +5 -0
- package/src/common/accordion/stories/NsAccordionHeader.stories.tsx +2 -1
- package/src/common/accordion/stories/NsAccordionItem.stories.tsx +6 -1
- package/src/common/accordion/stories/NsCollapse.stories.tsx +17 -2
- package/src/common/accordion/stories/NsToggleSection.stories.tsx +5 -1
- package/src/common/accordion/stories/data.tsx +66 -83
- package/src/common/accordion/types.d.ts +13 -12
- package/src/common/card/NsFfgCard.tsx +13 -7
- package/src/common/card/specs/NsFfgCard.spec.tsx +18 -8
- package/src/common/card/stories/NsFfgCard.stories.tsx +47 -17
- package/src/common/card/styled/NsFfgStyled.tsx +9 -7
- package/src/common/card/types.d.ts +7 -4
- package/src/common/common.types.d.ts +3 -4
- package/src/common/index.ts +5 -3
- package/src/common/modal/NsModal.spec.tsx +46 -0
- package/src/common/modal/NsModal.styled.tsx +28 -0
- package/src/common/modal/NsModal.tsx +37 -0
- package/src/common/modal/helper-component/NsModalContentBox.tsx +32 -0
- package/src/common/modal/helper-component/NsModalDefault.tsx +25 -0
- package/src/common/modal/helper-component/NsModalStatus.tsx +15 -0
- package/src/common/modal/helper-component/NsModalStatusIcon.tsx +14 -0
- package/src/common/modal/helper-component/NsModalTitle.tsx +26 -0
- package/src/common/modal/index.ts +2 -0
- package/src/common/modal/model/NsModalVariantMap.tsx +24 -0
- package/src/common/modal/stories/NsModal.stories.tsx +86 -0
- package/src/common/modal/stories/mock.tsx +46 -0
- package/src/common/modal/types.ts +56 -0
- package/src/common/nav-tab/types.d.ts +2 -2
- package/src/common/utility/Show.tsx +13 -0
- package/src/common/utility/index.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuskin/foundation-ui-components",
|
|
3
|
-
"version": "1.0.0-develop.
|
|
3
|
+
"version": "1.0.0-develop.9",
|
|
4
4
|
"description": "It is a foundation library written in react, that provides common components to all UI pages",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "src/common/index.ts",
|
|
@@ -8,7 +8,7 @@ import { StyledAccordionWrapper } from './ToggleSection.styled';
|
|
|
8
8
|
* multiple sections of accordion can remain open at a time
|
|
9
9
|
*
|
|
10
10
|
* we can define certain section to remain open by default using `isDefaultOpen` in the
|
|
11
|
-
*
|
|
11
|
+
* items
|
|
12
12
|
* if there are multiple items available for default open, but `allowMultipleExpanded`
|
|
13
13
|
* is false then only first item of default open is made open
|
|
14
14
|
*/
|
|
@@ -44,6 +44,8 @@ const NsAccordion: FC<NsAccordionProps> = ({
|
|
|
44
44
|
const isOpen = itemStateMap[key] ?? false;
|
|
45
45
|
return (
|
|
46
46
|
<NsAccordionItem
|
|
47
|
+
allowMultipleExpanded={item.allowMultipleExpanded}
|
|
48
|
+
type={item.type}
|
|
47
49
|
closedIconName={closedIconName}
|
|
48
50
|
content={item.content}
|
|
49
51
|
headerTypographyVariant={headerTypographyVariant}
|
|
@@ -2,26 +2,31 @@ import { NsTypography, NsIcon, NsAccordionHeaderProps, AccordionVariant, NsIconP
|
|
|
2
2
|
import { styled } from '@nuskin/foundation-theme';
|
|
3
3
|
import { isValidIconName } from '../icon/NsIconVariants';
|
|
4
4
|
import { getAccordionColor } from './colorMap';
|
|
5
|
+
const options = {
|
|
6
|
+
shouldForwardProp: (propKey: string) => !['variant', 'invert'].includes(propKey),
|
|
7
|
+
};
|
|
8
|
+
type StyledType = { variant: AccordionVariantType; invert: boolean };
|
|
5
9
|
|
|
6
|
-
const StyledHeader = styled(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
backgroundColor: headBg,
|
|
15
|
-
color: headText,
|
|
16
|
-
cursor: 'pointer',
|
|
17
|
-
display: 'grid',
|
|
18
|
-
gap: '4px',
|
|
19
|
-
gridTemplateColumns: 'auto 1fr 24px',
|
|
20
|
-
padding: '9px 16px',
|
|
21
|
-
borderBottom,
|
|
22
|
-
} as any;
|
|
10
|
+
const StyledHeader = styled(
|
|
11
|
+
'header',
|
|
12
|
+
options
|
|
13
|
+
)<StyledType>(({ theme, variant, invert }) => {
|
|
14
|
+
const { headBg, headText } = getAccordionColor({ theme, variant, invert, keys: ['headBg', 'headText'] });
|
|
15
|
+
let borderBottom = 'none';
|
|
16
|
+
if (variant === AccordionVariant.Compact) {
|
|
17
|
+
borderBottom = '1px solid rgb(0,0,0,0.125)';
|
|
23
18
|
}
|
|
24
|
-
|
|
19
|
+
return {
|
|
20
|
+
backgroundColor: headBg,
|
|
21
|
+
color: headText,
|
|
22
|
+
cursor: 'pointer',
|
|
23
|
+
display: 'grid',
|
|
24
|
+
gap: '4px',
|
|
25
|
+
gridTemplateColumns: 'auto 1fr 24px',
|
|
26
|
+
padding: '9px 16px',
|
|
27
|
+
borderBottom,
|
|
28
|
+
} as any;
|
|
29
|
+
});
|
|
25
30
|
|
|
26
31
|
/**
|
|
27
32
|
* NsAccordionHeader is primarily used by NsToggleSection and NsAccordionItem
|
|
@@ -38,6 +43,7 @@ const NsAccordionHeader = ({
|
|
|
38
43
|
headerTypographyVariant,
|
|
39
44
|
startIcon,
|
|
40
45
|
invert,
|
|
46
|
+
cslp,
|
|
41
47
|
}: NsAccordionHeaderProps) => {
|
|
42
48
|
return (
|
|
43
49
|
<StyledHeader
|
|
@@ -50,7 +56,7 @@ const NsAccordionHeader = ({
|
|
|
50
56
|
>
|
|
51
57
|
<HeaderIcon {...startIcon} />
|
|
52
58
|
{typeof title === 'string' ? (
|
|
53
|
-
<NsTypography variant={headerTypographyVariant ?? 'h4'} weight="bold">
|
|
59
|
+
<NsTypography variant={headerTypographyVariant ?? 'h4'} weight="bold" {...(cslp?.header ?? {})}>
|
|
54
60
|
{title}
|
|
55
61
|
</NsTypography>
|
|
56
62
|
) : (
|
|
@@ -6,6 +6,7 @@ import { StyledToggleSection } from './ToggleSection.styled';
|
|
|
6
6
|
/**
|
|
7
7
|
* this component is used by accordion to pass title
|
|
8
8
|
* and content
|
|
9
|
+
* cslp:{header:CslpTag, content:CslpTag}
|
|
9
10
|
*/
|
|
10
11
|
const NsAccordionItem = ({
|
|
11
12
|
isOpen,
|
|
@@ -21,6 +22,9 @@ const NsAccordionItem = ({
|
|
|
21
22
|
level,
|
|
22
23
|
additionalProps,
|
|
23
24
|
invert,
|
|
25
|
+
type,
|
|
26
|
+
cslp,
|
|
27
|
+
allowMultipleExpanded,
|
|
24
28
|
}: NsAccordionItemProps) => {
|
|
25
29
|
return (
|
|
26
30
|
<StyledToggleSection variant={variant}>
|
|
@@ -35,14 +39,18 @@ const NsAccordionItem = ({
|
|
|
35
39
|
title={title}
|
|
36
40
|
variant={variant}
|
|
37
41
|
startIcon={startIcon}
|
|
42
|
+
cslp={cslp}
|
|
38
43
|
/>
|
|
39
44
|
<NsCollapse
|
|
45
|
+
type={type}
|
|
40
46
|
isChild={isChild}
|
|
41
47
|
isOpen={isOpen}
|
|
42
48
|
variant={variant}
|
|
43
49
|
level={level}
|
|
44
50
|
invert={invert}
|
|
45
51
|
content={content}
|
|
52
|
+
cslp={cslp}
|
|
53
|
+
allowMultipleExpanded={allowMultipleExpanded}
|
|
46
54
|
/>
|
|
47
55
|
</StyledToggleSection>
|
|
48
56
|
);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { styled } from '@nuskin/foundation-theme';
|
|
2
|
-
import { AccordionVariant, AccordionVariantType, NsCollapseProps,
|
|
2
|
+
import { AccordionVariant, AccordionVariantType, NsCollapseProps, AccordionItem, NsAccordion } from '../';
|
|
3
3
|
import { getAccordionColor } from './colorMap';
|
|
4
4
|
import { ReactElement, isValidElement, useMemo } from 'react';
|
|
5
5
|
|
|
@@ -52,33 +52,49 @@ export const StyledCollapse = styled(
|
|
|
52
52
|
* NsCollapse component adds css animation while showing children items if prop `isOpen` is true,
|
|
53
53
|
* and while removing children if prop `isOpen` is false
|
|
54
54
|
*/
|
|
55
|
-
const NsCollapse = ({
|
|
55
|
+
const NsCollapse = ({
|
|
56
|
+
isOpen,
|
|
57
|
+
content,
|
|
58
|
+
additionalProps,
|
|
59
|
+
variant,
|
|
60
|
+
level,
|
|
61
|
+
invert,
|
|
62
|
+
isChild,
|
|
63
|
+
type,
|
|
64
|
+
cslp,
|
|
65
|
+
allowMultipleExpanded,
|
|
66
|
+
}: NsCollapseProps) => {
|
|
56
67
|
const body = useMemo(() => {
|
|
57
68
|
if (isValidElement(content)) {
|
|
58
69
|
return content as ReactElement;
|
|
59
70
|
}
|
|
60
|
-
if (
|
|
71
|
+
if (type === 'html') {
|
|
61
72
|
return (
|
|
62
73
|
<div
|
|
63
74
|
className="nsa-content-padded"
|
|
64
|
-
dangerouslySetInnerHTML={{ __html:
|
|
75
|
+
dangerouslySetInnerHTML={{ __html: content as string }}
|
|
76
|
+
{...(cslp?.content ?? {})}
|
|
65
77
|
/>
|
|
66
78
|
);
|
|
67
|
-
} else if (
|
|
68
|
-
return
|
|
69
|
-
|
|
79
|
+
} else if (type === 'text') {
|
|
80
|
+
return (
|
|
81
|
+
<div className="p-4" {...(cslp?.content ?? {})}>
|
|
82
|
+
{content as string}
|
|
83
|
+
</div>
|
|
84
|
+
);
|
|
85
|
+
} else if (type === 'accordion') {
|
|
70
86
|
return (
|
|
71
87
|
<NsAccordion
|
|
72
88
|
isChild={true}
|
|
73
89
|
invert={invert}
|
|
74
90
|
level={level}
|
|
75
91
|
variant={AccordionVariant.Gray}
|
|
76
|
-
items={
|
|
77
|
-
allowMultipleExpanded={
|
|
92
|
+
items={content as AccordionItem[]}
|
|
93
|
+
allowMultipleExpanded={allowMultipleExpanded ?? false}
|
|
78
94
|
/>
|
|
79
95
|
);
|
|
80
96
|
}
|
|
81
|
-
}, [content, invert, level]);
|
|
97
|
+
}, [allowMultipleExpanded, content, cslp?.content, invert, level, type]);
|
|
82
98
|
return (
|
|
83
99
|
<StyledCollapse
|
|
84
100
|
isChild={isChild}
|
|
@@ -17,6 +17,7 @@ const NsToggleSection = ({
|
|
|
17
17
|
variant,
|
|
18
18
|
invert,
|
|
19
19
|
isChild,
|
|
20
|
+
type,
|
|
20
21
|
}: NsToggleSectionProps) => {
|
|
21
22
|
const [isExpanded, setIsExpanded] = useState(defaultOpen ?? false);
|
|
22
23
|
|
|
@@ -25,6 +26,7 @@ const NsToggleSection = ({
|
|
|
25
26
|
};
|
|
26
27
|
return (
|
|
27
28
|
<NsAccordionItem
|
|
29
|
+
type={type}
|
|
28
30
|
level={2}
|
|
29
31
|
variant={variant}
|
|
30
32
|
additionalProps={additionalProps}
|
|
@@ -2,7 +2,10 @@ import { styled } from '@nuskin/foundation-theme';
|
|
|
2
2
|
import { AccordionVariant, AccordionVariantType } from '../';
|
|
3
3
|
|
|
4
4
|
const border = '1px solid rgb(0,0,0,0.125)';
|
|
5
|
-
|
|
5
|
+
|
|
6
|
+
type StyledType = { variant: AccordionVariantType };
|
|
7
|
+
|
|
8
|
+
export const StyledToggleSection = styled('section')<StyledType>(({ variant }) => {
|
|
6
9
|
if (variant === AccordionVariant.Compact) {
|
|
7
10
|
return { borderRight: border };
|
|
8
11
|
}
|
|
@@ -11,7 +14,7 @@ export const StyledToggleSection = styled('section')<{ variant: AccordionVariant
|
|
|
11
14
|
};
|
|
12
15
|
});
|
|
13
16
|
|
|
14
|
-
export const StyledAccordionWrapper = styled('div')<
|
|
17
|
+
export const StyledAccordionWrapper = styled('div')<StyledType>(({ variant }) => {
|
|
15
18
|
if (variant === AccordionVariant.Compact) {
|
|
16
19
|
return {
|
|
17
20
|
display: 'flex',
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
/* eslint-disable no-unused-vars */
|
|
2
|
-
// export enum AccordionVariant {
|
|
3
|
-
// Basic = 'basic', // basic is as per figma
|
|
4
|
-
// Compact = 'compact', // compact is as per test.nuskin.com
|
|
5
|
-
// Gray = 'gray',
|
|
6
|
-
// Stripe = 'stripe',
|
|
7
|
-
// }
|
|
8
1
|
export const AccordionVariant = {
|
|
9
2
|
Basic: 'basic',
|
|
10
3
|
Compact: 'compact',
|
|
@@ -9,6 +9,7 @@ describe('NsAccordionItem', () => {
|
|
|
9
9
|
it('1. renders title correctly', () => {
|
|
10
10
|
const { getByText } = render(
|
|
11
11
|
<NsAccordionItem
|
|
12
|
+
type="jsx"
|
|
12
13
|
variant={AccordionVariant.Basic}
|
|
13
14
|
isOpen={false}
|
|
14
15
|
toggleOpen={() => {}}
|
|
@@ -26,6 +27,7 @@ describe('NsAccordionItem', () => {
|
|
|
26
27
|
const toggleOpen = jest.fn();
|
|
27
28
|
const { getByText } = render(
|
|
28
29
|
<NsAccordionItem
|
|
30
|
+
type="jsx"
|
|
29
31
|
variant={AccordionVariant.Basic}
|
|
30
32
|
isOpen={false}
|
|
31
33
|
toggleOpen={toggleOpen}
|
|
@@ -47,6 +49,7 @@ describe('NsAccordionItem', () => {
|
|
|
47
49
|
isOpen={true}
|
|
48
50
|
toggleOpen={() => {}}
|
|
49
51
|
title={title}
|
|
52
|
+
type="jsx"
|
|
50
53
|
content={contentElement}
|
|
51
54
|
isChild={false}
|
|
52
55
|
invert={false}
|
|
@@ -59,6 +62,7 @@ describe('NsAccordionItem', () => {
|
|
|
59
62
|
it('4. when isOpen is false, renders jsx dom content within container with 0 height', () => {
|
|
60
63
|
const { queryByText } = render(
|
|
61
64
|
<NsAccordionItem
|
|
65
|
+
type="jsx"
|
|
62
66
|
variant={AccordionVariant.Basic}
|
|
63
67
|
isOpen={false}
|
|
64
68
|
toggleOpen={() => {}}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { render, screen } from '@/test-utils/index';
|
|
3
|
-
import { NsCollapse, AccordionVariant,
|
|
4
|
-
import { createAccordionItem3_1
|
|
3
|
+
import { NsCollapse, AccordionVariant, AccordionItem } from '@/common/index';
|
|
4
|
+
import { createAccordionItem3_1 } from '../stories/data';
|
|
5
5
|
|
|
6
6
|
describe('NsCollapse', () => {
|
|
7
7
|
it('1. renders children when isOpen is true', () => {
|
|
@@ -15,6 +15,7 @@ describe('NsCollapse', () => {
|
|
|
15
15
|
<div>Child 2</div>
|
|
16
16
|
</>
|
|
17
17
|
}
|
|
18
|
+
type="jsx"
|
|
18
19
|
isChild={false}
|
|
19
20
|
invert={false}
|
|
20
21
|
level={0}
|
|
@@ -24,11 +25,11 @@ describe('NsCollapse', () => {
|
|
|
24
25
|
expect(getByText('Child 2')).toBeInTheDocument();
|
|
25
26
|
});
|
|
26
27
|
it('2. renders children when isOpen is true and isChild is true', () => {
|
|
27
|
-
const
|
|
28
|
-
const content = { ...getTextContent(text) };
|
|
28
|
+
const content = 'renders children when isOpen is true and isChild is true';
|
|
29
29
|
const { getByText } = render(
|
|
30
30
|
<NsCollapse
|
|
31
31
|
isOpen
|
|
32
|
+
type="text"
|
|
32
33
|
variant={AccordionVariant.Basic}
|
|
33
34
|
content={content}
|
|
34
35
|
isChild={true}
|
|
@@ -36,60 +37,62 @@ describe('NsCollapse', () => {
|
|
|
36
37
|
level={0}
|
|
37
38
|
/>
|
|
38
39
|
);
|
|
39
|
-
expect(getByText(
|
|
40
|
+
expect(getByText(content)).toBeInTheDocument();
|
|
40
41
|
});
|
|
41
42
|
it('3. renders children when isOpen is true and variant is compact and content is of type accordion', () => {
|
|
43
|
+
const accItem = createAccordionItem3_1();
|
|
44
|
+
const content = accItem.content as AccordionItem[];
|
|
42
45
|
const { getByText } = render(
|
|
43
46
|
<NsCollapse
|
|
44
47
|
isOpen
|
|
45
48
|
variant={AccordionVariant.Compact}
|
|
46
|
-
content={
|
|
49
|
+
content={content}
|
|
50
|
+
type={accItem.type}
|
|
47
51
|
isChild={true}
|
|
48
52
|
invert={false}
|
|
49
53
|
level={0}
|
|
50
54
|
/>
|
|
51
55
|
);
|
|
52
|
-
expect(getByText(
|
|
53
|
-
expect(getByText(
|
|
56
|
+
expect(getByText(content[0].title)).toBeInTheDocument();
|
|
57
|
+
expect(getByText(content[1].title)).toBeInTheDocument();
|
|
54
58
|
});
|
|
55
59
|
|
|
56
60
|
it('4. does not render children when isOpen is false', () => {
|
|
61
|
+
const content = '<h2>Lorem ipsum dolor sit amet.</h2>';
|
|
57
62
|
render(
|
|
58
63
|
<NsCollapse
|
|
59
64
|
isOpen={false}
|
|
60
65
|
variant={AccordionVariant.Basic}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
data: '<h2>Lorem ipsum dolor sit amet.</h2>',
|
|
64
|
-
}}
|
|
66
|
+
type="html"
|
|
67
|
+
content={content}
|
|
65
68
|
isChild={false}
|
|
66
69
|
invert={true}
|
|
67
70
|
level={0}
|
|
68
71
|
/>
|
|
69
72
|
);
|
|
70
|
-
expect(screen.queryByText(
|
|
73
|
+
expect(screen.queryByText(content)).toBeNull();
|
|
71
74
|
});
|
|
72
75
|
it('5. renders html children when isOpen is true', () => {
|
|
76
|
+
const content = '<h2>Lorem ipsum dolor sit amet.</h2>';
|
|
73
77
|
render(
|
|
74
78
|
<NsCollapse
|
|
75
79
|
isOpen={true}
|
|
76
80
|
variant={AccordionVariant.Compact}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
data: '<h2>Lorem ipsum dolor sit amet.</h2>',
|
|
80
|
-
}}
|
|
81
|
+
type="html"
|
|
82
|
+
content={content}
|
|
81
83
|
isChild={false}
|
|
82
84
|
invert={true}
|
|
83
85
|
level={0}
|
|
84
86
|
/>
|
|
85
87
|
);
|
|
86
|
-
expect(screen.queryByText(
|
|
88
|
+
expect(screen.queryByText(content)).toBeDefined();
|
|
87
89
|
});
|
|
88
90
|
|
|
89
91
|
it('6. renders with additional class name', () => {
|
|
90
92
|
const additionalClassName = 'custom-class';
|
|
91
93
|
const { container } = render(
|
|
92
94
|
<NsCollapse
|
|
95
|
+
type="jsx"
|
|
93
96
|
isOpen
|
|
94
97
|
variant={AccordionVariant.Gray}
|
|
95
98
|
content={
|
|
@@ -107,11 +110,11 @@ describe('NsCollapse', () => {
|
|
|
107
110
|
expect(container.querySelector('section')).toHaveClass(`ns-collapse ${additionalClassName}`);
|
|
108
111
|
});
|
|
109
112
|
it('7. skipping allowMultipleExpanded in child data', () => {
|
|
110
|
-
const { content } = createAccordionItem3_1();
|
|
111
|
-
delete (content as ItemContent).allowMultipleExpanded;
|
|
113
|
+
const { content, type } = createAccordionItem3_1();
|
|
112
114
|
const additionalClassName = 'custom-class';
|
|
113
115
|
const { container } = render(
|
|
114
116
|
<NsCollapse
|
|
117
|
+
type={type}
|
|
115
118
|
isOpen
|
|
116
119
|
variant={AccordionVariant.Gray}
|
|
117
120
|
content={content}
|
|
@@ -16,6 +16,7 @@ describe('NsToggleSection', () => {
|
|
|
16
16
|
content={content}
|
|
17
17
|
invert={false}
|
|
18
18
|
isChild={false}
|
|
19
|
+
type="jsx"
|
|
19
20
|
/>
|
|
20
21
|
);
|
|
21
22
|
expect(getByText(title)).toBeInTheDocument();
|
|
@@ -28,6 +29,7 @@ describe('NsToggleSection', () => {
|
|
|
28
29
|
content={content}
|
|
29
30
|
invert={false}
|
|
30
31
|
isChild={false}
|
|
32
|
+
type="jsx"
|
|
31
33
|
/>
|
|
32
34
|
);
|
|
33
35
|
expect(getByText(title)).toBeInTheDocument();
|
|
@@ -41,6 +43,7 @@ describe('NsToggleSection', () => {
|
|
|
41
43
|
content={content}
|
|
42
44
|
invert={false}
|
|
43
45
|
isChild={false}
|
|
46
|
+
type="jsx"
|
|
44
47
|
/>
|
|
45
48
|
);
|
|
46
49
|
const el = queryByText(contentText);
|
|
@@ -62,6 +65,7 @@ describe('NsToggleSection', () => {
|
|
|
62
65
|
invert={false}
|
|
63
66
|
isChild={false}
|
|
64
67
|
defaultOpen
|
|
68
|
+
type="jsx"
|
|
65
69
|
/>
|
|
66
70
|
);
|
|
67
71
|
|
|
@@ -22,6 +22,11 @@ const meta = {
|
|
|
22
22
|
control: 'select',
|
|
23
23
|
options: [...Object.values(AccordionVariant)],
|
|
24
24
|
},
|
|
25
|
+
level: {
|
|
26
|
+
control: 'number',
|
|
27
|
+
description: `level = 1 means no padding on left from parent to child,
|
|
28
|
+
level = 2 means padding of 16px, level = 3 means padding of 32px and so on ..`,
|
|
29
|
+
},
|
|
25
30
|
},
|
|
26
31
|
args: {
|
|
27
32
|
variant: AccordionVariant.Basic,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { StoryObj, Meta } from '@storybook/react';
|
|
2
2
|
import { withCenterDecorator } from '@/stories/decorators/withCenterDecorator';
|
|
3
|
-
import { NsAccordionHeader, NsIconVariants } from '../..';
|
|
3
|
+
import { AccordionVariant, NsAccordionHeader, NsIconVariants } from '../..';
|
|
4
4
|
|
|
5
5
|
type ComponentType = typeof NsAccordionHeader;
|
|
6
6
|
type Story = StoryObj<ComponentType>;
|
|
@@ -23,6 +23,7 @@ export default {
|
|
|
23
23
|
},
|
|
24
24
|
args: {
|
|
25
25
|
title: 'Nuskin',
|
|
26
|
+
variant: AccordionVariant.Compact,
|
|
26
27
|
onClick: () => {
|
|
27
28
|
console.log('accordion header clicked');
|
|
28
29
|
},
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { StoryObj, Meta } from '@storybook/react';
|
|
2
2
|
import { withCenterDecorator } from '@/stories/decorators/withCenterDecorator';
|
|
3
|
-
import { NsAccordionItem } from '
|
|
3
|
+
import { AccordionVariant, NsAccordionItem } from '../../';
|
|
4
|
+
import NsAccordionStory from './NsAccordion.stories';
|
|
4
5
|
|
|
5
6
|
type ComponentType = typeof NsAccordionItem;
|
|
6
7
|
type Story = StoryObj<ComponentType>;
|
|
@@ -20,11 +21,14 @@ export default {
|
|
|
20
21
|
control: 'string',
|
|
21
22
|
description: 'text used for header of section',
|
|
22
23
|
},
|
|
24
|
+
level: NsAccordionStory.argTypes.level,
|
|
25
|
+
variant: NsAccordionStory.argTypes.variant,
|
|
23
26
|
},
|
|
24
27
|
} as MetaStory;
|
|
25
28
|
|
|
26
29
|
export const OpenSection: Story = {
|
|
27
30
|
args: {
|
|
31
|
+
variant: AccordionVariant.Compact,
|
|
28
32
|
isOpen: true,
|
|
29
33
|
content: <div className="p-2">Nuskin Description</div>,
|
|
30
34
|
title: 'Nuskin',
|
|
@@ -33,6 +37,7 @@ export const OpenSection: Story = {
|
|
|
33
37
|
|
|
34
38
|
export const ClosedSection: Story = {
|
|
35
39
|
args: {
|
|
40
|
+
variant: AccordionVariant.Compact,
|
|
36
41
|
isOpen: false,
|
|
37
42
|
content: <div className="p-2">Nuskin Description</div>,
|
|
38
43
|
title: 'Nuskin',
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { StoryObj, Meta } from '@storybook/react';
|
|
2
2
|
import { withCenterDecorator } from '@/stories/decorators/withCenterDecorator';
|
|
3
|
-
import { NsCollapse } from '../';
|
|
3
|
+
import { AccordionVariant, NsCollapse } from '../';
|
|
4
|
+
import NsAccordionStory from './NsAccordion.stories';
|
|
4
5
|
|
|
5
6
|
type ComponentType = typeof NsCollapse;
|
|
6
7
|
type Story = StoryObj<ComponentType>;
|
|
@@ -15,10 +16,24 @@ export default {
|
|
|
15
16
|
control: 'boolean',
|
|
16
17
|
description: 'if true renders NsCollapse in open state, and close state otherwise',
|
|
17
18
|
},
|
|
18
|
-
|
|
19
|
+
content: {
|
|
19
20
|
control: 'React Node',
|
|
20
21
|
description: 'Content for NsCollapse',
|
|
21
22
|
},
|
|
23
|
+
allowMultipleExpanded: {
|
|
24
|
+
control: 'boolean',
|
|
25
|
+
description: 'This prop is useful when content is an array of accordion items',
|
|
26
|
+
},
|
|
27
|
+
type: {
|
|
28
|
+
control: 'select',
|
|
29
|
+
values: ['jsx', 'html', 'text', 'accordion'],
|
|
30
|
+
description: 'This type should exactly match the content type to have accordion work correctly',
|
|
31
|
+
},
|
|
32
|
+
level: NsAccordionStory.argTypes.level,
|
|
33
|
+
variant: NsAccordionStory.argTypes.variant,
|
|
34
|
+
},
|
|
35
|
+
args: {
|
|
36
|
+
variant: AccordionVariant.Compact,
|
|
22
37
|
},
|
|
23
38
|
} as MetaStory;
|
|
24
39
|
export const Closed: Story = {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { StoryObj, Meta } from '@storybook/react';
|
|
2
2
|
import { withCenterDecorator } from '@/stories/decorators/withCenterDecorator';
|
|
3
|
-
import { NsToggleSection } from '../..';
|
|
3
|
+
import { AccordionVariant, NsToggleSection } from '../..';
|
|
4
|
+
import NsAccordionStory from './NsAccordion.stories';
|
|
4
5
|
|
|
5
6
|
type ComponentType = typeof NsToggleSection;
|
|
6
7
|
type Story = StoryObj<ComponentType>;
|
|
@@ -11,9 +12,12 @@ export default {
|
|
|
11
12
|
component: NsToggleSection,
|
|
12
13
|
decorators: [withCenterDecorator],
|
|
13
14
|
argTypes: {
|
|
15
|
+
level: NsAccordionStory.argTypes.level,
|
|
16
|
+
variant: NsAccordionStory.argTypes.variant,
|
|
14
17
|
title: { control: 'string' },
|
|
15
18
|
},
|
|
16
19
|
args: {
|
|
20
|
+
variant: AccordionVariant.Compact,
|
|
17
21
|
title: 'Nuskin',
|
|
18
22
|
content: <div className="p-2">Nuskin Details</div>,
|
|
19
23
|
},
|