@nuskin/foundation-ui-components 1.0.0-cft-35.13 → 1.0.0-develop.2
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/alert/NsAlert.spec.tsx +17 -16
- package/src/common/alert/NsAlert.stories.tsx +2 -2
- package/src/common/alert/NsAlert.styled.ts +20 -20
- package/src/common/alert/NsAlert.tsx +21 -40
- package/src/common/alert/index.ts +2 -2
- package/src/common/auth-dropdown/NsAuthDropdown.spec.tsx +1 -1
- package/src/common/auth-dropdown/NsAuthDropdown.tsx +1 -1
- package/src/common/auth-dropdown/index.ts +1 -1
- package/src/common/autocomplete/NsAutocomplete.spec.tsx +5 -5
- package/src/common/autocomplete/NsAutocomplete.stories.tsx +1 -1
- package/src/common/autocomplete/NsAutocomplete.tsx +1 -1
- package/src/common/autocomplete/index.ts +2 -1
- package/src/common/banner/NsBanner.spec.tsx +1 -1
- package/src/common/banner/NsBanner.styled.tsx +1 -1
- package/src/common/banner/NsBanner.tsx +1 -1
- package/src/common/banner/index.ts +1 -1
- package/src/common/brand-components/NsBrandComponent.tsx +1 -1
- package/src/common/brand-components/index.ts +1 -1
- package/src/common/breadcrumb/NsBreadcrumb.spec.tsx +1 -1
- package/src/common/breadcrumb/NsBreadcrumb.tsx +1 -1
- package/src/common/breadcrumb/index.ts +1 -1
- package/src/common/button/NsButton.spec.tsx +1 -1
- package/src/common/button/NsButton.styled.tsx +10 -13
- package/src/common/button/NsButton.tsx +1 -1
- package/src/common/button/index.ts +1 -1
- package/src/common/card/NsFfgCard.tsx +1 -1
- package/src/common/carousal/NsScrollingCarousal.tsx +37 -0
- package/src/common/carousal/index.ts +3 -0
- package/src/common/carousal/stories/NSCarousal.stories.tsx +1 -1
- package/src/common/carousal/stories/NsScrollingCarousal.stories.tsx +52 -0
- package/src/common/carousal/tests/NsCarousal.spec.tsx +2 -2
- package/src/common/carousal/tests/NsScrollingCarousal.spec.tsx +61 -0
- package/src/common/carousal/types.d.ts +21 -0
- package/src/common/cart-icon/NsCartIcon.spec.tsx +1 -1
- package/src/common/cart-icon/NsCartIcon.tsx +1 -1
- package/src/common/cart-icon/index.ts +1 -1
- package/src/common/checkbox/NsCheckbox.spec.tsx +2 -2
- package/src/common/checkbox/NsCheckbox.tsx +1 -1
- package/src/common/checkbox/index.ts +1 -1
- package/src/common/checkbox/types.d.ts +1 -7
- package/src/common/column-control/NsColumnControl.tsx +1 -1
- package/src/common/column-control/NsFlexColumns.tsx +27 -0
- package/src/common/column-control/NsGridColumns.tsx +27 -0
- package/src/common/column-control/index.ts +3 -1
- package/src/common/column-control/{NsColumnControl.spec.tsx → specs/NsColumnControl.spec.tsx} +3 -3
- package/src/common/column-control/specs/NsFlexColumns.spec.tsx +24 -0
- package/src/common/column-control/specs/NsGridColumns.spec.tsx +24 -0
- package/src/common/column-control/{NDivs.story.tsx → stories/NDivs.story.tsx} +1 -1
- package/src/common/column-control/{NsColumnControl.stories.tsx → stories/NsColumnControl.stories.tsx} +4 -14
- package/src/common/column-control/stories/NsFlexColumns.stories.tsx +59 -0
- package/src/common/column-control/stories/NsGridColumns.stories.tsx +59 -0
- package/src/common/column-control/stories/common.tsx +14 -0
- package/src/common/column-control/styled/StyledFlex.tsx +41 -0
- package/src/common/column-control/styled/StyledGrid.tsx +33 -0
- package/src/common/column-control/styled/common.ts +27 -0
- package/src/common/column-control/utils.ts +1 -1
- package/src/common/dropdown/NsDropdown.spec.tsx +1 -1
- package/src/common/dropdown/NsDropdown.tsx +1 -1
- package/src/common/dropdown/NsDropdownOption.tsx +1 -1
- package/src/common/dropdown/index.ts +1 -1
- package/src/common/flag/NsFlag.spec.tsx +1 -1
- package/src/common/flag/NsFlag.styled.tsx +3 -5
- package/src/common/flag/NsFlag.tsx +1 -1
- package/src/common/flag/index.ts +1 -1
- package/src/common/flag/types.d.ts +0 -2
- package/src/common/icon/NsIcon.spec.tsx +1 -1
- package/src/common/icon/NsIcon.styled.tsx +1 -1
- package/src/common/icon/NsIcon.tsx +1 -1
- package/src/common/icon/NsIconVariants.ts +8 -4
- package/src/common/icon/icons/AlertErrorIcon.tsx +15 -6
- package/src/common/icon/icons/HamburgerIcon.tsx +29 -0
- package/src/common/icon/icons/UserIcon.tsx +30 -0
- package/src/common/icon/icons/WarningIcon.tsx +14 -5
- package/src/common/icon/index.ts +1 -1
- package/src/common/image/NsImage.spec.tsx +1 -1
- package/src/common/image/NsImage.tsx +1 -1
- package/src/common/image/NsNextImage.spec.tsx +1 -1
- package/src/common/image/NsNextImage.tsx +1 -1
- package/src/common/image/index.ts +1 -1
- package/src/common/index.ts +7 -10
- package/src/common/input/InputWrapper.tsx +1 -1
- package/src/common/input/NsInputField.tsx +1 -1
- package/src/common/input/getAdornmentProps.tsx +1 -1
- package/src/common/input/index.ts +1 -1
- package/src/common/label/NsLabel.tsx +1 -1
- package/src/common/label/index.ts +1 -1
- package/src/common/link/NsLink.spec.tsx +1 -1
- package/src/common/link/NsLink.tsx +1 -1
- package/src/common/link/index.ts +1 -1
- package/src/common/nav-product-card/NsNavProductCard.spec.tsx +1 -1
- package/src/common/nav-product-card/NsNavProductCard.tsx +1 -1
- package/src/common/nav-product-card/index.ts +1 -1
- package/src/common/nav-tab/NsNavTab.spec.tsx +2 -2
- package/src/common/nav-tab/NsNavTab.tsx +1 -1
- package/src/common/nav-tab/index.ts +1 -1
- package/src/common/search-bar/NsSeachBar.spec.tsx +1 -1
- package/src/common/table/NsTable.spec.tsx +146 -0
- package/src/common/table/NsTable.stories.tsx +123 -0
- package/src/common/table/NsTable.styled.ts +33 -0
- package/src/common/table/NsTable.tsx +161 -0
- package/src/common/table/NsTableHeader.tsx +48 -0
- package/src/common/table/NsTablePagination.tsx +20 -0
- package/src/common/table/helper.ts +33 -0
- package/src/common/table/index.ts +2 -0
- package/src/common/table/types.d.ts +44 -0
- package/src/common/text-strip/NsTextStrip.spec.tsx +30 -0
- package/src/common/text-strip/NsTextStrip.stories.tsx +32 -0
- package/src/common/text-strip/NsTextStrip.tsx +41 -0
- package/src/common/text-strip/index.ts +2 -0
- package/src/common/text-strip/types.d.ts +14 -0
- package/src/common/typography/NsTypography.tsx +1 -1
- package/src/common/typography/Typography.styled.tsx +1 -1
- package/src/common/typography/index.ts +1 -1
- package/src/common/videos/NsVideo.tsx +1 -1
- package/src/common/videos/index.ts +1 -1
- /package/src/common/autocomplete/{types.ts → types.d.ts} +0 -0
- /package/src/common/{common.types.ts → common.types.d.ts} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuskin/foundation-ui-components",
|
|
3
|
-
"version": "1.0.0-
|
|
3
|
+
"version": "1.0.0-develop.2",
|
|
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",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { render, fireEvent, screen, act } from '
|
|
2
|
+
import { render, fireEvent, screen, act } from '@/test-utils/index';
|
|
3
3
|
// import { act } from 'react-dom/test-utils';
|
|
4
4
|
import NsAlert from './NsAlert';
|
|
5
5
|
|
|
@@ -67,34 +67,35 @@ describe('NsAlert', () => {
|
|
|
67
67
|
|
|
68
68
|
test('adds and removes event listener on mount/unmount', () => {
|
|
69
69
|
act(() => {
|
|
70
|
-
render(
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
70
|
+
render(
|
|
71
|
+
<NsAlert
|
|
72
|
+
context="notice"
|
|
73
|
+
title="Success Alert"
|
|
74
|
+
threshhold={700}
|
|
75
|
+
type="card"
|
|
76
|
+
visible={false}
|
|
77
|
+
head={<span>Alert Head</span>}
|
|
78
|
+
body={<p>Alert Body</p>}
|
|
79
|
+
/>
|
|
80
|
+
);
|
|
79
81
|
});
|
|
80
|
-
|
|
82
|
+
|
|
81
83
|
expect(addEventListenerMock).toHaveBeenCalledWith('resize', expect.any(Function));
|
|
82
|
-
|
|
83
|
-
|
|
84
|
+
|
|
84
85
|
expect(removeEventListenerMock).toHaveBeenCalledWith('resize', expect.any(Function));
|
|
85
86
|
});
|
|
86
87
|
|
|
87
88
|
test('updates windowWidth on resize', () => {
|
|
88
89
|
const originalInnerWidth = window.innerWidth;
|
|
89
90
|
window.innerWidth = 500; // Set a desired window width for testing
|
|
90
|
-
|
|
91
|
+
|
|
91
92
|
act(() => {
|
|
92
93
|
render(<NsAlert />);
|
|
93
94
|
});
|
|
94
|
-
|
|
95
|
+
|
|
95
96
|
// Simulate a resize event by restoring the original innerWidth
|
|
96
97
|
window.innerWidth = originalInnerWidth;
|
|
97
|
-
|
|
98
|
+
|
|
98
99
|
act(() => {
|
|
99
100
|
window.dispatchEvent(new Event('resize'));
|
|
100
101
|
});
|
|
@@ -29,12 +29,12 @@ export default {
|
|
|
29
29
|
visible: true,
|
|
30
30
|
onDismiss: () => {},
|
|
31
31
|
body:
|
|
32
|
-
<
|
|
32
|
+
<span>{`Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt
|
|
33
33
|
ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco
|
|
34
34
|
laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
|
|
35
35
|
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
|
|
36
36
|
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa
|
|
37
|
-
qui officia deserunt mollit anim id est laborum.`}</
|
|
37
|
+
qui officia deserunt mollit anim id est laborum.`}</span>,
|
|
38
38
|
foot: <span>Some message goes here.</span>
|
|
39
39
|
}
|
|
40
40
|
} as MetaStory;
|
|
@@ -3,40 +3,40 @@ import { styled, css } from '@nuskin/foundation-theme';
|
|
|
3
3
|
import { getAppColor } from '@nuskin/foundation-theme/src/utils/color-utils';
|
|
4
4
|
import { FoundationTheme } from '@nuskin/foundation-theme/src/themes';
|
|
5
5
|
|
|
6
|
-
import type { AlertContainerParams, AlertType, AlertParams, TypeMapCSS } from './types';
|
|
7
|
-
const gutter_width=
|
|
6
|
+
import type { AlertContainerParams, AlertType, AlertParams, TypeMapCSS } from './types.d';
|
|
7
|
+
const gutter_width = '10px';
|
|
8
8
|
const close_button_width = '12px';
|
|
9
9
|
const icon_width = '24px';
|
|
10
10
|
|
|
11
11
|
const TypeMap: TypeMapCSS = {
|
|
12
12
|
banner: {
|
|
13
|
-
'min-height'
|
|
14
|
-
|
|
13
|
+
'min-height': '114px',
|
|
14
|
+
padding: '15px 45px',
|
|
15
15
|
'content-column-start': 'row-center',
|
|
16
16
|
'content-column-end': 'row-center',
|
|
17
17
|
'bar-position': 'top',
|
|
18
|
-
'foot-visibility': 'block'
|
|
18
|
+
'foot-visibility': 'block',
|
|
19
19
|
},
|
|
20
20
|
card: {
|
|
21
|
-
'min-height'
|
|
22
|
-
|
|
21
|
+
'min-height': '72px',
|
|
22
|
+
padding: '24px 24px',
|
|
23
23
|
'content-column-start': 'row-left',
|
|
24
24
|
'content-column-end': 'row-right',
|
|
25
25
|
'bar-position': 'left',
|
|
26
26
|
'foot-display': 'none',
|
|
27
|
-
}
|
|
28
|
-
}
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
29
|
|
|
30
30
|
const contextType = {
|
|
31
31
|
error: 'red',
|
|
32
32
|
info: 'info',
|
|
33
33
|
notice: 'info',
|
|
34
34
|
success: 'success',
|
|
35
|
-
warning: 'warning'
|
|
36
|
-
}
|
|
35
|
+
warning: 'warning',
|
|
36
|
+
};
|
|
37
37
|
|
|
38
38
|
export const AlertContainer = styled.div<AlertContainerParams>`
|
|
39
|
-
display: ${({ visible }) => visible ? 'block' : 'none'};
|
|
39
|
+
display: ${({ visible }) => (visible ? 'block' : 'none')};
|
|
40
40
|
* {
|
|
41
41
|
box-sizing: border-box;
|
|
42
42
|
webkit-font-smoothing: antialiased;
|
|
@@ -45,9 +45,9 @@ export const AlertContainer = styled.div<AlertContainerParams>`
|
|
|
45
45
|
`;
|
|
46
46
|
|
|
47
47
|
const fontFamilyStyles = css`
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
font-family: 'proxima-nova', 'OpenSans', 'Pridi', 'NotoSans', 'NotoSansSC', 'NotoSansHebrew', 'NotoSansJapanese',
|
|
49
|
+
'Hiragino Kaku Gothic Pro', 'Yu Gothic Medium', 'Yu Gothic', Meiryo, 'source-han-sans-japanese',
|
|
50
|
+
'source-han-sans-korean', 'source-han-sans-simplified-c', Helvetica, Arial, sans-serif;
|
|
51
51
|
`;
|
|
52
52
|
|
|
53
53
|
export const Alert = styled.div<AlertParams>`
|
|
@@ -99,16 +99,16 @@ export const AlertHead = styled.div`
|
|
|
99
99
|
}
|
|
100
100
|
`;
|
|
101
101
|
|
|
102
|
-
export const AlertContent = styled.div<{type: AlertType}>`
|
|
102
|
+
export const AlertContent = styled.div<{ type: AlertType }>`
|
|
103
103
|
margin-top: 8px;
|
|
104
104
|
color: ${({ theme }) => getAppColor(theme, 'primary', 'black')};
|
|
105
|
-
grid-column-start: ${({ type }) => TypeMap?.[type]?.['content-column-start']};
|
|
105
|
+
grid-column-start: ${({ type }) => TypeMap?.[type]?.['content-column-start']};
|
|
106
106
|
grid-column-end: ${({ type }) => TypeMap?.[type]?.['content-column-end']};
|
|
107
107
|
`;
|
|
108
108
|
|
|
109
|
-
export const AlertFoot = styled.div<{type: AlertType}>`
|
|
109
|
+
export const AlertFoot = styled.div<{ type: AlertType }>`
|
|
110
110
|
margin-top: 8px;
|
|
111
|
-
color: ${({ theme }) => getAppColor(theme, 'primary', 'black')}
|
|
111
|
+
color: ${({ theme }) => getAppColor(theme, 'primary', 'black')};
|
|
112
112
|
display: ${({ type }) => TypeMap?.[type]?.['foot-display']};
|
|
113
113
|
${fontFamilyStyles}
|
|
114
114
|
font-weight: 300;
|
|
@@ -121,4 +121,4 @@ export const AlertBody = styled.div`
|
|
|
121
121
|
font-weight: 300;
|
|
122
122
|
font-size: 16px;
|
|
123
123
|
line-height: 21px;
|
|
124
|
-
`;
|
|
124
|
+
`;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable react/require-default-props */
|
|
2
2
|
import React, { useEffect, useState } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
4
|
AlertContainer,
|
|
5
5
|
Alert,
|
|
6
6
|
AlertIcon,
|
|
@@ -8,11 +8,11 @@ import {
|
|
|
8
8
|
AlertCloseButton,
|
|
9
9
|
AlertContent,
|
|
10
10
|
AlertFoot,
|
|
11
|
-
AlertBody
|
|
12
|
-
} from './NsAlert.styled'
|
|
13
|
-
import type { NsAlertProps, HeaderProps, ContextType, AlertType } from './types';
|
|
11
|
+
AlertBody,
|
|
12
|
+
} from './NsAlert.styled';
|
|
13
|
+
import type { NsAlertProps, HeaderProps, ContextType, AlertType } from './types.d';
|
|
14
14
|
import { NsIcon } from '../icon';
|
|
15
|
-
import { NsIconNameType } from '../icon/types'
|
|
15
|
+
import { NsIconNameType } from '../icon/types';
|
|
16
16
|
import { FoundationTheme } from '@nuskin/foundation-theme/src/themes';
|
|
17
17
|
|
|
18
18
|
const Header: React.FC<HeaderProps> = ({ children, head }) => (
|
|
@@ -26,11 +26,11 @@ function isValidContextValue(value: string): boolean {
|
|
|
26
26
|
return (value as ContextType) !== undefined;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
function isValidTypeValue(value: string):boolean {
|
|
29
|
+
function isValidTypeValue(value: string): boolean {
|
|
30
30
|
return (value as AlertType) !== undefined;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
const colorMap:{ [key: string]: FoundationTheme.PaletteColors } = {
|
|
33
|
+
const colorMap: { [key: string]: FoundationTheme.PaletteColors } = {
|
|
34
34
|
error: 'error',
|
|
35
35
|
notice: 'info',
|
|
36
36
|
success: 'secondary',
|
|
@@ -38,7 +38,7 @@ const colorMap:{ [key: string]: FoundationTheme.PaletteColors } = {
|
|
|
38
38
|
default: 'info',
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
-
const iconMap:{ [key: string]: NsIconNameType } = {
|
|
41
|
+
const iconMap: { [key: string]: NsIconNameType } = {
|
|
42
42
|
error: 'alertError',
|
|
43
43
|
success: 'success',
|
|
44
44
|
warning: 'warning',
|
|
@@ -54,7 +54,7 @@ export default function NsAlert({
|
|
|
54
54
|
head,
|
|
55
55
|
body,
|
|
56
56
|
foot,
|
|
57
|
-
onDismiss = undefined
|
|
57
|
+
onDismiss = undefined,
|
|
58
58
|
}: NsAlertProps) {
|
|
59
59
|
const [alertType, setAlertType] = useState('banner');
|
|
60
60
|
const [windowWidth, setWindowWidth] = useState(window.innerWidth);
|
|
@@ -86,14 +86,14 @@ export default function NsAlert({
|
|
|
86
86
|
};
|
|
87
87
|
|
|
88
88
|
useEffect(() => {
|
|
89
|
-
let aType = ''
|
|
89
|
+
let aType = '';
|
|
90
90
|
if (type === 'auto') {
|
|
91
91
|
aType = windowWidth < threshhold ? 'card' : 'banner';
|
|
92
92
|
} else {
|
|
93
93
|
aType = type;
|
|
94
94
|
}
|
|
95
|
-
setAlertType(aType)
|
|
96
|
-
}, [threshhold, type, windowWidth])
|
|
95
|
+
setAlertType(aType);
|
|
96
|
+
}, [threshhold, type, windowWidth]);
|
|
97
97
|
|
|
98
98
|
useEffect(() => {
|
|
99
99
|
if (!isValidContextValue(context)) {
|
|
@@ -116,38 +116,19 @@ export default function NsAlert({
|
|
|
116
116
|
<AlertContainer visible={visible} data-testid="alert-container">
|
|
117
117
|
<Alert type={alertType as AlertType} context={context as ContextType}>
|
|
118
118
|
<AlertIcon>
|
|
119
|
-
<NsIcon
|
|
120
|
-
name={getIcon()}
|
|
121
|
-
color={getColor()}
|
|
122
|
-
size="large"
|
|
123
|
-
/>
|
|
119
|
+
<NsIcon name={getIcon()} color={getColor()} size="large" />
|
|
124
120
|
</AlertIcon>
|
|
125
121
|
<AlertHead>
|
|
126
|
-
<Header head={<span>{getTitleText()}</span>}>
|
|
127
|
-
{head}
|
|
128
|
-
</Header>
|
|
122
|
+
<Header head={<span>{getTitleText()}</span>}>{head}</Header>
|
|
129
123
|
</AlertHead>
|
|
130
|
-
{
|
|
131
|
-
|
|
132
|
-
<
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
size='small'
|
|
136
|
-
/>
|
|
137
|
-
</AlertCloseButton>
|
|
138
|
-
) : null
|
|
139
|
-
}
|
|
124
|
+
{hasDismissListener ? (
|
|
125
|
+
<AlertCloseButton data-testid="alert-close-button" onClick={handleDismiss}>
|
|
126
|
+
<NsIcon name="close" size="small" />
|
|
127
|
+
</AlertCloseButton>
|
|
128
|
+
) : null}
|
|
140
129
|
<AlertContent type={alertType as AlertType}>
|
|
141
|
-
<AlertBody>
|
|
142
|
-
|
|
143
|
-
</AlertBody>
|
|
144
|
-
{
|
|
145
|
-
foot ? (
|
|
146
|
-
<AlertFoot type={alertType as AlertType}>
|
|
147
|
-
{foot}
|
|
148
|
-
</AlertFoot>
|
|
149
|
-
) : null
|
|
150
|
-
}
|
|
130
|
+
<AlertBody>{body}</AlertBody>
|
|
131
|
+
{foot ? <AlertFoot type={alertType as AlertType}>{foot}</AlertFoot> : null}
|
|
151
132
|
</AlertContent>
|
|
152
133
|
</Alert>
|
|
153
134
|
</AlertContainer>
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default as
|
|
2
|
-
export type { NsAlertProps } from './types';
|
|
1
|
+
export { default as NsAlert } from './NsAlert';
|
|
2
|
+
export type { NsAlertProps } from './types.d';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { default as NsAuthDropdown } from './NsAuthDropdown';
|
|
2
|
-
export type { NsAuthDropdownProps } from './types';
|
|
2
|
+
export type { NsAuthDropdownProps } from './types.d';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { render, screen, waitFor } from '@testing-library/react';
|
|
3
|
-
import { NsAutocomplete } from '
|
|
3
|
+
import { NsAutocomplete } from '@/common/index';
|
|
4
4
|
import { OptionUiComponent } from './mock/MockUI';
|
|
5
5
|
import { AutocompleteMockList } from './mock/MockData';
|
|
6
6
|
import userEvent from '@testing-library/user-event';
|
|
@@ -34,7 +34,7 @@ describe('CustomAutocomplete', () => {
|
|
|
34
34
|
const option1 = screen.getByText('GS Facial Gels 2pk Subscription');
|
|
35
35
|
expect(option1).toBeInTheDocument();
|
|
36
36
|
});
|
|
37
|
-
});
|
|
37
|
+
}, 40000);
|
|
38
38
|
|
|
39
39
|
test('selects an option when clicking on it', async () => {
|
|
40
40
|
render(
|
|
@@ -50,7 +50,7 @@ describe('CustomAutocomplete', () => {
|
|
|
50
50
|
const optionLi = screen.getByText('GS Facial Spa');
|
|
51
51
|
userEvent.click(optionLi);
|
|
52
52
|
});
|
|
53
|
-
});
|
|
53
|
+
}, 40000);
|
|
54
54
|
|
|
55
55
|
test('should load more options when clicking load more button', async () => {
|
|
56
56
|
render(
|
|
@@ -71,7 +71,7 @@ describe('CustomAutocomplete', () => {
|
|
|
71
71
|
const loadMoreButton = screen.getByTestId('autocomplete-loadmore-id');
|
|
72
72
|
userEvent.click(loadMoreButton);
|
|
73
73
|
});
|
|
74
|
-
});
|
|
74
|
+
}, 40000);
|
|
75
75
|
|
|
76
76
|
test('should clear options when clicking clear button', async () => {
|
|
77
77
|
render(
|
|
@@ -92,5 +92,5 @@ describe('CustomAutocomplete', () => {
|
|
|
92
92
|
const clearButton = screen.getByTestId('autocomplete-clear-id');
|
|
93
93
|
userEvent.click(clearButton);
|
|
94
94
|
});
|
|
95
|
-
});
|
|
95
|
+
}, 40000);
|
|
96
96
|
});
|
|
@@ -11,7 +11,7 @@ import { withCenterDecorator } from '../../stories/decorators/withCenterDecorato
|
|
|
11
11
|
import { NsAutocomplete } from './';
|
|
12
12
|
import { AutocompleteMockList } from './mock/MockData';
|
|
13
13
|
import { OptionUiComponent } from './mock/MockUI';
|
|
14
|
-
import { NsAutocompleteProps } from './types';
|
|
14
|
+
import { NsAutocompleteProps } from './types.d';
|
|
15
15
|
|
|
16
16
|
type ComponentType = typeof NsAutocomplete;
|
|
17
17
|
type Story = StoryObj<ComponentType>;
|
|
@@ -3,7 +3,7 @@ import { NsInputField } from '../input';
|
|
|
3
3
|
import { Autocomplete, AutocompleteRenderGroupParams, List, AutocompleteRenderInputParams } from '@mui/material';
|
|
4
4
|
import { useState, PropsWithChildren, useRef } from 'react';
|
|
5
5
|
import { NsTypography } from '../typography';
|
|
6
|
-
import { NsAutocompleteProps, OptionsProps, ComponentboxProps } from './types';
|
|
6
|
+
import { NsAutocompleteProps, OptionsProps, ComponentboxProps } from './types.d';
|
|
7
7
|
import { NsButton } from '../button';
|
|
8
8
|
|
|
9
9
|
const NsAutocomplete = ({
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { default as NsAutocomplete } from './NsAutocomplete';
|
|
1
|
+
export { default as NsAutocomplete } from './NsAutocomplete';
|
|
2
|
+
export * from './types.d';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { default as NsBanner } from './NsBanner';
|
|
2
|
-
export type { NsBannerProps } from './types';
|
|
2
|
+
export type { NsBannerProps } from './types.d';
|
|
@@ -5,7 +5,7 @@ import NSLogoPoweredBy from './icons/NSLogoPoweredBy';
|
|
|
5
5
|
import NSLogoStacked from './icons/NSLogoStacked';
|
|
6
6
|
import NSLogoWordMark from './icons/NSWordMark';
|
|
7
7
|
import LogoContainer from './NsBrandContanier.styled';
|
|
8
|
-
import { NsBrandComponentProps } from './types';
|
|
8
|
+
import { NsBrandComponentProps } from './types.d';
|
|
9
9
|
|
|
10
10
|
const VariantMap = {
|
|
11
11
|
stacked: NSLogoStacked,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { default as NsBrandComponent } from './NsBrandComponent';
|
|
2
|
-
export type { NsBrandComponentProps } from './types';
|
|
2
|
+
export type { NsBrandComponentProps } from './types.d';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { render, screen } from '@testing-library/react';
|
|
3
3
|
import { NsBreadcrumb } from './';
|
|
4
|
-
import { ItemProps } from './types';
|
|
4
|
+
import { ItemProps } from './types.d';
|
|
5
5
|
const { getByText } = screen;
|
|
6
6
|
export const breadcrumbItems: ItemProps[] = [
|
|
7
7
|
{ label: 'Home', href: '/', icon: 'home' },
|
|
@@ -8,7 +8,7 @@ import { PropsWithChildren } from 'react';
|
|
|
8
8
|
|
|
9
9
|
import { BreadcrumbContainer, BreadcrumbItem, BreadcrumbList } from './NsBreadcrumb.styled';
|
|
10
10
|
import { NsTypography, NsLink, NsIcon } from '../';
|
|
11
|
-
import { NsBreadcrumbProps, ItemProps } from './types';
|
|
11
|
+
import { NsBreadcrumbProps, ItemProps } from './types.d';
|
|
12
12
|
import { useTheme } from '@mui/material/styles';
|
|
13
13
|
import { ColorUtils } from '@nuskin/foundation-theme';
|
|
14
14
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { default as NsBreadcrumb } from './NsBreadcrumb';
|
|
2
|
-
export type { NsBreadcrumbProps } from './types';
|
|
2
|
+
export type { NsBreadcrumbProps } from './types.d';
|
|
@@ -2,12 +2,9 @@ import { Button as MUIButton } from '@mui/material';
|
|
|
2
2
|
|
|
3
3
|
import { styled, ColorUtils, FoundationTheme } from '@nuskin/foundation-theme';
|
|
4
4
|
import { ButtonConfig } from '@nuskin/foundation-theme/src/themes/types/button';
|
|
5
|
-
import { NsButtonProps } from './types';
|
|
5
|
+
import { NsButtonProps } from './types.d';
|
|
6
6
|
|
|
7
|
-
const {
|
|
8
|
-
getPaletteColor,
|
|
9
|
-
getButtonStateColor,
|
|
10
|
-
} = ColorUtils;
|
|
7
|
+
const { getPaletteColor, getButtonStateColor } = ColorUtils;
|
|
11
8
|
|
|
12
9
|
const getButtonConfig = (theme: FoundationTheme.Theme, attribute: keyof ButtonConfig) => {
|
|
13
10
|
const { config } = theme || {};
|
|
@@ -16,23 +13,23 @@ const getButtonConfig = (theme: FoundationTheme.Theme, attribute: keyof ButtonCo
|
|
|
16
13
|
|
|
17
14
|
const StyledButton = styled(MUIButton)<NsButtonProps>`
|
|
18
15
|
gap: 10px;
|
|
19
|
-
border-radius: ${({ theme}) => getButtonConfig(theme, 'borderRadius')} || 0;
|
|
16
|
+
border-radius: ${({ theme }) => getButtonConfig(theme, 'borderRadius')} || 0;
|
|
20
17
|
:focus {
|
|
21
|
-
border: 1px solid
|
|
18
|
+
border: 1px solid ${({ theme }) => getButtonConfig(theme, 'focusColor')} !important;
|
|
22
19
|
}
|
|
23
20
|
:disabled {
|
|
24
21
|
background-color: ${({ theme, color }) => getButtonStateColor(theme, color, 'disabled')};
|
|
25
22
|
color: ${({ theme, color }) => getButtonStateColor(theme, color, 'disabledText')};
|
|
26
23
|
}
|
|
27
24
|
${({ theme: { config }, size }) => {
|
|
28
|
-
return size === 'medium' ? config?.components?.button?.size?.medium?.padding : ''
|
|
25
|
+
return size === 'medium' ? config?.components?.button?.size?.medium?.padding : '';
|
|
29
26
|
}}
|
|
30
|
-
${({ theme: { config}, size }) => {
|
|
31
|
-
return size === 'large' ? config?.components?.button?.size?.large?.padding : ''
|
|
27
|
+
${({ theme: { config }, size }) => {
|
|
28
|
+
return size === 'large' ? config?.components?.button?.size?.large?.padding : '';
|
|
32
29
|
}}
|
|
33
30
|
${({ variant, theme, color = 'primary' }) => {
|
|
34
|
-
return variant === 'contained'
|
|
35
|
-
`
|
|
31
|
+
return variant === 'contained'
|
|
32
|
+
? `
|
|
36
33
|
background-color: ${getPaletteColor(theme, color)};
|
|
37
34
|
:hover {
|
|
38
35
|
background-color: ${getButtonStateColor(theme, color, 'hovered')};
|
|
@@ -44,7 +41,7 @@ const StyledButton = styled(MUIButton)<NsButtonProps>`
|
|
|
44
41
|
background-color: ${getButtonStateColor(theme, color, 'focused')};
|
|
45
42
|
}
|
|
46
43
|
`
|
|
47
|
-
: ''
|
|
44
|
+
: '';
|
|
48
45
|
}}
|
|
49
46
|
${({ variant, theme, color = 'primary' }) =>
|
|
50
47
|
variant === 'outlined' &&
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PropsWithChildren } from 'react';
|
|
2
2
|
import StyledButton from './NsButton.styled';
|
|
3
|
-
import { NsButtonProps } from './types';
|
|
3
|
+
import { NsButtonProps } from './types.d';
|
|
4
4
|
|
|
5
5
|
const NsButton = ({ children, ...props }: PropsWithChildren<NsButtonProps>) => {
|
|
6
6
|
return (
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { default as NsButton } from './NsButton';
|
|
2
|
-
export type { NsButtonProps } from './types';
|
|
2
|
+
export type { NsButtonProps } from './types.d';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NsNextImage, NsLink } from '../';
|
|
2
2
|
import { NsFfgStyled } from './styled/NsFfgStyled';
|
|
3
|
-
import { NsFfgCardProps } from './types';
|
|
3
|
+
import { NsFfgCardProps } from './types.d';
|
|
4
4
|
|
|
5
5
|
const NsFfgCard = ({ actionText, actionLink, text, topImageUrl, topImageAlt, additionalProps }: NsFfgCardProps) => {
|
|
6
6
|
return (
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import Slider from 'react-slick';
|
|
3
|
+
import { NsScrollingCarousalProps } from '../';
|
|
4
|
+
|
|
5
|
+
const NsScrollingCarousal = ({
|
|
6
|
+
slides,
|
|
7
|
+
scrollSeconds,
|
|
8
|
+
stillSeconds,
|
|
9
|
+
renderSlide,
|
|
10
|
+
settings,
|
|
11
|
+
additionalProps,
|
|
12
|
+
}: NsScrollingCarousalProps) => {
|
|
13
|
+
const defaultSettings = useMemo(() => {
|
|
14
|
+
return {
|
|
15
|
+
...settings,
|
|
16
|
+
autoplay: true,
|
|
17
|
+
autoplaySpeed: stillSeconds * 1000 || 2000, // autoplaySpeed = delay between scroll in milliseconds
|
|
18
|
+
accessibility: true,
|
|
19
|
+
adaptiveHeight: true,
|
|
20
|
+
arrows: true,
|
|
21
|
+
draggable: true,
|
|
22
|
+
dots: true,
|
|
23
|
+
infinite: true,
|
|
24
|
+
speed: scrollSeconds * 1000 || 500, // speed = animation speed in milliseconds
|
|
25
|
+
slidesToShow: 1,
|
|
26
|
+
slidesToScroll: 1,
|
|
27
|
+
swipeToSlide: true,
|
|
28
|
+
};
|
|
29
|
+
}, [stillSeconds, scrollSeconds, settings]);
|
|
30
|
+
return (
|
|
31
|
+
<div data-testid={additionalProps?.testid ?? 'scrolling-carousal-test-id'}>
|
|
32
|
+
<Slider {...defaultSettings}>{slides.map(renderSlide)}</Slider>
|
|
33
|
+
</div>
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export default NsScrollingCarousal;
|
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
export { default as NsCarousal } from './NsCarousal';
|
|
2
|
+
export { default as NsScrollingCarousal } from './NsScrollingCarousal';
|
|
2
3
|
export { default as NsDefaultCarousalSettings } from './slickSetting';
|
|
4
|
+
|
|
5
|
+
export type { NsCarousalProps, NsScrollingCarousalProps } from './types.d';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
import { NsCarousal } from '
|
|
2
|
+
import { NsCarousal } from '@/common/';
|
|
3
3
|
import { brandEntries } from '../../card/stories/data';
|
|
4
4
|
import { RenderBrand } from '../RenderBrand';
|
|
5
5
|
import settings from '../slickSetting';
|