@nuskin/foundation-ui-components 1.0.0-develop.1 → 1.0.0-develop.3
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 +15 -14
- 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.stories.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 +2 -2
- 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.stories.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/NsBrand.stories.tsx +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 -7
- package/src/common/breadcrumb/NsBreadcrumb.stories.tsx +2 -4
- package/src/common/breadcrumb/NsBreadcrumb.tsx +1 -1
- package/src/common/breadcrumb/data.ts +7 -0
- package/src/common/breadcrumb/index.ts +1 -1
- package/src/common/button/NsButton.spec.tsx +1 -1
- package/src/common/button/NsButton.stories.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/card/stories/NsBgCard.stories.tsx +1 -3
- package/src/common/card/stories/NsBrandProductCard.stories.tsx +1 -1
- package/src/common/card/stories/NsFfgCard.stories.tsx +1 -1
- package/src/common/card/stories/{data.js → data.ts} +1 -25
- package/src/common/carousal/NsScrollingCarousal.tsx +61 -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 +23 -0
- package/src/common/cart-icon/NsCartIcon.spec.tsx +1 -1
- package/src/common/cart-icon/NsCartIcon.stories.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.stories.tsx +1 -1
- 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 +22 -0
- package/src/common/column-control/NsGridColumns.tsx +22 -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/stories/DivArray.stories.tsx +18 -0
- package/src/common/column-control/stories/DivArray.tsx +63 -0
- package/src/common/column-control/{NsColumnControl.stories.tsx → stories/NsColumnControl.stories.tsx} +9 -16
- package/src/common/column-control/stories/NsFlexColumns.stories.tsx +63 -0
- package/src/common/column-control/stories/NsGridColumns.stories.tsx +63 -0
- package/src/common/column-control/stories/common.tsx +14 -0
- package/src/common/column-control/styled/StyledFlex.tsx +45 -0
- package/src/common/column-control/styled/StyledGrid.tsx +40 -0
- package/src/common/column-control/styled/common.ts +27 -0
- package/src/common/column-control/types.d.ts +15 -16
- 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/dropdown/stories/NsDropdown.stories.tsx +1 -1
- package/src/common/dropdown/stories/NsDropdownCountry.stories.tsx +1 -1
- package/src/common/flag/NsFlag.spec.tsx +1 -1
- package/src/common/flag/NsFlag.stories.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.stories.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.stories.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.stories.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.stories.tsx +2 -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/input/types.d.ts +15 -0
- package/src/common/label/NsLabel.stories.tsx +2 -0
- package/src/common/label/NsLabel.tsx +4 -4
- package/src/common/label/index.ts +1 -1
- package/src/common/link/NsLink.spec.tsx +1 -1
- package/src/common/link/NsLink.stories.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.stories.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.stories.tsx +1 -1
- 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 +33 -0
- package/src/common/text-strip/NsTextStrip.tsx +44 -0
- package/src/common/text-strip/index.ts +2 -0
- package/src/common/text-strip/types.d.ts +17 -0
- package/src/common/typography/NsTypography.stories.tsx +1 -1
- 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.stories.tsx +1 -1
- package/src/common/videos/NsVideo.tsx +1 -1
- package/src/common/videos/index.ts +1 -1
- package/src/common/column-control/NDivs.story.tsx +0 -35
- /package/src/common/autocomplete/{types.ts → types.d.ts} +0 -0
- /package/src/common/{common.types.ts → common.types.d.ts} +0 -0
|
@@ -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 (
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
2
|
import { NsBgCard } from '../';
|
|
3
|
-
import { withCenterDecorator } from '
|
|
3
|
+
import { withCenterDecorator } from '@/stories/decorators/withCenterDecorator';
|
|
4
4
|
|
|
5
5
|
type ComponentType = typeof NsBgCard;
|
|
6
6
|
type Story = StoryObj<ComponentType>;
|
|
@@ -13,8 +13,6 @@ export default {
|
|
|
13
13
|
args: {
|
|
14
14
|
title: 'ageLOC LumiSpa',
|
|
15
15
|
backgroundImageUrl: 'https://media.nuskin.com/m/3604b5202b0b64c6/webimage-brand-lumispa-optweb.png',
|
|
16
|
-
// brandImageUrl:
|
|
17
|
-
// 'https://media.nuskin.com/m/2571a0407433a6e8/webimage-brand-lumispa.png',
|
|
18
16
|
},
|
|
19
17
|
decorators: [withCenterDecorator],
|
|
20
18
|
} as MetaStory;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { StoryObj, Meta } from '@storybook/react';
|
|
2
|
-
import { withCenterDecorator } from '
|
|
2
|
+
import { withCenterDecorator } from '@/stories/decorators/withCenterDecorator';
|
|
3
3
|
import { NsBrandProductCard } from '../';
|
|
4
4
|
|
|
5
5
|
type ComponentType = typeof NsBrandProductCard;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { StoryObj, Meta } from '@storybook/react';
|
|
2
2
|
import { within, userEvent } from '@storybook/testing-library';
|
|
3
3
|
import { expect } from '@storybook/jest';
|
|
4
|
-
import { withCenterDecorator } from '
|
|
4
|
+
import { withCenterDecorator } from '@/stories/decorators/withCenterDecorator';
|
|
5
5
|
import { NsFfgCard } from '../';
|
|
6
6
|
|
|
7
7
|
type ComponentType = typeof NsFfgCard;
|
|
@@ -8,14 +8,6 @@ export const brandImages = [
|
|
|
8
8
|
'https://media.nuskin.com/m/4bd7ab9b46bd456d/webimage-brand-pharmanex.png',
|
|
9
9
|
'https://media.nuskin.com/m/501d638a8af80087/webimage-brand-ap24.png',
|
|
10
10
|
'https://media.nuskin.com/m/f3a91129cbbae32/webimage-brand-nutricentials.png',
|
|
11
|
-
'https://media.nuskin.com/m/63a454ff90d038b4/webimage-brand-epoch.png',
|
|
12
|
-
'https://media.nuskin.com/m/3eb406f465d4b0fe/webimage-brand-sunright.png',
|
|
13
|
-
'https://media.nuskin.com/m/2d3276518912283b/webimage-brand-nu_colour.png',
|
|
14
|
-
'https://media.nuskin.com/m/3855d3836d920639/webimage-brand-nuskin180.png',
|
|
15
|
-
'https://media.nuskin.com/m/6245528b8f76ad32/webimage-brand-ageLOC.png',
|
|
16
|
-
'https://media.nuskin.com/m/2571a0407433a6e8/webimage-brand-lumispa.png',
|
|
17
|
-
'https://media.nuskin.com/m/4bd7ab9b46bd456d/webimage-brand-pharmanex.png',
|
|
18
|
-
'https://media.nuskin.com/m/501d638a8af80087/webimage-brand-ap24.png',
|
|
19
11
|
];
|
|
20
12
|
|
|
21
13
|
export const brandBackImages = [
|
|
@@ -28,34 +20,18 @@ export const brandBackImages = [
|
|
|
28
20
|
'https://media.nuskin.com/m/4a1245a63c595262/webimage-brand-pharmanex-optweb.png',
|
|
29
21
|
'https://media.nuskin.com/m/14a0fd6ef63e5dbb/webimage-brand-ap_24.png',
|
|
30
22
|
'https://media.nuskin.com/m/298104036e885b40/webimage-brand-nutricentials.png',
|
|
31
|
-
'https://media.nuskin.com/m/549aa3e5184434d8/webimage-brand-epoch-optweb.png',
|
|
32
|
-
'https://media.nuskin.com/m/14e238d7599e1811/webimage-brand-sunright.png',
|
|
33
|
-
'https://media.nuskin.com/m/2543e79419276727/webimage-brand-nu_colour-optweb.png',
|
|
34
|
-
'https://media.nuskin.com/m/446c7a2aad513f58/webimage-brand-nu_skin_180-optweb.png',
|
|
35
|
-
'https://media.nuskin.com/m/42911c8b05600476/webimage-brand-ageloc-optweb.png',
|
|
36
|
-
'https://media.nuskin.com/m/3604b5202b0b64c6/webimage-brand-lumispa-optweb.png',
|
|
37
|
-
'https://media.nuskin.com/m/4a1245a63c595262/webimage-brand-pharmanex-optweb.png',
|
|
38
|
-
'https://media.nuskin.com/m/14a0fd6ef63e5dbb/webimage-brand-ap_24.png',
|
|
39
23
|
];
|
|
40
24
|
|
|
41
25
|
export const brandTitles = [
|
|
42
26
|
'Epoch',
|
|
43
27
|
'Sunright',
|
|
44
|
-
'Nu
|
|
28
|
+
'Nu Color',
|
|
45
29
|
'180 System',
|
|
46
30
|
'ageLOC',
|
|
47
31
|
'ageLOC LumiSpa',
|
|
48
32
|
'Pharmanex',
|
|
49
33
|
'AP 24',
|
|
50
34
|
'Nutricentials',
|
|
51
|
-
'Epoch',
|
|
52
|
-
'Sunright',
|
|
53
|
-
'Nu Colour',
|
|
54
|
-
'180 System',
|
|
55
|
-
'ageLOC',
|
|
56
|
-
'ageLOC LumiSpa',
|
|
57
|
-
'Pharmanex',
|
|
58
|
-
'AP 24',
|
|
59
35
|
];
|
|
60
36
|
export const brandEntries = brandTitles.map((title, index) => {
|
|
61
37
|
return {
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import Slider from 'react-slick';
|
|
3
|
+
import { NsScrollingCarousalProps } from '../';
|
|
4
|
+
import { styled } from '@nuskin/foundation-theme';
|
|
5
|
+
|
|
6
|
+
const options = {
|
|
7
|
+
shouldForwardProp: (prop: string) => prop !== 'dotsBottomPixel',
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const StyledDiv = styled(
|
|
11
|
+
'div',
|
|
12
|
+
options
|
|
13
|
+
)<{
|
|
14
|
+
dotsBottomPixel?: number;
|
|
15
|
+
}>(({ dotsBottomPixel }) => {
|
|
16
|
+
return {
|
|
17
|
+
'.slick-dots': {
|
|
18
|
+
zIndex: 9,
|
|
19
|
+
bottom: `${dotsBottomPixel ?? -25}px`,
|
|
20
|
+
opacity: '0.5',
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const NsScrollingCarousal = ({
|
|
26
|
+
slides,
|
|
27
|
+
scrollSeconds,
|
|
28
|
+
stillSeconds,
|
|
29
|
+
renderSlide,
|
|
30
|
+
settings,
|
|
31
|
+
dotsBottomPixel,
|
|
32
|
+
additionalProps,
|
|
33
|
+
}: NsScrollingCarousalProps) => {
|
|
34
|
+
const defaultSettings = useMemo(() => {
|
|
35
|
+
return {
|
|
36
|
+
...settings,
|
|
37
|
+
autoplay: true,
|
|
38
|
+
autoplaySpeed: stillSeconds * 1000 || 2000, // autoplaySpeed = delay between scroll in milliseconds
|
|
39
|
+
accessibility: true,
|
|
40
|
+
adaptiveHeight: true,
|
|
41
|
+
arrows: true,
|
|
42
|
+
draggable: true,
|
|
43
|
+
dots: true,
|
|
44
|
+
infinite: true,
|
|
45
|
+
speed: scrollSeconds * 1000 || 500, // speed = animation speed in milliseconds
|
|
46
|
+
slidesToShow: 1,
|
|
47
|
+
slidesToScroll: 1,
|
|
48
|
+
swipeToSlide: true,
|
|
49
|
+
};
|
|
50
|
+
}, [stillSeconds, scrollSeconds, settings]);
|
|
51
|
+
return (
|
|
52
|
+
<StyledDiv
|
|
53
|
+
dotsBottomPixel={dotsBottomPixel}
|
|
54
|
+
data-testid={additionalProps?.testid ?? 'scrolling-carousal-test-id'}
|
|
55
|
+
>
|
|
56
|
+
<Slider {...defaultSettings}>{slides.map(renderSlide)}</Slider>
|
|
57
|
+
</StyledDiv>
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
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';
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NsScrollingText.stories.tsx
|
|
3
|
+
* @description NsScrollingText component.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { StoryObj, Meta } from '@storybook/react';
|
|
7
|
+
import { withCenterDecorator } from '@/stories/decorators/withCenterDecorator';
|
|
8
|
+
import { NsScrollingCarousal, NsTextStrip } from '@/common/';
|
|
9
|
+
|
|
10
|
+
type ComponentType = typeof NsScrollingCarousal;
|
|
11
|
+
type Story = StoryObj<ComponentType>;
|
|
12
|
+
type MetaStory = Meta<ComponentType>;
|
|
13
|
+
|
|
14
|
+
export const renderSlide = (slide: any, i: number) => <NsTextStrip key={i} {...slide} />;
|
|
15
|
+
|
|
16
|
+
export const slides = [
|
|
17
|
+
{
|
|
18
|
+
text: 'Hello Nike App',
|
|
19
|
+
description: 'Download the app to access everything Nike',
|
|
20
|
+
link: { href: 'https://www.nike.com/in/help/a/shipping-delivery-gs', title: 'Get Your Great' },
|
|
21
|
+
alignment: 'center',
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
text: 'New Styles on Sale: Up to 40% Off',
|
|
25
|
+
// description: 'Download the app to access everything Nike',
|
|
26
|
+
link: { href: 'https://www.nike.com/in/help/a/shipping-delivery-gs', title: 'Shop All Our New Markdowns' },
|
|
27
|
+
alignment: 'center',
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
text: 'Free Delivery',
|
|
31
|
+
// description: 'Applies to orders of ₹ 14 000.00 or more. ',
|
|
32
|
+
// link: { href: 'https://www.nike.com/in/help/a/shipping-delivery-gs', title: 'View Details' },
|
|
33
|
+
alignment: 'center',
|
|
34
|
+
},
|
|
35
|
+
];
|
|
36
|
+
export default {
|
|
37
|
+
title: 'Components/NsCarousal/NsScrollingCarousal',
|
|
38
|
+
component: NsScrollingCarousal,
|
|
39
|
+
decorators: [withCenterDecorator],
|
|
40
|
+
argTypes: {},
|
|
41
|
+
args: {
|
|
42
|
+
slides,
|
|
43
|
+
renderSlide,
|
|
44
|
+
stillSeconds: 3,
|
|
45
|
+
scrollSeconds: 1,
|
|
46
|
+
additionalProps: {
|
|
47
|
+
testid: 'scrolling-carousal',
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
} as MetaStory;
|
|
51
|
+
|
|
52
|
+
export const ScrollingText: Story = {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { render, screen, fireEvent } from '
|
|
2
|
-
import NsCarousal from '
|
|
1
|
+
import { render, screen, fireEvent } from '@/test-utils/index';
|
|
2
|
+
import { NsCarousal } from '@/common/';
|
|
3
3
|
|
|
4
4
|
const mockEntries = [
|
|
5
5
|
{ id: 1, title: 'First entry' },
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { render, screen, fireEvent } from '@/test-utils/index';
|
|
2
|
+
import { NsScrollingCarousal } from '@/common/';
|
|
3
|
+
|
|
4
|
+
const mockEntries = [
|
|
5
|
+
{ id: 1, title: 'First entry' },
|
|
6
|
+
{ id: 2, title: 'Second entry' },
|
|
7
|
+
{ id: 3, title: 'Third entry' },
|
|
8
|
+
{ id: 4, title: 'Fourth entry' },
|
|
9
|
+
{ id: 5, title: 'Fifth entry' },
|
|
10
|
+
];
|
|
11
|
+
|
|
12
|
+
const mockRenderEntry = (entry: any, index: number) => {
|
|
13
|
+
return <div key={index}>{entry.title}</div>;
|
|
14
|
+
};
|
|
15
|
+
const mockSettings = {
|
|
16
|
+
slidesToShow: 2,
|
|
17
|
+
slidesToScroll: 1,
|
|
18
|
+
};
|
|
19
|
+
const testId = 'scrolling-carousal';
|
|
20
|
+
describe('NsScrollingCarousal', () => {
|
|
21
|
+
it('should have slides', () => {
|
|
22
|
+
render(
|
|
23
|
+
<NsScrollingCarousal
|
|
24
|
+
slides={mockEntries}
|
|
25
|
+
renderSlide={mockRenderEntry}
|
|
26
|
+
settings={mockSettings}
|
|
27
|
+
scrollSeconds={1}
|
|
28
|
+
stillSeconds={9}
|
|
29
|
+
additionalProps={{
|
|
30
|
+
testid: testId,
|
|
31
|
+
}}
|
|
32
|
+
/>
|
|
33
|
+
);
|
|
34
|
+
const el = screen.getAllByText(mockEntries[0].title);
|
|
35
|
+
expect(el).toHaveLength(2);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('should change slides when clicking on prev or next buttons', () => {
|
|
39
|
+
const { container } = render(
|
|
40
|
+
<NsScrollingCarousal
|
|
41
|
+
slides={mockEntries}
|
|
42
|
+
renderSlide={mockRenderEntry}
|
|
43
|
+
settings={mockSettings}
|
|
44
|
+
scrollSeconds={1}
|
|
45
|
+
stillSeconds={9}
|
|
46
|
+
/>
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
let currentSlide = container.querySelector('.slick-slide.slick-current');
|
|
50
|
+
expect(currentSlide!.attributes['data-index' as any].value).toEqual('0');
|
|
51
|
+
|
|
52
|
+
/* this is library's button, not our button, it is used for changing slides,
|
|
53
|
+
clicking svg is not making any slide change in this test */
|
|
54
|
+
const nextButton = screen.getByRole('button', { name: /next/i });
|
|
55
|
+
fireEvent.click(nextButton);
|
|
56
|
+
|
|
57
|
+
let slickTrack = container.querySelector('.slick-track');
|
|
58
|
+
currentSlide = slickTrack!.querySelector('.slick-slide.slick-current');
|
|
59
|
+
expect(currentSlide!.attributes['data-index' as any].value).toEqual('1');
|
|
60
|
+
});
|
|
61
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { AdditionalProps } from '../common.types';
|
|
3
|
+
|
|
4
|
+
export type NsCarousalProps<T = any> = {
|
|
5
|
+
entries: T[];
|
|
6
|
+
// eslint-disable-next-line no-unused-vars
|
|
7
|
+
renderEntry(entry: T, index: number): ReactNode;
|
|
8
|
+
allEntryLink: string;
|
|
9
|
+
settings: any;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export type NsScrollingCarousalProps<T = any> = {
|
|
13
|
+
slides: T;
|
|
14
|
+
// eslint-disable-next-line no-unused-vars
|
|
15
|
+
renderSlide(slide: T, index: number): ReactNode;
|
|
16
|
+
/* time it takes while scrolling */
|
|
17
|
+
scrollSeconds: number;
|
|
18
|
+
/* time for which slide stays still before scrolling */
|
|
19
|
+
stillSeconds: number;
|
|
20
|
+
settings: any;
|
|
21
|
+
/* value in number, specifying how much the dots should be from bottom of slides container */
|
|
22
|
+
dotsBottomPixel?: number;
|
|
23
|
+
} & AdditionalProps;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { StoryObj, Meta } from '@storybook/react';
|
|
2
|
-
import { withCenterDecorator } from '
|
|
2
|
+
import { withCenterDecorator } from '@/stories/decorators/withCenterDecorator';
|
|
3
3
|
import { NsCartIcon } from './';
|
|
4
4
|
|
|
5
5
|
type ComponentType = typeof NsCartIcon;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NsIcon } from '../icon';
|
|
2
2
|
import { CartIconContainer, ItemCount } from './NsCartIcon.styled';
|
|
3
|
-
import { NsCartIconProps } from './types';
|
|
3
|
+
import { NsCartIconProps } from './types.d';
|
|
4
4
|
|
|
5
5
|
const NsCartIcon = ({ itemCount, size = 'large', color = 'primary' }: NsCartIconProps) => {
|
|
6
6
|
return (
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { default as NsCartIcon } from './NsCartIcon';
|
|
2
|
-
export type { NsCartIconProps } from './types';
|
|
2
|
+
export type { NsCartIconProps } from './types.d';
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
import React from 'react';
|
|
8
8
|
|
|
9
|
-
import { render, fireEvent, noop } from '
|
|
9
|
+
import { render, fireEvent, noop } from '@/test-utils/index';
|
|
10
10
|
import NsCheckbox from './NsCheckbox';
|
|
11
11
|
|
|
12
12
|
// Test suite for CustomCheckbox
|
|
@@ -54,4 +54,4 @@ describe('CustomCheckbox', () => {
|
|
|
54
54
|
// Assert that the handleChange function has been called
|
|
55
55
|
expect(handleChange).toHaveBeenCalled();
|
|
56
56
|
});
|
|
57
|
-
});
|
|
57
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
2
|
import { within } from '@testing-library/react';
|
|
3
|
-
import { withCenterDecorator } from '
|
|
3
|
+
import { withCenterDecorator } from '@/stories/decorators/withCenterDecorator';
|
|
4
4
|
import type { StoryObj, Meta } from '@storybook/react';
|
|
5
5
|
import { expect } from '@storybook/jest';
|
|
6
6
|
|
|
@@ -9,7 +9,7 @@ import FormControlLabel from '@mui/material/FormControlLabel';
|
|
|
9
9
|
import { default as MUICheckbox } from '@mui/material/Checkbox';
|
|
10
10
|
|
|
11
11
|
import { BpCheckedIcon, BpIcon, StyledLabel, StyledFlagLabel } from './NsCheckbox.styled';
|
|
12
|
-
import { NsCheckboxProps } from './types';
|
|
12
|
+
import { NsCheckboxProps } from './types.d';
|
|
13
13
|
|
|
14
14
|
import { NsTypography } from '../';
|
|
15
15
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { default as NsCheckbox } from './NsCheckbox';
|
|
2
|
-
export type { NsCheckboxProps } from './types';
|
|
2
|
+
export type { NsCheckboxProps } from './types.d';
|
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @author [vijayaprathap Kumar] (vpkumar@nuskin.com)
|
|
3
|
-
* types.d.ts
|
|
4
|
-
* @description NsCheckbox Props extending Mui CheckboxProps interface.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
1
|
import { CheckboxProps as MUICheckboxProps } from '@material-ui/core/Checkbox';
|
|
8
2
|
|
|
9
3
|
import { NsFlagProps } from '../flag';
|
|
10
4
|
|
|
11
5
|
// Define the props for the custom checkbox component
|
|
12
|
-
export type NsCheckboxProps = Pick<MUICheckboxProps, 'label' | 'onChange'
|
|
6
|
+
export type NsCheckboxProps = Partial<Pick<MUICheckboxProps, 'label' | 'onChange'>> & {
|
|
13
7
|
name: string;
|
|
14
8
|
className?: string;
|
|
15
9
|
checked: boolean;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
2
|
import { Box } from '@mui/material';
|
|
3
3
|
import { styled } from '@nuskin/foundation-theme';
|
|
4
|
-
import { NsColumnControlProps, sizeObjectType } from './types';
|
|
4
|
+
import { NsColumnControlProps, sizeObjectType } from './types.d';
|
|
5
5
|
import { getColumnSizes } from './utils';
|
|
6
6
|
|
|
7
7
|
const options = {
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { getColumnSizes } from './utils';
|
|
3
|
+
import { StyledFlex } from './styled/StyledFlex';
|
|
4
|
+
import { NsFlexColumnsProps } from './types';
|
|
5
|
+
|
|
6
|
+
const NsFlexColumns = ({ columnClass, children, gap, additionalProps, isFullWidth }: NsFlexColumnsProps) => {
|
|
7
|
+
const sizes = useMemo(() => {
|
|
8
|
+
return getColumnSizes(columnClass ?? 'ns-col-lg-1-1');
|
|
9
|
+
}, [columnClass]);
|
|
10
|
+
return (
|
|
11
|
+
<StyledFlex
|
|
12
|
+
isFullWidth={isFullWidth || false}
|
|
13
|
+
gap={gap}
|
|
14
|
+
sizes={sizes}
|
|
15
|
+
className="ns-flex-columns"
|
|
16
|
+
data-testid={additionalProps?.testid ?? 'ns-flex-columns'}
|
|
17
|
+
>
|
|
18
|
+
{children}
|
|
19
|
+
</StyledFlex>
|
|
20
|
+
);
|
|
21
|
+
};
|
|
22
|
+
export default NsFlexColumns;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { getColumnSizes } from './utils';
|
|
3
|
+
import { StyledGrid } from './styled/StyledGrid';
|
|
4
|
+
import { NsGridColumnsProps } from './types';
|
|
5
|
+
|
|
6
|
+
const NsGridColumns = ({ columnClass, children, gap, isFullWidth, additionalProps }: NsGridColumnsProps) => {
|
|
7
|
+
const sizes = useMemo(() => {
|
|
8
|
+
return getColumnSizes(columnClass ?? 'ns-col-lg-1-1');
|
|
9
|
+
}, [columnClass]);
|
|
10
|
+
return (
|
|
11
|
+
<StyledGrid
|
|
12
|
+
isFullWidth={isFullWidth || false}
|
|
13
|
+
gap={gap}
|
|
14
|
+
sizes={sizes}
|
|
15
|
+
className="ns-grid-columns"
|
|
16
|
+
data-testid={additionalProps?.testid ?? 'ns-grid-columns'}
|
|
17
|
+
>
|
|
18
|
+
{children}
|
|
19
|
+
</StyledGrid>
|
|
20
|
+
);
|
|
21
|
+
};
|
|
22
|
+
export default NsGridColumns;
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
export { default as NsColumnControl } from './NsColumnControl';
|
|
2
|
-
export
|
|
2
|
+
export { default as NsFlexColumns } from './NsFlexColumns';
|
|
3
|
+
export { default as NsGridColumns } from './NsGridColumns';
|
|
4
|
+
export type { NsColumnControlProps } from './types.d';
|
package/src/common/column-control/{NsColumnControl.spec.tsx → specs/NsColumnControl.spec.tsx}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { DivArray } from '
|
|
1
|
+
import { NsColumnControl } from '@/common/index';
|
|
2
|
+
import { render, screen } from '@/test-utils/index';
|
|
3
|
+
import { DivArray } from '../stories/DivArray';
|
|
4
4
|
|
|
5
5
|
describe('NsColumnControl component', () => {
|
|
6
6
|
it('renders an column with proper grid value for tablet', () => {
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { render, screen } from '../../../../test-utils';
|
|
2
|
+
import { NsFlexColumns } from '@/common/index';
|
|
3
|
+
import { DivArray } from '../stories/DivArray';
|
|
4
|
+
|
|
5
|
+
describe('NsFlexColumns component', () => {
|
|
6
|
+
it('renders an column with proper grid value for tablet', () => {
|
|
7
|
+
render(
|
|
8
|
+
<NsFlexColumns columnClass="ns-col-lg-1-1-1" gap={16}>
|
|
9
|
+
<DivArray elementsCount={4} />
|
|
10
|
+
</NsFlexColumns>
|
|
11
|
+
);
|
|
12
|
+
const element = screen.getByTestId('ns-flex-columns');
|
|
13
|
+
expect(element).toBeInTheDocument();
|
|
14
|
+
});
|
|
15
|
+
it('renders an column with proper grid value', () => {
|
|
16
|
+
console.warn = jest.fn();
|
|
17
|
+
render(
|
|
18
|
+
<NsFlexColumns columnClass="" gap={16}>
|
|
19
|
+
<DivArray elementsCount={4} />
|
|
20
|
+
</NsFlexColumns>
|
|
21
|
+
);
|
|
22
|
+
expect(console.warn).toHaveBeenCalledWith(expect.stringContaining('Received invalid className'));
|
|
23
|
+
});
|
|
24
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { render, screen } from '../../../../test-utils';
|
|
2
|
+
import { NsGridColumns } from '@/common/index';
|
|
3
|
+
import { DivArray } from '../stories/DivArray';
|
|
4
|
+
|
|
5
|
+
describe('NsGridColumns component', () => {
|
|
6
|
+
it('renders an column with proper grid value for tablet', () => {
|
|
7
|
+
render(
|
|
8
|
+
<NsGridColumns columnClass="ns-col-lg-1-1-1" gap={16}>
|
|
9
|
+
<DivArray elementsCount={4} />
|
|
10
|
+
</NsGridColumns>
|
|
11
|
+
);
|
|
12
|
+
const element = screen.getByTestId('ns-grid-columns');
|
|
13
|
+
expect(element).toBeInTheDocument();
|
|
14
|
+
});
|
|
15
|
+
it('renders an column with proper grid value', () => {
|
|
16
|
+
console.warn = jest.fn();
|
|
17
|
+
render(
|
|
18
|
+
<NsGridColumns columnClass="" gap={16}>
|
|
19
|
+
<DivArray elementsCount={4} />
|
|
20
|
+
</NsGridColumns>
|
|
21
|
+
);
|
|
22
|
+
expect(console.warn).toHaveBeenCalledWith(expect.stringContaining('Received invalid className'));
|
|
23
|
+
});
|
|
24
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { StoryObj, Meta } from '@storybook/react';
|
|
2
|
+
import { withCenterDecorator } from '@/stories/decorators/withCenterDecorator';
|
|
3
|
+
import {DivArray} from './DivArray';
|
|
4
|
+
|
|
5
|
+
type ComponentType = typeof DivArray;
|
|
6
|
+
type Story = StoryObj<ComponentType>;
|
|
7
|
+
type MetaStory = Meta<ComponentType>;
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
title: 'Components/Column/NDivs',
|
|
11
|
+
component: DivArray,
|
|
12
|
+
decorators: [withCenterDecorator],
|
|
13
|
+
args: {
|
|
14
|
+
elementsCount: 2,
|
|
15
|
+
},
|
|
16
|
+
} as MetaStory;
|
|
17
|
+
|
|
18
|
+
export const Basic: Story = {};
|