@nuskin/foundation-ui-components 1.21.0 → 1.22.0-cx130-1102.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuskin/foundation-ui-components",
3
- "version": "1.21.0",
3
+ "version": "1.22.0-cx130-1102.2",
4
4
  "description": "It is a foundation library written in react, that provides common components to all UI pages",
5
5
  "main": "src/common/index.ts",
6
6
  "repository": {
@@ -46,7 +46,7 @@
46
46
  "@mui/material": "5.14.16",
47
47
  "@mui/utils": "^5.14.16",
48
48
  "@next/font": "13.5.6",
49
- "@nuskin/foundation-theme": "1.4.1",
49
+ "@nuskin/foundation-theme": "^1.5.0",
50
50
  "@types/react": "^18.2.34",
51
51
  "@types/react-dom": "^18.2.14",
52
52
  "cliui": "^8.0.1",
@@ -1,7 +1,6 @@
1
- import { Themed } from '../common.types';
2
- import { ColorUtils } from '@nuskin/foundation-theme';
3
- import { AllColorKeyType } from '@nuskin/foundation-theme/src/common/themes/genome-colors/AllColors';
1
+ import { AllColorKeyType, ColorUtils } from '@nuskin/foundation-theme';
4
2
 
3
+ import { Themed } from '../common.types';
5
4
  import { AccordionVariant, AccordionVariantType } from './enums';
6
5
 
7
6
  const { getGenomeColor } = ColorUtils;
@@ -1,10 +1,11 @@
1
- import { styled, ColorUtils } from '@nuskin/foundation-theme';
2
- import { DarkModeEnabledOption } from '../common.types';
1
+ import {
2
+ ColorUtils,
3
+ styled,
4
+ } from '@nuskin/foundation-theme';
3
5
 
4
- //[TODO-Arun] - Use from custom color variables
5
- // const MAGENTA_COLOR = '#bb29bb';
6
+ import { DarkModeEnabledOption } from '../common.types';
6
7
 
7
- const { color, paletteColor } = ColorUtils;
8
+ const { getGenomeColor } = ColorUtils;
8
9
 
9
10
  export const AuthDropdownContainer = styled.div`
10
11
  position: relative;
@@ -21,7 +22,7 @@ export const AuthDropdown = styled.div`
21
22
  z-index: 600;
22
23
  top: calc(100% + 18px);
23
24
  right: 5%;
24
- box-shadow: 0 0 5px 0 ${color('neutral', '20')};
25
+ box-shadow: 0 0 5px 0 ${({ theme }) => getGenomeColor(theme, 'N70')};
25
26
  transition: all 0.15s ease-in-out;
26
27
  padding: 25px;
27
28
  `;
@@ -41,11 +42,11 @@ export const Triangle = styled.div`
41
42
  position: absolute;
42
43
  width: 14px;
43
44
  height: 14px;
44
- background-color: ${color('primary', 'white')};
45
+ background-color: ${({ theme }) => getGenomeColor(theme, 'N10')};
45
46
  transform: rotate(45deg);
46
47
  top: 17px;
47
48
  left: 5px;
48
- box-shadow: 0 0 5px 0 ${color('neutral', '20')};
49
+ box-shadow: 0 0 5px 0 ${({ theme }) => getGenomeColor(theme, 'N70')};
49
50
  }
50
51
  `;
51
52
  export const AuthHead = styled('div')<DarkModeEnabledOption>`
@@ -54,7 +55,7 @@ export const AuthHead = styled('div')<DarkModeEnabledOption>`
54
55
  display: flex;
55
56
  justify-content: space-between;
56
57
  align-items: center;
57
- color: ${paletteColor('primary')};
58
+ color: ${({ theme }) => getGenomeColor(theme, 'N100')};
58
59
  `;
59
60
 
60
61
  export const Button = styled.div`
@@ -69,18 +70,18 @@ export const SignInButton = styled(Link)`
69
70
  display: block;
70
71
  padding: 13px;
71
72
  width: 100%;
72
- background-color: ${color('primary', 'black')};
73
- color: ${color('primary', 'white')};
73
+ background-color: ${({ theme }) => getGenomeColor(theme, 'N100')};
74
+ color: ${({ theme }) => getGenomeColor(theme, 'N10')};
74
75
  border: 0;
75
76
  font-size: 16px;
76
77
  &:hover {
77
- background-color: ${color('neutral', '70')};
78
+ background-color: ${({ theme }) => getGenomeColor(theme, 'N60')};
78
79
  }
