@noya-app/noya-designsystem 0.1.59 → 0.1.61

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@noya-app/noya-designsystem",
3
- "version": "0.1.59",
3
+ "version": "0.1.61",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",
@@ -22,12 +22,12 @@
22
22
  "dependencies": {
23
23
  "@dnd-kit/core": "6.3.1",
24
24
  "@dnd-kit/sortable": "10.0.0",
25
- "@noya-app/noya-colorpicker": "0.1.23",
25
+ "@noya-app/noya-colorpicker": "0.1.25",
26
26
  "@noya-app/noya-utils": "0.1.5",
27
- "@noya-app/noya-geometry": "0.1.11",
27
+ "@noya-app/noya-geometry": "0.1.12",
28
28
  "@noya-app/noya-icons": "0.1.10",
29
29
  "@noya-app/noya-keymap": "0.1.3",
30
- "@noya-app/noya-tailwind-config": "0.1.3",
30
+ "@noya-app/noya-tailwind-config": "0.1.4",
31
31
  "@radix-ui/primitive": "^1.0.0",
32
32
  "@radix-ui/react-avatar": "^1.0.1",
33
33
  "@radix-ui/react-compose-refs": "^1.0.0",
@@ -12,6 +12,7 @@ export interface BaseToolbarProps {
12
12
  }
13
13
 
14
14
  const toolbarStyle = {
15
+ [cssVarNames.colors.buttonBackground]: "transparent",
15
16
  [cssVarNames.colors.inputBackground]: "transparent",
16
17
  };
17
18
 
@@ -25,7 +25,7 @@ type ButtonSize = "small" | "normal" | "large" | "floating";
25
25
 
26
26
  const variantStyles: Record<ButtonVariant, string> = {
27
27
  normal:
28
- "bg-input-background text-text hover:bg-input-background-light active:bg-active-background min-w-[31px]",
28
+ "bg-button-background text-button-text hover:bg-button-background-hover active:bg-button-background-active min-w-[31px]",
29
29
  primary:
30
30
  "bg-primary text-white hover:bg-primary-light active:bg-primary min-w-[31px]",
31
31
  secondary:
@@ -96,7 +96,7 @@ export const Button = forwardRef(function Button(
96
96
  disabled ? "opacity-25" : "",
97
97
  !className?.includes("flex") ? "flex-none" : "",
98
98
  active
99
- ? "bg-primary-pastel text-primary hover:bg-primary-pastel-light min-w-[31px]"
99
+ ? "bg-button-background-active text-button-text-active hover:bg-button-background-active-hover min-w-[31px]"
100
100
  : variantStyles[variant],
101
101
  sizeStyles[
102
102
  variant === "thin"
@@ -15,7 +15,7 @@ const colorSchemeStyles = {
15
15
 
16
16
  export const Checkbox = React.memo(
17
17
  React.forwardRef<HTMLInputElement, CheckboxProps>(function Checkbox(
18
- { className, style, colorScheme = "secondary", ...props },
18
+ { className, style, colorScheme = "primary", ...props },
19
19
  ref
20
20
  ) {
21
21
  const { fieldId: id } = useLabel({ fieldId: props.id });
@@ -39,10 +39,10 @@ export const Checkbox = React.memo(
39
39
  m-0
40
40
  rounded
41
41
  bg-input-background
42
-
43
42
  border
44
43
  border-divider
45
44
  disabled:opacity-50
45
+ cursor-pointer
46
46
  disabled:cursor-not-allowed
47
47
  focus:ring-2
48
48
  focus:ring-primary
@@ -115,5 +115,6 @@ export type CollectionItemSize =
115
115
  | "xs"
116
116
  | "small"
117
117
  | "medium"
118
+ | "mediumLarge"
118
119
  | "large"
119
120
  | "xl";
@@ -20,11 +20,12 @@ export const Divider = memo(function Divider({
20
20
  return (
21
21
  <div
22
22
  className={cx(
23
- `
24
- h-px min-h-px
25
- ${variant === "strong" ? "bg-divider-strong" : variant === "subtle" ? "bg-divider-subtle" : "bg-divider"}
26
- self-stretch
27
- `,
23
+ `h-px min-h-px self-stretch`,
24
+ variant === "strong"
25
+ ? "bg-divider-strong"
26
+ : variant === "subtle"
27
+ ? "bg-divider-subtle"
28
+ : "bg-divider",
28
29
  className
29
30
  )}
30
31
  style={{
@@ -46,12 +47,15 @@ export const DividerVertical = memo(function DividerVertical({
46
47
  }: DividerProps) {
47
48
  return (
48
49
  <div
49
- className={cx(`
50
- w-px min-w-px
51
- ${variant === "strong" ? "bg-divider-strong" : variant === "subtle" ? "bg-divider-subtle" : "bg-divider"}
52
- self-stretch
53
- ${className}
54
- `)}
50
+ className={cx(
51
+ `w-px min-w-px self-stretch`,
52
+ variant === "strong"
53
+ ? "bg-divider-strong"
54
+ : variant === "subtle"
55
+ ? "bg-divider-subtle"
56
+ : "bg-divider",
57
+ className
58
+ )}
55
59
  style={{
56
60
  marginTop: `-${overflow}px`,
57
61
  marginBottom: `-${overflow}px`,
@@ -41,6 +41,10 @@ export const getGridSize = (size: CollectionItemSize) => {
41
41
  minColumnWidth: "220px",
42
42
  gap: 30,
43
43
  },
44
+ mediumLarge: {
45
+ minColumnWidth: "250px",
46
+ gap: 35,
47
+ },
44
48
  large: {
45
49
  minColumnWidth: "280px",
46
50
  gap: 40,
@@ -336,6 +336,7 @@ const pyMap: Record<CollectionItemSize, string> = {
336
336
  xs: "py-0.5",
337
337
  small: "py-0.5",
338
338
  medium: "py-1",
339
+ mediumLarge: "py-1.5",
339
340
  large: "py-2",
340
341
  xl: "py-3",
341
342
  };
@@ -345,6 +346,7 @@ const thumbnailSizeMap: Record<CollectionItemSize, string> = {
345
346
  xs: "w-5 h-5",
346
347
  small: "w-5 h-5",
347
348
  medium: "w-8 h-8",
349
+ mediumLarge: "w-12 h-12",
348
350
  large: "w-16 h-16",
349
351
  xl: "w-24 h-24",
350
352
  };
@@ -354,6 +356,7 @@ const rowGapMap: Record<CollectionItemSize, string> = {
354
356
  xs: "gap-2",
355
357
  small: "gap-2",
356
358
  medium: "gap-3",
359
+ mediumLarge: "gap-3",
357
360
  large: "gap-3",
358
361
  xl: "gap-4",
359
362
  };
@@ -363,6 +366,7 @@ const fontStyleMap: Record<CollectionItemSize, string> = {
363
366
  xs: "font-medium text-list-small",
364
367
  small: "font-medium text-list-small",
365
368
  medium: "font-medium",
369
+ mediumLarge: "font-medium",
366
370
  large: "font-medium",
367
371
  xl: "font-medium text-heading4 text-text",
368
372
  };
@@ -158,6 +158,7 @@ const iconSizeMap: Record<CollectionItemSize, number | string> = {
158
158
  xs: 12,
159
159
  small: 12,
160
160
  medium: "max(15px, 20%)",
161
+ mediumLarge: "max(15px, 20%)",
161
162
  large: "max(15px, 20%)",
162
163
  xl: "max(15px, 20%)",
163
164
  };
@@ -88,7 +88,7 @@ const SegmentedControlItem = forwardRef(function SegmentedControlItem<
88
88
  ? "aria-checked:bg-secondary aria-checked:text-white"
89
89
  : colorScheme === "primary"
90
90
  ? "aria-checked:bg-primary aria-checked:text-white"
91
- : "aria-checked:bg-background aria-checked:text-text",
91
+ : "aria-checked:bg-segmented-control-item-active-background aria-checked:text-segmented-control-item-active-text",
92
92
  "focus:z-interactable",
93
93
  variant === "default"
94
94
  ? "px-1 rounded aria-checked:shadow-segment"
@@ -1,4 +1,5 @@
1
1
  import {
2
+ cssVarNames,
2
3
  portalScopeProps,
3
4
  usePortalScopeId,
4
5
  } from "@noya-app/noya-designsystem";
@@ -6,7 +7,7 @@ import { Rect } from "@noya-app/noya-geometry";
6
7
  import { useSize } from "@noya-app/react-utils";
7
8
  import * as PopperPrimitive from "@radix-ui/react-popper";
8
9
  import type { MeasurableElement } from "@radix-ui/utils";
9
- import React, { CSSProperties, memo, useMemo } from "react";
10
+ import React, { memo, useMemo } from "react";
10
11
  import { createPortal } from "react-dom";
11
12
 
12
13
  // Create a Measurable from a Rect
@@ -61,7 +62,8 @@ export const SelectionToolbarContainer = memo(
61
62
  zIndex: 1000,
62
63
  opacity: size ? 1 : 0,
63
64
  transition: "opacity 0.2s ease-in-out",
64
- ["--n-input-background" as keyof CSSProperties]: "transparent",
65
+ [cssVarNames.colors.inputBackground]: "transparent",
66
+ [cssVarNames.colors.buttonBackground]: "transparent",
65
67
  }}
66
68
  >
67
69
  <div
@@ -1,9 +1,7 @@
1
1
  import * as RadixSlider from "@radix-ui/react-slider";
2
2
  import React, { FocusEventHandler, memo, useCallback, useMemo } from "react";
3
- import { useLabel, useLabelPosition } from "../hooks/useLabel";
3
+ import { useLabel } from "../hooks/useLabel";
4
4
  import { cx } from "../utils/classNames";
5
- import { getInsetEndStyles } from "../utils/inputs";
6
- import { Label } from "./Label";
7
5
 
8
6
  type ColorScheme = "primary" | "secondary";
9
7
 
@@ -29,8 +27,6 @@ const thumbStyle = {
29
27
  width: THUMB_WIDTH,
30
28
  };
31
29
 
32
- const insetEndStyles = getInsetEndStyles();
33
-
34
30
  export const Slider = memo(function Slider({
35
31
  style,
36
32
  className,
@@ -50,11 +46,9 @@ export const Slider = memo(function Slider({
50
46
  [value, min, max]
51
47
  );
52
48
 
53
- const { label, fieldId: id } = useLabel({
54
- label: props.label,
49
+ const { fieldId: id } = useLabel({
55
50
  fieldId: props.id,
56
51
  });
57
- const labelPosition = useLabelPosition();
58
52
 
59
53
  const handleValueChange = useCallback(
60
54
  (arrayValue: number[]) => {
@@ -63,31 +57,7 @@ export const Slider = memo(function Slider({
63
57
  [onValueChange]
64
58
  );
65
59
 
66
- const percentage = useMemo(() => {
67
- // Calculate the raw percentage (for label)
68
- const rawPercent = (arrayValue[0] - min) / (max - min);
69
- // Adjust the percentage to account for thumb width (for fill)
70
- const adjustedPercent =
71
- rawPercent * (100 - (THUMB_WIDTH * 100) / 300) + (THUMB_WIDTH * 50) / 300;
72
- return {
73
- raw: rawPercent * 100,
74
- adjusted: adjustedPercent,
75
- };
76
- }, [arrayValue, min, max]);
77
-
78
- const trackFillStyle = useMemo(
79
- () => ({
80
- clipPath: `inset(0 ${100 - percentage.adjusted}% 0 0)`,
81
- }),
82
- [percentage.adjusted]
83
- );
84
-
85
- const labelStyle = useMemo(
86
- () => ({
87
- clipPath: `inset(0 ${100 - percentage.raw}% 0 0)`,
88
- }),
89
- [percentage.raw]
90
- );
60
+ const ratio = (arrayValue[0] - min) / (max - min);
91
61
 
92
62
  return (
93
63
  <RadixSlider.Root
@@ -98,7 +68,7 @@ export const Slider = memo(function Slider({
98
68
  value={arrayValue}
99
69
  onValueChange={handleValueChange}
100
70
  className={cx(
101
- "flex relative items-center select-none touch-none h-input-height rounded overflow-hidden flex-grow max-h-input-height",
71
+ "flex relative items-center select-none touch-none h-input-height rounded flex-grow max-h-input-height cursor-pointer",
102
72
  className
103
73
  )}
104
74
  style={style}
@@ -106,34 +76,28 @@ export const Slider = memo(function Slider({
106
76
  onBlur={onBlur}
107
77
  disabled={readOnly}
108
78
  >
109
- <RadixSlider.Track className="flex-grow h-full rounded overflow-hidden bg-input-background">
110
- {label && labelPosition === "inset" && (
111
- <div className={insetEndStyles}>
112
- <Label htmlFor={id} className="text-text-disabled">
113
- {label}
114
- </Label>
115
- </div>
116
- )}
79
+ <div className="relative flex-grow h-[3px] overflow-hidden">
117
80
  <div
118
- style={trackFillStyle}
119
- className={cx(
120
- "absolute inset-0 w-full h-full rounded overflow-hidden bg-primary-pastel",
121
- colorScheme === "primary" && "bg-primary",
122
- colorScheme === "secondary" && "bg-secondary"
123
- )}
81
+ className="absolute h-full rounded-l bg-primary"
82
+ style={{
83
+ left: 0,
84
+ width: `calc(${ratio * 100}% - ${ratio * 8}px - 2px)`,
85
+ }}
124
86
  />
125
- </RadixSlider.Track>
126
- {label && labelPosition === "inset" && colorScheme !== undefined && (
127
- <div className={insetEndStyles}>
128
- <Label className="text-white overflow-hidden" style={labelStyle}>
129
- {label}
130
- </Label>
131
- </div>
132
- )}
87
+ <div
88
+ className="absolute h-full rounded-r bg-input-background"
89
+ style={{
90
+ right: 0,
91
+ width: `calc(100% - ${ratio * 100}% + ${ratio * 8}px - 10px)`,
92
+ }}
93
+ />
94
+ </div>
133
95
  <RadixSlider.Thumb
134
96
  style={thumbStyle}
135
97
  className={cx(
136
- "block h-input-height rounded border border-solid bg-slider-thumb-background transition-colors focus:border-primary focus:border-2 outline-none",
98
+ "block h-[21px] rounded-sm bg-slider-thumb-background shadow-sliderThumb transition-colors focus:outline-primary focus:outline-2",
99
+ "cursor-ew-resize",
100
+ // "outline-none outline outline-2 outline-offset-[0px] outline-background",
137
101
  colorScheme === undefined && "border-slider-border",
138
102
  colorScheme === "primary" && "border-primary",
139
103
  colorScheme === "secondary" && "border-secondary"
package/src/index.css CHANGED
@@ -1,5 +1,7 @@
1
1
  :root {
2
2
  --n-primary-900: rgb(45, 25, 95); /* dark: --n-primary-pastel */
3
+ --n-primary-800: rgb(64, 39, 140);
4
+ --n-primary-700: rgb(95, 68, 190);
3
5
  --n-primary-600: rgb(103, 70, 255); /* --n-primary */
4
6
  --n-primary-500: rgb(119, 66, 255); /* dark: --n-primary */
5
7
  --n-primary-400: rgb(147, 86, 255); /* --n-primary-light */
@@ -8,6 +10,7 @@
8
10
  --n-primary-200: rgb(188, 160, 255);
9
11
  --n-primary-150: rgb(225, 219, 255);
10
12
  --n-primary-100: rgb(234, 230, 255); /* --n-primary-pastel */
13
+ --n-primary-50: rgb(243, 242, 255);
11
14
 
12
15
  --n-indigo-950: rgb(18, 26, 37);
13
16
  --n-indigo-900: rgb(30, 40, 60);
@@ -41,6 +44,7 @@
41
44
  --n-secondary-light: rgb(0, 160, 129);
42
45
  --n-secondary-pastel: rgb(205, 238, 231);
43
46
  --n-secondary-bright: #0ab557;
47
+ --n-input-background: var(--n-indigo-100);
44
48
  --n-input-background-light: rgb(243, 245, 249);
45
49
  --n-code-background: rgb(250, 250, 250);
46
50
  --n-code-background-dark: var(--n-indigo-950);
@@ -48,6 +52,12 @@
48
52
  --n-breadcrumb-text: var(--n-indigo-500);
49
53
  --n-breadcrumb-text-hover: var(--n-indigo-400);
50
54
  --n-breadcrumb-icon: var(--n-indigo-300);
55
+ --n-button-background: var(--n-input-background);
56
+ --n-button-background-hover: var(--n-input-background-light);
57
+ --n-button-background-active: var(--n-primary-100);
58
+ --n-button-background-active-hover: var(--n-primary-50);
59
+ --n-button-text: var(--n-text);
60
+ --n-button-text-active: var(--n-primary);
51
61
  --n-canvas-background: var(--n-indigo-25);
52
62
  --n-canvas-grid: rgba(0, 0, 0, 0.05);
53
63
  --n-sidebar-background: rgb(255, 255, 255);
@@ -55,7 +65,6 @@
55
65
  --n-popover-divider: transparent;
56
66
  --n-listview-raised-background: rgba(0, 0, 0, 0.03);
57
67
  --n-listview-editing-background: #fff;
58
- --n-input-background: var(--n-indigo-100);
59
68
  --n-list-view-hover-background: rgb(244, 246, 250);
60
69
  --n-list-view-thumbnail-background: var(--n-input-background);
61
70
  --n-slider-thumb-background: white;
@@ -84,6 +93,8 @@
84
93
  --n-icon-selected: rgb(220, 220, 220);
85
94
  --n-warning: rgb(251, 211, 0);
86
95
  --n-segmented-control-item: rgb(139, 139, 139);
96
+ --n-segmented-control-item-active-background: var(--n-background);
97
+ --n-segmented-control-item-active-text: var(--n-text);
87
98
  --n-dot: rgba(0, 0, 0, 0.25);
88
99
  --n-row-highlight: #3390ff10;
89
100
  --n-table-row-background: var(--n-background);
@@ -136,12 +147,17 @@
136
147
  --n-divider-strong: rgba(0, 0, 0, 1);
137
148
  --n-primary: var(--n-primary-500);
138
149
  --n-primary-light: var(--n-primary-300);
150
+ --n-icon: var(--n-text-muted);
139
151
  --n-selected-list-item-background: var(--n-primary-900);
140
- --n-selected-list-item-text: var(--n-primary-200);
152
+ --n-selected-list-item-text: var(--n-primary-100);
141
153
  --n-selected-list-item-icon-background: var(--n-primary-900);
154
+ --n-button-background-active: var(--n-primary-900);
155
+ --n-button-background-active-hover: var(--n-primary-800);
156
+ --n-button-text: var(--n-text);
157
+ --n-button-text-active: var(--n-primary-100);
142
158
  --n-secondary-bright: #36fe91;
143
- --n-input-background: rgba(181, 178, 255, 0.08);
144
- --n-input-background-light: rgba(181, 178, 255, 0.1);
159
+ --n-input-background: rgb(45 43 54);
160
+ --n-input-background-light: rgb(60 58 70);
145
161
  --n-code-background: rgb(20, 19, 23);
146
162
  --n-canvas-background: rgb(20, 19, 23);
147
163
  --n-canvas-grid: rgba(0, 0, 0, 0.1);
@@ -154,6 +170,8 @@
154
170
  --n-list-view-thumbnail-background: var(--n-input-background);
155
171
  --n-slider-thumb-background: var(--n-input-background-light);
156
172
  --n-slider-border: var(--n-divider);
173
+ --n-segmented-control-item-active-text: var(--n-text);
174
+ --n-segmented-control-item-active-background: var(--n-input-background-light);
157
175
  --n-mask: rgb(102, 187, 106);
158
176
  --n-transparent-checker: rgba(255, 255, 255, 0.3);
159
177
  --n-scrollbar: rgba(199, 199, 199, 0.2);