aural-ui 2.0.8 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/switch/Switch.stories.tsx +18 -0
- package/dist/components/switch/index.tsx +32 -12
- package/dist/icons/index.ts +2 -0
- package/dist/icons/moon-icon/MoonIcon.stories.tsx +591 -0
- package/dist/icons/moon-icon/index.tsx +21 -0
- package/dist/icons/moon-icon/meta.ts +8 -0
- package/dist/icons/sun-icon/SunIcon.stories.tsx +886 -0
- package/dist/icons/sun-icon/index.tsx +34 -0
- package/dist/icons/sun-icon/meta.ts +8 -0
- package/dist/index.js +102 -111
- package/package.json +4 -2
|
@@ -3,6 +3,8 @@ import { Button } from "@components/button"
|
|
|
3
3
|
import Label from "@components/label"
|
|
4
4
|
import type { Meta, StoryObj } from "@storybook/react"
|
|
5
5
|
|
|
6
|
+
import { CrossIcon, TickIcon } from "src/ui/icons"
|
|
7
|
+
|
|
6
8
|
import { Switch } from "."
|
|
7
9
|
|
|
8
10
|
const meta: Meta<typeof Switch> = {
|
|
@@ -90,3 +92,19 @@ export const WithForm: Story = {
|
|
|
90
92
|
</form>
|
|
91
93
|
),
|
|
92
94
|
}
|
|
95
|
+
|
|
96
|
+
export const WithIcons: Story = {
|
|
97
|
+
args: {
|
|
98
|
+
checked: false,
|
|
99
|
+
onIcon: <TickIcon />,
|
|
100
|
+
offIcon: <CrossIcon />,
|
|
101
|
+
},
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export const CheckedWithIcons: Story = {
|
|
105
|
+
args: {
|
|
106
|
+
checked: true,
|
|
107
|
+
onIcon: <TickIcon />,
|
|
108
|
+
offIcon: <CrossIcon />,
|
|
109
|
+
},
|
|
110
|
+
}
|
|
@@ -2,33 +2,53 @@ import * as React from "react"
|
|
|
2
2
|
import { cn } from "@lib/utils"
|
|
3
3
|
import * as SwitchPrimitives from "@radix-ui/react-switch"
|
|
4
4
|
|
|
5
|
+
type SwitchWithIconsProps = React.ComponentPropsWithoutRef<
|
|
6
|
+
typeof SwitchPrimitives.Root
|
|
7
|
+
> & {
|
|
8
|
+
offIcon?: React.ReactNode
|
|
9
|
+
onIcon?: React.ReactNode
|
|
10
|
+
}
|
|
11
|
+
|
|
5
12
|
const Switch = React.forwardRef<
|
|
6
13
|
React.ElementRef<typeof SwitchPrimitives.Root>,
|
|
7
|
-
|
|
8
|
-
>(({ className, ...props }, ref) => (
|
|
14
|
+
SwitchWithIconsProps
|
|
15
|
+
>(({ className, onIcon, offIcon, checked, disabled, ...props }, ref) => (
|
|
9
16
|
<SwitchPrimitives.Root
|
|
17
|
+
ref={ref}
|
|
18
|
+
checked={checked}
|
|
19
|
+
disabled={disabled}
|
|
10
20
|
className={cn(
|
|
11
|
-
"data-[state=checked]:not-[:disabled]:border-fm-divider-positive data-[state=checked]:not-[:disabled]:bg-fm-green-50
|
|
12
|
-
"data-[state=unchecked]:not-[:disabled]:
|
|
21
|
+
"data-[state=checked]:not-[:disabled]:border-fm-divider-positive data-[state=checked]:not-[:disabled]:bg-fm-green-50",
|
|
22
|
+
"data-[state=unchecked]:not-[:disabled]:border-fm-divider-primary data-[state=unchecked]:not-[:disabled]:bg-fm-surface-primary",
|
|
23
|
+
"data-[state=unchecked]:disabled:border-fm-divider-tertiary data-[state=unchecked]:disabled:bg-fm-surface-secondary",
|
|
24
|
+
"data-[state=checked]:disabled:border-fm-green-100 data-[state=checked]:disabled:bg-fm-green-50",
|
|
25
|
+
"focus-visible:ring-fm-primary focus-visible:ring-offset-fm-green-50",
|
|
26
|
+
"hover:bg-fm-surface-secondary data-[state=unchecked]:not-[:disabled]:hover:bg-fm-surface-secondary",
|
|
27
|
+
"data-[state=unchecked]:not-[:disabled]:hover:border-fm-divider-primary",
|
|
28
|
+
"relative h-8 w-14 rounded-full border border-solid transition-all duration-200 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-not-allowed",
|
|
13
29
|
className
|
|
14
30
|
)}
|
|
15
31
|
{...props}
|
|
16
|
-
ref={ref}
|
|
17
32
|
>
|
|
18
33
|
<span
|
|
19
|
-
className=
|
|
20
|
-
|
|
21
|
-
|
|
34
|
+
className={cn(
|
|
35
|
+
"font-fm-brand text-fm-positive absolute top-1/2 left-2 -translate-y-1/2 [font-size:var(--text-fm-sm)]",
|
|
36
|
+
disabled && "text-fm-positive-tert"
|
|
37
|
+
)}
|
|
38
|
+
data-state={checked ? "checked" : "unchecked"}
|
|
39
|
+
data-disabled={disabled || undefined}
|
|
22
40
|
>
|
|
23
|
-
ON
|
|
41
|
+
{onIcon ?? "ON"}
|
|
24
42
|
</span>
|
|
43
|
+
|
|
25
44
|
<span
|
|
26
45
|
className="font-fm-brand text-fm-tertiary absolute top-1/2 right-1.5 -translate-y-1/2 [font-size:var(--text-fm-sm)]"
|
|
27
|
-
data-state={
|
|
28
|
-
data-disabled={
|
|
46
|
+
data-state={checked ? "checked" : "unchecked"}
|
|
47
|
+
data-disabled={disabled || undefined}
|
|
29
48
|
>
|
|
30
|
-
OFF
|
|
49
|
+
{offIcon ?? "OFF"}
|
|
31
50
|
</span>
|
|
51
|
+
|
|
32
52
|
<SwitchPrimitives.Thumb className="bg-fm-icon-active data-[disabled]:bg-fm-icon-inactive pointer-events-none z-10 block size-6 rounded-full shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-7 data-[state=unchecked]:translate-x-1" />
|
|
33
53
|
</SwitchPrimitives.Root>
|
|
34
54
|
))
|
package/dist/icons/index.ts
CHANGED
|
@@ -42,6 +42,7 @@ export * from "./light-bulb-simple-icon"
|
|
|
42
42
|
export * from "./magic-book-icon"
|
|
43
43
|
export * from "./maintenance-icon"
|
|
44
44
|
export * from "./message-icon"
|
|
45
|
+
export * from "./moon-icon"
|
|
45
46
|
export * from "./move-horizontal-icon"
|
|
46
47
|
export * from "./move-vertical-icon"
|
|
47
48
|
export * from "./musical-note-icon"
|
|
@@ -60,6 +61,7 @@ export * from "./spinner-gradient-icon"
|
|
|
60
61
|
export * from "./spinner-solid-icon"
|
|
61
62
|
export * from "./spinner-solid-neutral-icon"
|
|
62
63
|
export * from "./suggestion-icon"
|
|
64
|
+
export * from "./sun-icon"
|
|
63
65
|
export * from "./text-color-icon"
|
|
64
66
|
export * from "./text-indicator-icon"
|
|
65
67
|
export * from "./tick-circle-icon"
|