@nuskin/foundation-ui-components 1.22.2 → 1.23.0-accordion-update.1
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/NsAccordionHeader.tsx +6 -2
- package/src/common/accordion/NsAccordionItem.tsx +2 -1
- package/src/common/accordion/NsCollapse.tsx +11 -2
- package/src/common/accordion/colorMap.ts +8 -2
- package/src/common/accordion/specs/NsAccordionHeader.spec.tsx +42 -1
- package/src/common/accordion/types.d.ts +1 -1
- package/src/common/text-strip/NsTextStrip.tsx +3 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuskin/foundation-ui-components",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.23.0-accordion-update.1",
|
|
4
4
|
"description": "It is a foundation library written in react, that provides common components to all UI pages",
|
|
5
5
|
"main": "src/common/index.ts",
|
|
6
6
|
"repository": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { styled } from '@nuskin/foundation-theme';
|
|
2
2
|
|
|
3
|
-
import { AccordionVariant, AccordionVariantType, NsAccordionHeaderProps, NsIcon, NsIconProps, NsTypography } from '
|
|
3
|
+
import { AccordionVariant, AccordionVariantType, NsAccordionHeaderProps, NsIcon, NsIconProps, NsTypography } from '../';
|
|
4
4
|
import { isValidIconName } from '../icon/NsIconVariants';
|
|
5
5
|
import { getAccordionColor } from './colorMap';
|
|
6
6
|
|
|
@@ -21,6 +21,9 @@ const StyledHeader = styled('header')<StyledType>(({ theme, variant, invert }) =
|
|
|
21
21
|
gridTemplateColumns: 'auto 1fr 24px',
|
|
22
22
|
padding: '9px 16px',
|
|
23
23
|
borderBottom,
|
|
24
|
+
'.nsa-item-title': {
|
|
25
|
+
color: headText,
|
|
26
|
+
},
|
|
24
27
|
} as any;
|
|
25
28
|
});
|
|
26
29
|
|
|
@@ -41,6 +44,7 @@ const NsAccordionHeader = ({
|
|
|
41
44
|
invert,
|
|
42
45
|
cslp,
|
|
43
46
|
showEndIconWhenEmpty,
|
|
47
|
+
content,
|
|
44
48
|
}: NsAccordionHeaderProps) => {
|
|
45
49
|
return (
|
|
46
50
|
<StyledHeader
|
|
@@ -59,7 +63,7 @@ const NsAccordionHeader = ({
|
|
|
59
63
|
) : (
|
|
60
64
|
title
|
|
61
65
|
)}
|
|
62
|
-
{showEndIconWhenEmpty ? (
|
|
66
|
+
{content || showEndIconWhenEmpty ? (
|
|
63
67
|
<span className="header-icon">
|
|
64
68
|
<NsIcon name={isOpen ? openedIconName ?? 'arrowUp' : closedIconName ?? 'arrowDown'} />
|
|
65
69
|
</span>
|
|
@@ -1,7 +1,16 @@
|
|
|
1
|
-
import { styled } from '@nuskin/foundation-theme';
|
|
2
1
|
import { isValidElement, ReactElement, useMemo } from 'react';
|
|
3
2
|
|
|
4
|
-
import {
|
|
3
|
+
import { styled } from '@nuskin/foundation-theme';
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
AccordionContentTypeObject,
|
|
7
|
+
AccordionItem,
|
|
8
|
+
AccordionVariant,
|
|
9
|
+
AccordionVariantType,
|
|
10
|
+
NsAccordion,
|
|
11
|
+
NsCollapseProps,
|
|
12
|
+
NsTypography,
|
|
13
|
+
} from '../';
|
|
5
14
|
import { getAccordionColor } from './colorMap';
|
|
6
15
|
|
|
7
16
|
const getLevelOffset = (level: number) => {
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
AllColorKeyType,
|
|
3
|
+
ColorUtils,
|
|
4
|
+
} from '@nuskin/foundation-theme';
|
|
2
5
|
|
|
3
6
|
import { Themed } from '../common.types';
|
|
4
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
AccordionVariant,
|
|
9
|
+
AccordionVariantType,
|
|
10
|
+
} from './enums';
|
|
5
11
|
|
|
6
12
|
const { getGenomeColor } = ColorUtils;
|
|
7
13
|
const compKeys = ['contentBg', 'contentText', 'headBg', 'headText'];
|
|
@@ -1,11 +1,44 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { render, fireEvent } from '@/test-utils/index';
|
|
3
|
-
import { NsAccordionHeader, AccordionVariant } from '@/common/index';
|
|
3
|
+
import { NsAccordionHeader, AccordionVariant, NsLink } from '@/common/index';
|
|
4
|
+
|
|
5
|
+
const content = [
|
|
6
|
+
{
|
|
7
|
+
type: 'text',
|
|
8
|
+
id: '1',
|
|
9
|
+
title: 'title1',
|
|
10
|
+
content: (
|
|
11
|
+
<div>
|
|
12
|
+
<p>1</p>
|
|
13
|
+
<p>2</p>
|
|
14
|
+
</div>
|
|
15
|
+
),
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
type: 'text',
|
|
19
|
+
id: '2',
|
|
20
|
+
title: <NsLink href={'/test'}>title2</NsLink>,
|
|
21
|
+
content: null,
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
type: 'text',
|
|
25
|
+
id: '3',
|
|
26
|
+
title: 'title3',
|
|
27
|
+
content: (
|
|
28
|
+
<div>
|
|
29
|
+
<p>1</p>
|
|
30
|
+
<p>2</p>
|
|
31
|
+
<p>3</p>
|
|
32
|
+
</div>
|
|
33
|
+
),
|
|
34
|
+
},
|
|
35
|
+
];
|
|
4
36
|
|
|
5
37
|
describe('NsAccordionHeader', () => {
|
|
6
38
|
it('1. renders title correctly', () => {
|
|
7
39
|
const onClick = jest.fn();
|
|
8
40
|
const title = 'Section Header';
|
|
41
|
+
|
|
9
42
|
const { getByText } = render(
|
|
10
43
|
<NsAccordionHeader
|
|
11
44
|
variant={AccordionVariant.Basic}
|
|
@@ -13,6 +46,7 @@ describe('NsAccordionHeader', () => {
|
|
|
13
46
|
onClick={onClick}
|
|
14
47
|
invert={false}
|
|
15
48
|
isOpen={true}
|
|
49
|
+
content={content}
|
|
16
50
|
/>
|
|
17
51
|
);
|
|
18
52
|
const el = getByText(title);
|
|
@@ -29,6 +63,7 @@ describe('NsAccordionHeader', () => {
|
|
|
29
63
|
onClick={onClick}
|
|
30
64
|
invert={false}
|
|
31
65
|
isOpen={false}
|
|
66
|
+
content={content}
|
|
32
67
|
/>
|
|
33
68
|
);
|
|
34
69
|
const el = getByText(title);
|
|
@@ -44,6 +79,7 @@ describe('NsAccordionHeader', () => {
|
|
|
44
79
|
onClick={onClick}
|
|
45
80
|
invert={false}
|
|
46
81
|
isOpen={false}
|
|
82
|
+
content={content}
|
|
47
83
|
/>
|
|
48
84
|
);
|
|
49
85
|
const header = container.querySelector('header');
|
|
@@ -64,6 +100,7 @@ describe('NsAccordionHeader', () => {
|
|
|
64
100
|
additionalProps={{ className: additionalClassName }}
|
|
65
101
|
onClick={onClick}
|
|
66
102
|
invert={false}
|
|
103
|
+
content={content}
|
|
67
104
|
/>
|
|
68
105
|
);
|
|
69
106
|
expect(container.querySelector('header')).toHaveClass(`section-header ${additionalClassName}`);
|
|
@@ -78,6 +115,7 @@ describe('NsAccordionHeader', () => {
|
|
|
78
115
|
isOpen
|
|
79
116
|
onClick={onClick}
|
|
80
117
|
invert={false}
|
|
118
|
+
content={content}
|
|
81
119
|
/>
|
|
82
120
|
);
|
|
83
121
|
expect(container.querySelector('header')).toHaveClass('expanded');
|
|
@@ -93,6 +131,7 @@ describe('NsAccordionHeader', () => {
|
|
|
93
131
|
invert={false}
|
|
94
132
|
isOpen
|
|
95
133
|
showEndIconWhenEmpty={true}
|
|
134
|
+
content={content}
|
|
96
135
|
/>
|
|
97
136
|
);
|
|
98
137
|
// this icon refers to end icon which is either arrowUp or arrowDown
|
|
@@ -108,6 +147,7 @@ describe('NsAccordionHeader', () => {
|
|
|
108
147
|
invert={false}
|
|
109
148
|
isOpen
|
|
110
149
|
startIcon={{ name: 'hamburgerIcon', testId: 'hamburger-test' }}
|
|
150
|
+
content={content}
|
|
111
151
|
/>
|
|
112
152
|
);
|
|
113
153
|
expect(getByTestId('hamburger-test')).toBeInTheDocument();
|
|
@@ -124,6 +164,7 @@ describe('NsAccordionHeader', () => {
|
|
|
124
164
|
invert={false}
|
|
125
165
|
isOpen
|
|
126
166
|
startIcon={{ name: invalidIconName as any, testId }}
|
|
167
|
+
content={content}
|
|
127
168
|
/>
|
|
128
169
|
);
|
|
129
170
|
expect(queryByTestId(testId)).toBeNull();
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//types
|
|
2
1
|
import { ReactElement, ReactNode } from 'react';
|
|
3
2
|
import { AdditionalProps } from '../common.types';
|
|
4
3
|
import { NsIconNameType, NsIconProps } from '../icon';
|
|
@@ -50,6 +49,7 @@ export type NsAccordionHeaderProps = AdditionalProps & {
|
|
|
50
49
|
headerTypographyVariant?: Variants;
|
|
51
50
|
startIcon?: NsIconProps;
|
|
52
51
|
showEndIconWhenEmpty?: boolean;
|
|
52
|
+
content: AccordionItem['content'];
|
|
53
53
|
} & Pick<CommonAccordionType, 'invert' | 'variant'>;
|
|
54
54
|
|
|
55
55
|
export type NsCollapseProps = AdditionalProps & {
|
|
@@ -5,10 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import React from 'react';
|
|
7
7
|
|
|
8
|
-
import {
|
|
9
|
-
ColorUtils,
|
|
10
|
-
styled,
|
|
11
|
-
} from '@nuskin/foundation-theme';
|
|
8
|
+
import { ColorUtils, styled } from '@nuskin/foundation-theme';
|
|
12
9
|
|
|
13
10
|
import { NsLink } from '../link';
|
|
14
11
|
import { NsTypography } from '../typography';
|
|
@@ -46,12 +43,12 @@ const NsTextStrip = (props: NsTextStripProps) => {
|
|
|
46
43
|
>
|
|
47
44
|
{link?.title ? (
|
|
48
45
|
<NsTypography weight="bold" variant="label-m" className="text-strip-title whitespace-nowrap" noSpacing>
|
|
49
|
-
|
|
46
|
+
{link.title}
|
|
50
47
|
</NsTypography>
|
|
51
48
|
) : null}
|
|
52
49
|
{description ? (
|
|
53
50
|
<NsTypography className="text-strip-description whitespace-nowrap" variant="body-m" noSpacing>
|
|
54
|
-
|
|
51
|
+
{description}
|
|
55
52
|
</NsTypography>
|
|
56
53
|
) : null}
|
|
57
54
|
</StyledHeader>
|