@noya-app/noya-designsystem 0.1.63 → 0.1.65

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.
Files changed (143) hide show
  1. package/.turbo/turbo-build.log +13 -10
  2. package/CHANGELOG.md +25 -0
  3. package/dist/index.css +1 -1
  4. package/dist/index.d.mts +648 -333
  5. package/dist/index.d.ts +648 -333
  6. package/dist/index.js +13813 -9157
  7. package/dist/index.js.map +1 -1
  8. package/dist/index.mjs +13949 -9269
  9. package/dist/index.mjs.map +1 -1
  10. package/package.json +10 -22
  11. package/src/__tests__/validateDropIndicator.test.ts +26 -41
  12. package/src/__tests__/workspaceLayout.test.ts +281 -0
  13. package/src/components/ActionMenu.tsx +2 -0
  14. package/src/components/ActivityIndicator.tsx +13 -6
  15. package/src/components/ActivityLog.tsx +197 -0
  16. package/src/components/AnimatePresence.tsx +43 -26
  17. package/src/components/Avatar.tsx +45 -26
  18. package/src/components/Banner.tsx +57 -11
  19. package/src/components/BaseToolbar.tsx +67 -34
  20. package/src/components/Breadcrumbs.tsx +4 -2
  21. package/src/components/Button.tsx +28 -23
  22. package/src/components/Checkbox.tsx +6 -35
  23. package/src/components/Chip.tsx +47 -33
  24. package/src/components/Collection.tsx +20 -12
  25. package/src/components/ColorSwatch.tsx +42 -22
  26. package/src/components/ColorSwatchControl.tsx +7 -5
  27. package/src/components/Combobox.tsx +8 -6
  28. package/src/components/ComboboxMenu.tsx +6 -5
  29. package/src/components/CommandPalette.tsx +3 -1
  30. package/src/components/ContextMenu.tsx +3 -1
  31. package/src/components/Dialog.tsx +9 -13
  32. package/src/components/DimensionInput.tsx +2 -0
  33. package/src/components/Divider.tsx +18 -14
  34. package/src/components/DraggableMenuButton.tsx +11 -5
  35. package/src/components/Drawer.tsx +14 -6
  36. package/src/components/DropdownMenu.tsx +4 -2
  37. package/src/components/EditableText.tsx +4 -2
  38. package/src/components/Fade.tsx +13 -13
  39. package/src/components/FileUploadIndicator.tsx +108 -0
  40. package/src/components/FloatingWindow.tsx +4 -2
  41. package/src/components/Grid.tsx +58 -42
  42. package/src/components/GridView.tsx +65 -36
  43. package/src/components/IVirtualizedList.tsx +5 -0
  44. package/src/components/IconButton.tsx +2 -0
  45. package/src/components/Icons.tsx +24 -4
  46. package/src/components/InputField.tsx +21 -19
  47. package/src/components/InspectorContainer.tsx +2 -2
  48. package/src/components/InspectorPrimitives.tsx +15 -9
  49. package/src/components/Label.tsx +4 -3
  50. package/src/components/LabeledElementView.tsx +9 -5
  51. package/src/components/LabeledField.tsx +8 -6
  52. package/src/components/List.tsx +112 -46
  53. package/src/components/ListMenu.tsx +91 -0
  54. package/src/components/ListNavigator.tsx +106 -0
  55. package/src/components/ListView.tsx +22 -1147
  56. package/src/components/MediaThumbnail.tsx +84 -14
  57. package/src/components/Message.tsx +11 -12
  58. package/src/components/Navigator.tsx +461 -0
  59. package/src/components/NoyaLogo.tsx +1 -1
  60. package/src/components/Popover.tsx +12 -6
  61. package/src/components/Progress.tsx +31 -8
  62. package/src/components/ResizableContainer.tsx +187 -0
  63. package/src/components/RingProgress.tsx +128 -0
  64. package/src/components/ScrollArea.tsx +7 -5
  65. package/src/components/ScrollableSidebar.tsx +10 -0
  66. package/src/components/SearchCompletionMenu.tsx +5 -3
  67. package/src/components/Section.tsx +109 -57
  68. package/src/components/SegmentedControl.tsx +51 -25
  69. package/src/components/SelectMenu.tsx +16 -21
  70. package/src/components/SelectionToolbar.tsx +7 -4
  71. package/src/components/Slider.tsx +12 -10
  72. package/src/components/Spacer.tsx +2 -2
  73. package/src/components/StackNavigator.tsx +378 -0
  74. package/src/components/Stepper.tsx +88 -0
  75. package/src/components/Switch.tsx +7 -5
  76. package/src/components/Tabs.tsx +6 -4
  77. package/src/components/Text.tsx +29 -18
  78. package/src/components/TextArea.tsx +5 -3
  79. package/src/components/Toast.tsx +5 -5
  80. package/src/components/Toolbar.tsx +57 -10
  81. package/src/components/ToolbarDrawer.tsx +29 -0
  82. package/src/components/Tooltip.tsx +2 -2
  83. package/src/components/TreeView.tsx +13 -4
  84. package/src/components/UserPointer.tsx +6 -4
  85. package/src/components/ai-assistant/AIAssistantLayout.tsx +10 -8
  86. package/src/components/blocks/ImageBlockComponent.tsx +162 -0
  87. package/src/components/connected-users-menu/ConnectedUsersMenuLayout.tsx +6 -4
  88. package/src/components/file-explorer/FileExplorerLayout.tsx +22 -8
  89. package/src/components/internal/Checkmark.tsx +24 -0
  90. package/src/components/internal/Menu.tsx +24 -19
  91. package/src/components/internal/MenuViewport.tsx +15 -6
  92. package/src/components/internal/SelectItem.tsx +7 -26
  93. package/src/components/internal/TextInput.tsx +7 -1
  94. package/src/components/listView/ListViewContexts.tsx +68 -0
  95. package/src/components/listView/ListViewEditableRowTitle.tsx +55 -0
  96. package/src/components/listView/ListViewRoot.tsx +521 -0
  97. package/src/components/listView/ListViewRow.tsx +475 -0
  98. package/src/components/listView/ListViewRowTitle.tsx +21 -0
  99. package/src/components/listView/types.ts +11 -0
  100. package/src/components/pipeline/PipelineResultLayout.tsx +6 -6
  101. package/src/components/sorting/DragRegistration.tsx +10 -5
  102. package/src/components/sorting/SharedDragProvider.tsx +134 -27
  103. package/src/components/sorting/Sortable.tsx +90 -27
  104. package/src/components/sorting/createSharedDrag.tsx +7 -6
  105. package/src/components/sorting/sorting.ts +6 -9
  106. package/src/components/workspace/DrawerWorkspaceLayout.tsx +110 -29
  107. package/src/components/workspace/PanelWorkspaceLayout.tsx +148 -99
  108. package/src/components/workspace/VerticalTabMenu.tsx +46 -0
  109. package/src/components/workspace/WorkspaceLayout.tsx +76 -63
  110. package/src/components/workspace/constants.ts +4 -0
  111. package/src/components/workspace/panelStorage.ts +216 -0
  112. package/src/components/workspace/types.ts +11 -4
  113. package/src/contexts/DesignSystemConfiguration.tsx +12 -5
  114. package/src/contexts/DialogContext.tsx +19 -5
  115. package/src/contexts/FloatingWindowContext.tsx +2 -0
  116. package/src/contexts/GlobalInputBlurContext.tsx +2 -0
  117. package/src/contexts/ImageDataContext.tsx +2 -0
  118. package/src/contexts/LinkComponentContext.tsx +17 -0
  119. package/src/contexts/OpenPortalsContext.tsx +2 -0
  120. package/src/contexts/PortalScopeContext.tsx +2 -0
  121. package/src/hooks/mergeEventHandlers.ts +1 -1
  122. package/src/hooks/useHover.ts +30 -17
  123. package/src/hooks/useIndent.ts +5 -8
  124. package/src/hooks/useLabel.ts +2 -0
  125. package/src/hooks/useObjectURL.ts +5 -3
  126. package/src/hooks/usePlatform.ts +5 -3
  127. package/src/hooks/useTheme.ts +3 -1
  128. package/src/index.css +43 -10
  129. package/src/index.tsx +15 -7
  130. package/src/utils/classNames.ts +56 -9
  131. package/src/utils/combobox.ts +2 -0
  132. package/src/utils/editableBlockStyles.ts +2 -2
  133. package/src/utils/formatByteSize.ts +9 -0
  134. package/src/utils/inputs.ts +8 -6
  135. package/src/utils/sketchColor.ts +0 -34
  136. package/src/utils/withSeparatorElements.ts +1 -1
  137. package/tailwind.config.ts +1 -0
  138. package/src/components/FillInputField.tsx +0 -37
  139. package/src/components/FillPreviewBackground.tsx +0 -132
  140. package/src/components/GradientPicker.tsx +0 -88
  141. package/src/hooks/usePreservePanelSize.tsx +0 -183
  142. package/src/mediaQuery.ts +0 -13
  143. package/src/utils/getGradientBackground.tsx +0 -31
