@noya-app/noya-designsystem 0.1.5 → 0.1.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@noya-app/noya-designsystem",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",
@@ -13,10 +13,10 @@
13
13
  "@dnd-kit/core": "3.1.1",
14
14
  "@dnd-kit/modifiers": "3.0.0",
15
15
  "@dnd-kit/sortable": "4.0.0",
16
- "@noya-app/noya-colorpicker": "0.1.3",
16
+ "@noya-app/noya-colorpicker": "0.1.5",
17
17
  "@noya-app/noya-utils": "0.1.0",
18
- "@noya-app/noya-geometry": "0.1.1",
19
- "@noya-app/noya-icons": "0.1.0",
18
+ "@noya-app/noya-geometry": "0.1.2",
19
+ "@noya-app/noya-icons": "0.1.2",
20
20
  "@noya-app/noya-keymap": "0.1.0",
21
21
  "@radix-ui/primitive": "^1.0.0",
22
22
  "@radix-ui/react-avatar": "^1.0.1",
@@ -11,6 +11,7 @@ import { Tooltip } from "./Tooltip";
11
11
  type ButtonVariant =
12
12
  | "normal"
13
13
  | "primary"
14
+ | "primaryGradient"
14
15
  | "secondary"
15
16
  | "secondaryBright"
16
17
  | "white"
@@ -54,19 +55,27 @@ export const ButtonElement = styled.button<{
54
55
  }),
55
56
  background: active
56
57
  ? theme.colors.primary
57
- : variant === "none" || variant === "thin"
58
- ? "transparent"
59
- : theme.colors.inputBackground,
58
+ : variant === "primaryGradient"
59
+ ? `linear-gradient(90deg, ${theme.colors.primary}, ${theme.colors.primaryLight})`
60
+ : variant === "none" || variant === "thin"
61
+ ? "transparent"
62
+ : theme.colors.inputBackground,
60
63
  color: active ? "white" : theme.colors.text,
61
64
  opacity: disabled ? 0.25 : 1,
62
65
  "&:focus": {
63
66
  boxShadow: `0 0 0 1px ${theme.colors.sidebar.background}, 0 0 0 3px ${theme.colors.primary}`,
64
67
  },
65
68
  "&:hover": {
66
- background: theme.colors.inputBackgroundLight,
69
+ background:
70
+ variant === "primaryGradient"
71
+ ? theme.colors.primaryLight
72
+ : theme.colors.inputBackgroundLight,
67
73
  },
68
74
  "&:active": {
69
- background: theme.colors.activeBackground,
75
+ background:
76
+ variant === "primaryGradient"
77
+ ? theme.colors.primary
78
+ : theme.colors.activeBackground,
70
79
  },
71
80
  ...(variant === "primary" && {
72
81
  background: theme.colors.primary,
@@ -35,8 +35,8 @@ export const DraggableMenuButton = memo(function DraggableMenuButton<
35
35
  onSelect,
36
36
  isVisible = true,
37
37
  }: {
38
- items: MenuItem<T>[];
39
- onSelect: (value: T) => void;
38
+ items?: MenuItem<T>[];
39
+ onSelect?: (value: T) => void;
40
40
  isVisible?: boolean;
41
41
  }) {
42
42
  const color = useDesignSystemTheme().colors.icon;
@@ -98,19 +98,25 @@ export const DraggableMenuButton = memo(function DraggableMenuButton<
98
98
  event.preventDefault();
99
99
  }}
100
100
  >
101
- <DropdownMenu
102
- open={open}
103
- onOpenChange={handleOpenChange}
104
- items={items}
105
- onSelect={onSelect}
106
- shouldBindKeyboardShortcuts={false}
107
- >
108
- <TriggerElement>
109
- <DragHandleDots2Icon
110
- color={isVisible || open ? color : "transparent"}
111
- />
112
- </TriggerElement>
113
- </DropdownMenu>
101
+ {items && onSelect ? (
102
+ <DropdownMenu
103
+ open={open}
104
+ onOpenChange={handleOpenChange}
105
+ items={items}
106
+ onSelect={onSelect}
107
+ shouldBindKeyboardShortcuts={false}
108
+ >
109
+ <TriggerElement>
110
+ <DragHandleDots2Icon
111
+ color={isVisible || open ? color : "transparent"}
112
+ />
113
+ </TriggerElement>
114
+ </DropdownMenu>
115
+ ) : (
116
+ <DragHandleDots2Icon
117
+ color={isVisible || open ? color : "transparent"}
118
+ />
119
+ )}
114
120
  </DotButtonElement>
115
121
  );
116
122
  });
@@ -90,6 +90,7 @@ export const RowLabel = styled.span<{
90
90
  fontWeight: "bold",
91
91
  }),
92
92
  lineHeight: "19px", // Button height
93
+ alignItems: "center",
93
94
  }));
94
95
 
