@nuskin/foundation-ui-components 1.12.0 → 1.14.0
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/autocomplete/NsAutocomplete.spec.tsx +6 -5
- package/src/common/card/CardButton.tsx +11 -2
- package/src/common/card/NsMediumCard.tsx +35 -4
- package/src/common/card/index.ts +1 -0
- package/src/common/card/stories/NsMediumCard.stories.tsx +3 -1
- package/src/common/cart-icon/NsCartIcon.styled.tsx +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
1
3
|
import { render, screen, waitFor } from '@/test-utils/index';
|
|
2
4
|
import userEvent from '@testing-library/user-event';
|
|
3
|
-
import React from 'react';
|
|
4
5
|
|
|
5
6
|
import { AutocompleteMockList } from '../autocomplete/mock/MockData';
|
|
6
7
|
import { OptionUiComponent } from '../autocomplete/mock/MockUI';
|
|
@@ -43,7 +44,7 @@ describe('CustomAutocomplete', () => {
|
|
|
43
44
|
},
|
|
44
45
|
{ timeout: 5000 }
|
|
45
46
|
);
|
|
46
|
-
},
|
|
47
|
+
}, 160000);
|
|
47
48
|
|
|
48
49
|
it('4. selects an option when clicking on it', async () => {
|
|
49
50
|
const onChangeMock = jest.fn();
|
|
@@ -55,7 +56,7 @@ describe('CustomAutocomplete', () => {
|
|
|
55
56
|
await userEvent.click(optionLi);
|
|
56
57
|
});
|
|
57
58
|
expect(onChangeMock).toHaveBeenCalled();
|
|
58
|
-
},
|
|
59
|
+
}, 160000);
|
|
59
60
|
|
|
60
61
|
it('5. should load more options when clicking load more button', async () => {
|
|
61
62
|
const seeMore = {
|
|
@@ -71,7 +72,7 @@ describe('CustomAutocomplete', () => {
|
|
|
71
72
|
await userEvent.click(loadMoreButton);
|
|
72
73
|
});
|
|
73
74
|
expect(seeMore.onSeeMore).toHaveBeenCalled();
|
|
74
|
-
},
|
|
75
|
+
}, 160000);
|
|
75
76
|
|
|
76
77
|
it('6. should clear options when clicking clear button', async () => {
|
|
77
78
|
const clear = {
|
|
@@ -86,5 +87,5 @@ describe('CustomAutocomplete', () => {
|
|
|
86
87
|
const clearButton = screen.getByText(clear.text);
|
|
87
88
|
await userEvent.click(clearButton);
|
|
88
89
|
});
|
|
89
|
-
},
|
|
90
|
+
}, 160000);
|
|
90
91
|
});
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
NsButton,
|
|
3
|
+
NsIcon,
|
|
4
|
+
} from '../';
|
|
2
5
|
import { NsCardButton } from './types';
|
|
3
6
|
|
|
4
7
|
const CardButton = ({
|
|
@@ -18,7 +21,13 @@ const CardButton = ({
|
|
|
18
21
|
color={buttonColor}
|
|
19
22
|
variant={buttonVariant}
|
|
20
23
|
fullWidth={fullWidth}
|
|
21
|
-
endIcon={
|
|
24
|
+
endIcon={
|
|
25
|
+
buttonVariant === 'text' ? (
|
|
26
|
+
<NsIcon name="arrowRight" size="small" color="primary" />
|
|
27
|
+
) : endIcon ? (
|
|
28
|
+
<NsIcon name={endIcon} color={buttonColor} />
|
|
29
|
+
) : null
|
|
30
|
+
}
|
|
22
31
|
>
|
|
23
32
|
{buttonText}
|
|
24
33
|
</NsButton>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Box from '@mui/material/Box';
|
|
2
2
|
import { styled } from '@nuskin/foundation-theme';
|
|
3
|
+
|
|
3
4
|
import { NsImage, NsTypography } from '../';
|
|
4
5
|
import CardButton from './CardButton';
|
|
5
6
|
import { NsCardButton } from './types';
|
|
@@ -12,21 +13,42 @@ type NsMediumCardProps = {
|
|
|
12
13
|
backgroundImageAlt: string;
|
|
13
14
|
button?: NsCardButton;
|
|
14
15
|
className?: string;
|
|
16
|
+
fluid?: boolean;
|
|
17
|
+
};
|
|
18
|
+
const textVariantButton = {
|
|
19
|
+
padding: '0 0 4px',
|
|
20
|
+
gap: '7px',
|
|
21
|
+
span: {
|
|
22
|
+
margin: 0,
|
|
23
|
+
},
|
|
24
|
+
'>div': {
|
|
25
|
+
margin: 0,
|
|
26
|
+
borderBottom: '1px solid #252525',
|
|
27
|
+
},
|
|
28
|
+
'.MuiButton-endIcon': {
|
|
29
|
+
svg: {
|
|
30
|
+
g: {
|
|
31
|
+
strokeWidth: 2,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
},
|
|
15
35
|
};
|
|
36
|
+
const buttonVariantStyle = (variant: string) => (variant === 'text' ? { a: textVariantButton } : {});
|
|
37
|
+
const CardContainer = styled(Box)<{ fluid: boolean; variant: string }>(({ fluid, variant }) => {
|
|
38
|
+
const textVariantCssModification = buttonVariantStyle(variant);
|
|
16
39
|
|
|
17
|
-
const CardContainer = styled(Box)(() => {
|
|
18
40
|
return {
|
|
19
41
|
display: 'flex',
|
|
20
42
|
flexDirection: 'column',
|
|
21
43
|
position: 'relative',
|
|
22
44
|
'.image': {
|
|
23
|
-
width: '300px',
|
|
45
|
+
width: fluid ? '100%' : '300px',
|
|
24
46
|
height: '300px',
|
|
25
47
|
objectFit: 'cover',
|
|
26
48
|
},
|
|
27
49
|
'.content': {
|
|
28
50
|
display: 'flex',
|
|
29
|
-
width: '300px',
|
|
51
|
+
width: fluid ? '100%' : '300px',
|
|
30
52
|
flexDirection: 'column',
|
|
31
53
|
},
|
|
32
54
|
'.subtitle': {
|
|
@@ -40,6 +62,7 @@ const CardContainer = styled(Box)(() => {
|
|
|
40
62
|
},
|
|
41
63
|
'.cta': {
|
|
42
64
|
marginTop: '10px',
|
|
65
|
+
...textVariantCssModification,
|
|
43
66
|
},
|
|
44
67
|
};
|
|
45
68
|
});
|
|
@@ -52,9 +75,17 @@ export default function NsMediumCard({
|
|
|
52
75
|
backgroundImageAlt,
|
|
53
76
|
button,
|
|
54
77
|
className,
|
|
78
|
+
fluid,
|
|
55
79
|
}: NsMediumCardProps) {
|
|
56
80
|
return (
|
|
57
|
-
<CardContainer
|
|
81
|
+
<CardContainer
|
|
82
|
+
className={className}
|
|
83
|
+
role="medium-card"
|
|
84
|
+
component="div"
|
|
85
|
+
data-testid="medium-card"
|
|
86
|
+
fluid={fluid || false}
|
|
87
|
+
variant={button?.buttonVariant ?? ''}
|
|
88
|
+
>
|
|
58
89
|
<NsImage alt={backgroundImageAlt} src={backgroundImageUrl} className="image" />
|
|
59
90
|
<div className="content">
|
|
60
91
|
<NsTypography variant="h5" color="primary" className="title" weight={titleFontWeight}>
|
package/src/common/card/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { StoryObj, Meta } from '@storybook/react';
|
|
2
1
|
import { withCenterDecorator } from '@/stories/decorators/withCenterDecorator';
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
|
|
3
4
|
import { NsMediumCard } from '../';
|
|
4
5
|
|
|
5
6
|
type ComponentType = typeof NsMediumCard;
|
|
@@ -30,5 +31,6 @@ export const Default: Story = {
|
|
|
30
31
|
buttonColor: 'primary',
|
|
31
32
|
url: 'https://www.forceforgood.org/',
|
|
32
33
|
},
|
|
34
|
+
fluid: false,
|
|
33
35
|
},
|
|
34
36
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Badge, Theme } from '@mui/material';
|
|
2
|
-
import { ColorUtils,
|
|
2
|
+
import { ColorUtils, FoundationTheme, styled } from '@nuskin/foundation-theme';
|
|
3
3
|
|
|
4
4
|
type ItemCountParams = {
|
|
5
5
|
theme?: Theme;
|
|
@@ -8,6 +8,7 @@ type ItemCountParams = {
|
|
|
8
8
|
const { paletteColor } = ColorUtils;
|
|
9
9
|
export const StyledBadge = styled(Badge)<ItemCountParams>`
|
|
10
10
|
& .MuiBadge-badge {
|
|
11
|
+
cursor: pointer;
|
|
11
12
|
background-color: ${({ bgcolor, theme }) => paletteColor(bgcolor)({ theme })};
|
|
12
13
|
color: ${({ bgcolor, theme }) => paletteColor(bgcolor, 'contrastText')({ theme })};
|
|
13
14
|
}
|