@takaro/lib-components 0.4.6 → 0.4.7

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 (50) hide show
  1. package/Dockerfile.dev +1 -1
  2. package/package.json +1 -1
  3. package/src/components/actions/Button/Button.stories.tsx +0 -37
  4. package/src/components/actions/Button/__snapshots__/Button.test.tsx.snap +1 -1
  5. package/src/components/actions/Button/index.tsx +2 -8
  6. package/src/components/actions/Button/style.ts +0 -7
  7. package/src/components/actions/ContextMenu/index.tsx +0 -1
  8. package/src/components/actions/IconButton/__snapshots__/IconButton.test.tsx.snap +1 -1
  9. package/src/components/actions/IconButton/style.ts +0 -8
  10. package/src/components/actions/ToggleButton/style.ts +2 -1
  11. package/src/components/charts/echarts/EChartsBase.tsx +0 -1
  12. package/src/components/data/Avatar/style.ts +1 -1
  13. package/src/components/data/Chip/index.tsx +3 -17
  14. package/src/components/data/Chip/style.ts +4 -40
  15. package/src/components/data/CopyId/index.tsx +0 -2
  16. package/src/components/data/Stats/Stat.tsx +3 -0
  17. package/src/components/feedback/Alert/__snapshots__/Alert.test.tsx.snap +1 -1
  18. package/src/components/feedback/Alert/index.tsx +1 -4
  19. package/src/components/feedback/Alert/style.ts +1 -3
  20. package/src/components/feedback/ErrorFallback/index.tsx +1 -0
  21. package/src/components/feedback/ErrorPage/index.tsx +3 -3
  22. package/src/components/feedback/IconTooltip/index.tsx +0 -2
  23. package/src/components/feedback/NotificationBanner/index.tsx +6 -7
  24. package/src/components/feedback/Skeleton/__snapshots__/Skeleton.test.tsx.snap +1 -1
  25. package/src/components/feedback/Tooltip/TooltipContent.tsx +2 -4
  26. package/src/components/feedback/snacks/CookieConsent/style.ts +0 -1
  27. package/src/components/feedback/snacks/Default/style.ts +0 -1
  28. package/src/components/feedback/snacks/Drawer/index.tsx +0 -1
  29. package/src/components/feedback/snacks/NetworkDetector/index.tsx +0 -1
  30. package/src/components/inputs/Date/DatePicker/style.ts +0 -1
  31. package/src/components/inputs/Date/subcomponents/Calendar/style.ts +4 -2
  32. package/src/components/inputs/Date/subcomponents/TimePicker/style.ts +4 -2
  33. package/src/components/inputs/RadioGroup/RadioItem.tsx +1 -1
  34. package/src/components/inputs/selects/SubComponents/style.ts +1 -3
  35. package/src/components/inputs/selects/sharedStyle.ts +0 -1
  36. package/src/components/navigation/HorizontalNav/style.ts +1 -1
  37. package/src/components/navigation/IconNav/index.tsx +2 -1
  38. package/src/components/navigation/Steppers/Stepper/style.ts +2 -1
  39. package/src/components/other/ActionMenu/index.tsx +1 -4
  40. package/src/components/other/ActionMenu/style.ts +2 -3
  41. package/src/components/other/ClipBoard/__snapshots__/ClipBoard.test.tsx.snap +2 -2
  42. package/src/components/other/Empty/__snapshots__/Empty.test.tsx.snap +1 -1
  43. package/src/components/other/Plan/index.tsx +1 -1
  44. package/src/components/visual/Divider/__snapshots__/Divider.test.tsx.snap +1 -1
  45. package/src/styled/GlobalStyle.ts +1 -0
  46. package/src/styled/Snackbar.tsx +0 -1
  47. package/src/styled/index.ts +2 -3
  48. package/src/styled/{theme.ts → theme.tsx} +42 -19
  49. package/src/stories/Elevation.mdx +0 -56
  50. package/src/styled/elevation.ts +0 -20
package/Dockerfile.dev CHANGED
@@ -1,4 +1,4 @@
1
- FROM node:22.11.0-alpine AS build
1
+ FROM node:24.11.0-alpine AS build
2
2
 
3
3
  ENV NODE_ENV=development
4
4
  WORKDIR /app
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@takaro/lib-components",
3
- "version": "0.4.6",
3
+ "version": "0.4.7",
4
4
  "private": false,
5
5
  "description": "Takaro UI is a simple and customizable component library to build React apps faster within the Takaro eco system",
6
6
  "license": "AGPL-3.0-or-later",
@@ -145,42 +145,5 @@ export const Examples = () => (
145
145
  >
146
146
  Loading Button
147
147
  </Button>
148
-
149
- {/* white */}
150
- <Button
151
- onClick={() => {
152
- /* */
153
- }}
154
- variant="white"
155
- >
156
- White Button
157
- </Button>
158
- <Button
159
- icon={<Icon size={20} />}
160
- onClick={() => {
161
- /* */
162
- }}
163
- variant="white"
164
- >
165
- Icon Button
166
- </Button>
167
- <Button
168
- disabled
169
- onClick={() => {
170
- /* */
171
- }}
172
- variant="white"
173
- >
174
- Disabled Button
175
- </Button>
176
- <Button
177
- isLoading
178
- onClick={() => {
179
- /* */
180
- }}
181
- variant="white"
182
- >
183
- Loading Button
184
- </Button>
185
148
  </>
186
149
  );
