@nuskin/foundation-ui-components 1.0.0-develop.4 → 1.0.0-develop.6
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 +9 -4
- package/src/common/accordion/specs/NsAccordion.spec.tsx +3 -1
- package/src/common/accordion/specs/NsAccordionHeader.spec.tsx +21 -5
- package/src/common/accordion/specs/NsAccordionItem.spec.tsx +29 -5
- package/src/common/accordion/specs/NsCollapse.spec.tsx +4 -4
- package/src/common/accordion/specs/NsToggleSection.spec.tsx +10 -5
- package/src/common/alert/NsAlert.spec.tsx +0 -1
- package/src/common/alert/NsAlert.styled.ts +10 -10
- package/src/common/alert/NsAlert.tsx +4 -3
- package/src/common/auth-dropdown/NsAuthDropdown.styled.ts +12 -11
- package/src/common/auth-dropdown/NsAuthDropdown.tsx +2 -1
- package/src/common/auth-dropdown/types.d.ts +3 -1
- package/src/common/autocomplete/NsAutocomplete.spec.tsx +10 -0
- package/src/common/autocomplete/NsAutocomplete.stories.tsx +44 -6
- package/src/common/autocomplete/NsAutocomplete.tsx +18 -15
- package/src/common/autocomplete/types.d.ts +8 -6
- package/src/common/brand-components/NsBrandComponent.tsx +3 -0
- package/src/common/breadcrumb/NsBreadcrumb.tsx +4 -2
- 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 +25 -23
- package/src/common/button/NsButton.tsx +9 -2
- package/src/common/button/types.d.ts +1 -0
- package/src/common/common.types.d.ts +1 -0
- package/src/common/dropdown/types.d.ts +3 -1
- package/src/common/flag/NsFlag.spec.tsx +1 -0
- package/src/common/flag/NsFlag.styled.tsx +5 -5
- package/src/common/icon/types.d.ts +1 -0
- package/src/common/input/InputFieldWrapper.tsx +4 -4
- package/src/common/label/NsLabel.tsx +11 -7
- package/src/common/nav-tab/NsNavTab.styled.tsx +7 -4
- package/src/common/radiogroup/NsRadioGroup.spec.tsx +2 -1
- package/src/common/radiogroup/NsRadioGroup.stories.tsx +2 -1
- package/src/common/radiogroup/NsRadioGroup.styled.tsx +26 -32
- package/src/common/radiogroup/NsRadioGroup.tsx +20 -5
- package/src/common/radiogroup/types.d.ts +4 -3
- package/src/common/select/NsSelect.styled.tsx +19 -23
- package/src/common/table/NsTable.styled.ts +69 -66
- package/src/common/text-strip/NsTextStrip.tsx +10 -7
- package/src/common/typography/Typography.styled.tsx +3 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { PropsWithChildren } from 'react';
|
|
2
2
|
import { Autocomplete, AutocompleteRenderGroupParams, List, AutocompleteRenderInputParams } from '@mui/material';
|
|
3
3
|
import { NsTypography, NsButton } from '../';
|
|
4
4
|
import { NsAutocompleteProps, OptionsProps, ComponentBoxProps } from './types.d';
|
|
@@ -18,23 +18,23 @@ const NsAutocomplete = ({
|
|
|
18
18
|
className,
|
|
19
19
|
iconStart,
|
|
20
20
|
iconEnd,
|
|
21
|
+
inputValue,
|
|
22
|
+
value,
|
|
21
23
|
}: PropsWithChildren<NsAutocompleteProps>) => {
|
|
22
|
-
const inputRef = useRef(null);
|
|
23
|
-
|
|
24
|
-
const [selectedOption, setSelectedOption] = useState<OptionsProps | null>(null);
|
|
25
24
|
const OptionUI = renderOptions;
|
|
26
25
|
|
|
27
|
-
const handleSelect = (event: React.SyntheticEvent<Element, Event>, value: OptionsProps | null) => {
|
|
28
|
-
setSelectedOption(value);
|
|
26
|
+
const handleSelect = (event: React.SyntheticEvent<Element, Event>, value: string | OptionsProps | null) => {
|
|
29
27
|
onSelect ? onSelect(value) : null;
|
|
30
28
|
};
|
|
31
29
|
|
|
30
|
+
const handleInputChange = (event: React.SyntheticEvent<Element, Event>, newInputValue: string) => {
|
|
31
|
+
onChange ? onChange(newInputValue) : null;
|
|
32
|
+
};
|
|
33
|
+
|
|
32
34
|
const renderInput = (params: AutocompleteRenderInputParams) => (
|
|
33
35
|
<StyledTextField
|
|
34
36
|
{...params}
|
|
35
|
-
onChange={onChange}
|
|
36
37
|
placeholder={placeholder}
|
|
37
|
-
inputRef={inputRef}
|
|
38
38
|
InputProps={{
|
|
39
39
|
...params.InputProps,
|
|
40
40
|
startAdornment: iconStart,
|
|
@@ -61,23 +61,23 @@ const NsAutocomplete = ({
|
|
|
61
61
|
{group}
|
|
62
62
|
</NsTypography>
|
|
63
63
|
) : null}
|
|
64
|
-
<
|
|
64
|
+
<ul className="p-0">{children}</ul>
|
|
65
65
|
</li>
|
|
66
66
|
);
|
|
67
67
|
|
|
68
68
|
const renderClearButton = () => {
|
|
69
|
-
const { show, onClear, text = '
|
|
69
|
+
const { show, onClear, text = 'Clear Search' } = clear || {};
|
|
70
70
|
if (!show) {
|
|
71
71
|
return null;
|
|
72
72
|
}
|
|
73
73
|
return (
|
|
74
|
-
<
|
|
74
|
+
<li className="text-right p-3">
|
|
75
75
|
<NsButton onClick={onClear} data-testid="autocomplete-clear-id">
|
|
76
76
|
<NsTypography variant={'p-xs'} weight="bold">
|
|
77
77
|
{text}
|
|
78
78
|
</NsTypography>
|
|
79
79
|
</NsButton>
|
|
80
|
-
</
|
|
80
|
+
</li>
|
|
81
81
|
);
|
|
82
82
|
};
|
|
83
83
|
|
|
@@ -87,13 +87,13 @@ const NsAutocomplete = ({
|
|
|
87
87
|
return null;
|
|
88
88
|
}
|
|
89
89
|
return (
|
|
90
|
-
<
|
|
90
|
+
<li className="text-center p-3">
|
|
91
91
|
<NsButton onClick={onSeeMore} data-testid="autocomplete-loadmore-id">
|
|
92
92
|
<NsTypography variant="p-xs" weight="bold">
|
|
93
93
|
{text}
|
|
94
94
|
</NsTypography>
|
|
95
95
|
</NsButton>
|
|
96
|
-
</
|
|
96
|
+
</li>
|
|
97
97
|
);
|
|
98
98
|
};
|
|
99
99
|
|
|
@@ -120,7 +120,10 @@ const NsAutocomplete = ({
|
|
|
120
120
|
ListboxComponent={renderListBoxComponent}
|
|
121
121
|
renderGroup={renderGroupName}
|
|
122
122
|
onChange={handleSelect}
|
|
123
|
-
|
|
123
|
+
onInputChange={handleInputChange}
|
|
124
|
+
value={value}
|
|
125
|
+
inputValue={inputValue}
|
|
126
|
+
freeSolo
|
|
124
127
|
/>
|
|
125
128
|
);
|
|
126
129
|
};
|
|
@@ -6,27 +6,29 @@ import { ComponentsProps } from '@mui/material';
|
|
|
6
6
|
export type NsAutocompleteProps = {
|
|
7
7
|
id?: string;
|
|
8
8
|
options: OptionsProps[];
|
|
9
|
-
loading?:boolean;
|
|
9
|
+
loading?: boolean;
|
|
10
10
|
renderOptions: React.ComponentType<any>;
|
|
11
|
-
noOptionsText
|
|
11
|
+
noOptionsText?: string;
|
|
12
12
|
// eslint-disable-next-line no-unused-vars
|
|
13
|
-
onSelect?: (params: OptionsProps | null) => void;
|
|
13
|
+
onSelect?: (params: string | OptionsProps | null) => void;
|
|
14
14
|
// eslint-disable-next-line no-unused-vars
|
|
15
|
-
onChange?: (params) => void;
|
|
15
|
+
onChange?: (params: string) => void;
|
|
16
16
|
clear?: {
|
|
17
17
|
text: string;
|
|
18
18
|
show?: boolean; //default to false
|
|
19
|
-
onClear: () =>
|
|
19
|
+
onClear: () => void;
|
|
20
20
|
};
|
|
21
21
|
seeMore?: {
|
|
22
22
|
text: string;
|
|
23
23
|
show?: boolean; //default to false
|
|
24
|
-
onSeeMore: () =>
|
|
24
|
+
onSeeMore: () => void;
|
|
25
25
|
};
|
|
26
26
|
placeholder?: string;
|
|
27
27
|
className?: string;
|
|
28
28
|
iconStart?: string | React.ReactNode;
|
|
29
29
|
iconEnd?: string | React.ReactNode;
|
|
30
|
+
inputValue: string;
|
|
31
|
+
value: string | OptionsProps | null;
|
|
30
32
|
} & AdditionalProps;
|
|
31
33
|
|
|
32
34
|
export type ListUiProps = {
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import React, { PropsWithChildren, useCallback } from 'react';
|
|
2
|
+
|
|
2
3
|
import NSLogoHorizontal from './icons/NSLogoHorizontal';
|
|
3
4
|
import NSLogoMark from './icons/NSLogoMark';
|
|
4
5
|
import NSLogoPoweredBy from './icons/NSLogoPoweredBy';
|
|
5
6
|
import NSLogoStacked from './icons/NSLogoStacked';
|
|
6
7
|
import NSLogoWordMark from './icons/NSWordMark';
|
|
7
8
|
import LogoContainer from './NsBrandContanier.styled';
|
|
9
|
+
|
|
8
10
|
import { NsBrandComponentProps } from './types.d';
|
|
9
11
|
|
|
10
12
|
const VariantMap = {
|
|
@@ -19,6 +21,7 @@ const NsBrandComponent = (props: PropsWithChildren<NsBrandComponentProps>) => {
|
|
|
19
21
|
const { variant = 'stacked', size = '108px', color = 'primary' } = props;
|
|
20
22
|
const renderBrand = useCallback(() => {
|
|
21
23
|
const BrandComponent = VariantMap[variant || 'stacked'];
|
|
24
|
+
// [Todo - Add neutral as FoundationTheme.PaletteColor]
|
|
22
25
|
return <BrandComponent color={color as any} />;
|
|
23
26
|
}, [color, variant]);
|
|
24
27
|
return <LogoContainer size={size}>{renderBrand()}</LogoContainer>;
|
|
@@ -12,12 +12,14 @@ import { NsBreadcrumbProps, ItemProps } from './types.d';
|
|
|
12
12
|
import { useTheme } from '@mui/material/styles';
|
|
13
13
|
import { ColorUtils } from '@nuskin/foundation-theme';
|
|
14
14
|
|
|
15
|
+
const { color } = ColorUtils;
|
|
16
|
+
|
|
15
17
|
const NsBreadcrumb = (props: PropsWithChildren<NsBreadcrumbProps>) => {
|
|
16
18
|
const { items, iconVisibility } = props;
|
|
17
19
|
|
|
18
20
|
const theme = useTheme();
|
|
19
|
-
const neutral80 =
|
|
20
|
-
const neutral60 =
|
|
21
|
+
const neutral80 = color('neutral', '80')({ theme });
|
|
22
|
+
const neutral60 = color('neutral', '60')({ theme });
|
|
21
23
|
|
|
22
24
|
const getLabel = (item: ItemProps) => {
|
|
23
25
|
if (item?.href) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { render, screen } from '@/test-utils/index';
|
|
3
|
-
import nuskinTheme from '@nuskin/foundation-theme
|
|
3
|
+
import { nuskinTheme } from '@nuskin/foundation-theme';
|
|
4
4
|
import Button from './NsButton';
|
|
5
5
|
|
|
6
6
|
const { palette } = nuskinTheme;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Button as MUIButton } from '@mui/material';
|
|
2
2
|
|
|
3
3
|
import { styled, ColorUtils, FoundationTheme } from '@nuskin/foundation-theme';
|
|
4
|
-
import { ButtonConfig } from '@nuskin/foundation-theme/src/themes/types/button';
|
|
4
|
+
import { ButtonConfig } from '@nuskin/foundation-theme/src/common/themes/types/button';
|
|
5
|
+
|
|
5
6
|
import { NsButtonProps } from './types.d';
|
|
6
7
|
|
|
7
|
-
const {
|
|
8
|
+
const { buttonColor, paletteColor } = ColorUtils;
|
|
8
9
|
|
|
9
10
|
const getButtonConfig = (theme: FoundationTheme.Theme, attribute: keyof ButtonConfig) => {
|
|
10
11
|
const { config } = theme || {};
|
|
@@ -18,8 +19,8 @@ const StyledButton = styled(MUIButton)<NsButtonProps>`
|
|
|
18
19
|
border: 1px solid ${({ theme }) => getButtonConfig(theme, 'focusColor')} !important;
|
|
19
20
|
}
|
|
20
21
|
:disabled {
|
|
21
|
-
background-color: ${(
|
|
22
|
-
color: ${(
|
|
22
|
+
background-color: ${(btnProps) => buttonColor(btnProps?.color, 'disabled')};
|
|
23
|
+
color: ${(btnProps) => buttonColor(btnProps?.color, 'disabledText')};
|
|
23
24
|
}
|
|
24
25
|
${({ theme: { config }, size }) => {
|
|
25
26
|
return size === 'medium' ? config?.components?.button?.size?.medium?.padding : '';
|
|
@@ -27,37 +28,38 @@ const StyledButton = styled(MUIButton)<NsButtonProps>`
|
|
|
27
28
|
${({ theme: { config }, size }) => {
|
|
28
29
|
return size === 'large' ? config?.components?.button?.size?.large?.padding : '';
|
|
29
30
|
}}
|
|
30
|
-
${({ variant, theme, color = 'primary' }) => {
|
|
31
|
+
${({ variant, theme, color = 'primary', darkModeEnabled }) => {
|
|
31
32
|
return variant === 'contained'
|
|
32
33
|
? `
|
|
33
|
-
background-color: ${
|
|
34
|
+
background-color: ${paletteColor(color)({ theme, darkModeEnabled })};
|
|
35
|
+
color: ${paletteColor(color, 'contrastText')({ theme, darkModeEnabled })} !important;
|
|
34
36
|
:hover {
|
|
35
|
-
background-color: ${
|
|
37
|
+
background-color: ${buttonColor(color, 'hovered')({ theme })};
|
|
36
38
|
}
|
|
37
39
|
:active {
|
|
38
|
-
background-color: ${
|
|
40
|
+
background-color: ${buttonColor(color, 'pressed')({ theme })};
|
|
39
41
|
}
|
|
40
42
|
:focus {
|
|
41
|
-
background-color: ${
|
|
43
|
+
background-color: ${buttonColor(color, 'focused')({ theme })};
|
|
42
44
|
}
|
|
43
45
|
`
|
|
44
46
|
: '';
|
|
45
47
|
}}
|
|
46
|
-
${({ variant, theme, color = 'primary' }) =>
|
|
48
|
+
${({ variant, theme, color = 'primary', darkModeEnabled }) =>
|
|
47
49
|
variant === 'outlined' &&
|
|
48
50
|
`
|
|
49
|
-
border-color: ${
|
|
50
|
-
color: ${
|
|
51
|
+
border-color: ${paletteColor(color)({ theme, darkModeEnabled })};
|
|
52
|
+
color: ${paletteColor(color)({ theme, darkModeEnabled })};
|
|
51
53
|
:hover {
|
|
52
|
-
border-color: ${
|
|
53
|
-
color: ${
|
|
54
|
+
border-color: ${buttonColor(color, 'hovered')({ theme })};
|
|
55
|
+
color: ${paletteColor(color)({ theme, darkModeEnabled })};
|
|
54
56
|
}
|
|
55
57
|
:active {
|
|
56
|
-
border-color: ${
|
|
57
|
-
color: ${
|
|
58
|
+
border-color: ${buttonColor(color, 'pressed')({ theme })};
|
|
59
|
+
color: ${paletteColor(color)({ theme })};
|
|
58
60
|
}
|
|
59
61
|
`}
|
|
60
|
-
${({ variant, theme, color = 'primary' }) =>
|
|
62
|
+
${({ variant, theme, color = 'primary', darkModeEnabled }) =>
|
|
61
63
|
variant === 'text' &&
|
|
62
64
|
`
|
|
63
65
|
text-decoration: underline 1px !important;
|
|
@@ -65,15 +67,15 @@ const StyledButton = styled(MUIButton)<NsButtonProps>`
|
|
|
65
67
|
padding: 0;
|
|
66
68
|
min-width: auto;
|
|
67
69
|
background-color: transparent !important;
|
|
68
|
-
text-decoration-color: ${
|
|
69
|
-
color: ${
|
|
70
|
+
text-decoration-color: ${paletteColor(color)({ theme, darkModeEnabled })};
|
|
71
|
+
color: ${paletteColor(color)({ theme, darkModeEnabled })};
|
|
70
72
|
:hover {
|
|
71
|
-
color: ${
|
|
72
|
-
text-decoration-color: ${
|
|
73
|
+
color: ${buttonColor(color, 'hovered')({ theme })};
|
|
74
|
+
text-decoration-color: ${buttonColor(color, 'hovered')({ theme })};
|
|
73
75
|
}
|
|
74
76
|
:active {
|
|
75
|
-
color: ${
|
|
76
|
-
text-decoration-color: ${
|
|
77
|
+
color: ${paletteColor(color)};
|
|
78
|
+
text-decoration-color: ${buttonColor(color, 'pressed')({ theme })};
|
|
77
79
|
}
|
|
78
80
|
`}
|
|
79
81
|
${({ iconOnly }) =>
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import { PropsWithChildren } from 'react';
|
|
2
|
+
import { useTheme } from '@mui/material/styles';
|
|
3
|
+
|
|
2
4
|
import StyledButton from './NsButton.styled';
|
|
5
|
+
|
|
3
6
|
import { NsButtonProps } from './types.d';
|
|
7
|
+
import { FoundationTheme } from '@nuskin/foundation-theme';
|
|
4
8
|
|
|
5
|
-
const NsButton = ({ children, ...props }: PropsWithChildren<NsButtonProps>) => {
|
|
9
|
+
const NsButton = ({ children, darkModeEnabled = true, ...props }: PropsWithChildren<NsButtonProps>) => {
|
|
10
|
+
const { color } = props;
|
|
11
|
+
const { palette } = useTheme();
|
|
12
|
+
const btnColor = (color && palette?.[color] ? color : 'primary') as FoundationTheme.PaletteColors;
|
|
6
13
|
return (
|
|
7
|
-
<StyledButton {...props} disableRipple>
|
|
14
|
+
<StyledButton {...props} color={btnColor} disableRipple darkModeEnabled={darkModeEnabled}>
|
|
8
15
|
{children}
|
|
9
16
|
</StyledButton>
|
|
10
17
|
);
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { FoundationTheme } from '@nuskin/foundation-theme';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
import { AdditionalProps } from '../common.types';
|
|
5
|
+
|
|
6
|
+
export interface DropdownProps extends AdditionalProps {
|
|
5
7
|
selectedValue: string;
|
|
6
8
|
selectedLabel: string;
|
|
7
9
|
onSelect: (arg: string) => void; // eslint-disable-line
|
|
@@ -9,6 +9,8 @@ import { styled, ColorUtils, FoundationTheme } from '@nuskin/foundation-theme';
|
|
|
9
9
|
|
|
10
10
|
import { NsFlagSize } from './types.d';
|
|
11
11
|
|
|
12
|
+
const { paletteColor } = ColorUtils;
|
|
13
|
+
|
|
12
14
|
type NsFlagThemeParams = {
|
|
13
15
|
$size: NsFlagSize;
|
|
14
16
|
$bgColor?: FoundationTheme.PaletteColors;
|
|
@@ -33,11 +35,9 @@ const makeFlagSize = ({ $size }: { $size: NsFlagSize }) => {
|
|
|
33
35
|
return sizeValue / FLAG_SCALE_VALUE;
|
|
34
36
|
};
|
|
35
37
|
|
|
36
|
-
const { getPaletteColor } = ColorUtils;
|
|
37
|
-
|
|
38
38
|
const makeFlagBorder = ({ $size, $bgColor = 'accentColorA', theme }: NsFlagThemeParams) => {
|
|
39
39
|
if (theme) {
|
|
40
|
-
return `${makeFlagSize({ $size })}px solid ${
|
|
40
|
+
return `${makeFlagSize({ $size })}px solid ${paletteColor($bgColor)({ theme })}`;
|
|
41
41
|
}
|
|
42
42
|
return '';
|
|
43
43
|
};
|
|
@@ -45,8 +45,8 @@ const makeFlagBorder = ({ $size, $bgColor = 'accentColorA', theme }: NsFlagTheme
|
|
|
45
45
|
export const StyledFlag = styled('span')<NsFlagThemeParams>`
|
|
46
46
|
min-width: 29px;
|
|
47
47
|
height: ${getFlagHeight}px;
|
|
48
|
-
color: ${({ $bgColor = 'accentColorA', theme }) =>
|
|
49
|
-
background: ${({ $bgColor = 'accentColorA', theme }) =>
|
|
48
|
+
color: ${({ $bgColor = 'accentColorA', theme }) => paletteColor($bgColor, 'contrastText')({ theme })};
|
|
49
|
+
background: ${({ $bgColor = 'accentColorA', theme }) => paletteColor($bgColor)({ theme })};
|
|
50
50
|
position: relative;
|
|
51
51
|
padding: 0 15px;
|
|
52
52
|
display: inline-grid;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Stack } from '@mui/material';
|
|
2
2
|
import { styled, ColorUtils } from '@nuskin/foundation-theme';
|
|
3
|
-
const {
|
|
3
|
+
const { color, paletteColor } = ColorUtils;
|
|
4
4
|
|
|
5
5
|
const InputFieldWrapper = styled(Stack)(({ theme }: any) => {
|
|
6
6
|
return {
|
|
@@ -10,12 +10,12 @@ const InputFieldWrapper = styled(Stack)(({ theme }: any) => {
|
|
|
10
10
|
'.MuiFormHelperText-root': {
|
|
11
11
|
fontSize: '11px',
|
|
12
12
|
marginTop: 0,
|
|
13
|
-
color:
|
|
13
|
+
color: paletteColor('primary', 'main')({ theme }),
|
|
14
14
|
'&.success': {
|
|
15
|
-
color:
|
|
15
|
+
color: color('success', '40')({ theme }),
|
|
16
16
|
},
|
|
17
17
|
'&.error': {
|
|
18
|
-
color:
|
|
18
|
+
color: paletteColor('error', 'main')({ theme }),
|
|
19
19
|
},
|
|
20
20
|
},
|
|
21
21
|
};
|
|
@@ -1,20 +1,24 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
|
|
1
3
|
import { FormLabel } from '@mui/material';
|
|
2
|
-
|
|
4
|
+
|
|
3
5
|
import { styled, ColorUtils } from '@nuskin/foundation-theme';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
+
|
|
7
|
+
import { NsLabelProps } from './types.d';
|
|
8
|
+
|
|
9
|
+
const { paletteColor, isDarkMode, color } = ColorUtils;
|
|
6
10
|
|
|
7
11
|
const StyledLabel = styled(FormLabel)<{ fontSize?: number; style?: CSSProperties }>(({ theme, fontSize, style }) => {
|
|
8
|
-
const isLight = theme
|
|
12
|
+
const isLight = !isDarkMode({ theme });
|
|
9
13
|
return {
|
|
10
14
|
fontSize: fontSize ? `${fontSize}px` : '14px',
|
|
11
15
|
textAlign: style?.textAlign ?? 'left',
|
|
12
|
-
color:
|
|
16
|
+
color: paletteColor('primary', 'main')({ theme }),
|
|
13
17
|
'.optional-label': {
|
|
14
|
-
color: isLight ?
|
|
18
|
+
color: isLight ? color('neutral', '60')({ theme }) : color('neutral', '50')({ theme }),
|
|
15
19
|
},
|
|
16
20
|
'.MuiInputLabel-asterisk': {
|
|
17
|
-
color: isLight ?
|
|
21
|
+
color: isLight ? color('error', '40')({ theme }) : color('error', '20')({ theme }),
|
|
18
22
|
},
|
|
19
23
|
...(style || {}),
|
|
20
24
|
} as any; // TODO: may be this "any" has to be fixed from foundation-theme
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import { FoundationTheme, styled } from '@nuskin/foundation-theme';
|
|
1
|
+
import { FoundationTheme, styled, ColorUtils } from '@nuskin/foundation-theme';
|
|
2
2
|
import { motion } from 'framer-motion';
|
|
3
3
|
|
|
4
|
+
const { paletteColor } = ColorUtils;
|
|
5
|
+
|
|
6
|
+
|
|
4
7
|
export const NavTabContainer = styled.div`
|
|
5
8
|
.shadow {
|
|
6
9
|
box-shadow: 0 2px 3px 0 rgba(0, 0, 0, 0.15);
|
|
@@ -23,7 +26,7 @@ export const NavTabUnderLine = styled(motion.div)<{ color?: FoundationTheme.Pale
|
|
|
23
26
|
position: absolute;
|
|
24
27
|
bottom: -2px;
|
|
25
28
|
height: 2px;
|
|
26
|
-
background-color: ${({ theme
|
|
29
|
+
background-color: ${({ theme, color = 'primary' }) => paletteColor(color)({ theme })};
|
|
27
30
|
`;
|
|
28
31
|
|
|
29
32
|
export const NavDrawer = styled.div`
|
|
@@ -37,7 +40,7 @@ export const NavDrawer = styled.div`
|
|
|
37
40
|
width: 100%;
|
|
38
41
|
max-height: 590px;
|
|
39
42
|
|
|
40
|
-
background-color: ${(
|
|
43
|
+
background-color: ${paletteColor('primary', 'contrastText')};
|
|
41
44
|
box-shadow: 0 2px 3px 0 rgba(0, 0, 0, 0.15);
|
|
42
45
|
transition: all 0.15s ease-in-out;
|
|
43
46
|
overflow: hidden;
|
|
@@ -54,7 +57,7 @@ export const NavDrawerContainer = styled(motion.div)`
|
|
|
54
57
|
z-index: 1;
|
|
55
58
|
}
|
|
56
59
|
box-shadow: 0 2px 3px 0 rgba(0, 0, 0, 0.15);
|
|
57
|
-
background-color: ${(
|
|
60
|
+
background-color: ${paletteColor('primary', 'contrastText')};
|
|
58
61
|
width: 100%;
|
|
59
62
|
text-align: left;
|
|
60
63
|
max-height: 590px;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { render, fireEvent, screen } from '@testing-library/react';
|
|
3
3
|
import { NsRadioGroup } from './';
|
|
4
|
+
import { FoundationTheme } from '@nuskin/foundation-theme';
|
|
4
5
|
|
|
5
6
|
|
|
6
7
|
describe('NsRadioGroup', () => {
|
|
@@ -16,7 +17,7 @@ describe('NsRadioGroup', () => {
|
|
|
16
17
|
items: options,
|
|
17
18
|
name: 'test',
|
|
18
19
|
label: 'I choose to signup as',
|
|
19
|
-
color: '#272525',
|
|
20
|
+
color: '#272525' as FoundationTheme.PaletteColors,
|
|
20
21
|
additionalSlot: 'An additional slot allows for more text',
|
|
21
22
|
size: 24,
|
|
22
23
|
labelFontSize: 16,
|
|
@@ -3,6 +3,7 @@ import type { StoryObj, Meta } from '@storybook/react';
|
|
|
3
3
|
import { within, userEvent } from '@storybook/testing-library';
|
|
4
4
|
import { expect } from '@storybook/jest';
|
|
5
5
|
import { NsRadioGroup } from './'
|
|
6
|
+
import { FoundationTheme } from '@nuskin/foundation-theme';
|
|
6
7
|
|
|
7
8
|
type ComponentType = typeof NsRadioGroup;
|
|
8
9
|
type Story = StoryObj<ComponentType>;
|
|
@@ -77,7 +78,7 @@ export const RadioGroup: Story = {
|
|
|
77
78
|
],
|
|
78
79
|
name: 'test',
|
|
79
80
|
label: 'I choose to signup as',
|
|
80
|
-
color: '#272525',
|
|
81
|
+
color: '#272525' as FoundationTheme.PaletteColors,
|
|
81
82
|
additionalSlot: 'An additional slot allows for more text',
|
|
82
83
|
size: 10,
|
|
83
84
|
labelFontSize: 16,
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { Radio, FormControlLabel, FormLabel, RadioGroup } from '@mui/material';
|
|
2
|
-
import { ColorUtils } from '@nuskin/foundation-theme';
|
|
3
|
-
import { styled, nuskinTheme } from '@nuskin/foundation-theme';
|
|
2
|
+
import { ColorUtils, FoundationTheme, styled } from '@nuskin/foundation-theme';
|
|
4
3
|
|
|
5
|
-
const {
|
|
6
|
-
const { colors } = nuskinTheme;
|
|
4
|
+
const { paletteColor, isDarkMode, color } = ColorUtils;
|
|
7
5
|
|
|
8
6
|
export const StyledHelperText = styled('div')`
|
|
9
7
|
margin-top :10px;
|
|
@@ -15,42 +13,38 @@ export const StyledHelperText = styled('div')`
|
|
|
15
13
|
export const StyledSpan = styled('span')`
|
|
16
14
|
font-size: '16px';
|
|
17
15
|
font-weight: 300;
|
|
18
|
-
color: ${(
|
|
16
|
+
color: ${paletteColor('primary')};
|
|
19
17
|
`;
|
|
20
18
|
|
|
21
|
-
export const StyledLabel = styled(FormLabel)
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
};
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
export const StyledRadio = styled(Radio)(({ theme }) => {
|
|
30
|
-
const isLight = theme.palette?.primary?.main === '#252525';
|
|
31
|
-
|
|
32
|
-
return {
|
|
33
|
-
color: isLight ? colors.primary.black : colors.primary.white,
|
|
34
|
-
};
|
|
35
|
-
});
|
|
19
|
+
export const StyledLabel = styled(FormLabel)`
|
|
20
|
+
color: ${paletteColor('primary')},
|
|
21
|
+
marginBottom: '15px',
|
|
22
|
+
backgroundColor: 'transparent',
|
|
23
|
+
`;
|
|
36
24
|
|
|
37
|
-
export const
|
|
38
|
-
|
|
25
|
+
export const StyledRadio = styled(Radio)`
|
|
26
|
+
color: ${(props) => !isDarkMode(props) ? color('primary', 'black')(props) : color('primary', 'white')(props)}
|
|
27
|
+
`;
|
|
39
28
|
|
|
29
|
+
export const StyledFormControlLabel = styled(FormControlLabel)<{ darkModeEnabled?: boolean }>((props) => {
|
|
40
30
|
return {
|
|
41
|
-
color:
|
|
31
|
+
color: paletteColor('primary')(props),
|
|
42
32
|
marginBottom: '10px',
|
|
43
33
|
'.MuiFormControlLabel-label.Mui-disabled': {
|
|
44
|
-
color:
|
|
34
|
+
color: `${!isDarkMode(props) ? color('neutral', 60)(props) : color('neutral', 20)(props)}`
|
|
45
35
|
},
|
|
46
36
|
};
|
|
47
37
|
});
|
|
48
38
|
|
|
49
|
-
export const StyledRadioGroup = styled(RadioGroup)
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
})
|
|
39
|
+
export const StyledRadioGroup = styled(RadioGroup)<
|
|
40
|
+
{ color: FoundationTheme.PaletteColors; darkModeEnabled?: boolean }
|
|
41
|
+
>(
|
|
42
|
+
({ theme, color, darkModeEnabled }) => {
|
|
43
|
+
return {
|
|
44
|
+
marginTop: '10px',
|
|
45
|
+
'.MuiRadio-root.custom-radio.Mui-checked': {
|
|
46
|
+
color: paletteColor(color)({ theme, darkModeEnabled })
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
);
|