79
80
  `;
80
81
 
81
82
  export const SignUpLinkContainer = styled.div`
82
83
  margin-top: 15px;
83
- color: ${color('primary', 'black')};
84
+ color: ${({ theme }) => getGenomeColor(theme, 'N100')};
84
85
  font-size: 13px;
85
86
  line-height: 16px;
86
87
  text-align: left;
@@ -92,11 +93,11 @@ export const SignUpLink = styled(Link)`
92
93
  font-size: 13px;
93
94
  line-height: 16px;
94
95
  text-decoration: none;
95
- color: ${color('primary', 'black')};
96
+ color: ${({ theme }) => getGenomeColor(theme, 'N100')};
96
97
  position: relative;
97
98
  transition: all 0.15s ease-in-out;
98
99
  &:hover {
99
- color: ${color('neutral', '70')};
100
+ color: ${({ theme }) => getGenomeColor(theme, 'N60')};
100
101
  font-size: 14px;
101
102
  }
102
103
  &:hover::after {
@@ -111,7 +112,7 @@ export const SignUpLink = styled(Link)`
111
112
  right: 0;
112
113
  width: 100%;
113
114
  height: 1px;
114
- background-color: ${color('primary', 'black')};
115
+ background-color: ${({ theme }) => getGenomeColor(theme, 'N100')};
115
116
  transition: all 0.15s ease-in-out;
116
117
  opacity: 0;
117
118
  visibility: hidden;
@@ -1,7 +1,9 @@
1
- import { styled } from '@nuskin/foundation-theme';
2
1
  import React, { useMemo } from 'react';
2
+
3
3
  import Slider from 'react-slick';
4
4
 
5
+ import { styled } from '@nuskin/foundation-theme';
6
+
5
7
  import { NsScrollingCarousalProps } from '../';
6
8
 