@@ -3,7 +3,7 @@
3
3
  exports[`Should render <Button/> 1`] = `
4
4
  <div>
5
5
  <button
6
- class="sc-gvPdwL csCrvu"
6
+ class="sc-pKqro cGkgJf"
7
7
  color="primary"
8
8
  tabindex="0"
9
9
  type="button"
@@ -1,6 +1,6 @@
1
1
  import { JSX, cloneElement, forwardRef, MouseEvent as ReactMouseEvent, ReactElement, PropsWithChildren } from 'react';
2
2
  import { Spinner } from '../../../components';
3
- import { ButtonColor, Default, Outline, Clear, White } from './style';
3
+ import { ButtonColor, Default, Outline, Clear } from './style';
4
4
  import { Size, Variant } from '../../../styled';
5
5
 
6
6
  export interface ButtonProps {
@@ -14,7 +14,7 @@ export interface ButtonProps {
14
14
  size?: Size;
15
15
  type?: 'submit' | 'reset' | 'button';
16
16
  // TODO: clear should be renamed to text
17
- variant?: Variant | 'white' | 'clear';
17
+ variant?: Variant | 'clear';
18
18
  color?: ButtonColor | 'white';
19
19
  /// When nesting forms a button can be linked to only fire the form with the given name.
20
20
  form?: string;
@@ -82,12 +82,6 @@ export const Button = forwardRef<HTMLButtonElement, PropsWithChildren<ButtonProp
82
82
  {iconPosition === 'left' && getIcon()} <span>{children}</span> {iconPosition === 'right' && getIcon()}
83
83
  </Clear>
84
84
  );
85
- case 'white':
86
- return (
87
- <White {...props}>
88
- {iconPosition === 'left' && getIcon()} <span>{children}</span> {iconPosition === 'right' && getIcon()}
89
- </White>
90
- );
91
85
  }
92
86
  }
93
87
 
@@ -140,10 +140,3 @@ export const Clear = styled(Outline)`
140
140
  color: ${({ theme, color }): string => theme.colors[color]};
141
141
  }
142
142
  `;
143
-
144
- export const White = styled(Clear)`
145
- background: ${({ theme }): string => theme.colors.white};
146
- &:disabled {
147
- background-color: white;
148
- }
149
- `;
@@ -31,7 +31,6 @@ import { styled } from '../../../styled';
31
31
 
32
32
  const Container = styled.div`
33
33
  border: 1px solid ${({ theme }) => theme.colors.backgroundAccent};
34
- box-shadow: ${({ theme }) => theme.elevation[2]};
35
34
  background-color: ${({ theme }) => theme.colors.background};
36
35
  border-radius: ${({ theme }) => theme.borderRadius.medium};
37
36
  &:focus-visible {
@@ -4,7 +4,7 @@ exports[`Should render <IconButton /> 1`] = `
4
4
  <div>
5
5
  <button
6
6
  aria-label="test"
7
- class="sc-djVXDX cRGHRs"
7
+ class="sc-dBFDNq bubVam"
8
8
  color="primary"
9
9
  type="button"
10
10
  >
@@ -22,10 +22,6 @@ export const Default = styled.button<{ color: Color }>`
22
22
  div {
23
23
  background-color: ${({ theme }) => theme.colors.backgroundAccent};
24
24
  }
25
- svg {
26
- fill: white;
27
- stroke: white;
28
- }
29
25
  }
30
26
 
31
27
  &:focus {
@@ -33,10 +29,6 @@ export const Default = styled.button<{ color: Color }>`
33
29
  div {
34
30
  border-color: ${({ theme, color }) => theme.colors[color]};
35
31
  }
36
- svg {
37
- fill: white;
38
- stroke: white;
39
- }
40
32
  }
41
33
 
42
34
  &:disabled {
@@ -1,3 +1,4 @@
1
+ import { shade } from 'polished';
1
2
  import { styled } from '../../../styled';
2
3
  import { orientation } from './ToggleButtonGroup';
3
4
 
@@ -65,7 +66,7 @@ export const Item = styled.button<{ isSelected: boolean; isDisabled: boolean }>`
65
66
  font-weight: 400;
66
67
  border-left: none;
67
68
  background-color: ${({ theme, isSelected, isDisabled }) =>
68
- isDisabled ? theme.colors.disabled : isSelected ? theme.colors.primary : theme.colors.background};
69
+ isDisabled ? theme.colors.disabled : isSelected ? shade(0.5, theme.colors.primary) : theme.colors.background};
69
70
  cursor: ${({ isDisabled }) => (isDisabled ? 'default' : 'pointer')};
70
71
 
