@noya-app/noya-designsystem 0.1.15 → 0.1.17

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.15",
3
+ "version": "0.1.17",
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.8",
16
+ "@noya-app/noya-colorpicker": "0.1.9",
17
17
  "@noya-app/noya-utils": "0.1.1",
18
18
  "@noya-app/noya-geometry": "0.1.3",
19
- "@noya-app/noya-icons": "0.1.3",
19
+ "@noya-app/noya-icons": "0.1.4",
20
20
  "@noya-app/noya-keymap": "0.1.2",
21
21
  "@radix-ui/primitive": "^1.0.0",
22
22
  "@radix-ui/react-avatar": "^1.0.1",
@@ -38,18 +38,18 @@
38
38
  "kiwi.js": "^1.1.3",
39
39
  "react-virtualized": "^9.22.3",
40
40
  "react-window": "^1.8.8",
41
- "styled-components": "5.3.0",
42
41
  "vscode-fuzzy-scorer": "^0.0.4"
43
42
  },
44
43
  "devDependencies": {
45
44
  "@types/react": "*",
46
45
  "@types/react-dom": "*",
47
46
  "@types/react-virtualized": "^9.21.21",
48
- "@types/react-window": "^1.8.5",
49
- "@types/styled-components": "5.1.26"
47
+ "@types/react-window": "^1.8.5"
50
48
  },
51
49
  "peerDependencies": {
52
50
  "react": "*",
53
- "react-dom": "*"
51
+ "react-dom": "*",
52
+ "styled-components": "6.1.12",
53
+ "stylis": "4.3.2"
54
54
  }
55
55
  }
@@ -1,5 +1,5 @@
1
- import React, { memo } from 'react';
2
- import styled, { keyframes } from 'styled-components';
1
+ import React, { memo } from "react";
2
+ import styled, { keyframes } from "styled-components";
3
3
 
