@noya-app/noya-designsystem 0.1.40 → 0.1.41
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/.turbo/turbo-build.log +9 -9
- package/CHANGELOG.md +6 -0
- package/dist/index.css +1 -1
- package/dist/index.d.mts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +38 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +50 -26
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/components/Checkbox.tsx +1 -1
- package/src/components/Slider.tsx +46 -14
- package/src/index.css +3 -3
- package/tailwind.config.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@noya-app/noya-designsystem",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.41",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/index.mjs",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@radix-ui/react-progress": "^1.0.1",
|
|
39
39
|
"@radix-ui/react-radio-group": "^1.1.0",
|
|
40
40
|
"@radix-ui/react-scroll-area": "^1.0.2",
|
|
41
|
-
"@radix-ui/react-slider": "^1.
|
|
41
|
+
"@radix-ui/react-slider": "^1.2.2",
|
|
42
42
|
"@radix-ui/react-switch": "^1.0.1",
|
|
43
43
|
"@radix-ui/react-toast": "^1.1.4",
|
|
44
44
|
"@radix-ui/react-toggle-group": "^1.0.1",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as RadixSlider from "@radix-ui/react-slider";
|
|
2
|
-
import React, { FocusEventHandler, useCallback, useMemo } from "react";
|
|
2
|
+
import React, { FocusEventHandler, memo, useCallback, useMemo } from "react";
|
|
3
3
|
import { cx } from "../utils/classNames";
|
|
4
4
|
|
|
5
5
|
type ColorScheme = "primary" | "secondary";
|
|
@@ -12,6 +12,7 @@ interface Props {
|
|
|
12
12
|
onValueChange: (value: number) => void;
|
|
13
13
|
min: number;
|
|
14
14
|
max: number;
|
|
15
|
+
step?: number;
|
|
15
16
|
colorScheme?: ColorScheme;
|
|
16
17
|
label?: React.ReactNode;
|
|
17
18
|
onFocus?: FocusEventHandler;
|
|
@@ -20,7 +21,13 @@ interface Props {
|
|
|
20
21
|
|
|
21
22
|
const labelStyles = `font-sans text-label uppercase text-text-disabled leading-[19px] font-bold text-[60%] pointer-events-none flex items-center z-label`;
|
|
22
23
|
|
|
23
|
-
|
|
24
|
+
const THUMB_WIDTH = 8; // Width of the thumb in pixels
|
|
25
|
+
|
|
26
|
+
const thumbStyle = {
|
|
27
|
+
width: THUMB_WIDTH,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const Slider = memo(function Slider({
|
|
24
31
|
id,
|
|
25
32
|
style,
|
|
26
33
|
className,
|
|
@@ -28,6 +35,7 @@ export const Slider = function Slider({
|
|
|
28
35
|
onValueChange,
|
|
29
36
|
min,
|
|
30
37
|
max,
|
|
38
|
+
step,
|
|
31
39
|
colorScheme,
|
|
32
40
|
label,
|
|
33
41
|
onFocus,
|
|
@@ -38,11 +46,6 @@ export const Slider = function Slider({
|
|
|
38
46
|
[value, min, max]
|
|
39
47
|
);
|
|
40
48
|
|
|
41
|
-
const percentage = useMemo(() => {
|
|
42
|
-
const percent = ((arrayValue[0] - min) / (max - min)) * 100;
|
|
43
|
-
return `${percent}%`;
|
|
44
|
-
}, [arrayValue, min, max]);
|
|
45
|
-
|
|
46
49
|
const handleValueChange = useCallback(
|
|
47
50
|
(arrayValue: number[]) => {
|
|
48
51
|
onValueChange(arrayValue[0]);
|
|
@@ -50,22 +53,49 @@ export const Slider = function Slider({
|
|
|
50
53
|
[onValueChange]
|
|
51
54
|
);
|
|
52
55
|
|
|
56
|
+
const percentage = useMemo(() => {
|
|
57
|
+
// Calculate the raw percentage (for label)
|
|
58
|
+
const rawPercent = (arrayValue[0] - min) / (max - min);
|
|
59
|
+
// Adjust the percentage to account for thumb width (for fill)
|
|
60
|
+
const adjustedPercent =
|
|
61
|
+
rawPercent * (100 - (THUMB_WIDTH * 100) / 300) + (THUMB_WIDTH * 50) / 300;
|
|
62
|
+
return {
|
|
63
|
+
raw: rawPercent * 100,
|
|
64
|
+
adjusted: adjustedPercent,
|
|
65
|
+
};
|
|
66
|
+
}, [arrayValue, min, max]);
|
|
67
|
+
|
|
68
|
+
const trackFillStyle = useMemo(
|
|
69
|
+
() => ({
|
|
70
|
+
clipPath: `inset(0 ${100 - percentage.adjusted}% 0 0)`,
|
|
71
|
+
}),
|
|
72
|
+
[percentage.adjusted]
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
const labelStyle = useMemo(
|
|
76
|
+
() => ({
|
|
77
|
+
clipPath: `inset(0 ${100 - percentage.raw}% 0 0)`,
|
|
78
|
+
}),
|
|
79
|
+
[percentage.raw]
|
|
80
|
+
);
|
|
81
|
+
|
|
53
82
|
return (
|
|
54
83
|
<RadixSlider.Root
|
|
55
84
|
min={min}
|
|
56
85
|
max={max}
|
|
86
|
+
step={step}
|
|
57
87
|
id={id}
|
|
58
88
|
value={arrayValue}
|
|
59
89
|
onValueChange={handleValueChange}
|
|
60
90
|
className={cx(
|
|
61
|
-
"flex relative items-center select-none touch-none h-[27px]",
|
|
91
|
+
"flex relative items-center select-none touch-none h-[27px] rounded overflow-hidden",
|
|
62
92
|
className
|
|
63
93
|
)}
|
|
64
94
|
style={style}
|
|
65
95
|
onFocus={onFocus}
|
|
66
96
|
onBlur={onBlur}
|
|
67
97
|
>
|
|
68
|
-
<RadixSlider.Track className="
|
|
98
|
+
<RadixSlider.Track className="relative flex-grow h-full rounded overflow-hidden bg-input-background">
|
|
69
99
|
{label && (
|
|
70
100
|
<label
|
|
71
101
|
htmlFor={id}
|
|
@@ -74,9 +104,10 @@ export const Slider = function Slider({
|
|
|
74
104
|
{label}
|
|
75
105
|
</label>
|
|
76
106
|
)}
|
|
77
|
-
<
|
|
107
|
+
<div
|
|
108
|
+
style={trackFillStyle}
|
|
78
109
|
className={cx(
|
|
79
|
-
"absolute h-full rounded",
|
|
110
|
+
"absolute inset-0 w-full h-full rounded overflow-hidden",
|
|
80
111
|
colorScheme === undefined && "bg-slider-border",
|
|
81
112
|
colorScheme === "primary" && "bg-primary",
|
|
82
113
|
colorScheme === "secondary" && "bg-secondary"
|
|
@@ -84,8 +115,9 @@ export const Slider = function Slider({
|
|
|
84
115
|
/>
|
|
85
116
|
</RadixSlider.Track>
|
|
86
117
|
<RadixSlider.Thumb
|
|
118
|
+
style={thumbStyle}
|
|
87
119
|
className={cx(
|
|
88
|
-
"block
|
|
120
|
+
"block h-[27px] rounded border border-solid bg-slider-thumb-background focus:outline-none cursor-ew-resize",
|
|
89
121
|
colorScheme === undefined && "border-slider-border",
|
|
90
122
|
colorScheme === "primary" && "border-primary",
|
|
91
123
|
colorScheme === "secondary" && "border-secondary"
|
|
@@ -98,11 +130,11 @@ export const Slider = function Slider({
|
|
|
98
130
|
labelStyles,
|
|
99
131
|
"absolute top-0 bottom-0 left-2 right-2 text-white overflow-hidden flex justify-end"
|
|
100
132
|
)}
|
|
101
|
-
style={
|
|
133
|
+
style={labelStyle}
|
|
102
134
|
>
|
|
103
135
|
{label}
|
|
104
136
|
</label>
|
|
105
137
|
)}
|
|
106
138
|
</RadixSlider.Root>
|
|
107
139
|
);
|
|
108
|
-
};
|
|
140
|
+
});
|
package/src/index.css
CHANGED
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
--popover-divider: transparent;
|
|
38
38
|
--listview-raised-background: rgba(0, 0, 0, 0.03);
|
|
39
39
|
--listview-editing-background: #fff;
|
|
40
|
-
--slider-background: white;
|
|
40
|
+
--slider-thumb-background: white;
|
|
41
41
|
--slider-border: #9698ac;
|
|
42
42
|
--radio-group-background: white;
|
|
43
43
|
--mask: rgb(12, 193, 67);
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
--text: rgb(248, 248, 250);
|
|
88
88
|
--text-muted: rgb(180, 179, 182);
|
|
89
89
|
--text-subtle: rgb(180, 179, 182);
|
|
90
|
-
--text-disabled: rgb(
|
|
90
|
+
--text-disabled: rgb(115, 114, 126);
|
|
91
91
|
--divider-subtle: rgba(255, 255, 255, 0.04);
|
|
92
92
|
--divider: rgba(255, 255, 255, 0.08);
|
|
93
93
|
--divider-strong: rgba(0, 0, 0, 1);
|
|
@@ -105,7 +105,7 @@
|
|
|
105
105
|
--popover-divider: rgba(255, 255, 255, 0.08);
|
|
106
106
|
--listview-raised-background: rgba(181, 178, 255, 0.1);
|
|
107
107
|
--listview-editing-background: #000;
|
|
108
|
-
--slider-background:
|
|
108
|
+
--slider-thumb-background: rgb(248, 248, 250);
|
|
109
109
|
--radio-group-background: rgba(181, 178, 255, 0.08);
|
|
110
110
|
--mask: rgb(102, 187, 106);
|
|
111
111
|
--transparent-checker: rgba(255, 255, 255, 0.3);
|
package/tailwind.config.ts
CHANGED
|
@@ -44,7 +44,7 @@ const config = {
|
|
|
44
44
|
"popover-divider": "var(--popover-divider)",
|
|
45
45
|
"listview-raised-background": "var(--listview-raised-background)",
|
|
46
46
|
"listview-editing-background": "var(--listview-editing-background)",
|
|
47
|
-
"slider-background": "var(--slider-background)",
|
|
47
|
+
"slider-thumb-background": "var(--slider-thumb-background)",
|
|
48
48
|
"slider-border": "var(--slider-border)",
|
|
49
49
|
"radio-group-background": "var(--radio-group-background)",
|
|
50
50
|
mask: "var(--mask)",
|