@@ -1,132 +0,0 @@
1
- import { Sketch } from "@noya-app/noya-file-format";
2
- // import { useSketchImage } from 'noya-renderer';
3
- import * as React from "react";
4
- import { useImageData } from "../contexts/ImageDataContext";
5
- import { useObjectURL } from "../hooks/useObjectURL";
6
- import { cssVars } from "../theme";
7
- import { getGradientBackground } from "../utils/getGradientBackground";
8
- import { sketchColorToRgbaString } from "../utils/sketchColor";
9
- import { SketchPattern } from "../utils/sketchPattern";
10
-
11
- const dotsHorizontalSvg = (fillColor: string) => `
12
- <svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 15 15' fill='${fillColor}'>
13
- <path d='M3.625 7.5C3.625 8.12132 3.12132 8.625 2.5 8.625C1.87868 8.625 1.375 8.12132 1.375 7.5C1.375 6.87868 1.87868 6.375 2.5 6.375C3.12132 6.375 3.625 6.87868 3.625 7.5ZM8.625 7.5C8.625 8.12132 8.12132 8.625 7.5 8.625C6.87868 8.625 6.375 8.12132 6.375 7.5C6.375 6.87868 6.87868 6.375 7.5 6.375C8.12132 6.375 8.625 6.87868 8.625 7.5ZM12.5 8.625C13.1213 8.625 13.625 8.12132 13.625 7.5C13.625 6.87868 13.1213 6.375 12.5 6.375C11.8787 6.375 11.375 6.87868 11.375 7.5C11.375 8.12132 11.8787 8.625 12.5 8.625Z'></path>
14
- </svg>
15
- `;
16
-
17
- const Background = React.memo(function Background({
18
- background,
19
- }: {
20
- background?: string;
21
- }) {
22
- return (
23
- <span
24
- className={`${background ? `bg-[${background}]` : "bg-input-background"} absolute inset-0`}
25
- />
26
- );
27
- });
28
-
29
- function getPatternSizeAndPosition(
30
- fillType: Sketch.PatternFillType,
31
- tileScale: number
32
- ) {
33
- switch (fillType) {
34
- case Sketch.PatternFillType.Fit:
35
- return "center / contain";
36
- case Sketch.PatternFillType.Tile:
37
- return `top left / ${tileScale * 100}%`;
38
- case Sketch.PatternFillType.Fill:
39
- return "center / cover";
40
- case Sketch.PatternFillType.Stretch:
41
- return "center / 100% 100%";
42
- }
43
- }
44
-
45
- export const PatternPreviewBackground = React.memo(
46
- function PatternPreviewBackground({
47
- fillType,
48
- tileScale,
49
- imageRef,
50
- }: {
51
- fillType: Sketch.PatternFillType;
52
- tileScale: number;
53
- imageRef: string;
54
- }) {
55
- const image = useImageData(imageRef);
56
-
57
- const url = useObjectURL(image);
58
-
59
- const size = getPatternSizeAndPosition(fillType, tileScale);
60
-
61
- const background = React.useMemo(
62
- () =>
63
- [
64
- size,
65
- `url(${url})`,
66
- fillType === Sketch.PatternFillType.Tile ? "repeat" : "no-repeat",
67
- ].join(" "),
68
- [fillType, size, url]
69
- );
70
-
71
- return <Background background={background} />;
72
- }
73
- );
74
-
75
- const ColorPreviewBackground = React.memo(function ColorPreviewBackground({
76
- color,
77
- }: {
78
- color: Sketch.Color;
79
- }) {
80
- const background = React.useMemo(
81
- () => sketchColorToRgbaString(color),
82
- [color]
83
- );
84
-
85
- return <Background background={background} />;
86
- });
87
-
88
- const GradientPreviewBackground = React.memo(
89
- function GradientPreviewBackground({
90
- gradient,
91
- }: {
92
- gradient: Sketch.Gradient;
93
- }) {
94
- const background = React.useMemo(
95
- () => getGradientBackground(gradient.stops, gradient.gradientType, 180),
96
- [gradient.gradientType, gradient.stops]
97
- );
98
-
99
- return <Background background={background} />;
100
- }
101
- );
102
-
103
- interface Props {
104
- value?: Sketch.Color | Sketch.Gradient | SketchPattern;
105
- }
106
-
107
- const background = `center url("data:image/svg+xml;utf8,${dotsHorizontalSvg(
108
- cssVars.colors.placeholderDots
109
- )}") no-repeat`;
110
-
111
- export const FillPreviewBackground = React.memo(function FillPreviewBackground({
112
- value,
113
- }: Props) {
114
- if (!value) return <Background background={background} />;
115
-
116
- switch (value._class) {
117
- case "color":
118
- return <ColorPreviewBackground color={value} />;
119
- case "gradient":
120
- return <GradientPreviewBackground gradient={value} />;
121
- case "pattern":
122
- if (!value.image) return null;
123
-
124
- return (
125
- <PatternPreviewBackground
126
- fillType={value.patternFillType}
127
- tileScale={value.patternTileScale}
128
- imageRef={value.image._ref}
129
- />
130
- );
131
- }
132
- });
@@ -1,88 +0,0 @@
1
- import {
2
- Alpha,
3
- ColorModel,
4
- Gradient,
5
- Hue,
6
- ColorPicker as NoyaColorPicker,
7
- RgbaColor,
8
- Saturation,
9
- equalColorObjects,
10
- hsvaToRgba,
11
- rgbaToHsva,
12
- } from "@noya-app/noya-colorpicker";
13
- import type { Sketch } from "@noya-app/noya-file-format";
14
- import * as React from "react";
15
- import { Spacer } from "../components/Spacer";
16
- import { rgbaToSketchColor, sketchColorToRgba } from "../utils/sketchColor";
17
-
18
- interface Props {
19
- value: Sketch.GradientStop[];
20
- selectedStop: number;
21
- onChangeColor: (color: Sketch.Color) => void;
22
- onChangePosition: (position: number) => void;
23
- onAdd: (color: Sketch.Color, position: number) => void;
24
- onDelete: () => void;
25
- onSelectStop: (index: number) => void;
26
- }
27
-
28
- export const GradientPicker = React.memo(function GradientPicker({
29
- value,
30
- selectedStop,
31
- onChangeColor,
32
- onChangePosition,
33
- onAdd,
34
- onDelete,
35
- onSelectStop,
36
- }: Props) {
37
- const colorModel: ColorModel<RgbaColor> = React.useMemo(
38
- () => ({
39
- defaultColor: { r: 0, g: 0, b: 0, a: 1 },
40
- toHsva: rgbaToHsva,
41
- fromHsva: hsvaToRgba,
42
- equal: equalColorObjects,
43
- }),
44
- []
45
- );
46
-
47
- const rgbaColor = React.useMemo(
48
- () => sketchColorToRgba(value[selectedStop].color),
49
- [value, selectedStop]
50
- );
51
-
52
- const handleChangeColor = React.useCallback(
53
- (value: RgbaColor) => {
54
- onChangeColor(rgbaToSketchColor(value));
55
- },
56
- [onChangeColor]
57
- );
58
-
59
- const handleAddGradientStop = React.useCallback(
60
- (value: RgbaColor, position: number) => {
61
- onAdd(rgbaToSketchColor(value), position);
62
- },
63
- [onAdd]
64
- );
65
-
66
- return (
67
- <NoyaColorPicker
68
- onChange={handleChangeColor}
69
- colorModel={colorModel}
70
- color={rgbaColor}
71
- >
72
- <Gradient
73
- gradients={value}
74
- selectedStop={selectedStop}
75
- onSelectStop={onSelectStop}
76
- onChangePosition={onChangePosition}
77
- onAdd={handleAddGradientStop}
78
- onDelete={onDelete}
79
- />
80
- <Spacer.Vertical size={10} />
81
- <Saturation />
82
- <Spacer.Vertical size={12} />
83
- <Hue />
84
- <Spacer.Vertical size={5} />
85
- <Alpha />
86
- </NoyaColorPicker>
87
- );
88
- });
@@ -1,183 +0,0 @@
1
- import { useWindowSize } from "@noya-app/react-utils";
2
- import React, { useLayoutEffect, useRef } from "react";
3
- import { ImperativePanelGroupHandle } from "react-resizable-panels";
4
- import { PanelLayoutState } from "../components/workspace/types";
5
-
6
- export const EDITOR_PANEL_GROUP_ID = "editor-panel-group";
7
- export const LEFT_SIDEBAR_ID = "editor-left-sidebar";
8
- export const RIGHT_SIDEBAR_ID = "editor-right-sidebar";
9
- export const CONTENT_AREA_ID = "editor-content-area";
10
-
11
- export function usePreservePanelSize(
12
- panelGroupRef: React.RefObject<ImperativePanelGroupHandle | null>,
13
- setPanelLayoutState?: (state: PanelLayoutState) => void
14
- ) {
15
- const windowSize = useWindowSize();
16
- const layoutRef = useRef<
17
- { windowWidth: number; panelPercentages: number[] } | undefined
18
- >();
19
-
20
- useLayoutEffect(() => {
21
- const panelGroup = document.querySelector(
22
- `[data-panel-group-id="${EDITOR_PANEL_GROUP_ID}"]`
23
- ) as HTMLElement;
24
-
25
- function observePanels() {
26
- const panels = [
27
- ...panelGroup.querySelectorAll<HTMLElement>("[data-panel]"),
28
- ];
29
-
30
- const panelObserver = new ResizeObserver(() => {
31
- const layout = {
32
- windowWidth: panelGroup.offsetWidth,
33
- panelPercentages: panelGroupRef.current?.getLayout() ?? [],
34
- };
35
- layoutRef.current = layout;
36
-
37
- const leftSidebar = panels.find(
38
- (panel) => panel.id === LEFT_SIDEBAR_ID
39
- );
40
- const rightSidebar = panels.find(
41
- (panel) => panel.id === RIGHT_SIDEBAR_ID
42
- );
43
-
44
- setPanelLayoutState?.({
45
- leftSidebarCollapsed: leftSidebar?.offsetWidth === 0,
46
- rightSidebarCollapsed: rightSidebar?.offsetWidth === 0,
47
- });
48
- });
49
-
50
- panels.forEach((panel) => panelObserver.observe(panel));
51
-
52
- return () => {
53
- panelObserver.disconnect();
54
- };
55
- }
56
-
57
- let disconnectPanelObserver = observePanels();
58
-
59
- const panelGroupObserver = new MutationObserver(() => {
60
- disconnectPanelObserver();
61
- disconnectPanelObserver = observePanels();
62
- });
63
-
64
- panelGroupObserver.observe(panelGroup, {
65
- childList: true,
66
- });
67
-
68
- return () => {
69
- disconnectPanelObserver();
70
- panelGroupObserver.disconnect();
71
- };
72
- }, [panelGroupRef, setPanelLayoutState]);
73
-
74
- useLayoutEffect(() => {
75
- if (!layoutRef.current) return;
76
-
77
- // Preserve the pixel values of the left and right sidebar when the window is resized.
78
- // To do this we convert the percentage values to pixel values based on the old window width,
79
- // then convert the pixel values to percentage values based on the new window width.
80
- const {
81
- windowWidth: oldWindowWidth,
82
- panelPercentages: oldPanelPercentages,
83
- } = layoutRef.current;
84
-
85
- // Check the types of the values in the array
86
- if (
87
- oldPanelPercentages.some(
88
- (value) => typeof value !== "number" || isNaN(value)
89
- ) ||
90
- oldWindowWidth === 0
91
- ) {
92
- return;
93
- }
94
-
95
- const currentLayout = panelGroupRef.current?.getLayout();
96
-
97
- // Ensure we have the same number of panels
98
- if (!currentLayout || currentLayout.length !== oldPanelPercentages.length) {
99
- return;
100
- }
101
-
102
- if (currentLayout.length === 3) {
103
- const leftSidebarWidth = (oldPanelPercentages[0] / 100) * oldWindowWidth;
104
- const rightSidebarWidth = (oldPanelPercentages[2] / 100) * oldWindowWidth;
105
-
106
- const newLeftSidebarPercentage =
107
- (leftSidebarWidth / windowSize.width) * 100;
108
- const newRightSidebarPercentage =
109
- (rightSidebarWidth / windowSize.width) * 100;
110
-
111
- const newLayout = [
112
- newLeftSidebarPercentage,
113
- 100 - newLeftSidebarPercentage - newRightSidebarPercentage,
114
- newRightSidebarPercentage,
115
- ];
116
-
117
- try {
118
- panelGroupRef.current?.setLayout(newLayout);
119
- } catch (e) {
120
- console.error(e);
121
- console.info("snapshot on error", {
122
- oldWindowWidth,
123
- oldPanelPercentages,
124
- newLayout,
125
- currentLayout,
126
- });
127
- }
128
- } else if (currentLayout.length === 2) {
129
- // Check if this is a right sidebar layout by looking at the panel IDs
130
- const panelGroup = document.querySelector(
131
- `[data-panel-group-id="${EDITOR_PANEL_GROUP_ID}"]`
132
- );
133
- const panels = [
134
- ...(panelGroup?.querySelectorAll<HTMLElement>("[data-panel]") ?? []),
135
- ];
136
- const isRightSidebarLayout = panels[1]?.id === RIGHT_SIDEBAR_ID;
137
-
138
- if (isRightSidebarLayout) {
139
- const rightSidebarWidth =
140
- (oldPanelPercentages[1] / 100) * oldWindowWidth;
141
- const newRightSidebarPercentage =
142
- (rightSidebarWidth / windowSize.width) * 100;
143
- const newLayout = [
144
- 100 - newRightSidebarPercentage,
145
- newRightSidebarPercentage,
146
- ];
147
-
148
- try {
149
- panelGroupRef.current?.setLayout(newLayout);
150
- } catch (e) {
151
- console.error(e);
152
- console.info("snapshot on error", {
153
- oldWindowWidth,
154
- oldPanelPercentages,
155
- newLayout,
156
- currentLayout,
157
- });
158
- }
159
- } else {
160
- const leftSidebarWidth =
161
- (oldPanelPercentages[0] / 100) * oldWindowWidth;
162
- const newLeftSidebarPercentage =
163
- (leftSidebarWidth / windowSize.width) * 100;
164
- const newLayout = [
165
- newLeftSidebarPercentage,
166
- 100 - newLeftSidebarPercentage,
167
- ];
168
-
169
- try {
170
- panelGroupRef.current?.setLayout(newLayout);
171
- } catch (e) {
172
- console.error(e);
173
- console.info("snapshot on error", {
174
- oldWindowWidth,
175
- oldPanelPercentages,
176
- newLayout,
177
- currentLayout,
178
- });
179
- }
180
- }
181
- }
182
- }, [panelGroupRef, windowSize.width]);
183
- }
package/src/mediaQuery.ts DELETED
@@ -1,13 +0,0 @@
1
- export const size = {
2
- medium: '800px',
3
- large: '1280px',
4
- xlarge: '1550px',
5
- xxlarge: '1680px',
6
- };
7
-
8
- export const mediaQuery = {
9
- small: `@media (max-width: ${size.medium})`,
10
- medium: `@media (max-width: ${size.large}) and (min-width: ${size.medium})`,
11
- large: `@media (max-width: ${size.xlarge}) and (min-width: ${size.large})`,
12
- xlarge: `@media (min-width: ${size.xlarge})`,
13
- };
@@ -1,31 +0,0 @@
1
- import { Sketch } from "@noya-app/noya-file-format";
2
- import { sketchColorToRgbaString } from "./sketchColor";
3
-
4
- const getRGBAColor = (value: Sketch.GradientStop[], num: 100 | 360) =>
5
- [...value]
6
- .sort((a, b) => a.position - b.position)
7
- .map(
8
- (g) =>
9
- `${sketchColorToRgbaString(g.color)} ${g.position * num}${
10
- num === 100 ? "%" : "deg"
11
- }`
12
- )
13
- .join(", \n");
14
-
15
- export function getGradientBackground(
16
- value: Sketch.GradientStop[],
17
- type: Sketch.GradientType,
18
- direction?: number
19
- ) {
20
- if (type === Sketch.GradientType.Angular) {
21
- return `conic-gradient(${getRGBAColor(value, 360)})`;
22
- }
23
-
24
- const color = getRGBAColor(value, 100);
25
- const position =
26
- type === Sketch.GradientType.Radial
27
- ? "radial-gradient(circle"
28
- : `linear-gradient(${direction !== undefined ? direction : 180}deg`;
29
-
30
- return `${position}, ${color})`;
31
- }