@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.
Files changed (40) hide show
  1. package/package.json +9 -4
  2. package/src/common/accordion/specs/NsAccordion.spec.tsx +3 -1
  3. package/src/common/accordion/specs/NsAccordionHeader.spec.tsx +21 -5
  4. package/src/common/accordion/specs/NsAccordionItem.spec.tsx +29 -5
  5. package/src/common/accordion/specs/NsCollapse.spec.tsx +4 -4
  6. package/src/common/accordion/specs/NsToggleSection.spec.tsx +10 -5
  7. package/src/common/alert/NsAlert.spec.tsx +0 -1
  8. package/src/common/alert/NsAlert.styled.ts +10 -10
  9. package/src/common/alert/NsAlert.tsx +4 -3
  10. package/src/common/auth-dropdown/NsAuthDropdown.styled.ts +12 -11
  11. package/src/common/auth-dropdown/NsAuthDropdown.tsx +2 -1
  12. package/src/common/auth-dropdown/types.d.ts +3 -1
  13. package/src/common/autocomplete/NsAutocomplete.spec.tsx +10 -0
  14. package/src/common/autocomplete/NsAutocomplete.stories.tsx +44 -6
  15. package/src/common/autocomplete/NsAutocomplete.tsx +18 -15
  16. package/src/common/autocomplete/types.d.ts +8 -6
  17. package/src/common/brand-components/NsBrandComponent.tsx +3 -0
  18. package/src/common/breadcrumb/NsBreadcrumb.tsx +4 -2
  19. package/src/common/button/NsButton.spec.tsx +1 -1
  20. package/src/common/button/NsButton.stories.tsx +1 -1
  21. package/src/common/button/NsButton.styled.tsx +25 -23
  22. package/src/common/button/NsButton.tsx +9 -2
  23. package/src/common/button/types.d.ts +1 -0
  24. package/src/common/common.types.d.ts +1 -0
  25. package/src/common/dropdown/types.d.ts +3 -1
  26. package/src/common/flag/NsFlag.spec.tsx +1 -0
  27. package/src/common/flag/NsFlag.styled.tsx +5 -5
  28. package/src/common/icon/types.d.ts +1 -0
  29. package/src/common/input/InputFieldWrapper.tsx +4 -4
  30. package/src/common/label/NsLabel.tsx +11 -7
  31. package/src/common/nav-tab/NsNavTab.styled.tsx +7 -4
  32. package/src/common/radiogroup/NsRadioGroup.spec.tsx +2 -1
  33. package/src/common/radiogroup/NsRadioGroup.stories.tsx +2 -1
  34. package/src/common/radiogroup/NsRadioGroup.styled.tsx +26 -32
  35. package/src/common/radiogroup/NsRadioGroup.tsx +20 -5
  36. package/src/common/radiogroup/types.d.ts +4 -3
  37. package/src/common/select/NsSelect.styled.tsx +19 -23
  38. package/src/common/table/NsTable.styled.ts +69 -66
  39. package/src/common/text-strip/NsTextStrip.tsx +10 -7
  40. package/src/common/typography/Typography.styled.tsx +3 -3
@@ -1,5 +1,5 @@
1
1
  import { FormControl } from '@mui/material';
