@noya-app/noya-designsystem 0.0.14 → 0.0.16

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.
@@ -6,63 +6,64 @@ import React, {
6
6
  memo,
7
7
  ReactHTML,
8
8
  ReactNode,
9
- } from 'react';
10
- import styled from 'styled-components';
11
- import { BreakpointCollection, mergeBreakpoints } from '../utils/breakpoints';
12
- import withSeparatorElements from '../utils/withSeparatorElements';
9
+ } from "react";
10
+ import styled from "styled-components";
11
+ import { BreakpointCollection, mergeBreakpoints } from "../utils/breakpoints";
12
+ import withSeparatorElements from "../utils/withSeparatorElements";
13
13
 
14
14
  interface StyleProps {
15
- display?: 'flex' | 'inline-flex' | 'none' | 'block';
16
- visibility?: CSSProperties['visibility'];
17
- position?: CSSProperties['position'];
18
- zIndex?: CSSProperties['zIndex'];
19
- gap?: CSSProperties['gap'];
20
- inset?: CSSProperties['inset'];
21
- top?: CSSProperties['top'];
22
- right?: CSSProperties['right'];
23
- bottom?: CSSProperties['bottom'];
24
- left?: CSSProperties['left'];
25
- flexDirection?: CSSProperties['flexDirection'];
26
- justifyContent?: CSSProperties['justifyContent'];
27
- alignItems?: CSSProperties['alignItems'];
28
- alignSelf?: CSSProperties['alignSelf'];
29
- flex?: CSSProperties['flex'];
30
- flexWrap?: CSSProperties['flexWrap'];
31
- height?: CSSProperties['height'];
32
- minHeight?: CSSProperties['minHeight'];
33
- maxHeight?: CSSProperties['maxHeight'];
34
- width?: CSSProperties['width'];
35
- minWidth?: CSSProperties['minWidth'];
36
- maxWidth?: CSSProperties['maxWidth'];
37
- aspectRatio?: CSSProperties['aspectRatio'];
38
- padding?: CSSProperties['padding'];
15
+ display?: "flex" | "inline-flex" | "none" | "block";
16
+ visibility?: CSSProperties["visibility"];
17
+ position?: CSSProperties["position"];
18
+ zIndex?: CSSProperties["zIndex"];
19
+ gap?: CSSProperties["gap"];
20
+ inset?: CSSProperties["inset"];
21
+ top?: CSSProperties["top"];
22
+ right?: CSSProperties["right"];
23
+ bottom?: CSSProperties["bottom"];
24
+ left?: CSSProperties["left"];
25
+ flexDirection?: CSSProperties["flexDirection"];
26
+ justifyContent?: CSSProperties["justifyContent"];
27
+ alignItems?: CSSProperties["alignItems"];
28
+ alignSelf?: CSSProperties["alignSelf"];
29
+ flex?: CSSProperties["flex"];
30
+ flexWrap?: CSSProperties["flexWrap"];
31
+ height?: CSSProperties["height"];
32
+ minHeight?: CSSProperties["minHeight"];
33
+ maxHeight?: CSSProperties["maxHeight"];
34
+ width?: CSSProperties["width"];
35
+ minWidth?: CSSProperties["minWidth"];
36
+ maxWidth?: CSSProperties["maxWidth"];
37
+ aspectRatio?: CSSProperties["aspectRatio"];
38
+ padding?: CSSProperties["padding"];
39
39
  paddingVertical?: string | number;
40
40
  paddingHorizontal?: string | number;
41
- margin?: CSSProperties['margin'];
42
- background?: CSSProperties['background'];
43
- backgroundSize?: CSSProperties['backgroundSize'];
44
- backgroundPosition?: CSSProperties['backgroundPosition'];
45
- borderRadius?: CSSProperties['borderRadius'];
46
- overflowX?: CSSProperties['overflowX'];
47
- overflowY?: CSSProperties['overflowY'];
48
- overflow?: CSSProperties['overflow'];
49
- textOverflow?: CSSProperties['textOverflow'];
50
- boxShadow?: CSSProperties['boxShadow'];
51
- outline?: CSSProperties['outline'];
52
- border?: CSSProperties['border'];
53
- borderTop?: CSSProperties['borderTop'];
54
- borderRight?: CSSProperties['borderRight'];
55
- borderBottom?: CSSProperties['borderBottom'];
56
- borderLeft?: CSSProperties['borderLeft'];
57
- cursor?: CSSProperties['cursor'];
58
- userSelect?: CSSProperties['userSelect'];
59
- transition?: CSSProperties['transition'];
60
- opacity?: CSSProperties['opacity'];
61
- filter?: CSSProperties['filter'];
62
- color?: CSSProperties['color'];
63
- order?: CSSProperties['order'];
64
- pointerEvents?: CSSProperties['pointerEvents'];
65
- lineHeight?: CSSProperties['lineHeight'];
41
+ margin?: CSSProperties["margin"];
42
+ background?: CSSProperties["background"];
43
+ backgroundSize?: CSSProperties["backgroundSize"];
44
+ backgroundPosition?: CSSProperties["backgroundPosition"];
45
+ borderRadius?: CSSProperties["borderRadius"];
46
+ overflowX?: CSSProperties["overflowX"];
47
+ overflowY?: CSSProperties["overflowY"];
48
+ overflow?: CSSProperties["overflow"];
49
+ textOverflow?: CSSProperties["textOverflow"];
50
+ boxShadow?: CSSProperties["boxShadow"];
51
+ outline?: CSSProperties["outline"];
52
+ border?: CSSProperties["border"];
53
+ borderTop?: CSSProperties["borderTop"];
54
+ borderRight?: CSSProperties["borderRight"];
55
+ borderBottom?: CSSProperties["borderBottom"];
56
+ borderLeft?: CSSProperties["borderLeft"];
57
+ cursor?: CSSProperties["cursor"];
58
+ userSelect?: CSSProperties["userSelect"];
59
+ transition?: CSSProperties["transition"];
60
+ opacity?: CSSProperties["opacity"];
61
+ filter?: CSSProperties["filter"];
62
+ color?: CSSProperties["color"];
63
+ order?: CSSProperties["order"];
64
+ pointerEvents?: CSSProperties["pointerEvents"];
65
+ lineHeight?: CSSProperties["lineHeight"];
66
+ isolation?: CSSProperties["isolation"];
66
67
  }