7
9
  type StyledType = {
@@ -1,35 +1,56 @@
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
1
  import { NsScrollingCarousal, NsTextStrip } from '@/common/';
2
+ import { withCenterDecorator } from '@/stories/decorators/withCenterDecorator';
3
+ import type { Meta, StoryObj } from '@storybook/react';
9
4
 
10
5
  type ComponentType = typeof NsScrollingCarousal;
11
6
  type Story = StoryObj<ComponentType>;
12
7
  type MetaStory = Meta<ComponentType>;
13
8
 
14
- export const renderSlide = (slide: any, i: number) => <NsTextStrip key={i} {...slide} />;
9
+ const renderSlide = (slide: any, i: number) => <NsTextStrip key={i} {...slide} />;
15
10
 
16
- export const slides = [
11
+ const slides = [
17
12
  {
18
- text: 'Hello Nike App',
19
13
  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' },
14
+ link: { href: 'https://www.nike.com/in/help/a/shipping-delivery-gs', title: 'Hello Nike App' },
21
15
  alignment: 'center',
22
16
  },
23
17
  {
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' },
18
+ description: '',
19
+ link: {
20
+ href: 'https://www.nike.com/in/help/a/shipping-delivery-gs',
21
+ title: 'Shop All Our New Markdowns, New Styles on Sale: Up to 40% Off (empty description)',
22
+ },
27
23
  alignment: 'center',
28
24
  },
29
25
  {
30
- text: 'Free Delivery',
31
26
  // 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' },
27
+ link: { href: 'https://www.nike.com/in/help/a/shipping-delivery-gs', title: 'Free Delivery' },
28
+ alignment: 'center',
29
+ },
30
+ {
31
+ description:
32
+ 'Download the app to access everything Nike Download the app to access everything Nike Download the app to access everything Nike Download the app to access everything Nike',
33
+ link: {
34
+ href: 'https://www.nike.com/in/help/a/shipping-delivery-gs',
35
+ title: ' Hello Nike AppHello Nike App Hello Nike App Hello Nike App',
36
+ },
37
+ alignment: 'center',
38
+ },
39
+ {
40
+ description: '',
41
+ link: {
42
+ href: 'https://www.nike.com/in/help/a/shipping-delivery-gs',
43
+ title: 'Shop All Our New Markdowns, New Styles on Sale: Up to 40% Off (empty description)',
44
+ },
45
+ alignment: 'center',
46
+ },
47
+ {
48
+ link: { href: 'https://www.nike.com/in/help/a/shipping-delivery-gs', title: 'Free Delivery' },
49
+ alignment: 'center',
50
+ },
51
+ {
52
+ description: 'Empty href Empty href Empty href Empty href Empty href Empty href Empty href Empty href',
53
+ link: { href: '', title: '' },
33
54
  alignment: 'center',
34
55
  },
35
56
  ];
@@ -41,12 +62,17 @@ export default {
41
62
  args: {
42
63
  slides,
43
64
  renderSlide,
44
- stillSeconds: 3,
45
- scrollSeconds: 1,
65
+ stillSeconds: 6,
66
+ scrollSeconds: 4,
46
67
  additionalProps: {
47
68
  testid: 'scrolling-carousal',
48
69
  },
49
70
  },
71
+ render: (args) => (
72
+ <div style={{ width: '90vw' }}>
73
+ <NsScrollingCarousal {...args} />
74
+ </div>
75
+ ),
50
76
  } as MetaStory;
51
77
 
52
78
  export const ScrollingText: Story = {};
@@ -1,30 +1,27 @@
1
1
  import React from 'react';
2
- import { render, screen } from '@testing-library/react';
2
+
3
3
  import { NsTextStrip } from '@/common/';
4
+ import { render, screen } from '@testing-library/react';
4
5
 
5
6
  describe('NsTextStrip component', () => {
6
7
  it('renders text description and link', () => {
7
- const text = 'Free Delivery';
8
8
  const description = 'Download the app to access everything Nike';
9
- const link = { href: 'https://www.nike.com/in/help/a/shipping-delivery-gs', title: 'View Details' };
10
- render(<NsTextStrip link={link} description={description} text={text} />);
11
- const element = screen.getByText(text);
9
+ const link = { href: 'https://www.nike.com/in/help/a/shipping-delivery-gs', title: 'Free Delivery' };
10
+ const { container } = render(<NsTextStrip link={link} description={description} />);
11
+ const element = screen.getByText(link.title);
12
12
  expect(element).toBeInTheDocument();
13
13
  const descElement = screen.getByText(description);
14
14
  expect(descElement).toBeInTheDocument();
15
- const anchorElement = screen.getByText(link.title);
16
- expect(anchorElement.tagName).toBe('A');
15
+ const anchorElement = container.querySelector('a');
17
16
  expect(anchorElement).toHaveAttribute('href', link.href);
18
17
  });
19
18
  it('does not have anchor when link is undefined', () => {
20
- const text = 'Free Delivery';
21
19
  const description = 'Download the app to access everything Nike';
22
- let link = { title: 'hi' };
23
- render(<NsTextStrip link={link} description={description} text={text} />);
24
- const element = screen.getByText(text);
20
+ let link = { title: 'Free Delivery' };
21
+ render(<NsTextStrip link={link} description={description} />);
22
+ const element = screen.getByText(link.title);
25
23
  expect(element).toBeInTheDocument();
26
24
  const descElement = screen.getByText(description);
27
25
  expect(descElement).toBeInTheDocument();
28
- expect(() => screen.getByText(link.title)).toThrow();
29
26
  });
30
27
  });
@@ -3,9 +3,9 @@
3
3
  * @description NsTextStrip component.
4
4
  */
5
5
 
6
- import type { StoryObj, Meta } from '@storybook/react';
7
6
  import { NsTextStrip } from '@/common/';
8
7
  import { withCenterDecorator } from '@/stories/decorators/withCenterDecorator';
8
+ import type { Meta, StoryObj } from '@storybook/react';
9
9
 
10
10
  type ComponentType = typeof NsTextStrip;
11
11
  type Story = StoryObj<ComponentType>;
@@ -23,11 +23,39 @@ export default {
23
23
  },
24
24
  },
25
25
  args: {
26
- text: 'Free Delivery',
27
- description: 'Download the app to access everything Nike',
28
- link: { href: 'https://www.nike.com/in/help/a/shipping-delivery-gs', title: 'View Details' },
26
+ description: 'Download the app to access everything Nike. View Details',
27
+ link: { href: 'https://www.nike.com/in/help/a/shipping-delivery-gs', title: 'Free Delivery' },
29
28
  alignment: 'center',
30
29
  },
31
30
  } as MetaStory;
32
31
 
33
32
  export const DefaultTextStrip: Story = {};