71
72
  svg {
@@ -139,7 +139,6 @@ export const EChartsBase: FC<EChartsBaseProps> = ({
139
139
  textStyle: {
140
140
  color: theme.colors.text,
141
141
  },
142
- extraCssText: `box-shadow: ${theme.elevation[200]};`,
143
142
  },
144
143
  grid: {
145
144
  left: '3%',
@@ -42,7 +42,7 @@ export const Container = styled.div<{ size: Size; variant?: AvatarVariant }>`
42
42
  display: flex;
43
43
  align-items: center;
44
44
  justify-content: center;
45
- color: white;
45
+ color: ${({ theme }) => theme.colors.text};
46
46
  font-weight: 700;
47
47
 
48
48
  img {
@@ -1,7 +1,7 @@
1
1
  import { forwardRef, ReactElement, cloneElement } from 'react';
2
2
  import { AiOutlineClose as Icon } from 'react-icons/ai';
3
- import { Container, Dot } from './style';
4
- import { AlertVariants, Color, Variant } from '../../../styled/types';
3
+ import { Container } from './style';
4
+ import { AlertVariants, Color } from '../../../styled/types';
5
5
 
6
6
  export type ChipColor = Color | AlertVariants | 'backgroundAccent';
7
7
 
@@ -15,7 +15,6 @@ export interface ChipProps {
15
15
  onClick?: () => void;
16
16
  onDelete?: () => void;
17
17
  color: ChipColor;
18
- variant?: Variant;
19
18
  isLoading?: boolean;
20
19
  icon?: ReactElement;
21
20
  showIcon?: ShowIcon;
@@ -24,14 +23,12 @@ export interface ChipProps {
24
23
  export const Chip = forwardRef<HTMLDivElement, ChipProps>(function Chip(
25
24
  {
26
25
  color,
27
- variant = 'default',
28
26
  label,
29
27
  disabled = false,
30
28
  readOnly = false,
31
29
  onClick = undefined,
32
30
  onDelete = undefined,
33
31
  isLoading = false,
34
- dot = false,
35
32
  icon,
36
33
  showIcon = 'always',
37
34
  },
@@ -44,28 +41,17 @@ export const Chip = forwardRef<HTMLDivElement, ChipProps>(function Chip(
44
41
  clickable={!readOnly && !disabled && onClick !== undefined}
45
42
  color={color}
46
43
  disabled={disabled}
47
- outline={false}
48
44
  onClick={onClick ? onClick : undefined}
49
45
  className="placeholder"
50
46
  showIcon={showIcon}
51
47
  >
52
- {dot && <Dot color={color} outline={variant !== 'default'} />}
53
48
  <span style={{ minWidth: '70px', minHeight: '15px' }}></span>
54
49
  </Container>
55
50
  );
56
51
  }
57
52
 
58
53
  return (
59
- <Container
60
- ref={ref}
61
- clickable={onClick !== undefined}
62
- color={color}
63
- disabled={disabled}
64
- onClick={onClick ? onClick : undefined}
65
- outline={variant !== 'default'}
66
- showIcon={showIcon}
67
- >
68
- {dot && <Dot color={color} outline={variant !== 'default'} />}
54
+ <Container ref={ref} clickable={onClick !== undefined} color={color} disabled={disabled} showIcon={showIcon}>
69
55
  <span>{label}</span>
70
56
  {!onDelete && icon && cloneElement(icon, { size: 12, className: 'icon' })}
71
57
  {onDelete && !readOnly && !disabled && <Icon onClick={onDelete} size={12} />}
@@ -5,7 +5,6 @@ import { shade } from 'polished';
5
5
  export const Container = styled.div<{
6
6
  disabled: boolean;
7
7
  color: ChipColor;
8
- outline: boolean;
9
8
  clickable: boolean;
10
9
  showIcon: ShowIcon;
11
10
  }>`
@@ -17,6 +16,8 @@ export const Container = styled.div<{
17
16
  cursor: ${({ clickable }): string => (clickable ? 'pointer' : 'auto')};
18
17
  width: fit-content;
19
18
  height: 20px;
19
+ background-color: ${({ theme, color }) => shade(0.5, theme.colors[color])};
20
+ border: 0.1rem solid ${({ theme, color }) => theme.colors[color]};
20
21
 
21
22
  svg {
22
23
  margin-left: ${({ theme }) => theme.spacing['0_5']};
@@ -24,21 +25,11 @@ export const Container = styled.div<{
24
25
  transition: width 0.2s ease-in-out;
25
26
  will-change: width;
26
27
  display: ${({ showIcon }): string => (showIcon === 'always' ? 'inline-block' : 'none')};
27
- ${({ theme, color, outline }) => {
28
- if (!outline) {
29
- return 'fill: white; stroke: white;';
30
- }
28
+ ${({ theme, color }) => {
31
29
  return `fill: ${theme.colors[color]};`;
32
30
  }}
33
31
  }
34
32
 
35
- ${({ theme, color, outline }): string => {
36
- if (!outline) {
37
- return 'border: 0.1rem solid transparent;';
38
- }
39
- return `border: 0.1rem solid ${shade(0.5, theme.colors[color])};`;
40
- }}
41
-
42
33
  &:hover {
43
34
  svg {
44
35
  display: inline-block;
@@ -53,33 +44,6 @@ export const Container = styled.div<{
53
44
 
54
45
  font-size: ${({ theme }) => theme.fontSize.medium};
55
46
  user-select: none;
56
-
57
- ${({ theme, color, outline }) => {
58
- if (!outline) {
59
- return 'color: white;';
60
- }
61
- switch (color) {
62
- case 'backgroundAccent':
63
- case 'secondary':
64
- return `color: ${theme.colors.text};`;
65
- default:
66
- return `color: ${theme.colors[color]};`;
67
- }
68
- }}
47
+ color: white;
69
48
  }
70
-
71
- ${({ theme, color, outline }): string => {
72
- if (outline) {
73
- return `background-color: ${shade('0.8', theme.colors[color])};`;
74
- }
75
- return `background-color: ${theme.colors[color]};`;
76
- }}
77
- `;
78
-
79
- export const Dot = styled.div<{ color: ChipColor; outline: boolean }>`
80
- width: 0.6rem;
81
- height: 0.6rem;
82
- border-radius: 50%;
83
- margin-right: ${({ theme }) => theme.spacing['0_5']};
84
- background-color: ${({ outline, theme, color }) => (outline ? theme.colors[color] : 'white')};
85
49
  `;
@@ -75,7 +75,6 @@ export const CopyId: FC<CopyIdProps> = ({
75
75
  <Chip
76
76
  icon={copied ? <CheckmarkIcon /> : <CopyIcon />}
77
77
  onClick={() => handleCopy(id)}
78
- variant="outline"
79
78
  label={copied ? copyText : placeholder ? placeholder : id}
80
79
  color="backgroundAccent"
81
80
  />
@@ -101,7 +100,6 @@ export const CopyId: FC<CopyIdProps> = ({
101
100
  <Chip
102
101
  icon={copied ? <CheckmarkIcon /> : <CopyIcon />}
103
102
  onClick={() => handleCopy(id)}
104
- variant="outline"
105
103
  label={copied ? copyText : placeholder ? placeholder : id}
106
104
  color="backgroundAccent"
107
105
  />
@@ -67,6 +67,7 @@ const Container = styled.div<{ isGrouped: boolean; direction: Direction; size: S
67
67
  }
68
68
  }};
69
69
  color: ${({ theme }) => theme.colors.secondary};
70
+ font-size: ${({ theme }) => theme.fontSize.medium};
70
71
  margin-bottom: ${({ theme }) => theme.spacing['0_5']};
71
72
  }
72
73
 
@@ -83,6 +84,8 @@ const Container = styled.div<{ isGrouped: boolean; direction: Direction; size: S
83
84
  return theme.fontSize.large;
84
85
  }
85
86
  }};
87
+ color: ${({ theme }) => theme.colors.text};
88
+ font-size: ${({ theme }) => theme.fontSize.mediumLarge};
86
89
  letter-spacing: 1px;
87
90
  margin: 0;
88
91
  padding: 0;
@@ -5,7 +5,7 @@ exports[`Should render <Alert/> 1`] = `
5
5
  <div
6
6
  aria-atomic="true"
7
7
  aria-live="polite"
8
- class="sc-aXZVg efcfNn"
8
+ class="sc-aXZVg dfhkGl"
9
9
  role="status"
10
10
  style="opacity: 0; will-change: opacity;"
11
11
  >
@@ -7,7 +7,6 @@ import {
7
7
  AiFillInfoCircle as Info,
8
8
  } from 'react-icons/ai';
9
9
  import { AnimatePresence } from 'framer-motion';
10
- import { Elevation } from '../../../styled/';
11
10
  import { Button } from '../../../components';
12
11
 
13
12
  export type AlertVariants = 'success' | 'error' | 'warning' | 'info';
@@ -21,13 +20,12 @@ export interface AlertProps {
21
20
  variant: AlertVariants;
22
21
  title?: string;
23
22
  text?: string | string[] | ReactElement;
24
- elevation?: Elevation;
25
23
  dismiss?: boolean;
26
24
  action?: Action;
27
25
  }
28
26
 
29
27
  export const Alert = forwardRef<HTMLDivElement, AlertProps>(function Alert(
30
- { variant, title, text, dismiss = false, elevation = 2, action },
28
+ { variant, title, text, dismiss = false, action },
31
29
  ref,
32
30
  ) {
33
31
  const [visible, setVisible] = useState(true);
@@ -92,7 +90,6 @@ export const Alert = forwardRef<HTMLDivElement, AlertProps>(function Alert(
92
90
  $hasTitle={hasTitle}
93
91
  initial={{ opacity: 0 }}
94
92
  $variant={variant}
95
- $elevation={elevation}
96
93
  transition={{ duration: 0.2 }}
97
94
  ref={ref}
98
95
  role={getAriaRole()}
@@ -1,4 +1,4 @@
1
- import { Elevation, styled } from '../../../styled';
1
+ import { styled } from '../../../styled';
2
2
  import { AlertVariants } from '.';
3
3
  import { motion } from 'framer-motion';
4
4
  import { shade } from 'polished';
@@ -9,12 +9,10 @@ import { shade } from 'polished';
9
9
  export const Container = styled(motion.div)<{
10
10
  $variant: AlertVariants;
11
11
  $hasTitle: boolean;
12
- $elevation: Elevation;
13
12
  }>`
14
13
  width: 100%;
15
14
  padding: ${({ theme }) => theme.spacing['0_75']};
16
15
  border-radius: ${({ theme }) => theme.borderRadius.large};
17
- box-shadow: ${({ theme, $elevation }) => theme.elevation[$elevation]};
18
16
  margin: ${({ theme }) => `${theme.spacing['1_5']} auto`};
19
17
  h2 {
20
18
  font-size: ${({ theme }) => theme.fontSize.mediumLarge};
@@ -27,6 +27,7 @@ const Container = styled.div`
27
27
  justify-content: center;
28
28
  font-size: ${({ theme }) => theme.fontSize.mediumLarge};
29
29
  margin-bottom: ${({ theme }) => theme.spacing['0_5']};
30
+ color: ${({ theme }) => theme.colors.text};
30
31
 
31
32
  svg {
32
33
  margin-right: ${({ theme }) => theme.spacing['0_75']};
@@ -16,11 +16,11 @@ const Container = styled.div`
16
16
  width: 700px;
17
17
  margin: 0 auto;
18
18
  padding: 6rem 0;
19
-
20
19
 
21
20
  p {
22
21
  font-size: 1.7rem;
23
22
  text-align: center;
23
+ color: ${({ theme }) => theme.colors.textAlt};
24
24
 
25
25
  &.error {
26
26
  margin-top: ${({ theme }) => theme.spacing[6]};
@@ -34,14 +34,14 @@ const Container = styled.div`
34
34
  h3 {
35
35
  font-size: 4.125rem;
36
36
  font-weight: 700;
37
- color: ${({ theme }) => theme.colors.secondary};
37
+ color: ${({ theme }) => theme.colors.text};
38
38
  margin-bottom: .5rem;
39
39
  text-align: center;
40
40
  }
41
41
  h4 {
42
42
  font-weight: 600;
43
43
  font-size: 1.5rem;
44
- color: ${({ theme }) => theme.colors.secondary};
44
+ color: ${({ theme }) => theme.colors.textAlt};
45
45
  margin: 3rem 0 1.5rem 0;
46
46
  }
47
47
  h5 {
@@ -3,12 +3,10 @@ import { Tooltip, TooltipProps } from '../Tooltip';
3
3
  import { Size, styled } from '../../../styled';
4
4
  import { getIconSize } from '../../actions/IconButton/getIconSize';
5
5
  import { ButtonColor } from '../../actions/Button/style';
6
- import { shade } from 'polished';
7
6
 
8
7
  type TooltipIconColor = Exclude<ButtonColor, 'white'>;
9
8
 
10
9
  const TriggerContainer = styled.div<{ color: TooltipIconColor }>`
11
- background: ${({ theme, color }) => shade(0.5, theme.colors[color])};
12
10
  border: 1px solid ${({ theme, color }) => theme.colors[color]};
13
11
  border-radius: ${({ theme }) => theme.borderRadius.small};
14
12
  display: flex;
@@ -1,13 +1,14 @@
1
1
  import { FC, useState } from 'react';
2
2
  import { createPortal } from 'react-dom';
3
- import { Elevation, styled } from '../../../styled';
3
+ import { styled } from '../../../styled';
4
4
  import { AnimatePresence, motion } from 'framer-motion';
5
5
  import { Tooltip } from '../Tooltip';
6
6
  import { AiOutlineClose as CloseIcon } from 'react-icons/ai';
7
+ import { shade } from 'polished';
7
8
 
8
- const Container = styled(motion.div)<{ $elevation: Elevation }>`
9
+ const Container = styled(motion.div)`
9
10
  position: sticky;
10
- background-color: ${({ theme }): string => theme.colors.primaryShade};
11
+ background-color: ${({ theme }): string => shade(0.5, theme.colors.primary)};
11
12
  border: 1px solid ${({ theme }) => theme.colors.primary};
12
13
  display: flex;
13
14
  align-items: center;
@@ -15,7 +16,6 @@ const Container = styled(motion.div)<{ $elevation: Elevation }>`
15
16
  padding: ${({ theme }) => `${theme.spacing['0_75']} ${theme.spacing[1]}`};
16
17
  will-change: height;
17
18
  overflow: hidden;
18
- box-shadow: ${({ theme, $elevation }) => theme.elevation[$elevation]};
19
19
  z-index: ${({ theme }) => theme.zIndex.notificationBanner};
20
20
 
21
21
  div {
@@ -44,7 +44,6 @@ const Container = styled(motion.div)<{ $elevation: Elevation }>`
44
44
  export interface NotificationBannerProps {
45
45
  title: string;
46
46
  description: string;
47
- elevation?: Elevation;
48
47
  }
49
48
 
50
49
  /* What is <NotificationBanner?
@@ -54,13 +53,13 @@ export interface NotificationBannerProps {
54
53
  IMPORTANT: the component requires a separate div mounted outside of root called with id notification-banner.
55
54
  */
56
55
 
57
- export const NotificationBanner: FC<NotificationBannerProps> = ({ title, description, elevation = 4 }) => {
56
+ export const NotificationBanner: FC<NotificationBannerProps> = ({ title, description }) => {
58
57
  const [visible, setVisible] = useState<boolean>(true);
59
58
 
60
59
  return createPortal(
61
60
  <AnimatePresence>
62
61
  {visible && (
63
- <Container $elevation={elevation} initial={{ y: -40 }} animate={{ y: 0 }} exit={{ opacity: '0' }}>
62
+ <Container initial={{ y: -40 }} animate={{ y: 0 }} exit={{ opacity: '0' }}>
64
63
  <div>
65
64
  <h3>{title}</h3>
66
65
  <p>{description}</p>
@@ -3,7 +3,7 @@
3
3
  exports[`Should render <Skeleton/> 1`] = `
4
4
  <div>
5
5
  <div
6
- class="sc-aXZVg dMeLsA"
6
+ class="sc-aXZVg VRVWh"
7
7
  />
8
8
  </div>
9
9
  `;
@@ -1,13 +1,12 @@
1
1
  import { forwardRef, HTMLProps } from 'react';
2
2
  import { useMergeRefs, FloatingPortal, FloatingArrow } from '@floating-ui/react';
3
3
  import { useTooltipContext } from './TooltipContext';
4
- import { Elevation, styled } from '../../../styled';
4
+ import { styled } from '../../../styled';
5
5
  import { useTheme } from '../../../hooks';
6
6
 
7
- const Container = styled.div<{ elevation: Elevation }>`
7
+ const Container = styled.div`
8
8
  background: ${({ theme }) => theme.colors.background};
9
9
  color: ${({ theme }) => theme.colors.text};
10
- box-shadow: ${({ theme, elevation }) => theme.elevation[elevation]};
11
10
  pointer-events: none;
12
11
  border-radius: ${({ theme }) => theme.borderRadius.medium};
13
12
  border: 1px solid ${({ theme }) => theme.colors.backgroundAlt};
@@ -30,7 +29,6 @@ export const TooltipContent = forwardRef<HTMLDivElement, HTMLProps<HTMLDivElemen
30
29
  return (
31
30
  <FloatingPortal>
32
31
  <Container
33
- elevation={1}
34
32
  ref={ref}
35
33
  style={{
36
34
  ...floatingStyles,
@@ -6,7 +6,6 @@ export const Wrapper = styled.div`
6
6
  padding: ${({ theme }) => theme.spacing['1_5']};
7
7
  max-width: 450px;
8
8
  border-radius: ${({ theme }) => theme.borderRadius.large};
9
- box-shadow: ${({ theme }) => theme.elevation[4]};
10
9
 
11
10
  & > p {
12
11
  margin-top: ${({ theme }) => theme.spacing[1]};
@@ -6,7 +6,6 @@ export const Wrapper = styled.div`
6
6
  background-color: ${({ theme }) => theme.colors.background};
7
7
  padding: ${({ theme }) =>
8
8
  `${theme.spacing['1']} ${theme.spacing[2]} ${theme.spacing['1_5']} ${theme.spacing['1_5']}`};
9
- box-shadow: ${({ theme }) => theme.elevation[4]};
10
9
  border: 0.1rem solid ${({ theme }) => theme.colors.backgroundAlt};
11
10
  border-radius: ${({ theme }) => theme.borderRadius.large};
12
11
  `;
@@ -5,7 +5,6 @@ import { AiOutlineClose as CloseIcon, AiOutlineDown as ArrowDownIcon } from 'rea
5
5
  import { Tooltip } from '../../../../components';
6
6
 
7
7
  const Wrapper = styled.div`
8
- box-shadow: ${({ theme }) => theme.elevation[4]};
9
8
  border-radius: ${({ theme }) => theme.borderRadius.large};
10
9
  width: 300px;
11
10
  border: 1px solid ${({ theme }) => theme.colors.backgroundAlt};
@@ -13,7 +13,6 @@ const Container = styled.div`
13
13
  border-radius: ${({ theme }) => theme.borderRadius.large};
14
14
  width: 300px;
15
15
  background-color: white;
16
- box-shadow: ${({ theme }): string => theme.elevation[4]};
17
16
  p {
18
17
  font-size: 1.325rem;
19
18
  }
@@ -13,7 +13,6 @@ export const ResultContainer = styled.div<{ readOnly: boolean; hasError: boolean
13
13
  border: 0.1rem solid ${({ theme }) => theme.colors.secondary};
14
14
  border-radius: ${({ theme }) => theme.borderRadius.medium};
15
15
  background-color: ${({ theme }) => theme.colors.backgroundAlt};
16
- box-shadow: ${({ theme }) => theme.elevation[4]};
17
16
  text-transform: capitalize;
18
17
  z-index: ${({ theme }) => theme.zIndex.dropdown};
19
18
  cursor: ${({ readOnly }) => (readOnly ? 'not-allowed' : 'pointer')};
@@ -1,3 +1,4 @@
1
+ import { shade } from 'polished';
1
2
  import { styled } from '../../../../../styled';
2
3
 
3
4
  export const Wrapper = styled.div`
@@ -20,14 +21,15 @@ export const DayButton = styled.button<{ isSelected: boolean; isToday: boolean;
20
21
  width: 2rem;
21
22
  margin-left: auto;
22
23
  margin-right: auto;
23
- background-color: ${({ theme, isSelected }) => (isSelected ? theme.colors.primaryShade : 'transparent')};
24
+ background-color: ${({ theme, isSelected }) => (isSelected ? shade(0.5, theme.colors.primary) : 'transparent')};
24
25
  border: 1px solid ${({ theme, isSelected }) => (isSelected ? theme.colors.primary : 'transparent')};
25
26
  color: white;
26
27
  padding: ${({ theme }) => theme.spacing['1_5']};
27
28
  margin: 0;
28
29
 
29
30
  &:hover {
30
- background-color: ${({ theme, isSelected }) => (isSelected ? theme.colors.primaryShade : theme.colors.secondary)};
31
+ background-color: ${({ theme, isSelected }) =>
32
+ isSelected ? shade(0.5, theme.colors.primary) : theme.colors.secondary};
31
33
  }
32
34
 
33
35
  &:disabled {
@@ -1,3 +1,4 @@
1
+ import { shade } from 'polished';
1
2
  import { styled } from '../../../../../styled';
2
3
 
3
4
  export const List = styled.ul`
@@ -21,12 +22,13 @@ export const List = styled.ul`
21
22
 
22
23
  export const Item = styled.li<{ isSelected: boolean }>`
23
24
  cursor: pointer;
24
- background-color: ${({ theme, isSelected }) => (isSelected ? theme.colors.primaryShade : 'transparent')};
25
+ background-color: ${({ theme, isSelected }) => (isSelected ? shade(0.5, theme.colors.primary) : 'transparent')};
25
26
  border: 1px solid ${({ theme, isSelected }) => (isSelected ? theme.colors.primary : 'transparent')};
26
27
  padding: ${({ theme }) => theme.spacing['0_5']};
27
28
  border-radius: ${({ theme }) => theme.borderRadius.small};
28
29
 
29
30
  &:hover {
30
- background-color: ${({ theme, isSelected }) => (isSelected ? theme.colors.primaryShade : theme.colors.background)};
31
+ background-color: ${({ theme, isSelected }) =>
32
+ isSelected ? shade(0.5, theme.colors.primary) : theme.colors.background};
31
33
  }
32
34
  `;
@@ -52,7 +52,7 @@ const Inner = styled(motion.div)<{ $isChecked: boolean; $readOnly: boolean }>`
52
52
  border-radius: 100%;
53
53
  background-color: ${({ theme, $readOnly }) => {
54
54
  if ($readOnly) return theme.colors.backgroundAlt;
55
- return theme.colors.primaryShade;
55
+ return shade(0.5, theme.colors.primary);
56
56
  }};
57
57
  overflow: hidden;
58
58
  opacity: ${({ $isChecked }): number => ($isChecked ? 1 : 0)};
@@ -27,9 +27,7 @@ export const OptionContainer = styled.li<{
27
27
 
28
28
  &:hover {
29
29
  border-color: ${({ theme, disabled }) => (disabled ? theme.colors.backgroundAlt : theme.colors.backgroundAccent)};
30
- span {
31
- color: white;
32
- }
30
+ background-color: ${({ theme, disabled }) => (disabled ? theme.colors.backgroundAlt : theme.colors.backgroundAccent)};
33
31
  }
34
32
 
35
33
  & > div {
@@ -15,7 +15,6 @@ export const SelectContainer = styled.div`
15
15
  border: 0.1rem solid ${({ theme }) => theme.colors.backgroundAccent};
16
16
  border-radius: ${({ theme }) => theme.borderRadius.medium};
17
17
  background-color: ${({ theme }) => theme.colors.backgroundAlt};
18
- box-shadow: ${({ theme }) => theme.elevation[4]};
19
18
  z-index: ${({ theme }) => theme.zIndex.dropdown};
20
19
  `;
21
20
 
@@ -62,7 +62,7 @@ export const NavBar = styled.nav<{ variant: HorizontalNavVariant }>`
62
62
  font-size: ${({ theme }) => theme.fontSize.medium};
63
63
 
64
64
  &.active {
65
- color: ${({ theme }) => theme.colors.text};
65
+ color: ${({ theme }) => theme.colors.primary};
66
66
 
67
67
  ${({ variant, theme }) => {
68
68
  switch (variant) {
@@ -2,6 +2,7 @@ import { JSX, FC, cloneElement } from 'react';
2
2
  import { styled } from '../../../styled';
3
3
  import { Link, LinkProps } from '@tanstack/react-router';
4
4
  import { Tooltip } from '../../../components';
5
+ import { shade } from 'polished';
5
6
 
6
7
  const Container = styled.nav`
7
8
  background-color: ${({ theme }) => theme.colors.backgroundAlt};
@@ -19,7 +20,7 @@ const Container = styled.nav`
19
20
  border: 1px solid transparent;
20
21
  border-radius: ${({ theme }) => theme.borderRadius.small};
21
22
  &:hover {
22
- background-color: ${({ theme }) => theme.colors.primaryShade};
23
+ background-color: ${({ theme }) => shade(0.5, theme.colors.primary)};
23
24
  border-color: ${({ theme }) => theme.colors.primary};
24
25
  }
25
26
  }
@@ -1,3 +1,4 @@
1
+ import { shade } from 'polished';
1
2
  import { styled } from '../../../../styled';
2
3
  import { StepStates } from '../stepStates';
3
4
 
@@ -81,7 +82,7 @@ export const StepCounter = styled.div<{
81
82
  border: 0.1rem solid
82
83
  ${({ theme, stepState }) => (stepState !== StepStates.OTHER ? theme.colors.primary : theme.colors.backgroundAccent)};
83
84
  background-color: ${({ stepState, theme }) =>
84
- stepState === StepStates.CURRENT ? theme.colors.primaryShade : theme.colors.background};
85
+ stepState === StepStates.CURRENT ? shade(0.5, theme.colors.primary) : theme.colors.background};
85
86
  transition: all 0.2s ease-in-out;
86
87
  margin-bottom: ${({ theme }) => theme.spacing[1]};
87
88
  color: ${({ theme, stepState }) => (stepState !== StepStates.OTHER ? theme.colors.white : theme.colors.text)};
@@ -1,7 +1,6 @@
1
1
  import { Children, forwardRef, FC, ReactElement, PropsWithChildren } from 'react';
2
2
  import { Container, Item } from './style';
3
3
  import { AiOutlineCheck as CheckMarkIcon } from 'react-icons/ai';
4
- import { Elevation } from '../../../styled/';
5
4
 
6
5
  export interface ActionMenuProps {
7
6
  attributes: {
@@ -12,16 +11,14 @@ export interface ActionMenuProps {
12
11
  selected: number;
13
12
  setSelected: (selected: number) => void;
14
13
  children: ReactElement | ReactElement[];
15
- elevation?: Elevation;
16
14
  }
17
15
 
18
16
  export const ActionMenu = forwardRef<HTMLUListElement, ActionMenuProps>(function ActionMenu(
19
- { attributes, children, selected, setSelected, elevation = 4 },
17
+ { attributes, children, selected, setSelected },
20
18
  ref,
21
19
  ) {
22
20
  return (
23
21
  <Container
24
- elevation={elevation}
25
22
  style={{
26
23
  position: attributes.strategy,
27
24
  top: attributes.y ? attributes.y + 5 : 0,
@@ -1,10 +1,9 @@
1
- import { Elevation, styled } from '../../../styled';
1
+ import { styled } from '../../../styled';
2
2
 
3
- export const Container = styled.ul<{ elevation: Elevation }>`
3
+ export const Container = styled.ul`
4
4
  display: flex;
5
5
  flex-direction: column;
6
6
  width: fit-content;
7
- box-shadow: ${({ theme, elevation }) => theme.elevation[elevation]};
8
7
  border-radius: ${({ theme }) => theme.borderRadius.medium};
9
8
  border: 0.1rem solid ${({ theme }) => theme.colors.backgroundAccent};
10
9
  background-color: ${({ theme }) => theme.colors.background};
@@ -3,7 +3,7 @@
3
3
  exports[`Should render <ClipBoard /> 1`] = `
4
4
  <div>
5
5
  <div
6
- class="sc-aXZVg jSPpZO"
6
+ class="sc-aXZVg kRYlLL"
7
7
  role="button"
8
8
  tabindex="-1"
9
9
  >
@@ -15,7 +15,7 @@ exports[`Should render <ClipBoard /> 1`] = `
15
15
  value="ClipBoard text"
16
16
  />
17
17
  <div
18
- class="sc-gEvEer bneOhB"
18
+ class="sc-gEvEer juIItl"
19
19
  >
20
20
  <svg
21
21
  fill="currentColor"
@@ -9,7 +9,7 @@ exports[`Should render <Empty /> 1`] = `
9
9
  this is the header
10
10
  </h2>
11
11
  <p
12
- class="sc-eqUAAy flGMfW"
12
+ class="sc-eqUAAy jLRJsD"
13
13
  >
14
14
  this is the description
15
15
  </p>
@@ -42,7 +42,7 @@ export const Plan: FC<PlanProps> = ({
42
42
  <FeaturesContainer>
43
43
  <h1 style={{}}>
44
44
  {title}
45
- {highlight && <Chip color="primary" variant="outline" label="Most popular" />}
45
+ {highlight && <Chip color="primary" label="Most popular" />}
46
46
  </h1>
47
47
  <p style={{ marginBottom: '3rem' }}>{description}</p>
48
48
  <Divider
@@ -6,7 +6,7 @@ exports[`Should render <Accordion /> 1`] = `
6
6
  class="sc-aXZVg ktErGV"
7
7
  >
8
8
  <div
9
- class="sc-eqUAAy hsBlKB"
9
+ class="sc-eqUAAy hPeIkm"
10
10
  />
11
11
  </div>
12
12
  </div>
@@ -22,6 +22,7 @@ export const GlobalStyle = createGlobalStyle<{ theme: ThemeType }>`
22
22
  #takaro-root {
23
23
  margin: 0 auto;
24
24
  overflow-x: hidden;
25
+ background-color: ${({ theme }) => theme.colors.background};
25
26
  }
26
27
 
27
28
 
@@ -20,7 +20,6 @@ export const SnackBarStyles = css<{ theme: ThemeType }>`
20
20
 
21
21
  div.SnackbarContent-root {
22
22
  border: 1px solid ${({ theme }) => theme.colors.background};
23
- box-shadow: ${({ theme }): string => theme.elevation[4]}!important;
24
23
  }
25
24
 
26
25
  /* info */
@@ -1,11 +1,10 @@
1
1
  /* Re-export of styled-components styled default export which at typings for the custom theme */
2
- export { styled, lightTheme, darkTheme } from './theme';
3
- export type { ThemeType } from './theme';
2
+ export { styled, lightTheme, darkTheme, ThemeProvider, useThemeSwitcher } from './theme';
3
+ export type { ThemeType, ThemeName } from './theme';
4
4
 
5
5
  export { GlobalStyle } from './GlobalStyle';
6
6
  export * from './types';
7
7
  export { device } from './device';
8
8
  export * from './animations';
9
9
 
10
- export type { Elevation } from './elevation';
11
10
  export type { Spacing } from './spacing';
@@ -1,9 +1,9 @@
1
- import baseStyled, { ThemedStyledInterface } from 'styled-components';
1
+ import baseStyled, { ThemedStyledInterface, ThemeProvider as StyledComponentsThemeProvider } from 'styled-components';
2
2
  import { breakpoint } from './breakpoint';
3
- import { elevationLight, elevationDark } from './elevation';
4
3
  import { spacing } from './spacing';
5
4
  import { zIndex } from './zIndex';
6
- import { shade } from 'polished';
5
+ import { FC, PropsWithChildren, createContext, useContext } from 'react';
6
+ import { useLocalStorage } from '../hooks';
7
7
 
8
8
  const fontSize = {
9
9
  tiny: '1rem',
@@ -24,7 +24,6 @@ const borderRadius = {
24
24
  };
25
25
 
26
26
  export const lightTheme = {
27
- elevation: elevationLight,
28
27
  spacing,
29
28
  breakpoint,
30
29
  fontSize,
@@ -32,19 +31,16 @@ export const lightTheme = {
32
31
  zIndex,
33
32
  colors: {
34
33
  primary: '#664de5',
35
- primaryShade: shade(0.5, '#664de5'),
36
- secondary: '#030917',
37
- placeholder: '#f5f5f5',
34
+ secondary: '#f0f0f0',
35
+ placeholder: '#f0f0f0',
38
36
  placeholderHighlight: '#ffffff',
39
- shade: '#eaf8f0',
40
37
  white: '#ffffff',
41
- background: '#f9f9f9',
42
- backgroundAlt: '#e9e9e9',
43
- // not set correctly yet.
44
- backgroundAccent: '#353535',
45
- disabled: '#151515',
46
- text: '#030303',
47
- textAlt: '#636363',
38
+ background: '#f5f5f5',
39
+ backgroundAlt: '#e0e0e0',
40
+ backgroundAccent: '#909090',
41
+ disabled: '#d0d0d0',
42
+ text: '#202020',
43
+ textAlt: '#666666',
48
44
  info: '#664de5',
49
45
  success: '#3ccd6A',
50
46
  warning: '#f57c00',
@@ -52,9 +48,7 @@ export const lightTheme = {
52
48
  },
53
49
  };
54
50
 
55
- // todo: this should be the color of modals:#343434
56
51
  export const darkTheme: ThemeType = {
57
- elevation: elevationDark,
58
52
  spacing,
59
53
  breakpoint,
60
54
  fontSize,
@@ -62,12 +56,10 @@ export const darkTheme: ThemeType = {
62
56
  borderRadius,
63
57
  colors: {
64
58
  primary: '#664DE5',
65
- primaryShade: shade(0.5, '#664de5'),
66
59
  secondary: '#353535',
67
60
  placeholder: '#202020',
68
61
  placeholderHighlight: '#303030',
69
62
  white: '#ffffff',
70
- shade: '#eaf8f0',
71
63
  text: '#c2c2c2',
72
64
  textAlt: '#818181',
73
65
  background: '#080808',
@@ -85,3 +77,34 @@ export const darkTheme: ThemeType = {
85
77
 
86
78
  export type ThemeType = typeof lightTheme;
87
79
  export const styled = baseStyled as ThemedStyledInterface<ThemeType>;
80
+
81
+ export type ThemeName = 'light' | 'dark';
82
+ const themes: Record<ThemeName, ThemeType> = {
83
+ light: lightTheme,
84
+ dark: darkTheme,
85
+ };
86
+
87
+ /// Multiple themes:
88
+ interface ThemeContextType {
89
+ theme: ThemeName;
90
+ setTheme: (theme: ThemeName) => void;
91
+ }
92
+ const ThemeContext = createContext<ThemeContextType | undefined>(undefined);
93
+
94
+ export const useThemeSwitcher = () => {
95
+ const context = useContext(ThemeContext);
96
+ if (context == undefined) {
97
+ throw new Error('useThemeSwitcher must be used within a ThemeProvider');
98
+ }
99
+ return context;
100
+ };
101
+
102
+ export const ThemeProvider: FC<PropsWithChildren> = ({ children }) => {
103
+ const { storedValue, setValue } = useLocalStorage<ThemeName>('theme', 'dark');
104
+
105
+ return (
106
+ <ThemeContext.Provider value={{ theme: storedValue, setTheme: setValue }}>
107
+ <StyledComponentsThemeProvider theme={themes[storedValue]}>{children} </StyledComponentsThemeProvider>
108
+ </ThemeContext.Provider>
109
+ );
110
+ };
@@ -1,56 +0,0 @@
1
- import { Meta } from '@storybook/addon-docs';
2
-
3
-
4
- <Meta title="Elevation" />
5
-
6
- ## Surface and Elevation
7
-
8
- Elevation styles are used to create separation between surfaces. 6 elevation styles are avilable in a range of depths.
9
- In default mode, elevation is created through shadows and elevation design tokens. In dark mode, on surfaces with elevation (i.e. Cards),
10
- an additional transparent overlay is used to lighten the surface color and creat the visual effect of an elevated surface.
11
-
12
- ### Elevation styles
13
-
14
-
15
-
16
- Elevation styles are used to create separation between surfaces. Six elevation styles are avilable in a range of depths.
17
-
18
- <div>
19
-
20
- </div>
21
-
22
- ### Examples
23
-
24
- Some elevation styles are used on specific components within the Design System:
25
-
26
- <table>
27
- <tr>
28
- <th>Depth level</th>
29
- <th>Uses</th>
30
- </tr>
31
-
32
- <tr>
33
- <td>Elevation 00</td>
34
- <td>Background</td>
35
- </tr>
36
- <tr>
37
- <td>Elevation 01</td>
38
- <td>Cards Minimal, Tooltips</td>
39
- </tr>
40
- <tr>
41
- <td>Elevation 02</td>
42
- <td>Panels, Cards Subtle</td>
43
- </tr>
44
- <tr>
45
- <td>Elevation 03</td>
46
- <td>Panels, Navigation Bars, Cards Bold, Dialogs</td>
47
- </tr>
48
- <tr>
49
- <td>Elevation 04</td>
50
- <td>Notifications, Menus</td>
51
- </tr>
52
- <tr>
53
- <td>Elevation 05</td>
54
- <td>No specific purpose</td>
55
- </tr>
56
- </table>
@@ -1,20 +0,0 @@
1
- export type Elevation = 0 | 1 | 2 | 3 | 4 | 5;
2
-
3
- // TODO: add link to docs
4
- export const elevationLight: Record<Elevation, string> = {
5
- 0: '0 1px 4px -1px hsla(214, 45%, 20%, 0.52)',
6
- 1: '0 2px 4px -1px hsla(214, 53%, 23%, 0.16), 0 3px 12px -1px hsla(214, 50%, 22%, 0.26)',
7
- 2: '0 2px 6px -1px hsla(214, 53%, 23%, 0.16), 0 8px 24px -4px hsla(214, 47%, 21%, 0.38)',
8
- 3: '0 3px 18px -2px hsla(214, 53%, 23%, 0.16), 0 12px 48px -6px hsla(214, 47%, 21%, 0.38)',
9
- 4: '0 4px 24px -3px hsla(214, 53%, 23%, 0.16), 0 18px 64px -8px hsla(214, 47%, 21%, 0.38)',
10
- 5: '0 5px 32px -4px hsla(214, 53%, 23%, 0.16), 0 24px 70px -12px hsla(214, 47%, 21%, 0.38)',
11
- };
12
-
13
- export const elevationDark: Record<Elevation, string> = {
14
- 0: '0 1px 4px -1px hsla(0, 0%, 0%, 0.52)',
15
- 1: '0 2px 4px -1px hsla(0, 0%, 0%, 0.16), 0 3px 12px -1px hsla(0, 0%, 0%, 0.26)',
16
- 2: '0 2px 6px -1px hsla(0, 0%, 0%, 0.16), 0 8px 24px -4px hsla(0, 0%, 0%, 0.38)',
17
- 3: '0 3px 18px -2px hsla(0, 0%, 0%, 0.16), 0 12px 48px -6px hsla(0, 0%, 0%, 0.38)',
18
- 4: '0 4px 24px -3px hsla(0, 0%, 0%, 0.16), 0 18px 64px -8px hsla(0, 0%, 0%, 0.38)',
19
- 5: '0 5px 32px -4px hsla(0, 0%, 0%, 0.16), 0 24px 70px -12px hsla(0, 0%, 0%, 0.38)',
20
- };