@noya-app/noya-designsystem 0.1.30 → 0.1.32

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 (64) hide show
  1. package/.turbo/turbo-build.log +20 -12
  2. package/.turbo/turbo-lint.log +15 -1
  3. package/CHANGELOG.md +17 -0
  4. package/README.md +13 -1
  5. package/dist/index.css +1 -0
  6. package/dist/index.d.ts +238 -627
  7. package/dist/index.js +4259 -2862
  8. package/dist/index.js.map +1 -1
  9. package/dist/index.mjs +4159 -2764
  10. package/dist/index.mjs.map +1 -1
  11. package/package.json +17 -7
  12. package/src/components/ActivityIndicator.tsx +4 -36
  13. package/src/components/Avatar.tsx +63 -62
  14. package/src/components/Button.tsx +53 -170
  15. package/src/components/Chip.tsx +117 -150
  16. package/src/components/ContextMenu.tsx +13 -35
  17. package/src/components/Dialog.tsx +66 -54
  18. package/src/components/Divider.tsx +31 -41
  19. package/src/components/DraggableMenuButton.tsx +29 -30
  20. package/src/components/DropdownMenu.tsx +30 -40
  21. package/src/components/FillInputField.tsx +16 -26
  22. package/src/components/FillPreviewBackground.tsx +18 -22
  23. package/src/components/FloatingWindow.tsx +4 -7
  24. package/src/components/GridView.tsx +70 -200
  25. package/src/components/IconButton.tsx +1 -5
  26. package/src/components/InputField.tsx +258 -234
  27. package/src/components/InputFieldWithCompletions.tsx +20 -27
  28. package/src/components/InspectorContainer.tsx +4 -9
  29. package/src/components/InspectorPrimitives.tsx +135 -109
  30. package/src/components/Label.tsx +5 -36
  31. package/src/components/LabeledElementView.tsx +5 -26
  32. package/src/components/ListView.tsx +239 -167
  33. package/src/components/Popover.tsx +15 -39
  34. package/src/components/Progress.tsx +21 -44
  35. package/src/components/RadioGroup.tsx +6 -71
  36. package/src/components/ScrollArea.tsx +11 -39
  37. package/src/components/SelectMenu.tsx +72 -32
  38. package/src/components/Slider.tsx +7 -43
  39. package/src/components/Spacer.tsx +6 -18
  40. package/src/components/Switch.tsx +4 -42
  41. package/src/components/Text.tsx +31 -66
  42. package/src/components/TextArea.tsx +5 -31
  43. package/src/components/Toast.tsx +15 -57
  44. package/src/components/Tooltip.tsx +4 -13
  45. package/src/components/WorkspaceLayout.tsx +27 -17
  46. package/src/components/internal/Menu.tsx +37 -83
  47. package/src/contexts/DesignSystemConfiguration.tsx +1 -47
  48. package/src/contexts/DialogContext.tsx +2 -10
  49. package/src/hooks/useDarkMode.ts +14 -0
  50. package/src/index.css +108 -0
  51. package/src/index.tsx +4 -5
  52. package/src/theme/index.ts +4 -16
  53. package/src/utils/tailwind.ts +17 -0
  54. package/tailwind.config.ts +223 -0
  55. package/tailwind.d.ts +11 -0
  56. package/tsconfig.json +4 -1
  57. package/tsup.config.ts +16 -0
  58. package/dist/index.d.mts +0 -1455
  59. package/src/components/Grid.tsx +0 -54
  60. package/src/components/Select.tsx +0 -183
  61. package/src/components/Stack.tsx +0 -155
  62. package/src/theme/dark.ts +0 -45
  63. package/src/theme/light.ts +0 -226
  64. package/src/utils/breakpoints.ts +0 -45
@@ -8,74 +8,9 @@ import React, {
8
8
  useContext,
9
9
  useMemo,
10
10
  } from "react";
11
- import styled from "styled-components";
12
11
  import { Tooltip } from "./Tooltip";