67
68
 
68
69
  export type StackBreakpointList = BreakpointCollection<StyleProps>;
@@ -88,16 +89,16 @@ const Element = styled.div<{
88
89
 
89
90
  const StackBase = forwardRef(function StackBase(
90
91
  { id, as, children, separator, breakpoints, tabIndex, href, ...rest }: Props,
91
- forwardedRef: ForwardedRef<HTMLElement>,
92
+ forwardedRef: ForwardedRef<HTMLElement>
92
93
  ) {
93
94
  const elements = separator
94
95
  ? withSeparatorElements(Children.toArray(children), separator)
95
96
  : children;
96
97
 
97
98
  const styleProps: StyleProps = {
98
- display: 'flex',
99
- position: 'relative',
100
- alignItems: 'stretch',
99
+ display: "flex",
100
+ position: "relative",
101
+ alignItems: "stretch",
101
102
  ...rest,
102
103
  };
103
104
 
@@ -116,24 +117,24 @@ const StackBase = forwardRef(function StackBase(
116
117
  );
117
118
  });
118
119
 
119
- type StackProps = Omit<Props, 'flexDirection'>;
120
+ type StackProps = Omit<Props, "flexDirection">;
120
121
 
121
122
  const VerticalStack = memo(
122
123
  forwardRef(function VStack(
123
124
  props: StackProps,
124
- forwardedRef: ForwardedRef<HTMLElement>,
125
+ forwardedRef: ForwardedRef<HTMLElement>
125
126
  ) {
126
127
  return <StackBase {...props} flexDirection="column" ref={forwardedRef} />;
127
- }),
128
+ })
128
129
  );
129
130
 
