@nuskin/foundation-ui-components 1.0.0-develop.6 → 1.0.0-develop.7
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 +17 -12
- package/src/common/accordion/NsAccordion.tsx +29 -39
- package/src/common/accordion/NsAccordionHeader.tsx +32 -17
- package/src/common/accordion/NsAccordionItem.tsx +16 -4
- package/src/common/accordion/NsCollapse.tsx +73 -35
- package/src/common/accordion/NsToggleSection.tsx +14 -3
- package/src/common/accordion/ToggleSection.styled.tsx +8 -7
- package/src/common/accordion/colorMap.ts +117 -0
- package/src/common/accordion/enums.ts +15 -0
- package/src/common/accordion/index.ts +1 -0
- package/src/common/accordion/specs/NsAccordion.spec.tsx +100 -31
- package/src/common/accordion/specs/NsAccordionHeader.spec.tsx +77 -10
- package/src/common/accordion/specs/NsAccordionItem.spec.tsx +23 -10
- package/src/common/accordion/specs/NsCollapse.spec.tsx +106 -17
- package/src/common/accordion/specs/NsToggleSection.spec.tsx +46 -14
- package/src/common/accordion/stories/NsAccordion.stories.tsx +27 -14
- package/src/common/accordion/stories/NsAccordionHeader.stories.tsx +4 -1
- package/src/common/accordion/stories/NsAccordionItem.stories.tsx +3 -3
- package/src/common/accordion/stories/NsCollapse.stories.tsx +3 -3
- package/src/common/accordion/stories/NsToggleSection.stories.tsx +2 -3
- package/src/common/accordion/stories/data.tsx +157 -19
- package/src/common/accordion/types.d.ts +56 -49
- package/src/common/alert/Header.tsx +29 -0
- package/src/common/alert/NsAlert.spec.tsx +46 -13
- package/src/common/alert/NsAlert.stories.tsx +3 -3
- package/src/common/alert/{NsAlert.styled.ts → NsAlert.styled.tsx} +22 -22
- package/src/common/alert/NsAlert.tsx +22 -87
- package/src/common/alert/types.d.ts +7 -7
- package/src/common/auth-dropdown/NsAuthDropdown.spec.tsx +23 -5
- package/src/common/auth-dropdown/NsAuthDropdown.stories.tsx +1 -1
- package/src/common/auth-dropdown/NsAuthDropdown.styled.ts +11 -7
- package/src/common/auth-dropdown/NsAuthDropdown.tsx +4 -4
- package/src/common/autocomplete/NsAutocomplete.spec.tsx +29 -6
- package/src/common/autocomplete/NsAutocomplete.stories.tsx +1 -1
- package/src/common/autocomplete/NsAutocomplete.tsx +18 -8
- package/src/common/autocomplete/mock/MockUI.tsx +1 -0
- package/src/common/banner/NsBanner.spec.tsx +12 -3
- package/src/common/banner/NsBanner.stories.tsx +1 -1
- package/src/common/brand-components/NsBrand.stories.tsx +1 -1
- package/src/common/brand-components/NsBrandComponent.tsx +2 -2
- package/src/common/breadcrumb/NsBreadcrumb.spec.tsx +8 -3
- package/src/common/breadcrumb/NsBreadcrumb.stories.tsx +1 -1
- package/src/common/breadcrumb/data.ts +8 -5
- package/src/common/button/NsButton.spec.tsx +65 -49
- package/src/common/button/NsButton.stories.tsx +59 -2
- package/src/common/button/NsButton.styled.tsx +49 -66
- package/src/common/button/NsButton.tsx +1 -2
- package/src/common/button/helper.ts +82 -0
- package/src/common/button/types.d.ts +2 -0
- package/src/common/card/stories/NsBgCard.stories.tsx +1 -1
- package/src/common/card/stories/NsBrandProductCard.stories.tsx +1 -1
- package/src/common/card/stories/NsFfgCard.stories.tsx +5 -2
- package/src/common/card/styled/NsFfgStyled.tsx +1 -1
- package/src/common/carousal/stories/NSCarousal.stories.tsx +1 -1
- package/src/common/carousal/stories/NsScrollingCarousal.stories.tsx +1 -1
- package/src/common/cart-icon/NsCartIcon.stories.tsx +1 -1
- package/src/common/checkbox/NsCheckbox.stories.tsx +1 -1
- package/src/common/checkbox/NsCheckbox.styled.tsx +15 -16
- package/src/common/checkbox/NsCheckbox.tsx +1 -1
- package/src/common/column-control/stories/DivArray.stories.tsx +1 -1
- package/src/common/column-control/stories/NsColumnControl.stories.tsx +1 -1
- package/src/common/column-control/stories/NsFlexColumns.stories.tsx +1 -1
- package/src/common/column-control/stories/NsGridColumns.stories.tsx +1 -1
- package/src/common/column-control/styled/common.ts +1 -1
- package/src/common/column-control/utils.ts +4 -4
- package/src/common/common.types.d.ts +11 -1
- package/src/common/dropdown/NsDropdown.styled.tsx +23 -18
- 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.stories.tsx +1 -1
- package/src/common/hooks/index.ts +2 -0
- package/src/common/hooks/specs/useWindowSize.spec.tsx +19 -0
- package/src/common/hooks/useAccordionMap.tsx +39 -0
- package/src/common/hooks/useWindowSize.tsx +30 -0
- package/src/common/icon/NsIcon.stories.tsx +1 -1
- package/src/common/icon/NsIconVariants.ts +1 -0
- package/src/common/image/NsImage.spec.tsx +56 -6
- package/src/common/image/NsImage.stories.tsx +1 -1
- package/src/common/image/NsImage.tsx +23 -11
- package/src/common/image/NsNextImage.stories.tsx +1 -1
- package/src/common/index.ts +2 -0
- package/src/common/input/InputWrapper.tsx +12 -7
- package/src/common/input/NsInputField.tsx +1 -1
- package/src/common/label/NsLabel.stories.tsx +1 -1
- package/src/common/link/NsLink.stories.tsx +1 -1
- package/src/common/nav-product-card/NsNavProductCard.stories.tsx +1 -1
- package/src/common/nav-tab/NsNavTab.stories.tsx +1 -1
- package/src/common/radiogroup/NsRadioGroup.spec.tsx +24 -25
- package/src/common/radiogroup/NsRadioGroup.stories.tsx +14 -32
- package/src/common/radiogroup/NsRadioGroup.styled.tsx +17 -15
- package/src/common/radiogroup/NsRadioGroup.tsx +6 -5
- package/src/common/search-bar/NsSearchBar.tsx +1 -3
- package/src/common/select/NsSelect.spec.tsx +10 -17
- package/src/common/select/NsSelect.styled.tsx +53 -34
- package/src/common/select/stories/NsSelect.stories.tsx +11 -11
- package/src/common/select/types.d.ts +3 -3
- package/src/common/spinner/NsSpinner.spec.tsx +21 -0
- package/src/common/spinner/NsSpinner.stories.tsx +26 -0
- package/src/common/spinner/NsSpinner.styled.tsx +344 -0
- package/src/common/spinner/NsSpinner.tsx +14 -0
- package/src/common/spinner/icons/Spinner.tsx +161 -0
- package/src/common/spinner/index.ts +2 -0
- package/src/common/spinner/types.ts +5 -0
- package/src/common/table/NsTable.stories.tsx +1 -1
- package/src/common/table/NsTable.tsx +32 -49
- package/src/common/table/NsTableHeader.tsx +30 -51
- package/src/common/text-strip/NsTextStrip.stories.tsx +1 -1
- package/src/common/typography/NsTypography.stories.tsx +1 -1
- package/src/common/util.ts +1 -0
- package/src/common/videos/NsVideo.stories.tsx +1 -1
- package/src/common/videos/types.d.ts +1 -1
- /package/src/common/brand-components/{NsBrandContanier.styled.tsx → NsBrandContainer.styled.tsx} +0 -0
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {ItemProps} from './types';
|
|
2
2
|
export const breadcrumbItems: ItemProps[] = [
|
|
3
|
-
{
|
|
4
|
-
{
|
|
5
|
-
{
|
|
6
|
-
{
|
|
3
|
+
{label: 'Home', href: '/', icon: 'home'},
|
|
4
|
+
{label: 'Products', href: '/products'},
|
|
5
|
+
{label: 'Shirts', href: '/products/shirts'},
|
|
6
|
+
{label: 'Blue shirt', href: '/products/shirts/blue'},
|
|
7
7
|
];
|
|
8
|
+
export const dummyItems: ItemProps[] = [
|
|
9
|
+
{label: 'Home', icon: 'home'}
|
|
10
|
+
]
|
|
@@ -1,68 +1,84 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { render, screen } from '@/test-utils/index';
|
|
3
|
+
import { NsButton } from '../';
|
|
3
4
|
import { nuskinTheme } from '@nuskin/foundation-theme';
|
|
4
|
-
import Button from './NsButton';
|
|
5
5
|
|
|
6
6
|
const { palette } = nuskinTheme;
|
|
7
7
|
|
|
8
8
|
describe('<Button />', () => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
);
|
|
9
|
+
it('1. should render default primary button styles ', () => {
|
|
10
|
+
const text = 'Click Me';
|
|
11
|
+
render(
|
|
12
|
+
<NsButton color="primary" variant="contained">
|
|
13
|
+
{text}
|
|
14
|
+
</NsButton>
|
|
15
|
+
);
|
|
17
16
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
});
|
|
17
|
+
const button = screen.getByText(text);
|
|
18
|
+
expect(button).toBeInTheDocument();
|
|
19
|
+
expect(button).toHaveStyle(`color: ${palette?.primary?.contrastText}`);
|
|
20
|
+
expect(button).toHaveStyle(`background-color: ${palette?.primary?.buttonState?.pressed}`);
|
|
23
21
|
});
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
);
|
|
22
|
+
it('2. should render default secondary button styles', () => {
|
|
23
|
+
const text = 'Click Me';
|
|
24
|
+
render(
|
|
25
|
+
<NsButton color="success" variant="contained" size="large">
|
|
26
|
+
{text}
|
|
27
|
+
</NsButton>
|
|
28
|
+
);
|
|
32
29
|
|
|
33
|
-
|
|
30
|
+
const button = screen.getByText(text);
|
|
34
31
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
});
|
|
32
|
+
expect(button).toBeInTheDocument();
|
|
33
|
+
expect(button).toHaveStyle(`color: ${palette.success.contrastText}`);
|
|
34
|
+
expect(button).toHaveStyle(`background-color: ${palette.success.buttonState?.pressed}`);
|
|
39
35
|
});
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
);
|
|
36
|
+
it('3. should render outlined success button', () => {
|
|
37
|
+
render(
|
|
38
|
+
<NsButton color="success" variant="outlined" size="large">
|
|
39
|
+
Click Me
|
|
40
|
+
</NsButton>
|
|
41
|
+
);
|
|
47
42
|
|
|
48
|
-
|
|
43
|
+
const button = screen.getByText('Click Me');
|
|
44
|
+
expect(button).toBeInTheDocument();
|
|
45
|
+
expect(button).toHaveStyle(`color: ${palette.success.main}`);
|
|
46
|
+
});
|
|
47
|
+
it('4. should render outlined accentColorA button', () => {
|
|
48
|
+
render(
|
|
49
|
+
<NsButton color="accentColorA" variant="outlined" size="large">
|
|
50
|
+
Click Me
|
|
51
|
+
</NsButton>
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
const button = screen.getByText('Click Me');
|
|
55
|
+
expect(button).toBeInTheDocument();
|
|
56
|
+
expect(button).toHaveStyle(`color: ${palette?.accentColorA?.main}`);
|
|
57
|
+
});
|
|
58
|
+
it('5. should render text button styles', () => {
|
|
59
|
+
const text = 'Click Me';
|
|
60
|
+
render(
|
|
61
|
+
<NsButton color="success" variant="text" size="large">
|
|
62
|
+
{text}
|
|
63
|
+
</NsButton>
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
const button = screen.getByText(text);
|
|
49
67
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
});
|
|
68
|
+
expect(button).toBeInTheDocument();
|
|
69
|
+
expect(button).toHaveStyle(`color: ${palette.success.main}`);
|
|
53
70
|
});
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
71
|
+
it('6. iconOnly variant', () => {
|
|
72
|
+
const text = 'Click Me';
|
|
73
|
+
render(
|
|
74
|
+
<NsButton color="success" variant="text" size="large" iconOnly>
|
|
75
|
+
{text}
|
|
76
|
+
</NsButton>
|
|
77
|
+
);
|
|
61
78
|
|
|
62
|
-
|
|
79
|
+
const button = screen.getByText(text);
|
|
63
80
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
});
|
|
81
|
+
expect(button).toBeInTheDocument();
|
|
82
|
+
expect(button).toHaveStyle(`color: ${palette.success.main}`);
|
|
67
83
|
});
|
|
68
84
|
});
|
|
@@ -3,13 +3,18 @@ import type { StoryObj, Meta } from '@storybook/react';
|
|
|
3
3
|
import { NsButton } from './';
|
|
4
4
|
import { ShoppingCart } from '@mui/icons-material';
|
|
5
5
|
import { withCenterDecorator } from '@/stories/decorators/withCenterDecorator';
|
|
6
|
+
import { within } from '@storybook/testing-library';
|
|
7
|
+
import { expect } from '@storybook/jest';
|
|
8
|
+
import { nuskinTheme } from '@nuskin/foundation-theme';
|
|
9
|
+
|
|
10
|
+
const { palette } = nuskinTheme;
|
|
6
11
|
|
|
7
12
|
type ComponentType = typeof NsButton;
|
|
8
13
|
type Story = StoryObj<ComponentType>;
|
|
9
14
|
type MetaStory = Meta<ComponentType>;
|
|
10
15
|
|
|
11
16
|
export default {
|
|
12
|
-
title: 'Components/NsButton',
|
|
17
|
+
title: 'Components/Inputs/NsButton',
|
|
13
18
|
component: NsButton,
|
|
14
19
|
decorators: [withCenterDecorator],
|
|
15
20
|
argTypes: {
|
|
@@ -21,6 +26,7 @@ export default {
|
|
|
21
26
|
color: { name: 'Color Variants' },
|
|
22
27
|
disabled: { control: 'boolean' },
|
|
23
28
|
fullWidth: { control: 'boolean' },
|
|
29
|
+
|
|
24
30
|
iconOnly: { control: 'hide' },
|
|
25
31
|
},
|
|
26
32
|
args: {
|
|
@@ -30,13 +36,15 @@ export default {
|
|
|
30
36
|
disabled: false,
|
|
31
37
|
variant: 'contained',
|
|
32
38
|
fullWidth: false,
|
|
39
|
+
startIcon: '',
|
|
40
|
+
endIcon: '',
|
|
33
41
|
},
|
|
34
42
|
} as MetaStory;
|
|
35
43
|
|
|
36
44
|
export const button: Story = {};
|
|
37
45
|
|
|
38
46
|
export const IconOnlyButton: Story = {
|
|
39
|
-
render: (args) => (
|
|
47
|
+
render: (args: any) => (
|
|
40
48
|
<NsButton {...args} iconOnly darkModeEnabled={false}>
|
|
41
49
|
<ShoppingCart />
|
|
42
50
|
</NsButton>
|
|
@@ -53,3 +61,52 @@ export const IconOnlyButton: Story = {
|
|
|
53
61
|
iconOnly: { control: 'hide' },
|
|
54
62
|
},
|
|
55
63
|
};
|
|
64
|
+
export const ButtonWithIcon: Story = {
|
|
65
|
+
render: (args: any) => (
|
|
66
|
+
<NsButton {...args} darkModeEnabled={false} startIcon={<ShoppingCart />}>
|
|
67
|
+
Add to Cart
|
|
68
|
+
</NsButton>
|
|
69
|
+
),
|
|
70
|
+
argTypes: {
|
|
71
|
+
children: {
|
|
72
|
+
control: 'hide',
|
|
73
|
+
},
|
|
74
|
+
color: { name: 'Color Variants' },
|
|
75
|
+
disabled: { control: 'boolean' },
|
|
76
|
+
fullWidth: { control: 'boolean' },
|
|
77
|
+
iconOnly: { control: 'hide' },
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export const TextVariant: Story = {
|
|
82
|
+
args: {
|
|
83
|
+
color: 'success',
|
|
84
|
+
variant: 'text',
|
|
85
|
+
size: 'large',
|
|
86
|
+
children: 'click me! icon',
|
|
87
|
+
},
|
|
88
|
+
play: ({ canvasElement }) => {
|
|
89
|
+
const canvas = within(canvasElement);
|
|
90
|
+
const button = canvas.getByText('click me! icon');
|
|
91
|
+
expect(button).toBeInTheDocument();
|
|
92
|
+
expect(button).toHaveStyle(`color: ${palette.success.main}`);
|
|
93
|
+
expect(button).toHaveStyle('background-color: rgba(0, 0, 0, 0);');
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export const IconOnly: Story = {
|
|
98
|
+
args: {
|
|
99
|
+
iconOnly: true,
|
|
100
|
+
color: 'success',
|
|
101
|
+
variant: 'text',
|
|
102
|
+
size: 'large',
|
|
103
|
+
children: 'click me! icon',
|
|
104
|
+
},
|
|
105
|
+
play: ({ canvasElement }) => {
|
|
106
|
+
const canvas = within(canvasElement);
|
|
107
|
+
const button = canvas.getByText('click me! icon');
|
|
108
|
+
expect(button).toBeInTheDocument();
|
|
109
|
+
expect(button).toHaveStyle(`color: ${palette.success.main}`);
|
|
110
|
+
expect(button).toHaveStyle('background-color: rgba(0, 0, 0, 0);');
|
|
111
|
+
},
|
|
112
|
+
};
|
|
@@ -4,6 +4,8 @@ import { styled, ColorUtils, FoundationTheme } from '@nuskin/foundation-theme';
|
|
|
4
4
|
import { ButtonConfig } from '@nuskin/foundation-theme/src/common/themes/types/button';
|
|
5
5
|
|
|
6
6
|
import { NsButtonProps } from './types.d';
|
|
7
|
+
import { generateContainedStyle, generateIconOnlyStyles, generateOutlinedStyle, generateTextStyles } from './helper';
|
|
8
|
+
import { skipDarkModeEnabled } from '../util';
|
|
7
9
|
|
|
8
10
|
const { buttonColor, paletteColor } = ColorUtils;
|
|
9
11
|
|
|
@@ -11,79 +13,60 @@ const getButtonConfig = (theme: FoundationTheme.Theme, attribute: keyof ButtonCo
|
|
|
11
13
|
const { config } = theme || {};
|
|
12
14
|
return config?.components?.button?.[attribute] || '';
|
|
13
15
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
const options = {
|
|
17
|
+
shouldForwardProp: skipDarkModeEnabled,
|
|
18
|
+
};
|
|
19
|
+
const StyledButton = styled(MUIButton, options)<NsButtonProps>`
|
|
16
20
|
gap: 10px;
|
|
17
|
-
border-radius: ${({ theme }) =>
|
|
18
|
-
|
|
21
|
+
border-radius: ${({ theme }) => {
|
|
22
|
+
const borderRadius = getButtonConfig(theme, 'borderRadius');
|
|
23
|
+
return borderRadius || 0;
|
|
24
|
+
}};
|
|
25
|
+
|
|
26
|
+
&:focus {
|
|
19
27
|
border: 1px solid ${({ theme }) => getButtonConfig(theme, 'focusColor')} !important;
|
|
20
28
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
color: ${(
|
|
29
|
+
|
|
30
|
+
&:disabled {
|
|
31
|
+
background-color: ${({ color }) => buttonColor(color, 'disabled')};
|
|
32
|
+
color: ${({ color }) => buttonColor(color, 'disabledText')};
|
|
24
33
|
}
|
|
34
|
+
|
|
25
35
|
${({ theme: { config }, size }) => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
36
|
+
if (size === 'medium') {
|
|
37
|
+
return config?.components?.button?.size?.medium?.padding;
|
|
38
|
+
} else if (size === 'large') {
|
|
39
|
+
return config?.components?.button?.size?.large?.padding;
|
|
40
|
+
} else {
|
|
41
|
+
return '';
|
|
42
|
+
}
|
|
30
43
|
}}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
|
|
45
|
+
${({ variant, theme, color = 'primary', darkModeEnabled, iconOnly }) => {
|
|
46
|
+
if (variant === 'contained') {
|
|
47
|
+
const hovered = buttonColor(color, 'hovered')({ theme });
|
|
48
|
+
const pressed = buttonColor(color, 'pressed')({ theme });
|
|
49
|
+
const focused = buttonColor(color, 'focused')({ theme });
|
|
50
|
+
const textColor = paletteColor(color, 'contrastText')({ theme, darkModeEnabled });
|
|
51
|
+
const backgroundColor = paletteColor(color)({ theme, darkModeEnabled });
|
|
52
|
+
return generateContainedStyle({ backgroundColor, textColor, hovered, pressed, focused });
|
|
53
|
+
} else if (variant === 'outlined') {
|
|
54
|
+
const borderColor = paletteColor(color)({ theme, darkModeEnabled });
|
|
55
|
+
const activeColor = paletteColor(color)({ theme });
|
|
56
|
+
const hovered = buttonColor(color, 'hovered')({ theme });
|
|
57
|
+
const pressed = buttonColor(color, 'pressed')({ theme });
|
|
58
|
+
return generateOutlinedStyle({ borderColor, hovered, pressed, activeColor });
|
|
59
|
+
} else if (variant === 'text') {
|
|
60
|
+
const underlineColor = paletteColor(color)({ theme, darkModeEnabled });
|
|
61
|
+
const hovered = buttonColor(color, 'hovered')({ theme });
|
|
62
|
+
const pressed = buttonColor(color, 'pressed')({ theme });
|
|
63
|
+
return generateTextStyles({ underlineColor, hovered, pressed });
|
|
64
|
+
} else if (iconOnly) {
|
|
65
|
+
return generateIconOnlyStyles();
|
|
66
|
+
} else {
|
|
67
|
+
return '';
|
|
68
|
+
}
|
|
47
69
|
}}
|
|
48
|
-
${({ variant, theme, color = 'primary', darkModeEnabled }) =>
|
|
49
|
-
variant === 'outlined' &&
|
|
50
|
-
`
|
|
51
|
-
border-color: ${paletteColor(color)({ theme, darkModeEnabled })};
|
|
52
|
-
color: ${paletteColor(color)({ theme, darkModeEnabled })};
|
|
53
|
-
:hover {
|
|
54
|
-
border-color: ${buttonColor(color, 'hovered')({ theme })};
|
|
55
|
-
color: ${paletteColor(color)({ theme, darkModeEnabled })};
|
|
56
|
-
}
|
|
57
|
-
:active {
|
|
58
|
-
border-color: ${buttonColor(color, 'pressed')({ theme })};
|
|
59
|
-
color: ${paletteColor(color)({ theme })};
|
|
60
|
-
}
|
|
61
|
-
`}
|
|
62
|
-
${({ variant, theme, color = 'primary', darkModeEnabled }) =>
|
|
63
|
-
variant === 'text' &&
|
|
64
|
-
`
|
|
65
|
-
text-decoration: underline 1px !important;
|
|
66
|
-
text-underline-offset: 4px;
|
|
67
|
-
padding: 0;
|
|
68
|
-
min-width: auto;
|
|
69
|
-
background-color: transparent !important;
|
|
70
|
-
text-decoration-color: ${paletteColor(color)({ theme, darkModeEnabled })};
|
|
71
|
-
color: ${paletteColor(color)({ theme, darkModeEnabled })};
|
|
72
|
-
:hover {
|
|
73
|
-
color: ${buttonColor(color, 'hovered')({ theme })};
|
|
74
|
-
text-decoration-color: ${buttonColor(color, 'hovered')({ theme })};
|
|
75
|
-
}
|
|
76
|
-
:active {
|
|
77
|
-
color: ${paletteColor(color)};
|
|
78
|
-
text-decoration-color: ${buttonColor(color, 'pressed')({ theme })};
|
|
79
|
-
}
|
|
80
|
-
`}
|
|
81
|
-
${({ iconOnly }) =>
|
|
82
|
-
iconOnly &&
|
|
83
|
-
`
|
|
84
|
-
padding: 10px;
|
|
85
|
-
min-width: unset;
|
|
86
|
-
`}
|
|
87
70
|
`;
|
|
88
71
|
|
|
89
72
|
export default StyledButton;
|
|
@@ -4,12 +4,11 @@ import { useTheme } from '@mui/material/styles';
|
|
|
4
4
|
import StyledButton from './NsButton.styled';
|
|
5
5
|
|
|
6
6
|
import { NsButtonProps } from './types.d';
|
|
7
|
-
import { FoundationTheme } from '@nuskin/foundation-theme';
|
|
8
7
|
|
|
9
8
|
const NsButton = ({ children, darkModeEnabled = true, ...props }: PropsWithChildren<NsButtonProps>) => {
|
|
10
9
|
const { color } = props;
|
|
11
10
|
const { palette } = useTheme();
|
|
12
|
-
const btnColor =
|
|
11
|
+
const btnColor = color && palette?.[color] ? color : 'primary';
|
|
13
12
|
return (
|
|
14
13
|
<StyledButton {...props} color={btnColor} disableRipple darkModeEnabled={darkModeEnabled}>
|
|
15
14
|
{children}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
type ContainedParams = {
|
|
2
|
+
backgroundColor: string;
|
|
3
|
+
textColor: string;
|
|
4
|
+
hovered: string;
|
|
5
|
+
pressed: string;
|
|
6
|
+
focused: string;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export function generateContainedStyle({
|
|
10
|
+
backgroundColor,
|
|
11
|
+
textColor,
|
|
12
|
+
hovered,
|
|
13
|
+
pressed,
|
|
14
|
+
focused,
|
|
15
|
+
}: ContainedParams): string {
|
|
16
|
+
return `
|
|
17
|
+
background-color: ${backgroundColor};
|
|
18
|
+
color: ${textColor} !important;
|
|
19
|
+
&:hover {
|
|
20
|
+
background-color: ${hovered};
|
|
21
|
+
}
|
|
22
|
+
&:active {
|
|
23
|
+
background-color: ${pressed};
|
|
24
|
+
}
|
|
25
|
+
&:focus {
|
|
26
|
+
background-color: ${focused};
|
|
27
|
+
}
|
|
28
|
+
`;
|
|
29
|
+
}
|
|
30
|
+
type OutlinedParams = {
|
|
31
|
+
borderColor: string;
|
|
32
|
+
hovered: string;
|
|
33
|
+
pressed: string;
|
|
34
|
+
activeColor: string;
|
|
35
|
+
};
|
|
36
|
+
export function generateOutlinedStyle({ borderColor, hovered, pressed, activeColor }: OutlinedParams) {
|
|
37
|
+
return `
|
|
38
|
+
border-color: ${borderColor};
|
|
39
|
+
color: ${borderColor};
|
|
40
|
+
&:hover {
|
|
41
|
+
border-color: ${hovered};
|
|
42
|
+
color: ${borderColor};
|
|
43
|
+
}
|
|
44
|
+
&:active {
|
|
45
|
+
border-color: ${pressed};
|
|
46
|
+
color: ${activeColor};
|
|
47
|
+
}
|
|
48
|
+
`;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
type TextParams = {
|
|
52
|
+
underlineColor: string;
|
|
53
|
+
hovered: string;
|
|
54
|
+
pressed: string;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export function generateTextStyles({ underlineColor, hovered, pressed }: TextParams): string {
|
|
58
|
+
return `
|
|
59
|
+
text-decoration: underline 1px !important;
|
|
60
|
+
text-underline-offset: 4px;
|
|
61
|
+
padding: 0;
|
|
62
|
+
min-width: auto;
|
|
63
|
+
background-color: transparent !important;
|
|
64
|
+
text-decoration-color: ${underlineColor};
|
|
65
|
+
color: ${underlineColor};
|
|
66
|
+
&:hover {
|
|
67
|
+
color: ${hovered};
|
|
68
|
+
text-decoration-color: ${hovered};
|
|
69
|
+
}
|
|
70
|
+
&:active {
|
|
71
|
+
color: ${underlineColor};
|
|
72
|
+
text-decoration-color: ${pressed};
|
|
73
|
+
}
|
|
74
|
+
`;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function generateIconOnlyStyles() {
|
|
78
|
+
return `
|
|
79
|
+
padding: 10px;
|
|
80
|
+
min-width: unset;
|
|
81
|
+
`;
|
|
82
|
+
}
|
|
@@ -8,7 +8,7 @@ type MetaStory = Meta<ComponentType>;
|
|
|
8
8
|
|
|
9
9
|
export default {
|
|
10
10
|
component: NsBrandProductCard,
|
|
11
|
-
title: 'Components/
|
|
11
|
+
title: 'Components/Containers/Card/NsBrandProductCard',
|
|
12
12
|
argTypes: {},
|
|
13
13
|
decorators: [withCenterDecorator],
|
|
14
14
|
} as MetaStory;
|
|
@@ -10,7 +10,7 @@ type MetaStory = Meta<ComponentType>;
|
|
|
10
10
|
|
|
11
11
|
export default {
|
|
12
12
|
component: NsFfgCard,
|
|
13
|
-
title: 'Components/
|
|
13
|
+
title: 'Components/Containers/Card/NsFfgCard',
|
|
14
14
|
argTypes: {},
|
|
15
15
|
decorators: [withCenterDecorator],
|
|
16
16
|
} as MetaStory;
|
|
@@ -19,8 +19,10 @@ export const Default: Story = {
|
|
|
19
19
|
args: {
|
|
20
20
|
actionText: 'LEARN MORE',
|
|
21
21
|
actionLink: 'https://www.forceforgood.org/',
|
|
22
|
+
// eslint-disable-next-line max-len
|
|
22
23
|
text: 'Every child deserves a chance to shine. Through our Nu Skin Force for Good Foundation, we’re empowering children around the world with hope for a brighter future.',
|
|
23
24
|
topImageUrl:
|
|
25
|
+
// eslint-disable-next-line max-len
|
|
24
26
|
'https://images.contentstack.io/v3/assets/blt594f30e2dc643eae/blt34cdb300dc9b93ff/645ccaa7520ba1a1af13a08a/nsffg-foundation.webp',
|
|
25
27
|
topImageAlt: 'Force for Good Foundation',
|
|
26
28
|
additionalProps: {
|
|
@@ -31,8 +33,9 @@ export const Default: Story = {
|
|
|
31
33
|
const canvas = within(canvasElement);
|
|
32
34
|
await userEvent.hover(canvas.getByTestId('ffg-card'));
|
|
33
35
|
await userEvent.hover(canvas.getByRole('link'));
|
|
34
|
-
|
|
36
|
+
expect(
|
|
35
37
|
canvas.getByText(
|
|
38
|
+
// eslint-disable-next-line max-len
|
|
36
39
|
'Every child deserves a chance to shine. Through our Nu Skin Force for Good Foundation, we’re empowering children around the world with hope for a brighter future.'
|
|
37
40
|
)
|
|
38
41
|
).toBeInTheDocument();
|
|
@@ -34,7 +34,7 @@ export const slides = [
|
|
|
34
34
|
},
|
|
35
35
|
];
|
|
36
36
|
export default {
|
|
37
|
-
title: 'Components/NsCarousal/NsScrollingCarousal',
|
|
37
|
+
title: 'Components/Containers/NsCarousal/NsScrollingCarousal',
|
|
38
38
|
component: NsScrollingCarousal,
|
|
39
39
|
decorators: [withCenterDecorator],
|
|
40
40
|
argTypes: {},
|
|
@@ -13,7 +13,7 @@ type MetaStory = Meta<ComponentType>;
|
|
|
13
13
|
const labelText = 'Checkbox Label';
|
|
14
14
|
// In this case, we're only passing the label prop.
|
|
15
15
|
export default {
|
|
16
|
-
title: 'Components/NsCheckbox',
|
|
16
|
+
title: 'Components/Inputs/NsCheckbox',
|
|
17
17
|
component: NsCheckbox,
|
|
18
18
|
decorators: [withCenterDecorator],
|
|
19
19
|
argTypes: {
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @author [vijayaprathap Kumar] (vpkumar@nuskin.com)
|
|
3
|
-
* checkbox.tsx
|
|
4
3
|
* @description Styled Components for Checkbox
|
|
5
4
|
*/
|
|
6
5
|
import DoneIcon from '@mui/icons-material/Done';
|
|
7
6
|
|
|
8
|
-
import { styled } from '@nuskin/foundation-theme';
|
|
7
|
+
import { styled, ColorUtils } from '@nuskin/foundation-theme';
|
|
9
8
|
import { NsFlag } from '../flag';
|
|
10
|
-
|
|
9
|
+
const { paletteColor, buttonColor } = ColorUtils;
|
|
11
10
|
/**
|
|
12
11
|
* Wrapper BpIcon for checkbox.tsx
|
|
13
12
|
* @params ( theme: { palette }) / Provide the color's to contaier from @nuskin/foundation-theme
|
|
14
13
|
*/
|
|
15
14
|
|
|
16
|
-
export const BpIcon = styled(DoneIcon)(({ theme
|
|
15
|
+
export const BpIcon = styled(DoneIcon)(({ theme }) => ({
|
|
17
16
|
border: '1px solid #8C8C8C',
|
|
18
17
|
path: {
|
|
19
18
|
display: 'none',
|
|
@@ -25,31 +24,31 @@ export const BpIcon = styled(DoneIcon)(({ theme: { palette } }) => ({
|
|
|
25
24
|
outline: '3px solid #94D6E9',
|
|
26
25
|
},
|
|
27
26
|
'input:disabled ~ &': {
|
|
28
|
-
background:
|
|
27
|
+
background: buttonColor('primary', 'hovered')({ theme }),
|
|
29
28
|
},
|
|
30
29
|
}));
|
|
31
30
|
|
|
32
31
|
/**
|
|
33
32
|
* Wrapper BpCheckedIcon for checkbox.tsx
|
|
34
|
-
* @params ( theme: { palette }) / Provide the color's to
|
|
33
|
+
* @params ( theme: { palette }) / Provide the color's to container from @nuskin/foundation-theme
|
|
35
34
|
*/
|
|
36
35
|
|
|
37
|
-
export const BpCheckedIcon = styled(BpIcon)(({ theme
|
|
36
|
+
export const BpCheckedIcon = styled(BpIcon)(({ theme }) => ({
|
|
38
37
|
path: {
|
|
39
38
|
display: 'block',
|
|
40
39
|
},
|
|
41
|
-
background:
|
|
42
|
-
color:
|
|
40
|
+
background: paletteColor('primary', 'main')({ theme }),
|
|
41
|
+
color: paletteColor('primary', 'contrastText')({ theme }),
|
|
43
42
|
}));
|
|
44
43
|
|
|
45
|
-
|
|
46
|
-
${({ $hasDisabled, theme: { palette } }) =>
|
|
47
|
-
$hasDisabled &&
|
|
48
|
-
`
|
|
49
|
-
color: ${palette?.primary?.buttonState?.hovered};
|
|
50
|
-
`}
|
|
51
|
-
`;
|
|
44
|
+
const getLabelColor = (isDisabled: boolean, color: string) => (!isDisabled ? '' : `color: ${color}`);
|
|
52
45
|
|
|
46
|
+
export const StyledLabel = styled('span')<{ isDisabled: boolean }>`
|
|
47
|
+
${({ isDisabled, theme }) => {
|
|
48
|
+
const color = buttonColor('primary', 'hovered')({ theme });
|
|
49
|
+
return getLabelColor(isDisabled, color);
|
|
50
|
+
}}
|
|
51
|
+
`;
|
|
53
52
|
export const StyledFlagLabel = styled(NsFlag)`
|
|
54
53
|
margin-right: 16px;
|
|
55
54
|
`;
|