13
12
 
14
13
  type RadioGroupColorScheme = "primary" | "secondary";
15
-
16
- const ignoredProps = new Set(["colorScheme"]);
17
-
18
- const StyledRoot = styled(ToggleGroupPrimitive.Root).withConfig({
19
- shouldForwardProp: (prop) => !ignoredProps.has(prop),
20
- })<{
21
- colorScheme?: RadioGroupColorScheme;
22
- }>(({ theme, colorScheme }) => ({
23
- appearance: "none",
24
- width: "0px", // Reset intrinsic width
25
- flex: "1 1 0px",
26
- position: "relative",
27
- border: "0",
28
- outline: "none",
29
- minWidth: "0",
30
- textAlign: "left",
31
- alignSelf: "stretch",
32
- borderRadius: "4px",
33
- background: theme.colors.inputBackground,
34
- "&:focus": {
35
- boxShadow: `0 0 0 1px ${theme.colors.sidebar.background}, 0 0 0 3px ${
36
- theme.colors[colorScheme ?? "primary"]
37
- }`,
38
- },
39
- display: "flex",
40
- alignItems: "stretch",
41
- minHeight: "27px",
42
- padding: colorScheme === undefined ? "2px" : 0,
43
- }));
44
-
45
- const StyledItem = styled(ToggleGroupPrimitive.Item).withConfig({
46
- shouldForwardProp: (prop) => !ignoredProps.has(prop),
47
- })<{
48
- colorScheme?: RadioGroupColorScheme;
49
- }>(({ theme, colorScheme }) => ({
50
- ...theme.textStyles.small,
51
- position: "relative",
52
- flex: "1 1 0",
53
- appearance: "none",
54
- border: "none",
55
- background: "none",
56
- color: "rgb(139, 139, 139)",
57
- padding: 0,
58
- margin: 0,
59
- borderRadius: "4px",
60
- display: "inline-flex",
61
- alignItems: "center",
62
- justifyContent: "center",
63
- verticalAlign: "middle",
64
- '&[aria-checked="true"]': {
65
- backgroundColor: colorScheme
66
- ? theme.colors[colorScheme]
67
- : theme.colors.radioGroup.background,
68
- color: colorScheme ? theme.colors.radioGroup.background : theme.colors.text,
69
- boxShadow: colorScheme ? undefined : `0 1px 1px rgba(0,0,0,0.1)`,
70
- },
71
- "&:focus": {
72
- outline: "none",
73
- boxShadow: `0 0 0 1px ${theme.colors.sidebar.background}, 0 0 0 3px ${
74
- theme.colors[colorScheme ?? "primary"]
75
- }`,
76
- },
77
- }));
78
-
79
14
  interface ItemProps {
80
15
  value: string;
81
16
  tooltip?: ReactNode;
@@ -90,14 +25,14 @@ const ToggleGroupItem = forwardRef(function ToggleGroupItem(
90
25
  const { colorScheme } = useContext(RadioGroupContext);
91
26
 
92
27
  const itemElement = (
93
- <StyledItem
28
+ <ToggleGroupPrimitive.Item
94
29
  ref={forwardedRef}
95
30
  value={value}
96
31
  disabled={disabled}
97
- colorScheme={colorScheme}
32
+ className={`font-sans text-heading5 font-normal relative flex-1 appearance-none border-none bg-none text-radio-group-item p-0 m-0 rounded inline-flex items-center justify-center align-middle focus:outline-none focus:shadow-[0_0_0_1px_var(--sidebar-background),0_0_0_3px_${colorScheme === "secondary" ? "var(--secondary)" : "var(--primary)"}] aria-checked:bg-${colorScheme ? colorScheme : "radio-group-background"} aria-checked:text-${colorScheme ? "radio-group-background" : "text"} aria-checked:shadow-${colorScheme ? "none" : "0_1px_1px_rgba(0,0,0,0.1)"}`}
98
33
  >
99
34
  {children}
100
- </StyledItem>
35
+ </ToggleGroupPrimitive.Item>
101
36
  );
102
37
 
103
38
  return tooltip ? (
@@ -146,15 +81,15 @@ function ToggleGroupRoot({
146
81
 
147
82
  return (
148
83
  <RadioGroupContext.Provider value={contextValue}>
149
- <StyledRoot
84
+ <ToggleGroupPrimitive.Root
150
85
  id={id}
151
86
  type="single"
152
87
  value={value}
153
- colorScheme={colorScheme}
154
88
  onValueChange={handleValueChange}
89
+ className={`appearance-none w-0 flex-1 relative border-0 outline-none min-w-0 min-h-[27px] text-left self-stretch rounded bg-input-background items-stretch focus:shadow-[0_0_0_1px_var(--sidebar-background),0_0_0_3px_${colorScheme === "secondary" ? "var(--secondary)" : "var(--primary)"}] ${colorScheme ? "p-0" : "p-0.5"}`}
155
90
  >
156
91
  {children}
157
- </StyledRoot>
92
+ </ToggleGroupPrimitive.Root>
158
93
  </RadioGroupContext.Provider>
159
94
  );
160
95
  }
@@ -1,37 +1,5 @@
1
1
  import * as RadixScrollArea from "@radix-ui/react-scroll-area";
2
2
  import React, { memo, ReactNode, useCallback, useState } from "react";
3
- import styled from "styled-components";
4
-
5
- const SCROLLBAR_SIZE = 10;
6
-
7
- const StyledViewport = styled(RadixScrollArea.Viewport)({
8
- width: "100%",
9
- height: "100%",
10
- // Override the `display: table` in the child, since this allows
11
- // elements to expand beyond the width of the viewport.
12
- "& > div": {
13
- display: "block !important",
14
- },
15
- });
16
-
17
- const StyledScrollbar = styled(RadixScrollArea.Scrollbar)({
18
- display: "flex",
19
- padding: "3px",
20
- '&[data-orientation="vertical"]': {
21
- width: SCROLLBAR_SIZE,
22
- },
23
- });
24
-
25
- const StyledThumb = styled(RadixScrollArea.Thumb)(({ theme }) => ({
26
- flex: 1,
27
- borderRadius: SCROLLBAR_SIZE,
28
- backgroundColor: theme.colors.scrollbar,
29
- }));
30
-
31
- const Container = styled.div({
32
- flex: "1 1 0px",
33
- minHeight: 0,
34
- });
35
3
 
36
4
  interface Props {
37
5
  children?: ReactNode | ((scrollElementRef: HTMLDivElement) => ReactNode);
@@ -42,9 +10,10 @@ export const ScrollArea = memo(function ScrollArea({ children }: Props) {
42
10
  useState<HTMLDivElement | null>(null);
43
11
 
44
12
  return (
45
- <Container>
13
+ <div className="flex-1 min-h-0">
46
14
  <RadixScrollArea.Root style={{ width: "100%", height: "100%" }}>
47
- <StyledViewport
15
+ <RadixScrollArea.Viewport
16
+ className="w-full h-full [&>div]:block"
48
17
  ref={useCallback(
49
18
  (ref: HTMLDivElement | null) => setScrollElementRef(ref),
50
19
  []
@@ -55,11 +24,14 @@ export const ScrollArea = memo(function ScrollArea({ children }: Props) {
55
24
  ? children(scrollElementRef)
56
25
  : null
57
26
  : children}
58
- </StyledViewport>
59
- <StyledScrollbar orientation="vertical" className="scroll-component">
60
- <StyledThumb className="scroll-component" />
61
- </StyledScrollbar>
27
+ </RadixScrollArea.Viewport>
28
+ <RadixScrollArea.Scrollbar
29
+ orientation="vertical"
30
+ className="scroll-component flex p-[3px] data-[orientation=vertical]:w-[10px]"
31
+ >
32
+ <RadixScrollArea.Thumb className="scroll-component flex-1 rounded-[10px] bg-scrollbar" />
33
+ </RadixScrollArea.Scrollbar>
62
34
  </RadixScrollArea.Root>
63
- </Container>
35
+ </div>
64
36
  );
65
37
  });
@@ -1,7 +1,7 @@
1
1
  import { DropdownChevronIcon } from "@noya-app/noya-icons";
2
2
  import * as Select from "@radix-ui/react-select";
3
- import React, { CSSProperties, memo } from "react";
4
- import { styled } from "styled-components";
3
+ import { type SelectProps } from "@radix-ui/react-select";
4
+ import React, { CSSProperties, memo, useMemo } from "react";
5
5
  import { Button } from "./Button";
6
6
  import { renderIcon } from "./Icons";
7
7
  import { Spacer } from "./Spacer";
@@ -17,17 +17,20 @@ type Props<T extends string> = {
17
17
  placeholder?: string;
18
18
  disabled?: boolean;
19
19
  readOnly?: boolean;
20
- };
20
+ label?: React.ReactNode;
21
+ } & Pick<SelectProps, "open">;
21
22
 
22
23
  const readOnlyStyle: CSSProperties = {
23
24
  justifyContent: "flex-start",
24
25
  textAlign: "left",
25
26
  };
26
27
 
27
- const flexStyle: CSSProperties = {
28
- flex: 1,
28
+ const textStyle: CSSProperties = {
29
+ fontSize: "0.85rem",
29
30
  };
30
31
 
32
+ const labelStyles = `font-sans text-label uppercase text-text-disabled leading-[19px] absolute inset-0 font-bold text-[60%] pointer-events-none flex items-center justify-end pr-6`;
33
+
31
34
  export const SelectMenu = memo(function SelectMenu<T extends string = string>({
32
35
  id,
33
36
  style,
@@ -38,6 +41,8 @@ export const SelectMenu = memo(function SelectMenu<T extends string = string>({
38
41
  placeholder,
39
42
  disabled,
40
43
  readOnly,
44
+ label,
45
+ open,
41
46
  }: Props<T>) {
42
47
  const selectedItem = menuItems.find(
43
48
  (item): item is RegularMenuItem<T> =>
@@ -45,13 +50,13 @@ export const SelectMenu = memo(function SelectMenu<T extends string = string>({
45
50
  );
46
51
  const icon = selectedItem?.icon;
47
52
 
48
- if (readOnly) {
49
- return (
53
+ const readOnlyButton = useMemo(
54
+ () => (
50
55
  <Button
51
56
  id={id}
52
57
  style={style}
53
58
  contentStyle={readOnlyStyle}
54
- className={className}
59
+ className={`${className ?? ""} flex-1`}
55
60
  disabled={disabled}
56
61
  >
57
62
  {icon && (
@@ -60,34 +65,76 @@ export const SelectMenu = memo(function SelectMenu<T extends string = string>({
60
65
  <Spacer.Horizontal inline size={6} />
61
66
  </>
62
67
  )}
63
- <span style={flexStyle}>{selectedItem?.title ?? value}</span>
68
+ <span style={{ ...textStyle }} className="flex flex-1">
69
+ {selectedItem?.title ?? value}
70
+ </span>
64
71
  </Button>
65
- );
66
- }
72
+ ),
73
+ [icon, id, style, className, disabled, value, selectedItem]
74
+ );
67
75
 
68
- return (
69
- <Select.Root value={value} onValueChange={onSelect}>
76
+ const trigger = useMemo(
77
+ () => (
70
78
  <Select.SelectTrigger asChild>
71
- <Button id={id} style={style} className={className} disabled={disabled}>
79
+ <Button
80
+ id={id}
81
+ style={{ ...textStyle, ...style }}
82
+ className={`${className ?? "w-full"} flex-1`}
83
+ disabled={disabled}
84
+ >
72
85
  {icon && (
73
86
  <>
74
87
  {renderIcon(icon)}
75
88
  <Spacer.Horizontal inline size={6} />
76
89
  </>
77
90
  )}
78
- <span style={flexStyle}>
91
+ <span className="flex flex-1">
79
92
  <Select.Value placeholder={placeholder} />
80
93
  </span>
81
94
  <Spacer.Horizontal inline size={6} />
82
95
  <DropdownChevronIcon />
83
96
  </Button>
84
97
  </Select.SelectTrigger>
98
+ ),
99
+ [icon, id, style, className, disabled, placeholder]
100
+ );
101
+
102
+ if (readOnly) {
103
+ return label ? (
104
+ <div className="flex flex-col relative">
105
+ {readOnlyButton}
106
+ <label
107
+ className={labelStyles}
108
+ htmlFor={id}
109
+ >
110
+ {label}
111
+ </label>
112
+ </div>
113
+ ) : (
114
+ readOnlyButton
115
+ );
116
+ }
117
+
118
+ return (
119
+ <Select.Root value={value} onValueChange={onSelect} open={open}>
120
+ {label ? (
121
+ <div className="flex-1 flex-col relative">
122
+ {trigger}
123
+ {label && (
124
+ <label className={labelStyles} htmlFor={id}>
125
+ {label}
126
+ </label>
127
+ )}
128
+ </div>
129
+ ) : (
130
+ trigger
131
+ )}
85
132
  <Select.Portal>
86
- <SelectContent>
87
- <SelectViewport>
133
+ <Select.Content className={styles.contentStyle}>
134
+ <Select.Viewport>
88
135
  {menuItems.map((menuItem) => {
89
136
  if (typeof menuItem === "string") {
90
- return <StyledSeparator />;
137
+ return <Select.Separator className={styles.separatorStyle} />;
91
138
  }
92
139
 
93
140
  const value = menuItem.value ?? "";
@@ -98,39 +145,32 @@ export const SelectMenu = memo(function SelectMenu<T extends string = string>({
98
145
  </SelectItem>
99
146
  );
100
147
  })}
101
- </SelectViewport>
102
- </SelectContent>
148
+ </Select.Viewport>
149
+ </Select.Content>
103
150
  </Select.Portal>
104
151
  </Select.Root>
105
152
  );
106
153
  });
107
154
 
108
- const SelectContent = styled(Select.Content)(styles.contentStyle);
109
-
110
- const SelectViewport = styled(Select.Viewport)({});
111
-
112
155
  const SelectItem = React.forwardRef(
113
156
  (
114
157
  {
115
158
  children,
116
- icon,
159
+ icon, disabled,
117
160
  ...props
118
161
  }: Select.SelectItemProps & { icon?: React.ReactNode },
119
162
  forwardedRef: React.ForwardedRef<HTMLDivElement>
120
163
  ) => {
121
164
  return (
122
- <StyledItem {...props} ref={forwardedRef}>
165
+ <Select.Item className={styles.itemStyle({disabled})} disabled={disabled} {...props} ref={forwardedRef}>
123
166
  {icon && (
124
167
  <>
125
168
  {renderIcon(icon)}
126
169
  <Spacer.Horizontal size={8} />
127
170
  </>
128
171
  )}
129
- <Select.ItemText>{children}</Select.ItemText>
130
- </StyledItem>
172
+ <Select.ItemText style={textStyle}>{children}</Select.ItemText>
173
+ </Select.Item>
131
174
  );
132
175
  }
133
- );
134
-
135
- const StyledItem = styled(Select.Item)(styles.itemStyle);
136
- const StyledSeparator = styled(Select.Separator)(styles.separatorStyle);
176
+ );
@@ -1,42 +1,5 @@
1
1
  import * as RadixSlider from '@radix-ui/react-slider';
2
2
  import React, { useCallback, useMemo } from 'react';
3
- import styled from 'styled-components';
4
-
5
- const StyledSlider = styled(RadixSlider.Root)({
6
- flex: '1',
7
- position: 'relative',
8
- display: 'flex',
9
- alignItems: 'center',
10
- userSelect: 'none',
11
- touchAction: 'none',
12
- height: '16px',
13
- });
14
-
15
- const StyledTrack = styled(RadixSlider.Track)(({ theme }) => ({
16
- backgroundColor: theme.colors.divider,
17
- position: 'relative',
18
- flexGrow: 1,
19
- height: '2px',
20
- }));
21
-
22
- const StyledRange = styled(RadixSlider.Range)(({ theme }) => ({
23
- position: 'absolute',
24
- backgroundColor: theme.colors.primary,
25
- borderRadius: '9999px',
26
- height: '100%',
27
- }));
28
-
29
- const StyledThumb = styled(RadixSlider.Thumb)(({ theme }) => ({
30
- display: 'block',
31
- width: '12px',
32
- height: '12px',
33
- backgroundColor: theme.colors.slider.background,
34
- border: `1px solid ${theme.colors.slider.border}`,
35
- borderRadius: '20px',
36
- ':focus': {
37
- outline: 'none',
38
- },
39
- }));
40
3
 
41
4
  interface Props {
42
5
  id?: string;
@@ -66,17 +29,18 @@ export const Slider = function Slider({
66
29
  );
67
30
 
68
31
  return (
69
- <StyledSlider
32
+ <RadixSlider.Root
70
33
  min={min}
71
34
  max={max}
72
35
  id={id}
73
36
  value={arrayValue}
74
37
  onValueChange={handleValueChange}
38
+ className="flex-1 flex relative items-center select-none touch-none h-4"
75
39
  >
76
- <StyledTrack>
77
- <StyledRange />
78
- </StyledTrack>
79
- <StyledThumb />
80
- </StyledSlider>
40
+ <RadixSlider.Track className="bg-divider relative flex-grow h-[2px]">
41
+ <RadixSlider.Range className="absolute bg-primary rounded-full h-full" />
42
+ </RadixSlider.Track>
43
+ <RadixSlider.Thumb className="block w-3 h-3 bg-slider-background border border-solid border-slider-border rounded-[20px] focus:outline-none" />
44
+ </RadixSlider.Root>
81
45
  );
82
46
  };
@@ -1,30 +1,21 @@
1
1
  /* eslint-disable react/jsx-pascal-case */
2
2
  import React, { ForwardedRef, forwardRef } from "react";
3
- import styled from "styled-components";
4
3
 
5
4
  interface Props {
6
5
  size?: number | string;
7
6
  inline?: boolean;
8
7
  }
9
8
 
10
- interface Props_ {
11
- $size?: number | string;
12
- $inline?: boolean;
13
- }
14
-
15
9
  /* ----------------------------------------------------------------------------
16
10
  * Vertical
17
11
  * ------------------------------------------------------------------------- */
18
12
 
19
- const SpacerVertical_ = styled.span<Props_>(({ $size, $inline }) => ({
20
- display: $inline ? "inline-block" : "block",
21
- ...($size === undefined ? { flex: 1 } : { minHeight: $size }),
22
- }));
23
-
24
13
  const SpacerVertical = forwardRef<HTMLSpanElement, Props>(
25
14
  ({ size, inline, ...props }, ref: ForwardedRef<HTMLSpanElement>) => {
26
15
  return (
27
- <SpacerVertical_ $size={size} $inline={inline} {...props} ref={ref} />
16
+ <span className={`${inline ? "inline-block" : "block"} ${size === undefined ? "flex flex-1" : ""}`} style={size ? {
17
+ minHeight: `${size}px`,
18
+ } : undefined} {...props} ref={ref} />
28
19
  );
29
20
  }
30
21
  );
@@ -33,15 +24,12 @@ const SpacerVertical = forwardRef<HTMLSpanElement, Props>(
33
24
  * Horizontal
34
25
  * ------------------------------------------------------------------------- */
35
26
 
36
- const SpacerHorizontal_ = styled.span<Props_>(({ $size, $inline }) => ({
37
- display: $inline ? "inline-block" : "block",
38
- ...($size === undefined ? { flex: 1 } : { minWidth: $size }),
39
- }));
40
-
41
27
  const SpacerHorizontal = forwardRef<HTMLSpanElement, Props>(
42
28
  ({ size, inline, ...props }, ref: ForwardedRef<HTMLSpanElement>) => {
43
29
  return (
44
- <SpacerHorizontal_ $size={size} $inline={inline} {...props} ref={ref} />
30
+ <span className={`${inline ? "inline-block" : "block"} ${size === undefined ? "flex flex-1" : ""}`} style={size ? {
31
+ minWidth: `${size}px`,
32
+ } : undefined} {...props} ref={ref} />
45
33
  );
46
34
  }
47
35
  );
@@ -1,46 +1,8 @@
1
1
  import * as SwitchPrimitive from "@radix-ui/react-switch";
2
2
  import React from "react";
3
- import styled from "styled-components";
4
3
 
5
4
  type SwitchColorScheme = "normal" | "primary" | "secondary";
6
5
 
7
- const SwitchRoot = styled(SwitchPrimitive.Root)<{
8
- $colorScheme: SwitchColorScheme;
9
- }>(({ theme, $colorScheme }) => ({
10
- all: "unset",
11
- width: 32,
12
- height: 19,
13
- backgroundColor: theme.colors.activeBackground,
14
- borderRadius: "9999px",
15
- position: "relative",
16
- WebkitTapHighlightColor: "rgba(0, 0, 0, 0)",
17
- cursor: "pointer",
18
- "&:focus": {
19
- outline: `2px solid ${theme.colors.primary}`,
20
- outlineOffset: "1px",
21
- },
22
- '&[data-state="checked"]': {
23
- backgroundColor:
24
- $colorScheme === "primary"
25
- ? theme.colors.primary
26
- : $colorScheme === "secondary"
27
- ? theme.colors.secondary
28
- : undefined,
29
- },
30
- }));
31
-
32
- const SwitchThumb = styled(SwitchPrimitive.Thumb)({
33
- display: "block",
34
- width: 15,
35
- height: 15,
36
- backgroundColor: "white",
37
- borderRadius: "9999px",
38
- transition: "transform 100ms",
39
- transform: "translateX(2px)",
40
- willChange: "transform",
41
- '&[data-state="checked"]': { transform: "translateX(15px)" },
42
- });
43
-
44
6
  interface Props {
45
7
  value: boolean;
46
8
  onChange: (value: boolean) => void;
@@ -56,15 +18,15 @@ export const Switch = function Switch({
56
18
  disabled,
57
19
  }: Props) {
58
20
  return (
59
- <SwitchRoot
60
- $colorScheme={colorScheme}
21
+ <SwitchPrimitive.Root
61
22
  checked={value}
62
23
  disabled={disabled}
63
24
  onCheckedChange={(newValue) => {
64
25
  onChange(newValue);
65
26
  }}
27
+ className={`all-unset w-8 h-[19px] bg-active-background rounded-full relative cursor-pointer [webkit-tap-highlight-color:rgba(0,0,0,0)] focus:ring-2 focus:outline-primary focus:ring-offset-[1px] data-[state=checked]:bg-primary ${colorScheme === "secondary" && "data-[state=checked]:bg-secondary"}`}
66
28
  >
67
- <SwitchThumb />
68
- </SwitchRoot>
29
+ <SwitchPrimitive.Thumb className="block w-[15px] h-[15px] bg-white rounded-full transition-transform translate-x-[2px] data-[state=checked]:translate-x-[15px]"/>
30
+ </SwitchPrimitive.Root>
69
31
  );
70
32
  };