33
+ export const NoDescription: Story = {
34
+ args: {
35
+ description: '',
36
+ link: {
37
+ href: 'https://www.nike.com/in/help/a/shipping-delivery-gs',
38
+ title: 'Shop All Our New Markdowns, New Styles on Sale: Up to 40% Off (empty description)',
39
+ },
40
+ alignment: 'center',
41
+ },
42
+ };
43
+ export const LongDescription: Story = {
44
+ args: {
45
+ description:
46
+ 'Download the app to access everything Nike Download the app to access everything Nike Download the app to access everything Nike Download the app to access everything Nike',
47
+ link: {
48
+ href: 'https://www.nike.com/in/help/a/shipping-delivery-gs',
49
+ title: 'Shop All Our New Markdowns, New Styles on Sale: Up to 40% Off (empty description)',
50
+ },
51
+ alignment: 'center',
52
+ },
53
+ };
54
+
55
+ export const NoTitle: Story = {
56
+ args: {
57
+ description: 'Empty href Empty href Empty href Empty href Empty href Empty href Empty href Empty href',
58
+ link: { href: '', title: '' },
59
+ alignment: 'center',
60
+ },
61
+ };
@@ -5,41 +5,52 @@
5
5
 
6
6
  import React from 'react';
7
7
 
8
- import { NsTextStripProps } from './types.d';
9
- import { NsTypography } from '../typography';
8
+ import { ColorUtils, styled } from '@nuskin/foundation-theme';
9
+
10
10
  import { NsLink } from '../link';
11
- import { styled, ColorUtils } from '@nuskin/foundation-theme';
12
-
13
- const { isDarkMode, paletteColor, color } = ColorUtils;
14
-
15
- const StyledHeader = styled.header`
16
- background: ${(props) => (
17
- !isDarkMode(props)
18
- ? color('primary', 'gray')
19
- : paletteColor('primary', 'contrastText')
20
- )};
21
- display: flex;
22
- flex-direction: column;
11
+ import { NsTypography } from '../typography';
12
+ import { NsTextStripProps } from './types.d';
13
+
14
+ const { getGenomeColor } = ColorUtils;
15
+
16
+ const StyledHeader = styled(NsLink)`
17
+ background: ${({ theme }) => getGenomeColor(theme, 'N20')};
23
18
  min-height: 60px;
24
- padding: 2px 10px 12px;
19
+ padding: 4px 12px;
25
20
  a {
26
21
  text-decoration: underline;
27
22
  font-weight: 600;
28
23
  }
24
+ .text-strip-title {
25
+ max-width: 90%;
26
+ overflow: hidden;
27
+ text-overflow: ellipsis;
28
+ }
29
+ .text-strip-description {
30
+ max-width: 90%;
31
+ overflow: hidden;
32
+ text-overflow: ellipsis;
33
+ }
29
34
  `;
30
35
 
31
36
  const NsTextStrip = (props: NsTextStripProps) => {
32
- const { alignment = 'center', text, description, link, className = '' } = props;
37
+ const { alignment = 'center', description, link, className = '' } = props;
33
38
 
34
39
  return (
35
- <StyledHeader className={`${className} items-${alignment}`}>
36
- <NsTypography variant="title-m" className="tracking-normal">
37
- {text}
38
- </NsTypography>
39
- <NsTypography variant="body-xs">
40
- {description}&nbsp;
41
- {link?.href ? <NsLink href={link.href}>{link.title}</NsLink> : ''}
42
- </NsTypography>
40
+ <StyledHeader
41
+ href={link?.href ?? ''}
42
+ className={`${className} items-${alignment} justify-center min-h-16 flex flex-col gap-1`}
43
+ >
44
+ {link?.title ? (
45
+ <NsTypography weight="bold" variant="label-m" className="text-strip-title whitespace-nowrapd" noSpacing>
46
+ <span title={link?.title}>{link?.title}</span>
47
+ </NsTypography>
48
+ ) : null}
49
+ {description ? (
50
+ <NsTypography className="text-strip-description whitespace-nowrap" variant="body-m" noSpacing>
51
+ <span title={description}>{description}</span>
52
+ </NsTypography>
53
+ ) : null}
43
54
  </StyledHeader>
44
55
  );
45
56
  };
@@ -3,11 +3,10 @@ import { AdditionalProps } from '../common.types';
3
3
  export type AlignmentType = 'start' | 'center' | 'end';
4
4
 
5
5
  export type TextCtaDataType = {
6
- link?: {
6
+ link: {
7
7
  href?: string;
8
8
  title?: string;
9
9
  };
10
- text?: string;
11
10
  description?: string;
12
11
  };
13
12
  export type NsTextStripProps = {