95
96
  export const LabeledRow = memo(function LabeledRow({
@@ -332,6 +332,7 @@ interface ListViewRowProps<MenuItemType extends string = string> {
332
332
  onContextMenu?: () => void;
333
333
  onMenuOpenChange?: (isOpen: boolean) => void;
334
334
  onKeyDown?: (event: React.KeyboardEvent) => void;
335
+ style?: CSSProperties;
335
336
  }
336
337
 
337
338
  const ListViewRow = forwardRef(function ListViewRow<
@@ -357,6 +358,7 @@ const ListViewRow = forwardRef(function ListViewRow<
357
358
  onSelectMenuItem,
358
359
  onMenuOpenChange,
359
360
  onKeyDown,
361
+ style,
360
362
  }: ListViewRowProps<MenuItemType>,
361
363
  forwardedRef: ForwardedRef<HTMLElement>
362
364
  ) {
@@ -402,15 +404,16 @@ const ListViewRow = forwardRef(function ListViewRow<
402
404
  [onDoubleClick]
403
405
  );
404
406
 
405
- const isDraggingStyle = useMemo(() => {
407
+ const mergedStyle = useMemo(() => {
406
408
  return isDragging
407
409
  ? {
408
410
  // TODO: Where do these offsets actually come from?
409
411
  transform: `translate3d(-36px, -6px, 0)`,
410
412
  width: `calc(100% + 48px)`,
413
+ ...style,
411
414
  }
412
- : undefined;
413
- }, [isDragging]);
415
+ : style;
416
+ }, [isDragging, style]);
414
417
 
415
418
  const renderContent = (
416
419
  {
@@ -443,7 +446,7 @@ const ListViewRow = forwardRef(function ListViewRow<
443
446
  aria-selected={selected}
444
447
  divider={!isDragging && divider}
445
448
  onKeyDown={onKeyDown}
446
- style={isDraggingStyle}
449
+ style={mergedStyle}
447
450
  {...renderProps}
448
451
  {...mergeEventHandlers(
449
452
  { onPointerDown: renderProps.onPointerDown },
@@ -655,7 +658,9 @@ type RenderProps<T> = {
655
658
  renderItem: (item: T, index: number, info: ListViewItemInfo) => ReactNode;
656
659
  keyExtractor: (item: T, index: number) => string;
657
660
  /**
658
- * Each item must have an `id` in order to be sortable
661
+ * Each item must have an `id` in order to be sortable.
662
+ *
663
+ * Additionally, the key extracted with `keyExtractor` must match the ListItem.Row `id`.
659
664
  */
660
665
  sortable?: boolean;
661
666
  virtualized?: Size;
@@ -1,4 +1,4 @@
1
- import * as ToggleGroupPrimitive from '@radix-ui/react-toggle-group';
1
+ import * as ToggleGroupPrimitive from "@radix-ui/react-toggle-group";
2
2
  import React, {
3
3
  ComponentProps,
4
4
  createContext,
@@ -8,39 +8,39 @@ import React, {
8
8
  useCallback,
9
9
  useContext,
10
10
  useMemo,
11
- } from 'react';
12
- import styled from 'styled-components';
13
- import { Tooltip } from './Tooltip';
11
+ } from "react";
12
+ import styled from "styled-components";
13
+ import { Tooltip } from "./Tooltip";
14
14
 
15
- type RadioGroupColorScheme = 'primary' | 'secondary';
15
+ type RadioGroupColorScheme = "primary" | "secondary";
16
16
 
17
- const ignoredProps = new Set(['colorScheme']);
17
+ const ignoredProps = new Set(["colorScheme"]);
18
18
 
19
19
  const StyledRoot = styled(ToggleGroupPrimitive.Root).withConfig({
20
20
  shouldForwardProp: (prop) => !ignoredProps.has(prop),
21
21
  })<{
22
22
  colorScheme?: RadioGroupColorScheme;
23
23
  }>(({ theme, colorScheme }) => ({
24
- appearance: 'none',
25
- width: '0px', // Reset intrinsic width
26
- flex: '1 1 0px',
27
- position: 'relative',
28
- border: '0',
29
- outline: 'none',
30
- minWidth: '0',
31
- textAlign: 'left',
32
- alignSelf: 'stretch',
33
- borderRadius: '4px',
24
+ appearance: "none",
25
+ width: "0px", // Reset intrinsic width
26
+ flex: "1 1 0px",
27
+ position: "relative",
28
+ border: "0",
29
+ outline: "none",
30
+ minWidth: "0",
31
+ textAlign: "left",
32
+ alignSelf: "stretch",
33
+ borderRadius: "4px",
34
34
  background: theme.colors.inputBackground,
35
- '&:focus': {
35
+ "&:focus": {
36
36
  boxShadow: `0 0 0 1px ${theme.colors.sidebar.background}, 0 0 0 3px ${
37
- theme.colors[colorScheme ?? 'primary']
37
+ theme.colors[colorScheme ?? "primary"]
38
38
  }`,
39
39
  },
40
- display: 'flex',
41
- alignItems: 'stretch',
42
- minHeight: '27px',
43
- padding: colorScheme === undefined ? '2px' : 0,
40
+ display: "flex",
41
+ alignItems: "stretch",
42
+ minHeight: "27px",
43
+ padding: colorScheme === undefined ? "2px" : 0,
44
44
  }));
45
45
 
46
46
  const StyledItem = styled(ToggleGroupPrimitive.Item).withConfig({
@@ -48,19 +48,20 @@ const StyledItem = styled(ToggleGroupPrimitive.Item).withConfig({
48
48
  })<{
49
49
  colorScheme?: RadioGroupColorScheme;
50
50
  }>(({ theme, colorScheme }) => ({
51
- position: 'relative',
52
- flex: '1 1 0',
53
- appearance: 'none',
54
- border: 'none',
55
- background: 'none',
56
- color: 'rgb(139, 139, 139)',
51
+ ...theme.textStyles.small,
52
+ position: "relative",
53
+ flex: "1 1 0",
54
+ appearance: "none",
55
+ border: "none",
56
+ background: "none",
57
+ color: "rgb(139, 139, 139)",
57
58
  padding: 0,
58
59
  margin: 0,
59
- borderRadius: '4px',
60
- display: 'inline-flex',
61
- alignItems: 'center',
62
- justifyContent: 'center',
63
- verticalAlign: 'middle',
60
+ borderRadius: "4px",
61
+ display: "inline-flex",
62
+ alignItems: "center",
63
+ justifyContent: "center",
64
+ verticalAlign: "middle",
64
65
  '&[aria-checked="true"]': {
65
66
  backgroundColor: colorScheme
66
67
  ? theme.colors[colorScheme]
@@ -68,10 +69,10 @@ const StyledItem = styled(ToggleGroupPrimitive.Item).withConfig({
68
69
  color: colorScheme ? theme.colors.radioGroup.background : theme.colors.text,
69
70
  boxShadow: colorScheme ? undefined : `0 1px 1px rgba(0,0,0,0.1)`,
70
71
  },
71
- '&:focus': {
72
- outline: 'none',
72
+ "&:focus": {
73
+ outline: "none",
73
74
  boxShadow: `0 0 0 1px ${theme.colors.sidebar.background}, 0 0 0 3px ${
74
- theme.colors[colorScheme ?? 'primary']
75
+ theme.colors[colorScheme ?? "primary"]
75
76
  }`,
76
77
  },
77
78
  }));
@@ -85,7 +86,7 @@ interface ItemProps {
85
86
 
86
87
  const ToggleGroupItem = forwardRef(function ToggleGroupItem(
87
88
  { value, tooltip, children, disabled = false }: ItemProps,
88
- forwardedRef: React.ForwardedRef<HTMLButtonElement>,
89
+ forwardedRef: React.ForwardedRef<HTMLButtonElement>
89
90
  ) {
90
91
  const { colorScheme } = useContext(RadioGroupContext);
91
92
 
@@ -112,13 +113,13 @@ type RadioGroupContextValue = {
112
113
  };
113
114
 
114
115
  const RadioGroupContext = createContext<RadioGroupContextValue>({
115
- colorScheme: 'primary',
116
+ colorScheme: "primary",
116
117
  });
117
118
 
118
119
  interface Props {
119
120
  id?: string;
120
121
  value?: string;
121
- onValueChange?: ComponentProps<typeof StyledRoot>['onValueChange'];
122
+ onValueChange?: ComponentProps<typeof StyledRoot>["onValueChange"];
122
123
  colorScheme?: RadioGroupColorScheme;
123
124
  allowEmpty?: boolean;
124
125
  children: ReactNode;
@@ -139,7 +140,7 @@ function ToggleGroupRoot({
139
140
  if (!allowEmpty && !value) return;
140
141
  onValueChange?.(value);
141
142
  },
142
- [allowEmpty, onValueChange],
143
+ [allowEmpty, onValueChange]
143
144
  );
144
145
 
145
146
  return (
@@ -87,7 +87,7 @@ type ChildrenProps<T> =
87
87
  children: ReactNode;
88
88
  }
89
89
  | {
90
- options: T[];
90
+ options: readonly T[];
91
91
  getTitle?: (option: T, index: number) => string;
92
92
  onChange: (value: T) => void;
93
93
  };
package/src/theme/dark.ts CHANGED
@@ -34,6 +34,9 @@ export const colors = produce(lightTheme.colors, (colors) => {
34
34
  colors.activeBackground = "rgba(181,178,255,0.08)";
35
35
  colors.thumbnailBackground = "#1f1d33";
36
36
  colors.thumbnailShadow = "#1f1d3366";
37
+ colors.breadcrumb.text = colors.textMuted;
38
+ colors.breadcrumb.textHover = colors.textSubtle;
39
+ colors.breadcrumb.icon = colors.icon;
37
40
  });
38
41
 
39
42
  export { fonts, sizes, textStyles } from "./light";