2
- import { NsRadioGroupProps } from './types';
2
+
3
3
  import {
4
4
  StyledHelperText,
5
5
  StyledFormControlLabel,
@@ -9,19 +9,33 @@ import {
9
9
  } from './NsRadioGroup.styled';
10
10
  import { NsLabel } from '../label';
11
11
 
12
+ import { NsRadioGroupProps } from './types';
13
+
12
14
  const NsRadioGroup = (props: NsRadioGroupProps) => {
13
- const { items, additionalSlot, label, onChange, color, disable, size, additionalProps, labelFontSize } = props;
15
+ const {
16
+ items,
17
+ additionalSlot,
18
+ label,
19
+ onChange,
20
+ color,
21
+ disable,
22
+ size,
23
+ additionalProps,
24
+ labelFontSize,
25
+ darkModeEnabled = true
26
+ } = props;
14
27
 
15
28
  return (
16
29
  <>
17
30
  <FormControl data-testid={additionalProps?.testid}>
18
31
  <NsLabel size={labelFontSize}>{label}</NsLabel>
19
32
  <StyledRadioGroup
20
- aria-labelledby="demo-radio-buttons-group-label"
33
+ aria-labelledby="radio-buttons-group-label"
21
34
  defaultValue={items?.[0]?.value}
22
35
  name="radio-buttons-group"
23
36
  onChange={onChange}
24
37
  color={color}
38
+ darkModeEnabled={darkModeEnabled}
25
39
  >
26
40
  {items?.map((item, index) => (
27
41
  <StyledFormControlLabel
@@ -31,13 +45,14 @@ const NsRadioGroup = (props: NsRadioGroupProps) => {
31
45
  control={<StyledRadio className="custom-radio" />}
32
46
  label={item?.label}
33
47
  disabled={disable}
48
+ darkModeEnabled={darkModeEnabled}
34
49
  />
35
50
  ))}
36
51
  </StyledRadioGroup>
37
52
  </FormControl>
38
- {additionalSlot && <StyledHelperText className={`ml-${size}`}>
53
+ {additionalSlot ? <StyledHelperText className={`ml-${size}`}>
39
54
  <StyledSpan className="text-sm">{additionalSlot}</StyledSpan>
40
- </StyledHelperText>}
55
+ </StyledHelperText> : null}
41
56
 
42
57
  </>
43
58
  );
@@ -1,16 +1,17 @@
1
+ import { FoundationTheme } from '@nuskin/foundation-theme';
1
2
  import { AdditionalProps } from '../common.types';
2
3
 
3
- export type NsRadioGroupProps = AdditionalProps & {
4
+ export type NsRadioGroupProps = {
4
5
  disable : boolean ;
5
6
  name : string;
6
7
  additionalSlot : string;
7
8
  label : string ;
8
9
  items: RadioItems[] ;
9
- color : string;
10
+ color: FoundationTheme.PaletteColors;
10
11
  size : number;
11
12
  labelFontSize:number,
12
13
  onChange : () => void;
13
- }
14
+ } & AdditionalProps;
14
15
 
15
16
  export type RadioItems = {
16
17
  label : string ;
@@ -1,5 +1,5 @@
1
1
  import { styled, ColorUtils, FoundationTheme } from '@nuskin/foundation-theme';
2
- const { getPaletteColor, getAppColor } = ColorUtils;
2
+ const { color, paletteColor, isDarkMode } = ColorUtils;
3
3
 
4
4
  export const SelectContainer = styled.div<{ disabled: boolean }>`
5
5
  position: relative;
@@ -14,8 +14,8 @@ export const SelectHead = styled.div<{ type: string; disabled: boolean }>`
14
14
  justify-content: space-between;
15
15
  align-items: center;
16
16
  border: ${({ type, theme }) =>
17
- type === 'outlined' ? `1px solid ${getAppColor(theme, 'primary', 'black')}` : 'none'};
18
- color: ${({ theme }) => getPaletteColor(theme, 'primary')};
17
+ type === 'outlined' ? `1px solid ${color('primary', 'black')({ theme })}` : 'none'};
18
+ color: ${paletteColor('primary')};
19
19
  width: 207px;
20
20
  position: relative;
21
21
  z-index: 2;
@@ -28,38 +28,34 @@ export const SelectButton = styled.div`
28
28
  export const SelectList = styled.div<{ borderColor: FoundationTheme.PaletteColors }>`
29
29
  position: absolute;
30
30
  z-index: 100;
31
- border: 1px solid ${({ borderColor, theme }) => getPaletteColor(theme, borderColor)};
31
+ border: 1px solid ${({ borderColor, theme }) => paletteColor(borderColor)({ theme })};
32
32
  padding: 0;
33
33
  margin: 0;
34
34
  width: -webkit-fill-available;
35
- color: ${({ theme }) => getPaletteColor(theme, 'primary', 'main')};
36
- background-color: ${({ theme }) => getPaletteColor(theme, 'primary', 'contrastText')};
35
+ color: ${paletteColor('primary')};
36
+ background-color: ${paletteColor('primary', 'contrastText')};
37
37
  `;
38
- const getIsLight = (theme: FoundationTheme.Theme) => {
39
- const { palette = { primary: { main: '', contrastText: '' } } } = theme;
40
- return palette.primary.main === getAppColor(theme, 'primary', 'black');
41
- };
42
38
 
43
- const getDividerColor = (theme: FoundationTheme.Theme) => {
44
- const isLight = getIsLight(theme);
45
- const dividerColor = isLight ? getAppColor(theme, 'neutral', '30') : getAppColor(theme, 'neutral', '20');
39
+ const getDividerColor = (props: { theme: FoundationTheme.Theme}) => {
40
+ const dividerColor = !isDarkMode(props) ? color('neutral', '30')(props) : color('neutral', '20')(props);
46
41
  return dividerColor;
47
42
  };
48
- const getListBgColor = (theme: FoundationTheme.Theme) => {
49
- const isLight = getIsLight(theme);
50
- const bgColor = isLight ? getAppColor(theme, 'accentColorB', '10') : getAppColor(theme, 'accentColorB', '50');
43
+
44
+ const getListBgColor = (props: { theme: FoundationTheme.Theme }) => {
45
+ const bgColor = !isDarkMode(props) ? color('accentColorB', '10')(props) : color('accentColorB', '50')(props);
51
46
  return bgColor;
52
47
  };
48
+
53
49
  export const ListItemContainer = styled.div<{ showListDivider: boolean; isSelected: boolean }>`
54
50
  ${({ showListDivider, isSelected, theme }) => `
55
51
  cursor: pointer;
56
52
  padding: 5px 0;
57
- border-bottom: 1px solid ${showListDivider ? getDividerColor(theme) : 'none'};
58
- background-color: ${isSelected ? getPaletteColor(theme, 'primary') : 'white'};
53
+ border-bottom: 1px solid ${showListDivider ? getDividerColor({ theme }) : 'none'};
54
+ background-color: ${isSelected ? paletteColor('primary')({ theme }) : 'white'};
59
55
  color: ${isSelected ? 'white' : 'black'};
60
56
 
61
57
  &:hover {
62
- background-color: ${getListBgColor(theme)};
58
+ background-color: ${getListBgColor({ theme })};
63
59
  }
64
60
 
65
61
  &:last-child {
@@ -71,13 +67,13 @@ export const ListItemContainer = styled.div<{ showListDivider: boolean; isSelect
71
67
  export const ListItem = styled.div<{ isSelected: boolean}>`
72
68
  padding: 5px 10px;
73
69
  border-left: ${({ isSelected, theme }) =>
74
- isSelected ? `2px solid ${getPaletteColor(theme, 'primary')}` : 'none'};
70
+ isSelected ? `2px solid ${paletteColor('primary')({ theme })}` : 'none'};
75
71
  background-color: ${({ isSelected, theme }) =>
76
- isSelected ? getPaletteColor(theme, 'primary', 'main') : 'white'};
72
+ isSelected ? paletteColor('primary', 'main')({ theme }) : 'white'};
77
73
  color: ${({ isSelected }) => (isSelected ? 'white' : 'black')};
78
74
  &:hover {
79
75
  background-color: ${({ isSelected, theme }) =>
80
- isSelected ? getPaletteColor(theme, 'primary', 'main') : getListBgColor(theme)};
76
+ isSelected ? paletteColor('primary')({ theme }) : getListBgColor({ theme })};
81
77
  font-weight: bold;
82
78
  }
83
79
  `;
@@ -85,5 +81,5 @@ export const ListItem = styled.div<{ isSelected: boolean}>`
85
81
  export const SelectLabel = styled.label`
86
82
  display: block;
87
83
  margin-bottom: 5px;
88
- color: ${({ theme }) => getPaletteColor(theme, 'primary')};
84
+ color: ${paletteColor('primary')} !important;
89
85
  `;
@@ -1,7 +1,7 @@
1
1
  // TODO: const ariel = #f8e9f8;
2
2
 
3
- import { styled } from '@nuskin/foundation-theme';
4
- import { getAppColor } from '@nuskin/foundation-theme/src/utils/color-utils';
3
+ import { styled, ColorUtils } from '@nuskin/foundation-theme';
4
+
5
5
  import {
6
6
  Table,
7
7
  TableContainer,
@@ -12,8 +12,10 @@ import {
12
12
  import Pagination from '@mui/material/Pagination';
13
13
  import LinearProgress from '@mui/material/LinearProgress';
14
14
 
15
+ const { color } = ColorUtils;
16
+
15
17
  export const StyledTableContainer= styled(TableContainer)`
16
- background-color: ${({ theme }) => getAppColor(theme, 'primary', 'white')};
18
+ background-color: ${color('primary', 'white')};
17
19
  `;
18
20
 
19
21
  export const StyledTable = styled(Table)`
@@ -21,53 +23,54 @@ export const StyledTable = styled(Table)`
21
23
  `;
22
24
 
23
25
  export const StyledTableSortLabel = styled(TableSortLabel)`
24
- font-size: 12px;
25
- text-transform: uppercase;
26
- font-weight: 600;
27
- line-height: 16px;
28
- letter-spacing: 0.05em;
29
- color: rgba(0, 0, 0, 0.54);
30
- &:hover {
31
- color: ${({ theme }) => getAppColor(theme, 'primary', 'black')};
32
- }
33
- `;
26
+ font-size: 12px;
27
+ text-transform: uppercase;
28
+ font-weight: 600;
29
+ line-height: 16px;
30
+ letter-spacing: 0.05em;
31
+ color: rgba(0, 0, 0, 0.54);
32
+ &:hover {
33
+ color: ${color('primary', 'black')};
34
+ }
35
+ `;
34
36
 
35
37
  export const StyledTableLabel = styled.span`
36
- font-size: 12px;
37
- text-transform: uppercase;
38
- font-weight: 700;
39
- line-height: 16px;
40
- letter-spacing: 0.05em;
41
- color: rgba(0, 0, 0, 0.54);
42
- &:hover {
43
- cursor: default;
44
- }
38
+ font-size: 12px;
39
+ text-transform: uppercase;
40
+ font-weight: 700;
41
+ line-height: 16px;
42
+ letter-spacing: 0.05em;
43
+ color: rgba(0, 0, 0, 0.54);
44
+ &:hover {
45
+ cursor: default;
46
+ }
45
47
  `;
46
48
 
47
49
  export const StyledPageComponent = styled.div`
48
- background-color: ${({ theme }) => getAppColor(theme, 'primary', 'white')};
50
+ background-color: ${color('primary', 'white')};
49
51
  `;
50
52
 
51
53
  export const StyledEmptyRow = styled(TableRow)<{emptyRows: number}>`
52
- height: ${({ emptyRows }) => 48 * emptyRows}px;
54
+ height: ${({ emptyRows }) => 48 * emptyRows}px;
53
55
  `;
54
56
 
57
+ // [Todo-Arun] - Move f8e9f8 to custom color palette
55
58
  export const StyledTableRow = styled(TableRow)`
56
- &:hover {
57
- background-color: #f8e9f8 !important;
58
- }
59
+ &:hover {
60
+ background-color: #f8e9f8 !important;
61
+ }
59
62
  `;
60
63
 
61
64
  export const StyledTableLastCell = styled(TableCell)`
62
- display: flex;
63
- height: 49px;
64
- align-items: center;
65
- padding: 0 24px;
66
- margin-bottom: -0.5px;
65
+ display: flex;
66
+ height: 49px;
67
+ align-items: center;
68
+ padding: 0 24px;
69
+ margin-bottom: -0.5px;
67
70
 
68
- .action {
69
- margin-left: auto;
70
- }
71
+ .action {
72
+ margin-left: auto;
73
+ }
71
74
  `;
72
75
 
73
76
  export const StyledOriginalTableCell = styled(TableCell)`
@@ -76,43 +79,43 @@ export const StyledOriginalTableCell = styled(TableCell)`
76
79
  `;
77
80
 
78
81
  export const StyledPagination = styled(Pagination)`
79
- .MuiPagination-ul {
80
- display: flex;
81
- justify-content: flex-end;
82
- background-color: ${({ theme }) => getAppColor(theme, 'primary', 'white')};
83
- }
84
- & .MuiPaginationItem-previousNext {
85
- margin: 0.3rem 10px;
86
- width: 2rem;
87
- height: 2rem;
88
- border-radius: 4px;
89
- }
90
- & .MuiPaginationItem-page {
91
- border-radius: 0px;
92
- width: auto;
93
- min-width: 34px;
94
- padding: 0 5px;
95
- font-size: 16px;
96
- line-height: 17px;
97
- border-color: ${({ theme }) => getAppColor(theme, 'primary', 'black')};
98
- }
99
- & .MuiPaginationItem-root.Mui-selected {
100
- background-color: ${({ theme }) => getAppColor(theme, 'primary', 'black')};
101
- color: ${({ theme }) => getAppColor(theme, 'primary', 'white')};
102
- }
82
+ .MuiPagination-ul {
83
+ display: flex;
84
+ justify-content: flex-end;
85
+ background-color: ${color('primary', 'white')};
86
+ }
87
+ & .MuiPaginationItem-previousNext {
88
+ margin: 0.3rem 10px;
89
+ width: 2rem;
90
+ height: 2rem;
91
+ border-radius: 4px;
92
+ }
93
+ & .MuiPaginationItem-page {
94
+ border-radius: 0px;
95
+ width: auto;
96
+ min-width: 34px;
97
+ padding: 0 5px;
98
+ font-size: 16px;
99
+ line-height: 17px;
100
+ border-color: ${color('primary', 'black')};
101
+ }
102
+ & .MuiPaginationItem-root.Mui-selected {
103
+ background-color: ${color('primary', 'black')};
104
+ color: ${color('primary', 'white')};
105
+ }
103
106
  `;
104
107
 
105
108
  export const StyledExpandCell= styled(TableCell)`
106
- padding-bottom: 0;
107
- padding-top: 0;
108
- &.remove {
109
- border: 0;
110
- }
109
+ padding-bottom: 0;
110
+ padding-top: 0;
111
+ &.remove {
112
+ border: 0;
113
+ }
111
114
  `;
112
115
 
113
116
  export const StyledProgressCell = styled(TableCell)`
114
- padding: 0;
115
- border: 0;
117
+ padding: 0;
118
+ border: 0;
116
119
  `;
117
120
 
118
121
  export const StyledLinearProgress = styled(LinearProgress)`
@@ -8,14 +8,16 @@ import React from 'react';
8
8
  import { NsTextStripProps } from './types.d';
9
9
  import { NsTypography } from '../typography';
10
10
  import { NsLink } from '../link';
11
- import { styled, ColorUtils, FoundationTheme } from '@nuskin/foundation-theme';
12
- const { getPaletteColor, getAppColor } = ColorUtils;
13
- const getIsLight = (theme: FoundationTheme.Theme) => {
14
- const { palette = { primary: { main: '', contrastText: '' } } } = theme;
15
- return palette.primary.main === getAppColor(theme, 'primary', 'black');
16
- };
11
+ import { styled, ColorUtils } from '@nuskin/foundation-theme';
12
+
13
+ const { isDarkMode, paletteColor, color } = ColorUtils;
14
+
17
15
  const StyledHeader = styled.header`
18
- background: ${({ theme }) => (getIsLight(theme) ? '#f5f5f5' : getPaletteColor(theme, 'primary', 'contrastText'))};
16
+ background: ${(props) => (
17
+ !isDarkMode(props)
18
+ ? color('primary', 'gray')
19
+ : paletteColor('primary', 'contrastText')
20
+ )};
19
21
  display: flex;
20
22
  flex-direction: column;
21
23
  min-height: 60px;
@@ -25,6 +27,7 @@ const StyledHeader = styled.header`
25
27
  font-weight: 600;
26
28
  }
27
29
  `;
30
+
28
31
  const NsTextStrip = (props: NsTextStripProps) => {
29
32
  const { alignment = 'center', text, description, link, className = '' } = props;
30
33
 
@@ -1,7 +1,7 @@
1
1
  import { styled, ColorUtils } from '@nuskin/foundation-theme';
2
2
  import { NsTypographyProps } from './types.d';
3
3
 
4
- const { getPaletteColor } = ColorUtils;
4
+ const { paletteColor } = ColorUtils;
5
5
 
6
6
  const variantStyles = {
7
7
  h1: 'font-size: 36px; line-height: 44px;',
@@ -29,8 +29,8 @@ const fontWeightMap = {
29
29
 
30
30
  export const StyledTypography = styled.div<NsTypographyProps>`
31
31
  font-family: Inter;
32
- color: ${({ color, theme, colorOverride }) =>
33
- colorOverride?.startsWith('#') ? colorOverride : getPaletteColor(theme, color)};
32
+ color: ${({ color, colorOverride }) =>
33
+ colorOverride?.startsWith('#') ? colorOverride : paletteColor(color)};
34
34
  font-weight: ${({ weight = 'normal' }) => fontWeightMap[weight]};
35
35
  font-style: ${({ fontStyle }) => fontStyle};
36
36
  ${({ variant = 'h1' }) => variantStyles[variant]};