@nuskin/foundation-ui-components 1.9.0 → 1.9.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/accordion/NsAccordionHeader.tsx +2 -7
- package/src/common/accordion/NsCollapse.tsx +35 -42
- package/src/common/alert/NsAlert.tsx +7 -5
- package/src/common/auth-dropdown/NsAuthDropdown.styled.ts +1 -5
- package/src/common/button/NsButton.styled.tsx +40 -45
- package/src/common/card/NsBgCard.tsx +2 -1
- package/src/common/card/NsLargeCard.tsx +1 -1
- package/src/common/card/NsMediumCard.tsx +1 -1
- package/src/common/carousal/CarousalControl.tsx +10 -6
- package/src/common/carousal/NsCarousal.tsx +21 -8
- package/src/common/carousal/NsScrollingCarousal.tsx +4 -8
- package/src/common/carousal/stories/NSCarousal.stories.tsx +7 -0
- package/src/common/column-control/NsColumnControl.tsx +6 -3
- package/src/common/column-control/styled/StyledFlex.tsx +5 -4
- package/src/common/column-control/styled/StyledGrid.tsx +2 -1
- package/src/common/icon/NsIcon.stories.tsx +42 -0
- package/src/common/icon/NsIcon.styled.tsx +5 -3
- package/src/common/icon/NsIcon.tsx +9 -1
- package/src/common/icon/types.d.ts +37 -0
- package/src/common/input/InputWrapper.tsx +3 -10
- package/src/common/link/NsLink.styled.tsx +2 -12
- package/src/common/link/NsLink.tsx +4 -7
- package/src/common/radiogroup/NsRadioGroup.styled.tsx +6 -7
- package/src/common/util.ts +3 -1
package/package.json
CHANGED
|
@@ -2,15 +2,10 @@ import { NsTypography, NsIcon, NsAccordionHeaderProps, AccordionVariant, NsIconP
|
|
|
2
2
|
import { styled } from '@nuskin/foundation-theme';
|
|
3
3
|
import { isValidIconName } from '../icon/NsIconVariants';
|
|
4
4
|
import { getAccordionColor } from './colorMap';
|
|
5
|
-
|
|
6
|
-
shouldForwardProp: (propKey: string) => !['variant', 'invert'].includes(propKey),
|
|
7
|
-
};
|
|
5
|
+
|
|
8
6
|
type StyledType = { variant: AccordionVariantType; invert: boolean };
|
|
9
7
|
|
|
10
|
-
const StyledHeader = styled(
|
|
11
|
-
'header',
|
|
12
|
-
options
|
|
13
|
-
)<StyledType>(({ theme, variant, invert }) => {
|
|
8
|
+
const StyledHeader = styled('header')<StyledType>(({ theme, variant, invert }) => {
|
|
14
9
|
const { headBg, headText } = getAccordionColor({ theme, variant, invert, keys: ['headBg', 'headText'] });
|
|
15
10
|
let borderBottom = 'none';
|
|
16
11
|
if (variant === AccordionVariant.Compact) {
|
|
@@ -1,59 +1,52 @@
|
|
|
1
1
|
import { styled } from '@nuskin/foundation-theme';
|
|
2
|
+
import { isValidElement, ReactElement, useMemo } from 'react';
|
|
3
|
+
|
|
2
4
|
import {
|
|
5
|
+
AccordionContentTypeObject,
|
|
6
|
+
AccordionItem,
|
|
3
7
|
AccordionVariant,
|
|
4
8
|
AccordionVariantType,
|
|
5
|
-
NsCollapseProps,
|
|
6
|
-
AccordionItem,
|
|
7
9
|
NsAccordion,
|
|
8
|
-
|
|
10
|
+
NsCollapseProps,
|
|
9
11
|
} from '../';
|
|
10
12
|
import { getAccordionColor } from './colorMap';
|
|
11
|
-
import { ReactElement, isValidElement, useMemo } from 'react';
|
|
12
13
|
|
|
13
14
|
const getLevelOffset = (level: number) => {
|
|
14
15
|
return level > 1 ? (level - 1) * 16 : 0;
|
|
15
16
|
};
|
|
17
|
+
type CollapsePropsType = { variant: AccordionVariantType; level: number; invert: boolean; isChild: boolean };
|
|
16
18
|
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
export const StyledCollapse = styled('section')<CollapsePropsType>(({ theme, variant, level, invert, isChild }) => {
|
|
20
|
+
const { contentBg, contentText } = getAccordionColor({
|
|
21
|
+
theme,
|
|
22
|
+
invert,
|
|
23
|
+
variant,
|
|
24
|
+
keys: ['contentBg', 'contentText'],
|
|
25
|
+
});
|
|
20
26
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
)<{ variant: AccordionVariantType; level: number; invert: boolean; isChild: boolean }>(
|
|
25
|
-
({ theme, variant, level, invert, isChild }) => {
|
|
26
|
-
const { contentBg, contentText } = getAccordionColor({
|
|
27
|
-
theme,
|
|
28
|
-
invert,
|
|
29
|
-
variant,
|
|
30
|
-
keys: ['contentBg', 'contentText'],
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
let borderBottom = 'none';
|
|
34
|
-
if (variant === AccordionVariant.Compact) {
|
|
35
|
-
borderBottom = isChild ? 'none' : '1px solid rgb(0,0,0,0.125)';
|
|
36
|
-
}
|
|
37
|
-
return {
|
|
38
|
-
backgroundColor: contentBg,
|
|
39
|
-
color: contentText,
|
|
40
|
-
opacity: 0,
|
|
41
|
-
padding: '0 16px',
|
|
42
|
-
height: 0,
|
|
43
|
-
overflow: 'hidden',
|
|
44
|
-
transition: '0.3s',
|
|
45
|
-
'&.expanded': {
|
|
46
|
-
padding: `9px 0 9px ${getLevelOffset(level)}px`,
|
|
47
|
-
height: 'auto',
|
|
48
|
-
opacity: 1,
|
|
49
|
-
borderBottom,
|
|
50
|
-
},
|
|
51
|
-
'.nsa-content-padded': {
|
|
52
|
-
padding: '0 16px 16px',
|
|
53
|
-
},
|
|
54
|
-
};
|
|
27
|
+
let borderBottom = 'none';
|
|
28
|
+
if (variant === AccordionVariant.Compact) {
|
|
29
|
+
borderBottom = isChild ? 'none' : '1px solid rgb(0,0,0,0.125)';
|
|
55
30
|
}
|
|
56
|
-
|
|
31
|
+
return {
|
|
32
|
+
backgroundColor: contentBg,
|
|
33
|
+
color: contentText,
|
|
34
|
+
opacity: 0,
|
|
35
|
+
padding: '0 16px',
|
|
36
|
+
height: 0,
|
|
37
|
+
overflow: 'hidden',
|
|
38
|
+
transition: '0.3s',
|
|
39
|
+
'&.expanded': {
|
|
40
|
+
padding: `9px 0 9px ${getLevelOffset(level)}px`,
|
|
41
|
+
height: 'auto',
|
|
42
|
+
opacity: 1,
|
|
43
|
+
borderBottom,
|
|
44
|
+
},
|
|
45
|
+
'.nsa-content-padded': {
|
|
46
|
+
padding: '0 16px 16px',
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
});
|
|
57
50
|
|
|
58
51
|
/**
|
|
59
52
|
* NsCollapse component adds css animation while showing children items if prop `isOpen` is true,
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import React, { useEffect, useState } from 'react';
|
|
2
|
+
|
|
2
3
|
import {
|
|
3
|
-
AlertContainer,
|
|
4
4
|
Alert,
|
|
5
|
-
|
|
6
|
-
AlertHead,
|
|
5
|
+
AlertBody,
|
|
7
6
|
AlertCloseButton,
|
|
7
|
+
AlertContainer,
|
|
8
8
|
AlertContent,
|
|
9
9
|
AlertFoot,
|
|
10
|
-
|
|
10
|
+
AlertHead,
|
|
11
|
+
AlertIcon,
|
|
11
12
|
} from './NsAlert.styled';
|
|
13
|
+
|
|
12
14
|
import type { NsAlertProps, ContextType, AlertType } from './types.d';
|
|
13
15
|
import { NsIcon } from '../icon';
|
|
14
16
|
import Header, { colorMap, iconMap } from './Header';
|
|
@@ -59,7 +61,7 @@ export default function NsAlert({
|
|
|
59
61
|
</AlertHead>
|
|
60
62
|
{hasDismissListener && (
|
|
61
63
|
<AlertCloseButton data-testid="alert-close-button" onClick={onDismiss}>
|
|
62
|
-
<NsIcon name="close" size="small" />
|
|
64
|
+
<NsIcon name="close" size="small" cursor="pointer" />
|
|
63
65
|
</AlertCloseButton>
|
|
64
66
|
)}
|
|
65
67
|
<AlertContent type={alertType as AlertType}>
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { styled, ColorUtils } from '@nuskin/foundation-theme';
|
|
2
2
|
import { DarkModeEnabledOption } from '../common.types';
|
|
3
|
-
import { skipDarkModeEnabled } from '../util';
|
|
4
3
|
|
|
5
4
|
//[TODO-Arun] - Use from custom color variables
|
|
6
5
|
// const MAGENTA_COLOR = '#bb29bb';
|
|
@@ -49,10 +48,7 @@ export const Triangle = styled.div`
|
|
|
49
48
|
box-shadow: 0 0 5px 0 ${color('neutral', '20')};
|
|
50
49
|
}
|
|
51
50
|
`;
|
|
52
|
-
const
|
|
53
|
-
shouldForwardProp: skipDarkModeEnabled,
|
|
54
|
-
};
|
|
55
|
-
export const AuthHead = styled('div', options)<DarkModeEnabledOption>`
|
|
51
|
+
export const AuthHead = styled('div')<DarkModeEnabledOption>`
|
|
56
52
|
cursor: pointer;
|
|
57
53
|
padding: 5px 10px;
|
|
58
54
|
display: flex;
|
|
@@ -5,7 +5,6 @@ import { ButtonConfig } from '@nuskin/foundation-theme/src/common/themes/types/b
|
|
|
5
5
|
|
|
6
6
|
import { NsButtonProps } from './types.d';
|
|
7
7
|
import { generateContainedStyle, generateIconOnlyStyles, generateOutlinedStyle, generateTextStyles } from './helper';
|
|
8
|
-
import { skipDarkModeEnabled } from '../util';
|
|
9
8
|
|
|
10
9
|
const { buttonColor, paletteColor } = ColorUtils;
|
|
11
10
|
|
|
@@ -13,49 +12,45 @@ const getButtonConfig = (theme: FoundationTheme.Theme, attribute: keyof ButtonCo
|
|
|
13
12
|
const { config } = theme || {};
|
|
14
13
|
return config?.components?.button?.[attribute] || '';
|
|
15
14
|
};
|
|
16
|
-
const options = {
|
|
17
|
-
shouldForwardProp: skipDarkModeEnabled,
|
|
18
|
-
};
|
|
19
15
|
|
|
20
|
-
export const StyledButton = styled(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
16
|
+
export const StyledButton = styled(MUIButton)<NsButtonProps>(
|
|
17
|
+
({ theme, color, size, darkModeEnabled, variant, iconOnly }) => {
|
|
18
|
+
const borderRadius = getButtonConfig(theme, 'borderRadius') || 0;
|
|
19
|
+
const focusBorderColor = getButtonConfig(theme, 'focusColor');
|
|
20
|
+
// TODO: remove as any from the theme and color
|
|
21
|
+
const sizeStyle = (theme as any)?.components?.button?.['size']?.[size ?? '']?.padding ?? {};
|
|
22
|
+
const btnColor = color as any;
|
|
23
|
+
|
|
24
|
+
let buttonStyles = {};
|
|
25
|
+
const hovered = buttonColor(btnColor, 'hovered')({ theme });
|
|
26
|
+
const pressed = buttonColor(btnColor, 'pressed')({ theme });
|
|
27
|
+
const focused = buttonColor(btnColor, 'focused')({ theme });
|
|
28
|
+
const textColor = paletteColor(btnColor, 'contrastText')({ theme, darkModeEnabled });
|
|
29
|
+
const backgroundColor = paletteColor(btnColor)({ theme, darkModeEnabled });
|
|
30
|
+
|
|
31
|
+
if (variant === 'contained') {
|
|
32
|
+
buttonStyles = generateContainedStyle({ backgroundColor, textColor, hovered, pressed, focused });
|
|
33
|
+
} else if (variant === 'outlined') {
|
|
34
|
+
const activeColor = paletteColor(btnColor)({ theme });
|
|
35
|
+
buttonStyles = generateOutlinedStyle({ borderColor: backgroundColor, hovered, pressed, activeColor });
|
|
36
|
+
} else if (variant === 'text') {
|
|
37
|
+
buttonStyles = generateTextStyles({ underlineColor: backgroundColor, hovered, pressed });
|
|
38
|
+
} else if (iconOnly) {
|
|
39
|
+
buttonStyles = generateIconOnlyStyles();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return {
|
|
43
|
+
gap: '10px',
|
|
44
|
+
borderRadius,
|
|
45
|
+
'&:focus': {
|
|
46
|
+
border: `1px solid ${focusBorderColor} !important`,
|
|
47
|
+
},
|
|
48
|
+
'&:disabled': {
|
|
49
|
+
backgroundColor: buttonColor(btnColor, 'disabled'),
|
|
50
|
+
color: buttonColor(btnColor, 'disabledText'),
|
|
51
|
+
},
|
|
52
|
+
...buttonStyles,
|
|
53
|
+
...sizeStyle,
|
|
54
|
+
};
|
|
46
55
|
}
|
|
47
|
-
|
|
48
|
-
return {
|
|
49
|
-
gap: '10px',
|
|
50
|
-
borderRadius,
|
|
51
|
-
'&:focus': {
|
|
52
|
-
border: `1px solid ${focusBorderColor} !important`,
|
|
53
|
-
},
|
|
54
|
-
'&:disabled': {
|
|
55
|
-
backgroundColor: buttonColor(btnColor, 'disabled'),
|
|
56
|
-
color: buttonColor(btnColor, 'disabledText'),
|
|
57
|
-
},
|
|
58
|
-
...buttonStyles,
|
|
59
|
-
...sizeStyle,
|
|
60
|
-
};
|
|
61
|
-
});
|
|
56
|
+
);
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import Card from '@mui/material/Card';
|
|
2
2
|
import { styled } from '@nuskin/foundation-theme';
|
|
3
|
+
import { shouldNotForwardPropsWithKeys } from '../util';
|
|
3
4
|
|
|
4
5
|
type NsBgCardProps = {
|
|
5
6
|
backgroundImageUrl: string;
|
|
6
7
|
};
|
|
7
8
|
const options = {
|
|
8
|
-
shouldForwardProp: (
|
|
9
|
+
shouldForwardProp: shouldNotForwardPropsWithKeys<NsBgCardProps>(['backgroundImageUrl']),
|
|
9
10
|
};
|
|
10
11
|
const Component = ({ backgroundImageUrl }: NsBgCardProps) => {
|
|
11
12
|
const width = 256;
|
|
@@ -7,7 +7,7 @@ type NsLargeCardProps = {
|
|
|
7
7
|
subtitle?: string;
|
|
8
8
|
intro: string;
|
|
9
9
|
icon?: NsIconNameType;
|
|
10
|
-
buttonVariant
|
|
10
|
+
buttonVariant?: 'text' | 'outlined' | 'contained';
|
|
11
11
|
backgroundImageUrl: string;
|
|
12
12
|
backgroundImageAlt: string;
|
|
13
13
|
cardLink: { href: string; title: string };
|
|
@@ -9,7 +9,7 @@ type NsMediumCardProps = {
|
|
|
9
9
|
icon?: NsIconNameType;
|
|
10
10
|
backgroundImageUrl: string;
|
|
11
11
|
backgroundImageAlt: string;
|
|
12
|
-
buttonVariant
|
|
12
|
+
buttonVariant?: 'text' | 'outlined' | 'contained';
|
|
13
13
|
cardLink: { href: string; title: string };
|
|
14
14
|
};
|
|
15
15
|
|
|
@@ -5,6 +5,7 @@ import { NsTypography, NsLink, NsIcon } from '..';
|
|
|
5
5
|
interface CarousalControlProps {
|
|
6
6
|
next(): void;
|
|
7
7
|
prev(): void;
|
|
8
|
+
viewAllLabel: string;
|
|
8
9
|
viewAllUrl: string;
|
|
9
10
|
}
|
|
10
11
|
/*
|
|
@@ -14,21 +15,24 @@ const Wrapper = styled.div`
|
|
|
14
15
|
display: flex;
|
|
15
16
|
justify-content: flex-end;
|
|
16
17
|
padding: 0 30px;
|
|
17
|
-
margin:
|
|
18
|
+
margin: 30px 20px;
|
|
18
19
|
`;
|
|
19
20
|
const InnerWrapper = styled.div`
|
|
20
21
|
display: flex;
|
|
21
|
-
width: 220px;
|
|
22
22
|
gap: 20px;
|
|
23
23
|
align-items: center;
|
|
24
24
|
`;
|
|
25
|
-
const CarousalControl = ({ next, prev, viewAllUrl }: CarousalControlProps) => {
|
|
25
|
+
const CarousalControl = ({ next, prev, viewAllUrl, viewAllLabel }: CarousalControlProps) => {
|
|
26
26
|
return (
|
|
27
27
|
<Wrapper>
|
|
28
28
|
<InnerWrapper>
|
|
29
|
-
|
|
30
|
-
<
|
|
31
|
-
|
|
29
|
+
{viewAllUrl ? (
|
|
30
|
+
<NsLink href={viewAllUrl} underlineOnHover={false}>
|
|
31
|
+
<NsTypography decoration="underline" variant={'h5'}>
|
|
32
|
+
{viewAllLabel}
|
|
33
|
+
</NsTypography>
|
|
34
|
+
</NsLink>
|
|
35
|
+
) : null}
|
|
32
36
|
<IconWrapper onClick={prev} className="carousal-prev-button">
|
|
33
37
|
<NsIcon name="arrowLeft" />
|
|
34
38
|
</IconWrapper>
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import Box from '@mui/material/Box';
|
|
2
2
|
import { styled } from '@nuskin/foundation-theme';
|
|
3
|
-
import {
|
|
3
|
+
import { ReactNode, useCallback, useRef } from 'react';
|
|
4
4
|
import Slider from 'react-slick';
|
|
5
|
-
|
|
6
|
-
import 'slick-carousel/slick/slick-theme.css';
|
|
7
|
-
import defaultCarousalSettings from './slickSetting';
|
|
5
|
+
|
|
8
6
|
import CarousalControl from './CarousalControl';
|
|
7
|
+
import defaultCarousalSettings from './slickSetting';
|
|
8
|
+
|
|
9
|
+
import 'slick-carousel/slick/slick-theme.css';
|
|
10
|
+
import 'slick-carousel/slick/slick.css';
|
|
9
11
|
|
|
10
12
|
const SlickContainer = styled(Box)(() => {
|
|
11
13
|
return {
|
|
@@ -18,13 +20,21 @@ const SlickContainer = styled(Box)(() => {
|
|
|
18
20
|
});
|
|
19
21
|
interface CarousalProps<T = any> {
|
|
20
22
|
entries: T[];
|
|
21
|
-
// eslint-disable-next-line no-unused-vars
|
|
22
23
|
renderEntry(entry: T, index: number): ReactNode;
|
|
23
|
-
allEntryLink
|
|
24
|
+
allEntryLink?: string;
|
|
25
|
+
allEntryLabel?: string;
|
|
24
26
|
settings: any;
|
|
27
|
+
showControlButtons?: boolean;
|
|
25
28
|
}
|
|
26
29
|
|
|
27
|
-
export default function NsCarousal({
|
|
30
|
+
export default function NsCarousal({
|
|
31
|
+
entries,
|
|
32
|
+
renderEntry,
|
|
33
|
+
allEntryLink = '',
|
|
34
|
+
settings,
|
|
35
|
+
allEntryLabel = 'View All',
|
|
36
|
+
showControlButtons = true,
|
|
37
|
+
}: CarousalProps) {
|
|
28
38
|
const sliderRef = useRef();
|
|
29
39
|
const prev = useCallback(() => {
|
|
30
40
|
if (sliderRef.current) {
|
|
@@ -40,9 +50,12 @@ export default function NsCarousal({ entries, renderEntry, allEntryLink, setting
|
|
|
40
50
|
}, [sliderRef]);
|
|
41
51
|
return (
|
|
42
52
|
<SlickContainer className="brand-carousal">
|
|
43
|
-
|
|
53
|
+
{showControlButtons ? (
|
|
54
|
+
<CarousalControl prev={prev} next={next} viewAllUrl={allEntryLink} viewAllLabel={allEntryLabel} />
|
|
55
|
+
) : null}
|
|
44
56
|
<Slider {...{ ...defaultCarousalSettings, ...settings }} ref={sliderRef as any}>
|
|
45
57
|
{entries.map((entry, index) => {
|
|
58
|
+
|
|
46
59
|
return renderEntry(entry, index);
|
|
47
60
|
})}
|
|
48
61
|
</Slider>
|
|
@@ -3,16 +3,11 @@ import Slider from 'react-slick';
|
|
|
3
3
|
import { NsScrollingCarousalProps } from '../';
|
|
4
4
|
import { styled } from '@nuskin/foundation-theme';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
type StyledType = {
|
|
7
|
+
dotsBottomPixel?: number;
|
|
8
8
|
};
|
|
9
9
|
|
|
10
|
-
const StyledDiv = styled(
|
|
11
|
-
'div',
|
|
12
|
-
options
|
|
13
|
-
)<{
|
|
14
|
-
dotsBottomPixel?: number;
|
|
15
|
-
}>(({ dotsBottomPixel }) => {
|
|
10
|
+
const StyledDiv = styled('div')<StyledType>(({ dotsBottomPixel }) => {
|
|
16
11
|
return {
|
|
17
12
|
'.slick-dots': {
|
|
18
13
|
zIndex: 9,
|
|
@@ -50,6 +45,7 @@ const NsScrollingCarousal = ({
|
|
|
50
45
|
}, [stillSeconds, scrollSeconds, settings]);
|
|
51
46
|
return (
|
|
52
47
|
<StyledDiv
|
|
48
|
+
className="scrolling-carousal-wrapper"
|
|
53
49
|
dotsBottomPixel={dotsBottomPixel}
|
|
54
50
|
data-testid={additionalProps?.testid ?? 'scrolling-carousal-test-id'}
|
|
55
51
|
>
|
|
@@ -12,6 +12,13 @@ export default {
|
|
|
12
12
|
title: 'Components/Containers/NsCarousal/Brand',
|
|
13
13
|
component: NsCarousal,
|
|
14
14
|
argTypes: {},
|
|
15
|
+
decorators: [
|
|
16
|
+
(Story) => (
|
|
17
|
+
<div style={{ width: 800 }}>
|
|
18
|
+
<Story />
|
|
19
|
+
</div>
|
|
20
|
+
),
|
|
21
|
+
],
|
|
15
22
|
} as MetaStory;
|
|
16
23
|
|
|
17
24
|
export const Default: Story = {
|
|
@@ -3,14 +3,17 @@ import { Box } from '@mui/material';
|
|
|
3
3
|
import { styled } from '@nuskin/foundation-theme';
|
|
4
4
|
import { NsColumnControlProps, sizeObjectType } from './types.d';
|
|
5
5
|
import { getColumnSizes } from './utils';
|
|
6
|
+
import { shouldNotForwardPropsWithKeys } from '../util';
|
|
6
7
|
|
|
7
|
-
const options = {
|
|
8
|
-
shouldForwardProp: (propKey: string) => propKey !== 'sizes',
|
|
9
|
-
};
|
|
10
8
|
type StyledDivProps = {
|
|
11
9
|
sizes: sizeObjectType;
|
|
12
10
|
gap?: number;
|
|
13
11
|
};
|
|
12
|
+
|
|
13
|
+
const options = {
|
|
14
|
+
shouldForwardProp: shouldNotForwardPropsWithKeys<StyledDivProps>(['sizes']),
|
|
15
|
+
};
|
|
16
|
+
|
|
14
17
|
const descMaxWidthBreakpoints = [960, 600];
|
|
15
18
|
|
|
16
19
|
/* media queries */
|
|
@@ -2,10 +2,7 @@ import { Box } from '@mui/material';
|
|
|
2
2
|
import { styled } from '@nuskin/foundation-theme';
|
|
3
3
|
import { sizeObjectType } from '../types';
|
|
4
4
|
import { commonStyles, getPercentArray } from './common';
|
|
5
|
-
|
|
6
|
-
const options = {
|
|
7
|
-
shouldForwardProp: (propKey: string) => !['sizes', 'gap', 'isFullWidth'].includes(propKey),
|
|
8
|
-
};
|
|
5
|
+
import { shouldNotForwardPropsWithKeys } from '../../../common/util';
|
|
9
6
|
|
|
10
7
|
type StyledFlexProps = {
|
|
11
8
|
sizes: sizeObjectType;
|
|
@@ -13,6 +10,10 @@ type StyledFlexProps = {
|
|
|
13
10
|
isFullWidth: boolean;
|
|
14
11
|
};
|
|
15
12
|
|
|
13
|
+
const options = {
|
|
14
|
+
shouldForwardProp: shouldNotForwardPropsWithKeys<StyledFlexProps>(['sizes']),
|
|
15
|
+
};
|
|
16
|
+
|
|
16
17
|
/* main wrapper for column control using css flex */
|
|
17
18
|
export const StyledFlex = styled(
|
|
18
19
|
Box as any,
|
|
@@ -2,6 +2,7 @@ import { Box } from '@mui/material';
|
|
|
2
2
|
import { styled } from '@nuskin/foundation-theme';
|
|
3
3
|
import { sizeObjectType } from '../types';
|
|
4
4
|
import { commonStyles, getPercentArray } from './common';
|
|
5
|
+
import { shouldNotForwardPropsWithKeys } from '../../../common/util';
|
|
5
6
|
|
|
6
7
|
type StyledGridProps = {
|
|
7
8
|
sizes: sizeObjectType;
|
|
@@ -9,7 +10,7 @@ type StyledGridProps = {
|
|
|
9
10
|
isFullWidth: boolean;
|
|
10
11
|
};
|
|
11
12
|
const options = {
|
|
12
|
-
shouldForwardProp: (
|
|
13
|
+
shouldForwardProp: shouldNotForwardPropsWithKeys<StyledGridProps>(['sizes']),
|
|
13
14
|
};
|
|
14
15
|
|
|
15
16
|
/* main wrapper for column control using css grid */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { PaletteColors } from '@nuskin/foundation-theme';
|
|
2
|
+
|
|
2
3
|
import type { StoryObj, Meta } from '@storybook/react';
|
|
3
4
|
import { withCenterDecorator } from '@/stories/decorators/withCenterDecorator';
|
|
4
5
|
import { NsIcon, NsIconVariants } from './';
|
|
@@ -24,6 +25,47 @@ export default {
|
|
|
24
25
|
colorOverride: {
|
|
25
26
|
control: 'color',
|
|
26
27
|
},
|
|
28
|
+
cursor: {
|
|
29
|
+
control: 'select',
|
|
30
|
+
options: [
|
|
31
|
+
'auto',
|
|
32
|
+
'default',
|
|
33
|
+
'none',
|
|
34
|
+
'context-menu',
|
|
35
|
+
'help',
|
|
36
|
+
'pointer',
|
|
37
|
+
'progress',
|
|
38
|
+
'wait',
|
|
39
|
+
'cell',
|
|
40
|
+
'crosshair',
|
|
41
|
+
'text',
|
|
42
|
+
'vertical-text',
|
|
43
|
+
'alias',
|
|
44
|
+
'copy',
|
|
45
|
+
'move',
|
|
46
|
+
'no-drop',
|
|
47
|
+
'not-allowed',
|
|
48
|
+
'grab',
|
|
49
|
+
'grabbing',
|
|
50
|
+
'e-resize',
|
|
51
|
+
'n-resize',
|
|
52
|
+
'ne-resize',
|
|
53
|
+
'nw-resize',
|
|
54
|
+
's-resize',
|
|
55
|
+
'se-resize',
|
|
56
|
+
'sw-resize',
|
|
57
|
+
'w-resize',
|
|
58
|
+
'ew-resize',
|
|
59
|
+
'ns-resize',
|
|
60
|
+
'nesw-resize',
|
|
61
|
+
'nwse-resize',
|
|
62
|
+
'col-resize',
|
|
63
|
+
'row-resize',
|
|
64
|
+
'all-scroll',
|
|
65
|
+
'zoom-in',
|
|
66
|
+
'zoom-out',
|
|
67
|
+
],
|
|
68
|
+
},
|
|
27
69
|
},
|
|
28
70
|
args: {
|
|
29
71
|
size: 'large',
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { styled } from '@nuskin/foundation-theme';
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
import { NsIconProps, NsIconSizeType } from './types.d';
|
|
3
4
|
|
|
4
5
|
export const iconSize: Record<NsIconSizeType, string> = {
|
|
5
6
|
small: '16px',
|
|
@@ -7,13 +8,14 @@ export const iconSize: Record<NsIconSizeType, string> = {
|
|
|
7
8
|
large: '24px',
|
|
8
9
|
xLarge: '30px',
|
|
9
10
|
};
|
|
10
|
-
type IconWrapperType = { size: NsIconSizeType };
|
|
11
|
+
type IconWrapperType = { size: NsIconSizeType; cursor: NsIconProps['cursor'] };
|
|
11
12
|
|
|
12
|
-
export const IconWrapper = styled('div')<IconWrapperType>(({ size }) => {
|
|
13
|
+
export const IconWrapper = styled('div')<IconWrapperType>(({ size, cursor }) => {
|
|
13
14
|
return {
|
|
14
15
|
display: 'flex',
|
|
15
16
|
placeContent: 'center',
|
|
16
17
|
placeItems: 'center',
|
|
18
|
+
cursor,
|
|
17
19
|
svg: {
|
|
18
20
|
width: iconSize[size],
|
|
19
21
|
height: iconSize[size],
|
|
@@ -15,6 +15,7 @@ const NsIcon = ({
|
|
|
15
15
|
className,
|
|
16
16
|
colorOverride,
|
|
17
17
|
onClick = () => {},
|
|
18
|
+
cursor = 'pointer',
|
|
18
19
|
...rest
|
|
19
20
|
}: NsIconProps) => {
|
|
20
21
|
const Icon = IconVariants[name as NsIconNameType];
|
|
@@ -25,7 +26,14 @@ const NsIcon = ({
|
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
return (
|
|
28
|
-
<IconWrapper
|
|
29
|
+
<IconWrapper
|
|
30
|
+
{...rest}
|
|
31
|
+
data-testid={testId}
|
|
32
|
+
size={size || 'large'}
|
|
33
|
+
className={className}
|
|
34
|
+
onClick={onClick}
|
|
35
|
+
cursor={cursor}
|
|
36
|
+
>
|
|
29
37
|
<Icon color={colorOverride ? colorOverride : (iconColor as any)} />
|
|
30
38
|
</IconWrapper>
|
|
31
39
|
);
|
|
@@ -13,4 +13,41 @@ export type NsIconProps = HTMLProps & {
|
|
|
13
13
|
color?: FoundationTheme.PaletteColors;
|
|
14
14
|
testId?: string;
|
|
15
15
|
colorOverride?: string;
|
|
16
|
+
cursor?:
|
|
17
|
+
| 'auto'
|
|
18
|
+
| 'default'
|
|
19
|
+
| 'none'
|
|
20
|
+
| 'context-menu'
|
|
21
|
+
| 'help'
|
|
22
|
+
| 'pointer'
|
|
23
|
+
| 'progress'
|
|
24
|
+
| 'wait'
|
|
25
|
+
| 'cell'
|
|
26
|
+
| 'crosshair'
|
|
27
|
+
| 'text'
|
|
28
|
+
| 'vertical-text'
|
|
29
|
+
| 'alias'
|
|
30
|
+
| 'copy'
|
|
31
|
+
| 'move'
|
|
32
|
+
| 'no-drop'
|
|
33
|
+
| 'not-allowed'
|
|
34
|
+
| 'grab'
|
|
35
|
+
| 'grabbing'
|
|
36
|
+
| 'e-resize'
|
|
37
|
+
| 'n-resize'
|
|
38
|
+
| 'ne-resize'
|
|
39
|
+
| 'nw-resize'
|
|
40
|
+
| 's-resize'
|
|
41
|
+
| 'se-resize'
|
|
42
|
+
| 'sw-resize'
|
|
43
|
+
| 'w-resize'
|
|
44
|
+
| 'ew-resize'
|
|
45
|
+
| 'ns-resize'
|
|
46
|
+
| 'nesw-resize'
|
|
47
|
+
| 'nwse-resize'
|
|
48
|
+
| 'col-resize'
|
|
49
|
+
| 'row-resize'
|
|
50
|
+
| 'all-scroll'
|
|
51
|
+
| 'zoom-in'
|
|
52
|
+
| 'zoom-out';
|
|
16
53
|
};
|
|
@@ -5,8 +5,8 @@ import { fieldStateType } from './types.d';
|
|
|
5
5
|
const { isDarkMode } = ColorUtils;
|
|
6
6
|
const { colors } = nuskinTheme;
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
type InputWrapperType = {
|
|
9
|
+
fieldState: fieldStateType;
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
const getInputBorderColor = (
|
|
@@ -23,14 +23,7 @@ const getInputBorderColor = (
|
|
|
23
23
|
}
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
fieldState: fieldStateType;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const InputWrapper = styled(
|
|
31
|
-
Box,
|
|
32
|
-
options
|
|
33
|
-
)<InputWrapperType>(({ theme, fieldState }) => {
|
|
26
|
+
const InputWrapper = styled(Box)<InputWrapperType>(({ theme, fieldState }) => {
|
|
34
27
|
/* default value added so that unit tests do not fail */
|
|
35
28
|
const { palette = { primary: { main: '', contrastText: '' } } } = theme;
|
|
36
29
|
const isLight = isDarkMode({ theme });
|
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @author [Vijayaprathap Kumar] (vpkumar@nuskin.com)
|
|
3
|
-
* NsLink.styled.tsx
|
|
4
|
-
* @description Styled Components for NsLink are defined here
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
1
|
import { styled } from '@nuskin/foundation-theme';
|
|
8
2
|
import MUILink from '@mui/material/Link';
|
|
9
3
|
import NextLink from 'next/link';
|
|
10
4
|
|
|
11
|
-
/** Prop Types doe Styled components */
|
|
12
5
|
type StyledProps = {
|
|
13
6
|
disabled?: boolean;
|
|
14
7
|
$underlineOnHover?: boolean;
|
|
@@ -53,16 +46,13 @@ const getLinkStyles = ({ disabled, $underlineOnHover = true }: StyledProps) => {
|
|
|
53
46
|
}
|
|
54
47
|
return '';
|
|
55
48
|
};
|
|
56
|
-
const options = {
|
|
57
|
-
shouldForwardProp: (propKey: string) => propKey !== '$underlineOnHover',
|
|
58
|
-
};
|
|
59
49
|
|
|
60
|
-
export const StyledNextLink = styled(NextLink
|
|
50
|
+
export const StyledNextLink = styled(NextLink)<StyledProps>`
|
|
61
51
|
${linkDefaultStyles};
|
|
62
52
|
${getLinkStyles}
|
|
63
53
|
`;
|
|
64
54
|
|
|
65
|
-
export const StyledLink = styled(MUILink
|
|
55
|
+
export const StyledLink = styled(MUILink)<StyledProps>`
|
|
66
56
|
${linkDefaultStyles};
|
|
67
57
|
${getLinkStyles}
|
|
68
58
|
`;
|
|
@@ -8,12 +8,6 @@ import React, { PropsWithChildren } from 'react';
|
|
|
8
8
|
import { StyledLink, StyledNextLink } from './NsLink.styled';
|
|
9
9
|
import { NsLinkProps } from './types.d';
|
|
10
10
|
|
|
11
|
-
/**
|
|
12
|
-
* @component NsLink
|
|
13
|
-
*
|
|
14
|
-
* Component for displaying an Link tag
|
|
15
|
-
*
|
|
16
|
-
*/
|
|
17
11
|
const NsLink = (props: PropsWithChildren<NsLinkProps>) => {
|
|
18
12
|
const {
|
|
19
13
|
className,
|
|
@@ -25,6 +19,7 @@ const NsLink = (props: PropsWithChildren<NsLinkProps>) => {
|
|
|
25
19
|
children,
|
|
26
20
|
passHref,
|
|
27
21
|
prefetch,
|
|
22
|
+
disabled,
|
|
28
23
|
} = props;
|
|
29
24
|
|
|
30
25
|
if (isSsr) {
|
|
@@ -33,9 +28,10 @@ const NsLink = (props: PropsWithChildren<NsLinkProps>) => {
|
|
|
33
28
|
className={className}
|
|
34
29
|
href={href}
|
|
35
30
|
$underlineOnHover={underlineOnHover}
|
|
36
|
-
{...additionalProps}
|
|
37
31
|
passHref={passHref}
|
|
38
32
|
prefetch={prefetch}
|
|
33
|
+
disabled={disabled}
|
|
34
|
+
{...additionalProps}
|
|
39
35
|
>
|
|
40
36
|
{children}
|
|
41
37
|
</StyledNextLink>
|
|
@@ -46,6 +42,7 @@ const NsLink = (props: PropsWithChildren<NsLinkProps>) => {
|
|
|
46
42
|
<StyledLink
|
|
47
43
|
className={className}
|
|
48
44
|
href={href}
|
|
45
|
+
disabled={disabled}
|
|
49
46
|
$underlineOnHover={underlineOnHover}
|
|
50
47
|
target={target}
|
|
51
48
|
{...additionalProps}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Radio, FormControlLabel, FormLabel, RadioGroup } from '@mui/material';
|
|
2
2
|
import { ColorUtils, FoundationTheme, styled } from '@nuskin/foundation-theme';
|
|
3
|
-
import { skipDarkModeEnabled } from '../util';
|
|
4
3
|
|
|
5
4
|
const { paletteColor, isDarkMode, color } = ColorUtils;
|
|
6
5
|
|
|
@@ -36,13 +35,13 @@ export const StyledFormControlLabel = styled(FormControlLabel)<{ darkModeEnabled
|
|
|
36
35
|
},
|
|
37
36
|
};
|
|
38
37
|
});
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
|
|
39
|
+
type StyledRadioPropsType = {
|
|
40
|
+
color: FoundationTheme.PaletteColors;
|
|
41
|
+
darkModeEnabled?: boolean;
|
|
41
42
|
};
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
options
|
|
45
|
-
)<{ color: FoundationTheme.PaletteColors; darkModeEnabled?: boolean }>(({ theme, color, darkModeEnabled }) => {
|
|
43
|
+
|
|
44
|
+
export const StyledRadioGroup = styled(RadioGroup)<StyledRadioPropsType>(({ theme, color, darkModeEnabled }) => {
|
|
46
45
|
return {
|
|
47
46
|
marginTop: '10px',
|
|
48
47
|
'.MuiRadio-root.custom-radio.Mui-checked': {
|
package/src/common/util.ts
CHANGED