4
4
  interface Props {
5
5
  size?: number;
@@ -8,37 +8,47 @@ interface Props {
8
8
  trackColor?: string;
9
9
  }
10
10
 
11
+ interface SpinnerProps {
12
+ $opacity: number;
13
+ }
14
+
15
+ interface SpinnerCircleProps {
16
+ $size: number;
17
+ $color: string;
18
+ $trackColor: string;
19
+ }
20
+
11
21
  const spin = keyframes`
12
22
  0% { transform: rotate(0deg); }
13
23
  100% { transform: rotate(360deg); }
14
24
  `;
15
25
 
16
- const Spinner = styled.div`
26
+ const Spinner = styled.div<SpinnerProps>`
17
27
  display: flex;
18
28
  justify-content: center;
19
29
  align-items: center;
20
- opacity: ${({ opacity }: Props) => opacity};
30
+ opacity: ${({ $opacity }: SpinnerProps) => $opacity};
21
31
  `;
22
32
 
23
33
  // Use css syntax to support keyframes
24
- const SpinnerCircle = styled.div<Props>`
25
- border: 2px solid ${({ trackColor }) => trackColor};
26
- border-top: 2px solid ${({ color }) => color};
34
+ const SpinnerCircle = styled.div<SpinnerCircleProps>`
35
+ border: 2px solid ${({ $trackColor }) => $trackColor};
36
+ border-top: 2px solid ${({ $color }) => $color};
27
37
  border-radius: 50%;
28
- width: ${({ size }) => `${size}px`};
29
- height: ${({ size }) => `${size}px`};
38
+ width: ${({ $size }) => `${$size}px`};
39
+ height: ${({ $size }) => `${$size}px`};
30
40
  animation: ${spin} 1s linear infinite;
31
41
  `;
32
42
 
33
43
  export const ActivityIndicator = memo(function ActivityIndicator({
34
44
  size = 16,
35
45
  opacity = 1,
36
- color = 'black',
37
- trackColor = 'rgba(0, 0, 0, 0.1)',
46
+ color = "black",
47
+ trackColor = "rgba(0, 0, 0, 0.1)",
38
48
  }: Props) {
39
49
  return (
40
- <Spinner opacity={opacity}>
41
- <SpinnerCircle size={size} color={color} trackColor={trackColor} />
50
+ <Spinner $opacity={opacity}>
51
+ <SpinnerCircle $size={size} $color={color} $trackColor={trackColor} />
42
52
  </Spinner>
43
53
  );
44
54
  });
@@ -97,7 +97,7 @@ export const ArrayController = memo(function ArrayController<Item>({
97
97
  };
98
98
 
99
99
  return (
100
- <InspectorPrimitives.Section id={id} padding={padding} gap="2px">
100
+ <InspectorPrimitives.Section id={id} $padding={padding} $gap="2px">
101
101
  <InspectorPrimitives.SectionHeader>
102
102
  <Button variant="none" onClick={onClickPlus}>
103
103
  <InspectorPrimitives.Title>{title}</InspectorPrimitives.Title>
@@ -147,10 +147,10 @@ export const ArrayController = memo(function ArrayController<Item>({
147
147
  {renderRow(index)}
148
148
  {relativeDropPosition && (
149
149
  <ListView.DragIndicator
150
- gap={0}
151
- colorScheme="primary"
152
- relativeDropPosition={relativeDropPosition}
153
- offsetLeft={0}
150
+ $gap={0}
151
+ $colorScheme="primary"
152
+ $relativeDropPosition={relativeDropPosition}
153
+ $offsetLeft={0}
154
154
  />
155
155
  )}
156
156
  </ItemContainer>
@@ -76,11 +76,11 @@ export const Avatar = forwardRef(function Avatar(
76
76
  });
77
77
 
78
78
  const AvatarStackItemWrapper = styled.div<{
79
- size: number;
80
- }>(({ size, theme }) => ({
79
+ $size: number;
80
+ }>(({ $size, theme }) => ({
81
81
  position: "relative",
82
- width: size,
83
- height: size,
82
+ width: $size,
83
+ height: $size,
84
84
  marginLeft: "-8px",
85
85
  // outline: `2px solid ${theme.colors.sidebar.background}`,
86
86
  borderRadius: "50%",
@@ -105,7 +105,7 @@ export function AvatarStack({
105
105
  if (index === 0) return child;
106
106
 
107
107
  return (
108
- <AvatarStackItemWrapper size={size} key={index}>
108
+ <AvatarStackItemWrapper $size={size} key={index}>
109
109
  {child}
110
110
  </AvatarStackItemWrapper>
111
111
  );
@@ -26,70 +26,73 @@ type ButtonSize = "normal" | "large";
26
26
  * ------------------------------------------------------------------------- */
27
27
 
28
28
  export const ButtonElement = styled.button<{
29
- active: boolean;
30
- variant: ButtonVariant;
31
- size: ButtonSize;
32
- flex?: CSSProperties["flex"];
33
- defaultBackground?: string;
29
+ $active: boolean;
30
+ $variant: ButtonVariant;
31
+ $size: ButtonSize;
32
+ $flex?: CSSProperties["flex"];
33
+ $defaultBackground?: string;
34
34
  }>(
35
35
  ({
36
36
  theme,
37
- active,
37
+ $active,
38
38
  disabled,
39
- variant,
40
- size,
41
- flex,
42
- defaultBackground = theme.colors.inputBackground,
39
+ $variant,
40
+ $size,
41
+ $flex,
42
+ $defaultBackground = theme.colors.inputBackground,
43
43
  }) => ({
44
- ...(size === "large" ? theme.textStyles.heading4 : theme.textStyles.button),
44
+ ...($size === "large"
45
+ ? theme.textStyles.heading4
46
+ : theme.textStyles.button),
45
47
  textDecoration: "none",
46
48
  lineHeight: "1",
47
- flex: flex ?? "0 0 auto",
49
+ flex: $flex ?? "0 0 auto",
48
50
  position: "relative",
49
51
  border: "0",
50
52
  outline: "none",
51
53
  WebkitAppRegion: "no-drag",
52
54
  userSelect: "none",
53
- minWidth: variant === "normal" ? "31px" : undefined,
55
+ minWidth: $variant === "normal" ? "31px" : undefined,
54
56
  textAlign: "left",
55
57
  borderRadius: "4px",
56
- paddingTop: variant === "none" ? "0px" : "4px",
58
+ paddingTop: $variant === "none" ? "0px" : "4px",
57
59
  paddingRight:
58
- variant === "none" ? "0px" : variant === "thin" ? "1px" : "8px",
59
- paddingBottom: variant === "none" ? "0px" : "4px",
60
+ $variant === "none" ? "0px" : $variant === "thin" ? "1px" : "8px",
61
+ paddingBottom: $variant === "none" ? "0px" : "4px",
60
62
  paddingLeft:
61
- variant === "none" ? "0px" : variant === "thin" ? "1px" : "8px",
62
- ...(size === "large" && {
63
+ $variant === "none" ? "0px" : $variant === "thin" ? "1px" : "8px",
64
+ ...($size === "large" && {
63
65
  paddingTop: "12px",
64
66
  paddingRight: "16px",
65
67
  paddingBottom: "12px",
66
68
  paddingLeft: "16px",
67
69
  }),
68
- background: active
70
+ background: $active
69
71
  ? theme.colors.primary
70
- : variant === "primaryGradient"
72
+ : $variant === "primaryGradient"
71
73
  ? `linear-gradient(90deg, ${theme.colors.primary}, ${theme.colors.primaryLight})`
72
- : variant === "none" || variant === "thin"
74
+ : $variant === "none" || $variant === "thin"
73
75
  ? "transparent"
74
- : defaultBackground,
75
- color: active ? "white" : theme.colors.text,
76
+ : $defaultBackground,
77
+ color: $active ? "white" : theme.colors.text,
76
78
  opacity: disabled ? 0.25 : 1,
77
79
  "&:focus": {
78
- boxShadow: `0 0 0 1px ${theme.colors.sidebar.background}, 0 0 0 3px ${theme.colors.primary}`,
80
+ outline: `2px solid ${theme.colors.primary}`,
81
+ boxShadow: `0 0 0 1px ${theme.colors.popover.background} inset`,
79
82
  },
80
83
  "&:hover": {
81
84
  background:
82
- variant === "primaryGradient" || active
85
+ $variant === "primaryGradient" || $active
83
86
  ? theme.colors.primaryLight
84
87
  : theme.colors.inputBackgroundLight,
85
88
  },
86
89
  "&:active": {
87
90
  background:
88
- variant === "primaryGradient" || active
91
+ $variant === "primaryGradient" || $active
89
92
  ? theme.colors.primary
90
93
  : theme.colors.activeBackground,
91
94
  },
92
- ...(variant === "primary" && {
95
+ ...($variant === "primary" && {
93
96
  background: theme.colors.primary,
94
97
  color: "white",
95
98
  "&:hover": {
@@ -99,7 +102,7 @@ export const ButtonElement = styled.button<{
99
102
  background: theme.colors.primary,
100
103
  },
101
104
  }),
102
- ...(variant === "secondary" && {
105
+ ...($variant === "secondary" && {
103
106
  background: theme.colors.secondary,
104
107
  color: "white",
105
108
  "&:hover": {
@@ -109,7 +112,7 @@ export const ButtonElement = styled.button<{
109
112
  background: theme.colors.secondary,
110
113
  },
111
114
  }),
112
- ...(variant === "secondaryBright" && {
115
+ ...($variant === "secondaryBright" && {
113
116
  background: "#0ab557",
114
117
  color: "white",
115
118
  "&:hover": {
@@ -119,7 +122,7 @@ export const ButtonElement = styled.button<{
119
122
  opacity: 0.9,
120
123
  },
121
124
  }),
122
- ...(variant === "white" && {
125
+ ...($variant === "white" && {
123
126
  background: "white",
124
127
  "&:hover": {
125
128
  opacity: 0.8,
@@ -128,7 +131,7 @@ export const ButtonElement = styled.button<{
128
131
  opacity: 0.9,
129
132
  },
130
133
  }),
131
- ...(variant === "floating" && {
134
+ ...($variant === "floating" && {
132
135
  background: "white",
133
136
  color: theme.colors.text,
134
137
  boxShadow: "0 1px 2px rgba(0, 0, 0, 0.1)",
@@ -214,13 +217,13 @@ export const Button = forwardRef(function Button(
214
217
  id={id}
215
218
  className={className}
216
219
  style={style}
217
- flex={flex}
220
+ $flex={flex}
218
221
  tabIndex={tabIndex}
219
- active={active}
222
+ $active={active}
220
223
  disabled={disabled}
221
- variant={variant}
222
- size={size}
223
- defaultBackground={defaultBackground}
224
+ $variant={variant}
225
+ $size={size}
226
+ $defaultBackground={defaultBackground}
224
227
  onClick={onClick}
225
228
  // Prevent double clicking a button from triggering any callbacks in ancestors
226
229
  onDoubleClick={useCallback((event: React.MouseEvent) => {
@@ -9,34 +9,34 @@ type ChipSize = "small" | "medium";
9
9
  type ChipVariant = "solid" | "outlined" | "ghost";
10
10
 
11
11
  const ChipElement = styled.span<{
12
- colorScheme?: ChipColorScheme;
13
- size: ChipSize;
14
- monospace: boolean;
15
- variant: ChipVariant;
16
- isInteractive: boolean;
17
- }>(({ theme, colorScheme, size, variant, monospace, isInteractive }) => {
12
+ $colorScheme?: ChipColorScheme;
13
+ $size: ChipSize;
14
+ $monospace: boolean;
15
+ $variant: ChipVariant;
16
+ $isInteractive: boolean;
17
+ }>(({ theme, $colorScheme, $size, $variant, $monospace, $isInteractive }) => {
18
18
  const color =
19
- colorScheme === "primary"
19
+ $colorScheme === "primary"
20
20
  ? theme.colors.primary
21
- : colorScheme === "secondary"
21
+ : $colorScheme === "secondary"
22
22
  ? theme.colors.secondary
23
23
  : theme.colors.text;
24
24
 
25
25
  const backgroundColor =
26
- colorScheme === "primary"
26
+ $colorScheme === "primary"
27
27
  ? "rgb(238, 229, 255)"
28
- : colorScheme === "secondary"
28
+ : $colorScheme === "secondary"
29
29
  ? "rgb(205, 238, 231)"
30
- : colorScheme === "error"
30
+ : $colorScheme === "error"
31
31
  ? "rgb(255, 219, 219)"
32
32
  : theme.colors.inputBackground;
33
33
 
34
34
  const subtleColor =
35
- colorScheme === "primary"
35
+ $colorScheme === "primary"
36
36
  ? "rgba(238, 229, 255, 0.2)"
37
- : colorScheme === "secondary"
37
+ : $colorScheme === "secondary"
38
38
  ? "rgba(205, 238, 231, 0.2)"
39
- : colorScheme === "error"
39
+ : $colorScheme === "error"
40
40
  ? "rgba(255, 219, 219, 0.2)"
41
41
  : "rgba(0, 0, 0, 0.1)";
42
42
 
@@ -48,7 +48,7 @@ const ChipElement = styled.span<{
48
48
  alignItems: "center",
49
49
  lineHeight: "1.4",
50
50
  whiteSpace: "pre",
51
- ...(size === "medium"
51
+ ...($size === "medium"
52
52
  ? {
53
53
  fontSize: "11px",
54
54
  padding: "4px 8px",
@@ -58,15 +58,15 @@ const ChipElement = styled.span<{
58
58
  padding: "0px 4px",
59
59
  lineHeight: "15px",
60
60
  }),
61
- ...(monospace && {
61
+ ...($monospace && {
62
62
  fontFamily: theme.fonts.monospace,
63
63
  }),
64
- ...(variant === "solid"
64
+ ...($variant === "solid"
65
65
  ? {
66
66
  color,
67
67
  backgroundColor,
68
68
  }
69
- : variant === "outlined"
69
+ : $variant === "outlined"
70
70
  ? {
71
71
  color,
72
72
  backgroundColor: "transparent",
@@ -74,12 +74,12 @@ const ChipElement = styled.span<{
74
74
  }
75
75
  : {}),
76
76
  "&:hover": {
77
- ...(variant === "outlined" && {
77
+ ...($variant === "outlined" && {
78
78
  backgroundColor: subtleColor,
79
79
  boxShadow: "none",
80
80
  }),
81
81
  },
82
- ...(isInteractive && {
82
+ ...($isInteractive && {
83
83
  cursor: "pointer",
84
84
  "&:hover": {
85
85
  opacity: 0.85,
@@ -188,13 +188,13 @@ export const Chip = memo(function Chip({
188
188
 
189
189
  return (
190
190
  <ChipElement
191
- variant={variant}
192
- colorScheme={colorScheme}
191
+ $variant={variant}
192
+ $colorScheme={colorScheme}
193
193
  style={style}
194
194
  onClick={handleClick}
195
- size={size}
196
- monospace={monospace}
197
- isInteractive={!!handleClick}
195
+ $size={size}
196
+ $monospace={monospace}
197
+ $isInteractive={!!handleClick}
198
198
  tabIndex={tabIndex}
199
199
  >
200
200
  {addable && (
@@ -1,40 +1,65 @@
1
- import React, { memo } from 'react';
2
- import styled from 'styled-components';
1
+ import React, { memo } from "react";
2
+ import styled from "styled-components";
3
3
 
4
4
  /* ----------------------------------------------------------------------------
5
5
  * Divider
6
6
  * ------------------------------------------------------------------------- */
7
7
 
8
- type DividerVariant = 'normal' | 'strong' | 'subtle';
8
+ type DividerVariant = "normal" | "strong" | "subtle";
9
9
 
10
10
  const DividerContainer = styled.div<
11
- DividerProps & {
12
- orientation: 'horizontal' | 'vertical';
11
+ DividerProps_ & {
12
+ $orientation: "horizontal" | "vertical";
13
13
  }
14
- >(({ theme, variant = 'normal', orientation, overflow = 0 }) => ({
15
- ...(orientation === 'horizontal'
16
- ? { height: '1px', minHeight: '1px', margin: `0px -${overflow}px` }
17
- : { width: '1px', minWidth: '1px', margin: `-${overflow}px 0px` }),
14
+ >(({ theme, $variant = "normal", $orientation, $overflow = 0 }) => ({
15
+ ...($orientation === "horizontal"
16
+ ? { height: "1px", minHeight: "1px", margin: `0px -${$overflow}px` }
17
+ : { width: "1px", minWidth: "1px", margin: `-${$overflow}px 0px` }),
18
18
  background:
19
- variant === 'strong'
19
+ $variant === "strong"
20
20
  ? theme.colors.dividerStrong
21
- : variant === 'subtle'
22
- ? theme.colors.dividerSubtle
23
- : theme.colors.divider,
24
- alignSelf: 'stretch',
21
+ : $variant === "subtle"
22
+ ? theme.colors.dividerSubtle
23
+ : theme.colors.divider,
24
+ alignSelf: "stretch",
25
25
  }));
26
26
 
27
+ interface DividerProps_ {
28
+ $variant?: DividerVariant;
29
+ $overflow?: number;
30
+ }
31
+
27
32
  interface DividerProps {
28
33
  variant?: DividerVariant;
29
34
  overflow?: number;
30
35
  }
31
36
 
32
- export const Divider = memo(function Divider(props: DividerProps) {
33
- return <DividerContainer orientation="horizontal" {...props} />;
37
+ export const Divider = memo(function Divider({
38
+ variant,
39
+ overflow,
40
+ ...props
41
+ }: DividerProps) {
42
+ return (
43
+ <DividerContainer
44
+ $orientation="horizontal"
45
+ $variant={variant}
46
+ $overflow={overflow}
47
+ {...props}
48
+ />
49
+ );
34
50
  });
35
51
 
36
- export const DividerVertical = memo(function DividerVertical(
37
- props: DividerProps,
38
- ) {
39
- return <DividerContainer orientation="vertical" {...props} />;
52
+ export const DividerVertical = memo(function DividerVertical({
53
+ variant,
54
+ overflow,
55
+ ...props
56
+ }: DividerProps) {
57
+ return (
58
+ <DividerContainer
59
+ $orientation="vertical"
60
+ $variant={variant}
61
+ $overflow={overflow}
62
+ {...props}
63
+ />
64
+ );
40
65
  });
@@ -1,43 +1,43 @@
1
- import { Sketch } from '@noya-app/noya-file-format';
2
- import React, { CSSProperties, ForwardedRef, forwardRef, memo } from 'react';
3
- import styled from 'styled-components';
4
- import { SketchPattern } from '../utils/sketchPattern';
5
- import { FillPreviewBackground } from './FillPreviewBackground';
1
+ import { Sketch } from "@noya-app/noya-file-format";
2
+ import React, { CSSProperties, ForwardedRef, forwardRef, memo } from "react";
3
+ import styled from "styled-components";
4
+ import { SketchPattern } from "../utils/sketchPattern";
5
+ import { FillPreviewBackground } from "./FillPreviewBackground";
6
6
 
7
- const Container = styled.button<{ flex?: CSSProperties['flex'] }>(
8
- ({ theme, flex }) => ({
9
- outline: 'none',
7
+ const Container = styled.button<{ $flex?: CSSProperties["flex"] }>(
8
+ ({ theme, $flex }) => ({
9
+ outline: "none",
10
10
  padding: 0,
11
- width: '50px',
12
- height: '27px',
13
- borderRadius: '4px',
14
- overflow: 'hidden',
15
- border: 'none',
11
+ width: "50px",
12
+ height: "27px",
13
+ borderRadius: "4px",
14
+ overflow: "hidden",
15
+ border: "none",
16
16
  boxShadow: `0 0 0 1px ${theme.colors.divider} inset`,
17
- background: 'transparent',
18
- '&:focus': {
17
+ background: "transparent",
18
+ "&:focus": {
19
19
  boxShadow: `0 0 0 1px ${theme.colors.sidebar.background}, 0 0 0 3px ${theme.colors.primary}`,
20
20
  },
21
- position: 'relative',
22
- flex,
23
- }),
21
+ position: "relative",
22
+ flex: $flex,
23
+ })
24
24
  );
25
25
 
26
26
  interface Props {
27
27
  id?: string;
28
28
  value?: Sketch.Color | Sketch.Gradient | SketchPattern;
29
- flex?: CSSProperties['flex'];
29
+ flex?: CSSProperties["flex"];
30
30
  }
31
31
 
32
32
  export const FillInputField = memo(
33
33
  forwardRef(function FillInputField(
34
- { id, value, ...rest }: Props,
35
- ref: ForwardedRef<HTMLButtonElement>,
34
+ { id, value, flex, ...rest }: Props,
35
+ ref: ForwardedRef<HTMLButtonElement>
36
36
  ) {
37
37
  return (
38
- <Container ref={ref} id={id} {...rest}>
38
+ <Container ref={ref} id={id} $flex={flex} {...rest}>
39
39
  <FillPreviewBackground value={value} />
40
40
  </Container>
41
41
  );
42
- }),
42
+ })
43
43
  );