130
131
  const HorizontalStack = memo(
131
132
  forwardRef(function HStack(
132
133
  props: StackProps,
133
- forwardedRef: ForwardedRef<HTMLElement>,
134
+ forwardedRef: ForwardedRef<HTMLElement>
134
135
  ) {
135
136
  return <StackBase {...props} flexDirection="row" ref={forwardedRef} />;
136
- }),
137
+ })
137
138
  );
138
139
 
139
140
  export const Stack = {
@@ -1,20 +1,20 @@
1
- import * as SwitchPrimitive from '@radix-ui/react-switch';
2
- import React from 'react';
3
- import styled from 'styled-components';
1
+ import * as SwitchPrimitive from "@radix-ui/react-switch";
2
+ import React from "react";
3
+ import styled from "styled-components";
4
4
 
5
- type SwitchVariant = 'normal' | 'primary' | 'secondary';
5
+ type SwitchColorScheme = "normal" | "primary" | "secondary";
6
6
 
7
7
  const SwitchRoot = styled(SwitchPrimitive.Root)<{
8
- variant: SwitchVariant;
9
- }>(({ theme, variant }) => ({
10
- all: 'unset',
8
+ colorScheme: SwitchColorScheme;
9
+ }>(({ theme, colorScheme: variant }) => ({
10
+ all: "unset",
11
11
  width: 32,
12
12
  height: 19,
13
13
  backgroundColor: theme.colors.activeBackground,
14
- borderRadius: '9999px',
15
- position: 'relative',
16
- WebkitTapHighlightColor: 'rgba(0, 0, 0, 0)',
17
- cursor: 'pointer',
14
+ borderRadius: "9999px",
15
+ position: "relative",
16
+ WebkitTapHighlightColor: "rgba(0, 0, 0, 0)",
17
+ cursor: "pointer",
18
18
  // '&:focus': {
19
19
  // boxShadow: `0 0 0 1px ${
20
20
  // variant === 'secondary' ? theme.colors.secondary : theme.colors.primary
@@ -22,40 +22,40 @@ const SwitchRoot = styled(SwitchPrimitive.Root)<{
22
22
  // },
23
23
  '&[data-state="checked"]': {
24
24
  backgroundColor:
25
- variant === 'primary'
25
+ variant === "primary"
26
26
  ? theme.colors.primary
27
- : variant === 'secondary'
28
- ? theme.colors.secondary
29
- : undefined,
27
+ : variant === "secondary"
28
+ ? theme.colors.secondary
29
+ : undefined,
30
30
  },
31
31
  }));
32
32
 
33
33
  const SwitchThumb = styled(SwitchPrimitive.Thumb)({
34
- display: 'block',
34
+ display: "block",
35
35
  width: 15,
36
36
  height: 15,
37
- backgroundColor: 'white',
38
- borderRadius: '9999px',
39
- transition: 'transform 100ms',
40
- transform: 'translateX(2px)',
41
- willChange: 'transform',
42
- '&[data-state="checked"]': { transform: 'translateX(15px)' },
37
+ backgroundColor: "white",
38
+ borderRadius: "9999px",
39
+ transition: "transform 100ms",
40
+ transform: "translateX(2px)",
41
+ willChange: "transform",
42
+ '&[data-state="checked"]': { transform: "translateX(15px)" },
43
43
  });
44
44
 
45
45
  interface Props {
46
46
  value: boolean;
47
47
  onChange: (value: boolean) => void;
48
- variant?: SwitchVariant;
48
+ colorScheme?: SwitchColorScheme;
49
49
  }
50
50
 
51
51
  export const Switch = function Switch({
52
52
  value,
53
53
  onChange,
54
- variant = 'normal',
54
+ colorScheme = "normal",
55
55
  }: Props) {
56
56
  return (
57
57
  <SwitchRoot
58
- variant={variant}
58
+ colorScheme={colorScheme}
59
59
  checked={value}
60
60
  onCheckedChange={(newValue) => {
61
61
  onChange(newValue);
@@ -32,6 +32,8 @@ type StyleProps = {
32
32
  whiteSpace?: CSSProperties["whiteSpace"];
33
33
  height?: CSSProperties["height"];
34
34
  width?: CSSProperties["width"];
35
+ minWidth?: CSSProperties["minWidth"];
36
+ maxWidth?: CSSProperties["maxWidth"];
35
37
  opacity?: CSSProperties["opacity"];
36
38
  position?: CSSProperties["position"];
37
39
  overflow?: CSSProperties["overflow"];
@@ -57,6 +59,7 @@ interface Props extends StyleProps {
57
59
  color?: ThemeColorName;
58
60
  children: ReactNode;
59
61
  onClick?: () => void;
62
+ onDoubleClick?: () => void;
60
63
  }
61
64
 
62
65
  const StyledElement = styled.span<
@@ -138,6 +138,9 @@ export const DialogProvider = function DialogProvider({
138
138
  event.preventDefault();
139
139
 
140
140
  inputRef.current?.focus();
141
+
142
+ // Select the entire input value
143
+ inputRef.current?.setSelectionRange(0, inputRef.current.value.length);
141
144
  }, [])}
142
145
  >
143
146
  <InputField.Root>
package/src/index.tsx CHANGED
@@ -21,6 +21,7 @@ export * from "./components/Chip";
21
21
  export * from "./components/ContextMenu";
22
22
  export * from "./components/Dialog";
23
23
  export * from "./components/Divider";
24
+ export * from "./components/DraggableMenuButton";
24
25
  export * from "./components/DropdownMenu";
25
26
  export * from "./components/FillInputField";
26
27
  export * from "./components/FillPreviewBackground";
@@ -78,6 +79,6 @@ export * from "./utils/sketchPattern";
78
79
  export { default as withSeparatorElements } from "./utils/withSeparatorElements";
79
80
 
80
81
  // Avoid dependency cycles
81
- export * as InspectorPrimitives from "./components/InspectorPrimitives";
82
82
  export * from "./components/ArrayController";
83
- export * from "./components/DimensionInput";
83
+ export * from "./components/DimensionInput";
84
+ export * as InspectorPrimitives from "./components/InspectorPrimitives";
@@ -71,7 +71,7 @@ export const colors = {
71
71
  return colors.primary;
72
72
  },
73
73
  selection: "rgb(179,215,254)",
74
- thumbnailBackground: "#E1DAFF",
74
+ thumbnailBackground: "#f0efff",
75
75
  thumbnailShadow: "#D3CEED66",
76
76
  };
77
77
 
@@ -1,5 +1,5 @@
1
- import { Sketch } from '@noya-app/noya-file-format';
2
- import { sketchColorToRgbaString } from './sketchColor';
1
+ import { Sketch } from "@noya-app/noya-file-format";
2
+ import { sketchColorToRgbaString } from "./sketchColor";
3
3
 
4
4
  const getRGBAColor = (value: Sketch.GradientStop[], num: 100 | 360) =>
5
5
  [...value]
@@ -7,15 +7,15 @@ const getRGBAColor = (value: Sketch.GradientStop[], num: 100 | 360) =>
7
7
  .map(
8
8
  (g) =>
9
9
  `${sketchColorToRgbaString(g.color)} ${g.position * num}${
10
- num === 100 ? '%' : 'deg'
11
- }`,
10
+ num === 100 ? "%" : "deg"
11
+ }`
12
12
  )
13
- .join(', \n');
13
+ .join(", \n");
14
14
 
15
15
  export function getGradientBackground(
16
16
  value: Sketch.GradientStop[],
17
17
  type: Sketch.GradientType,
18
- direction?: number,
18
+ direction?: number
19
19
  ) {
20
20
  if (type === Sketch.GradientType.Angular) {
21
21
  return `conic-gradient(${getRGBAColor(value, 360)})`;
@@ -24,10 +24,8 @@ export function getGradientBackground(
24
24
  const color = getRGBAColor(value, 100);
25
25
  const position =
26
26
  type === Sketch.GradientType.Radial
27
- ? 'radial-gradient(circle'
28
- : `linear-gradient(${
29
- typeof direction !== undefined ? direction : 180
30
- }deg`;
27
+ ? "radial-gradient(circle"
28
+ : `linear-gradient(${direction !== undefined ? direction : 180}deg`;
31
29
 
32
30
  return `${position}, ${color})`;
33
31
  }