@flightlesslabs/dodo-ui 0.17.1 → 0.18.0

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 (59) hide show
  1. package/dist/index.d.ts +5 -1
  2. package/dist/index.js +2 -0
  3. package/dist/stories/Home.mdx +2 -1
  4. package/dist/stories/components/Form/Button/Button.svelte +0 -2
  5. package/dist/stories/components/Form/Radio/Radio.svelte +0 -1
  6. package/dist/stories/components/Form/Select/Select.svelte.d.ts +2 -2
  7. package/dist/stories/components/Layout/Accordian/Accordian.stories.svelte +52 -0
  8. package/dist/stories/components/Layout/Accordian/Accordian.stories.svelte.d.ts +21 -0
  9. package/dist/stories/components/Layout/Accordian/Accordian.svelte +121 -0
  10. package/dist/stories/components/Layout/Accordian/Accordian.svelte.d.ts +34 -0
  11. package/dist/stories/components/Layout/Accordian/Customize/Customize.stories.svelte +69 -0
  12. package/dist/stories/components/Layout/Accordian/Customize/Customize.stories.svelte.d.ts +18 -0
  13. package/dist/stories/components/Layout/Accordian/Events/Events.stories.svelte +30 -0
  14. package/dist/stories/components/Layout/Accordian/Events/Events.stories.svelte.d.ts +18 -0
  15. package/dist/stories/components/Layout/Accordian/Size/Size.stories.svelte +48 -0
  16. package/dist/stories/components/Layout/Accordian/Size/Size.stories.svelte.d.ts +26 -0
  17. package/dist/stories/developer tools/Intro.mdx +1 -0
  18. package/dist/stories/developer tools/customize/AutoCustomize/AutoCustomize.mdx +4 -0
  19. package/dist/stories/developer tools/customize/AutoCustomize/Tool/Config/ColorTool/ColorButton.svelte +42 -0
  20. package/dist/stories/developer tools/customize/AutoCustomize/Tool/Config/ColorTool/ColorButton.svelte.d.ts +8 -0
  21. package/dist/stories/developer tools/customize/AutoCustomize/Tool/Config/ColorTool/ColorTool.svelte +21 -0
  22. package/dist/stories/developer tools/customize/AutoCustomize/Tool/Config/ColorTool/ColorTool.svelte.d.ts +9 -0
  23. package/dist/stories/developer tools/customize/AutoCustomize/Tool/Config/Config.svelte +144 -0
  24. package/dist/stories/developer tools/customize/AutoCustomize/Tool/Config/Config.svelte.d.ts +18 -0
  25. package/dist/stories/developer tools/customize/AutoCustomize/Tool/Config/Export.svelte +123 -0
  26. package/dist/stories/developer tools/customize/AutoCustomize/Tool/Config/Export.svelte.d.ts +18 -0
  27. package/dist/stories/developer tools/customize/AutoCustomize/Tool/Config/ValueSilder/ValueSilder.svelte +32 -0
  28. package/dist/stories/developer tools/customize/AutoCustomize/Tool/Config/ValueSilder/ValueSilder.svelte.d.ts +11 -0
  29. package/dist/stories/developer tools/customize/AutoCustomize/Tool/Preview/Preview.svelte +192 -0
  30. package/dist/stories/developer tools/customize/AutoCustomize/Tool/Preview/Preview.svelte.d.ts +3 -0
  31. package/dist/stories/developer tools/customize/AutoCustomize/Tool/Tool.stories.svelte +9 -0
  32. package/dist/stories/developer tools/customize/AutoCustomize/Tool/Tool.stories.svelte.d.ts +19 -0
  33. package/dist/stories/developer tools/customize/AutoCustomize/Tool/Tool.svelte +13 -0
  34. package/dist/stories/developer tools/customize/AutoCustomize/Tool/Tool.svelte.d.ts +18 -0
  35. package/dist/stories/developer tools/customize/AutoCustomize/Tool/helpers/download-file.d.ts +1 -0
  36. package/dist/stories/developer tools/customize/AutoCustomize/Tool/helpers/download-file.js +10 -0
  37. package/dist/stories/developer tools/customize/AutoCustomize/Tool/stores/config.svelte.d.ts +27 -0
  38. package/dist/stories/developer tools/customize/AutoCustomize/Tool/stores/config.svelte.js +70 -0
  39. package/dist/stories/developer tools/customize/Intro.mdx +8 -0
  40. package/dist/styles/_colors.css +1 -1
  41. package/dist/types/special.d.ts +1 -0
  42. package/dist/types/special.js +1 -0
  43. package/package.json +8 -6
  44. package/src/lib/index.ts +10 -5
  45. package/src/lib/stories/components/Form/Button/Button.svelte +0 -2
  46. package/src/lib/stories/components/Form/Radio/Radio.svelte +0 -1
  47. package/src/lib/stories/components/Form/Select/Select.svelte +2 -3
  48. package/src/lib/stories/components/Layout/Accordian/Accordian.svelte +195 -0
  49. package/src/lib/stories/developer tools/customize/AutoCustomize/Tool/Config/ColorTool/ColorButton.svelte +56 -0
  50. package/src/lib/stories/developer tools/customize/AutoCustomize/Tool/Config/ColorTool/ColorTool.svelte +32 -0
  51. package/src/lib/stories/developer tools/customize/AutoCustomize/Tool/Config/Config.svelte +149 -0
  52. package/src/lib/stories/developer tools/customize/AutoCustomize/Tool/Config/Export.svelte +172 -0
  53. package/src/lib/stories/developer tools/customize/AutoCustomize/Tool/Config/ValueSilder/ValueSilder.svelte +47 -0
  54. package/src/lib/stories/developer tools/customize/AutoCustomize/Tool/Preview/Preview.svelte +227 -0
  55. package/src/lib/stories/developer tools/customize/AutoCustomize/Tool/Tool.svelte +16 -0
  56. package/src/lib/stories/developer tools/customize/AutoCustomize/Tool/helpers/download-file.ts +11 -0
  57. package/src/lib/stories/developer tools/customize/AutoCustomize/Tool/stores/config.svelte.ts +107 -0
  58. package/src/lib/styles/_colors.css +1 -1
  59. package/src/lib/types/special.ts +1 -0
@@ -0,0 +1,172 @@
1
+ <script lang="ts">
2
+ import Button from '$lib/stories/components/Form/Button/Button.svelte';
3
+ import {
4
+ colorPalette,
5
+ colorPaletteValues,
6
+ } from '$lib/stories/developer tools/philosophy/Colors/utils/color.js';
7
+ import { downloadFile } from '../helpers/download-file.js';
8
+ import {
9
+ autoCustomizeConfigdefaultData,
10
+ useAutoCustomizeConfigStore,
11
+ type AutoCustomizeConfigDataColors,
12
+ } from '../stores/config.svelte.js';
13
+
14
+ async function onclick() {
15
+ try {
16
+ let rawText = `/* dodo-ui-custom.css */
17
+ :root {`;
18
+
19
+ for (let index = 0; index < colorPalette.length; index++) {
20
+ const colorName = colorPalette[index];
21
+
22
+ const fieldName = `${colorName}` as keyof AutoCustomizeConfigDataColors;
23
+
24
+ const dataPoint =
25
+ useAutoCustomizeConfigStore.data.colors &&
26
+ useAutoCustomizeConfigStore.data.colors[fieldName]
27
+ ? useAutoCustomizeConfigStore.data.colors[fieldName]
28
+ : undefined;
29
+
30
+ const defaultValue =
31
+ autoCustomizeConfigdefaultData.colors && autoCustomizeConfigdefaultData.colors[fieldName]
32
+ ? autoCustomizeConfigdefaultData.colors[fieldName]
33
+ : undefined;
34
+
35
+ const pass = dataPoint && dataPoint !== defaultValue ? true : false;
36
+
37
+ if (!pass) {
38
+ continue;
39
+ }
40
+
41
+ rawText += `
42
+ /* ${colorName} color */`;
43
+
44
+ for (let index = 0; index < colorPaletteValues.length; index++) {
45
+ const weight = colorPaletteValues[index];
46
+
47
+ rawText += `
48
+ --dodo-color-${colorName}-${weight}: var(--dodo-color-base-${dataPoint}-${weight});`;
49
+
50
+ if (colorPaletteValues[index] === colorPaletteValues[colorPaletteValues.length - 1]) {
51
+ rawText += `
52
+ `;
53
+ }
54
+ }
55
+ }
56
+
57
+ if (useAutoCustomizeConfigStore.data.components?.roundness) {
58
+ const roundness = useAutoCustomizeConfigStore.data.components?.roundness / 8;
59
+
60
+ rawText += `
61
+
62
+ /* Component: Roundness */
63
+ --dodo-ui-element-roundness-1: ${0.4375 + roundness}em;
64
+ --dodo-ui-element-roundness-2: ${0.8125 + roundness}em;
65
+ --dodo-ui-element-roundness-3: ${1.9375 + roundness}em;`;
66
+ }
67
+
68
+ if (useAutoCustomizeConfigStore.data.components?.elementHeight) {
69
+ const elementHeight = useAutoCustomizeConfigStore.data.components.elementHeight + 2;
70
+ const elementHeightTrack = useAutoCustomizeConfigStore.data.components.elementHeight / 2;
71
+
72
+ rawText += `
73
+
74
+ /* Component: Size */
75
+ --dodo-ui-element-height-small: ${34 + elementHeight}px;
76
+ --dodo-ui-element-height-normal: ${40 + elementHeight}px;
77
+ --dodo-ui-element-height-large: ${50 + elementHeight}px;
78
+ --dodo-ui-track-element-height-small: ${6 + elementHeightTrack}px;
79
+ --dodo-ui-track-element-height-normal: ${8 + elementHeightTrack}px;
80
+ --dodo-ui-track-element-height-large: ${10 + elementHeightTrack}px;`;
81
+ }
82
+
83
+ if (useAutoCustomizeConfigStore.data.components?.borderWidth) {
84
+ const borderWidth = useAutoCustomizeConfigStore.data.components.borderWidth;
85
+
86
+ rawText += `
87
+
88
+ /* Component: Border */
89
+ --dodo-ui-element-border-width: ${2 + borderWidth}px;`;
90
+ }
91
+
92
+ if (useAutoCustomizeConfigStore.data.space) {
93
+ const space = useAutoCustomizeConfigStore.data.space;
94
+
95
+ rawText += `
96
+
97
+ /* Space */
98
+ --dodo-ui-space-small: ${6 + space}px;
99
+ --dodo-ui-space: ${8 + space}px;
100
+ --dodo-ui-space-large: ${10 + space}px;`;
101
+ }
102
+
103
+ // end
104
+ rawText += `
105
+ }`;
106
+
107
+ rawText += `
108
+
109
+ .dodo-theme--dark {`;
110
+
111
+ for (let index = 0; index < colorPalette.length; index++) {
112
+ const colorName = colorPalette[index];
113
+
114
+ const fieldName = `${colorName}` as keyof AutoCustomizeConfigDataColors;
115
+
116
+ const dataPoint =
117
+ useAutoCustomizeConfigStore.data.colors &&
118
+ useAutoCustomizeConfigStore.data.colors[fieldName]
119
+ ? useAutoCustomizeConfigStore.data.colors[fieldName]
120
+ : undefined;
121
+
122
+ const defaultValue =
123
+ autoCustomizeConfigdefaultData.colors && autoCustomizeConfigdefaultData.colors[fieldName]
124
+ ? autoCustomizeConfigdefaultData.colors[fieldName]
125
+ : undefined;
126
+
127
+ const pass = dataPoint && dataPoint !== defaultValue ? true : false;
128
+
129
+ if (!pass) {
130
+ continue;
131
+ }
132
+
133
+ rawText += `
134
+
135
+ /* Dark: ${colorName} color */`;
136
+
137
+ const colorPaletteValuesReversed = [...colorPaletteValues].reverse();
138
+
139
+ for (let index = 0; index < colorPaletteValues.length; index++) {
140
+ const weight = colorPaletteValues[index];
141
+ const weightReversed = colorPaletteValuesReversed[index];
142
+
143
+ rawText += `
144
+ --dodo-color-${colorName}-${weight}: var(--dodo-color-base-${dataPoint}-${weightReversed});`;
145
+ }
146
+
147
+ if (
148
+ colorPaletteValuesReversed[index] ===
149
+ colorPaletteValuesReversed[colorPaletteValuesReversed.length - 1]
150
+ ) {
151
+ rawText += `
152
+ `;
153
+ }
154
+ }
155
+
156
+ // end
157
+ rawText += `
158
+ }`;
159
+
160
+ const data = new Blob([rawText], { type: 'text/plain' });
161
+
162
+ await downloadFile(`dodo-ui-custom.css`, data);
163
+ } catch (e) {
164
+ console.error(e);
165
+ }
166
+ }
167
+ </script>
168
+
169
+ <Button {onclick}>Export CSS</Button>
170
+
171
+ <style lang="scss">
172
+ </style>
@@ -0,0 +1,47 @@
1
+ <script lang="ts">
2
+ import FormControl from '$lib/stories/components/Form/FormControl/FormControl.svelte';
3
+ import RangeSlider from '$lib/stories/components/Form/RangeSlider/RangeSlider.svelte';
4
+
5
+ interface ValueSilderProps {
6
+ label?: string;
7
+ value: number;
8
+ min: number;
9
+ max: number;
10
+ /** oninput event handler */
11
+ oninput?: (value: number) => void;
12
+ }
13
+
14
+ const { label, value, min, max, oninput }: ValueSilderProps = $props();
15
+
16
+ let displayValue = $state(0);
17
+
18
+ function oninputMod(e: Event) {
19
+ const target = e.target as HTMLInputElement;
20
+
21
+ if (oninput) {
22
+ oninput(Number(target.value));
23
+ }
24
+ }
25
+
26
+ $effect(() => {
27
+ if (value === 0) {
28
+ displayValue = 1;
29
+ } else if (value < 0) {
30
+ displayValue = value;
31
+ } else {
32
+ displayValue = value + 1;
33
+ }
34
+ });
35
+ </script>
36
+
37
+ <div class="ValueSilder">
38
+ <FormControl label={`${label} ${displayValue}x`}>
39
+ <RangeSlider {value} {min} {max} oninput={oninputMod} size="small" />
40
+ </FormControl>
41
+ </div>
42
+
43
+ <style lang="scss">
44
+ .ValueSilder {
45
+ margin-bottom: calc(var(--dodo-ui-space) * 2.5);
46
+ }
47
+ </style>
@@ -0,0 +1,227 @@
1
+ <script lang="ts">
2
+ import Button from '$lib/stories/components/Form/Button/Button.svelte';
3
+ import RangeSlider from '$lib/stories/components/Form/RangeSlider/RangeSlider.svelte';
4
+ import Column from '$lib/stories/components/Layout/Grid/Column/Column.svelte';
5
+ import Grid from '$lib/stories/components/Layout/Grid/Grid.svelte';
6
+ import Paper from '$lib/stories/components/Layout/Paper/Paper.svelte';
7
+ import {
8
+ colorPalette,
9
+ colorPaletteValues,
10
+ } from '$lib/stories/developer tools/philosophy/Colors/utils/color.js';
11
+ import {
12
+ useAutoCustomizeConfigStore,
13
+ type AutoCustomizeConfigDataColors,
14
+ } from '../stores/config.svelte.js';
15
+
16
+ let cssVariables = $state<string[]>([]);
17
+
18
+ $effect(() => {
19
+ const newCssvariables: string[] = [];
20
+
21
+ for (let index = 0; index < colorPalette.length; index++) {
22
+ const colorName = colorPalette[index];
23
+ const fieldName = `${colorName}` as keyof AutoCustomizeConfigDataColors;
24
+
25
+ const dataPoint =
26
+ useAutoCustomizeConfigStore.data.colors &&
27
+ useAutoCustomizeConfigStore.data.colors[fieldName]
28
+ ? useAutoCustomizeConfigStore.data.colors[fieldName]
29
+ : undefined;
30
+
31
+ if (dataPoint) {
32
+ for (let index = 0; index < colorPaletteValues.length; index++) {
33
+ const weight = colorPaletteValues[index];
34
+
35
+ newCssvariables.push(
36
+ `--dodo-color-${colorName}-${weight}: var(--dodo-color-base-${dataPoint}-${weight})`,
37
+ );
38
+ }
39
+
40
+ newCssvariables.push(
41
+ ...[
42
+ `--dodo-ui-Button-outline-${colorName}: var(--dodo-color-base-${dataPoint}-400)`,
43
+ `--dodo-ui-Button-text-${colorName}-bg: var(--dodo-color-base-${dataPoint}-100)`,
44
+ `--dodo-ui-Button-text-${colorName}-hover-bg: var(--dodo-color-base-${dataPoint}-200)`,
45
+ `--dodo-ui-Button-text-${colorName}-active-bg: var(--dodo-color-base-${dataPoint}-300)`,
46
+ `--dodo-ui-Button-solid-${colorName}-bg: var(--dodo-color-base-${dataPoint}-500)`,
47
+ `--dodo-ui-Button-solid-${colorName}-hover-bg: var(--dodo-color-base-${dataPoint}-600)`,
48
+ `--dodo-ui-Button-solid-${colorName}-active-bg: var(--dodo-color-base-${dataPoint}-700)`,
49
+ `--dodo-ui-RangeSlider-thumb-${colorName}-bg: var(--dodo-color-base-${dataPoint}-500)`,
50
+ `--dodo-ui-RangeSlider-thumb-${colorName}-hover-bg: var(--dodo-color-base-${dataPoint}-600)`,
51
+ `--dodo-ui-RangeSlider-thumb-${colorName}-active-bg: var(--dodo-color-base-${dataPoint}-700)`,
52
+ `--dodo-ui-RangeSlider-track-filled-${colorName}-bg: var(--dodo-color-base-${dataPoint}-500)`,
53
+ ],
54
+ );
55
+ }
56
+ }
57
+
58
+ if (useAutoCustomizeConfigStore.data.components?.roundness) {
59
+ const roundness = useAutoCustomizeConfigStore.data.components.roundness / 8;
60
+
61
+ newCssvariables.push(`--dodo-ui-element-roundness-1: ${0.4375 + roundness}em`);
62
+ newCssvariables.push(`--dodo-ui-element-roundness-2: ${0.8125 + roundness}em`);
63
+ newCssvariables.push(`--dodo-ui-element-roundness-3: ${1.9375 + roundness}em`);
64
+ }
65
+
66
+ if (useAutoCustomizeConfigStore.data.components?.elementHeight) {
67
+ const elementHeight = useAutoCustomizeConfigStore.data.components.elementHeight + 2;
68
+ const elementHeightTrack = useAutoCustomizeConfigStore.data.components.elementHeight / 2;
69
+
70
+ newCssvariables.push(`--dodo-ui-element-height-small: ${34 + elementHeight}px`);
71
+ newCssvariables.push(`--dodo-ui-element-height-normal: ${40 + elementHeight}px`);
72
+ newCssvariables.push(`--dodo-ui-element-height-large: ${50 + elementHeight}px`);
73
+
74
+ newCssvariables.push(`--dodo-ui-track-element-height-small: ${6 + elementHeightTrack}px`);
75
+ newCssvariables.push(`--dodo-ui-track-element-height-normal: ${8 + elementHeightTrack}px`);
76
+ newCssvariables.push(`--dodo-ui-track-element-height-large: ${10 + elementHeightTrack}px`);
77
+ }
78
+
79
+ if (useAutoCustomizeConfigStore.data.components?.borderWidth) {
80
+ const borderWidth = useAutoCustomizeConfigStore.data.components.borderWidth;
81
+
82
+ newCssvariables.push(`--dodo-ui-element-border-width: ${1 + borderWidth}px`);
83
+ }
84
+
85
+ if (useAutoCustomizeConfigStore.data.space) {
86
+ const space = useAutoCustomizeConfigStore.data.space;
87
+
88
+ newCssvariables.push(`--dodo-ui-space-small: ${6 + space}px`);
89
+ newCssvariables.push(`--dodo-ui-space: ${8 + space}px`);
90
+ newCssvariables.push(`--dodo-ui-space-large: ${10 + space}px`);
91
+ }
92
+
93
+ cssVariables = [...newCssvariables];
94
+ });
95
+ </script>
96
+
97
+ <div class="Preview" style={cssVariables.join(';')}>
98
+ <div class="section">
99
+ <div class="column">
100
+ <Button>Primary</Button>
101
+ </div>
102
+ <div class="column">
103
+ <Button color="secondary">Secondary</Button>
104
+ </div>
105
+ <div class="column">
106
+ <Button color="neutral">Neutral</Button>
107
+ </div>
108
+ <div class="column">
109
+ <Button color="safe">Safe</Button>
110
+ </div>
111
+ <div class="column">
112
+ <Button color="warning">Warning</Button>
113
+ </div>
114
+ <div class="column">
115
+ <Button color="danger">Danger</Button>
116
+ </div>
117
+ </div>
118
+
119
+ <div class="section">
120
+ <div class="column">
121
+ <Button variant="text" outline>Primary</Button>
122
+ </div>
123
+ <div class="column">
124
+ <Button variant="text" outline color="secondary">Secondary</Button>
125
+ </div>
126
+ <div class="column">
127
+ <Button variant="text" outline color="neutral">Neutral</Button>
128
+ </div>
129
+ <div class="column">
130
+ <Button variant="text" outline color="safe">Safe</Button>
131
+ </div>
132
+ <div class="column">
133
+ <Button variant="text" outline color="warning">Warning</Button>
134
+ </div>
135
+ <div class="column">
136
+ <Button variant="text" outline color="danger">Danger</Button>
137
+ </div>
138
+ </div>
139
+
140
+ <div class="section">
141
+ <div class="column">
142
+ <Paper shadow={1} width="150px" height="180px">
143
+ <div style="padding: var(--dodo-ui-space)">Hola!</div>
144
+ </Paper>
145
+ </div>
146
+ <div class="column">
147
+ <RangeSlider value={50} min={20} max={70} />
148
+ </div>
149
+ </div>
150
+
151
+ <div class="section">
152
+ <Grid class="GridSection">
153
+ <Column md={6}>
154
+ <Paper shadow={1}>
155
+ <div style="padding: var(--dodo-ui-space)">Hola!</div>
156
+ </Paper>
157
+ </Column>
158
+ <Column md={6}>
159
+ <Paper shadow={1}>
160
+ <div style="padding: var(--dodo-ui-space)">Hola!</div>
161
+ </Paper>
162
+ </Column>
163
+ <Column md={4}>
164
+ <Paper shadow={1}>
165
+ <div style="padding: var(--dodo-ui-space)">Hola!</div>
166
+ </Paper>
167
+ </Column>
168
+ <Column md={3}>
169
+ <Paper shadow={1}>
170
+ <div style="padding: var(--dodo-ui-space)">Hola!</div>
171
+ </Paper>
172
+ </Column>
173
+ <Column md={2}>
174
+ <Paper shadow={1}>
175
+ <div style="padding: var(--dodo-ui-space)">Hola!</div>
176
+ </Paper>
177
+ </Column>
178
+ <Column md={3}>
179
+ <Paper shadow={1}>
180
+ <div style="padding: var(--dodo-ui-space)">Hola!</div>
181
+ </Paper>
182
+ </Column>
183
+ </Grid>
184
+ </div>
185
+ </div>
186
+
187
+ <style lang="scss">
188
+ @use '../../../../../../styles/scss' as *;
189
+
190
+ :global(:root) {
191
+ --AutoCustomize-Preview-bgColor: var(--dodo-color-base-gray-100);
192
+ }
193
+
194
+ :global(.dodo-theme--dark) {
195
+ --AutoCustomize-Preview-bgColor: var(--dodo-color-base-gray-800);
196
+ }
197
+
198
+ .Preview {
199
+ background-color: var(--AutoCustomize-Preview-bgColor);
200
+ padding: calc(var(--dodo-ui-space) * 2);
201
+ border-radius: var(--dodo-ui-element-roundness-2);
202
+ width: 100%;
203
+
204
+ @media (min-width: $breakpoints-lg) {
205
+ flex: 1;
206
+ width: initial;
207
+ height: calc(100vh - 130px);
208
+ overflow: auto;
209
+ }
210
+
211
+ .section {
212
+ width: 100%;
213
+ margin: var(--dodo-ui-space) 0;
214
+ display: flex;
215
+ flex-wrap: wrap;
216
+ }
217
+
218
+ .column {
219
+ margin: 4px;
220
+ display: inline-flex;
221
+ }
222
+
223
+ :global(.GridSection) {
224
+ width: 100%;
225
+ }
226
+ }
227
+ </style>
@@ -0,0 +1,16 @@
1
+ <script lang="ts">
2
+ import Config from './Config/Config.svelte';
3
+ import Preview from './Preview/Preview.svelte';
4
+ </script>
5
+
6
+ <div class="Tool">
7
+ <Config />
8
+ <Preview />
9
+ </div>
10
+
11
+ <style lang="scss">
12
+ .Tool {
13
+ display: flex;
14
+ flex-wrap: wrap;
15
+ }
16
+ </style>
@@ -0,0 +1,11 @@
1
+ import { saveAs } from 'file-saver';
2
+
3
+ export async function downloadFile(fileName: string, data: Blob) {
4
+ try {
5
+ saveAs(data, fileName);
6
+
7
+ return Promise.resolve();
8
+ } catch (e) {
9
+ return Promise.reject(e);
10
+ }
11
+ }
@@ -0,0 +1,107 @@
1
+ import { browser } from '$app/environment';
2
+
3
+ const AUTO_CUSTOMIZE_TOOL_CONFIG = 'AUTO_CUSTOMIZE_TOOL_CONFIG';
4
+
5
+ export type AutoCustomizeConfigDataColors = {
6
+ primary?: string;
7
+ secondary?: string;
8
+ neutral?: string;
9
+ safe?: string;
10
+ warning?: string;
11
+ danger?: string;
12
+ };
13
+
14
+ export type AutoCustomizeConfigDataComponents = {
15
+ roundness?: number;
16
+ elementHeight?: number;
17
+ borderWidth?: number;
18
+ };
19
+
20
+ export type AutoCustomizeConfigData = {
21
+ colors?: AutoCustomizeConfigDataColors;
22
+ components?: AutoCustomizeConfigDataComponents;
23
+ space?: number;
24
+ };
25
+
26
+ export const autoCustomizeConfigdefaultData: AutoCustomizeConfigData = {
27
+ colors: {
28
+ primary: 'violet',
29
+ secondary: 'blue',
30
+ neutral: 'gray',
31
+ safe: 'emerald',
32
+ warning: 'amber',
33
+ danger: 'red',
34
+ },
35
+ components: {
36
+ roundness: 0,
37
+ elementHeight: 0,
38
+ borderWidth: 0,
39
+ },
40
+ space: 0,
41
+ };
42
+
43
+ function getDefaultData() {
44
+ if (!browser) {
45
+ return autoCustomizeConfigdefaultData;
46
+ }
47
+
48
+ let values = JSON.parse(localStorage.getItem(AUTO_CUSTOMIZE_TOOL_CONFIG) || `{}`);
49
+
50
+ values = { ...autoCustomizeConfigdefaultData, ...values };
51
+
52
+ return values as AutoCustomizeConfigData;
53
+ }
54
+
55
+ function createAutoCustomizeConfigStore() {
56
+ let updatedAt: number = $state(Date.now());
57
+ let data: AutoCustomizeConfigData = $state(getDefaultData());
58
+
59
+ return {
60
+ get data() {
61
+ return data;
62
+ },
63
+ get updatedAt() {
64
+ return updatedAt;
65
+ },
66
+ updateData(newData: Partial<AutoCustomizeConfigData>) {
67
+ data = {
68
+ ...data,
69
+ ...newData,
70
+ };
71
+ updatedAt = Date.now();
72
+
73
+ if (browser) {
74
+ localStorage.setItem(AUTO_CUSTOMIZE_TOOL_CONFIG, JSON.stringify(newData));
75
+ }
76
+ },
77
+ updateDataColor(newData: Partial<AutoCustomizeConfigDataColors>) {
78
+ const colors = {
79
+ ...data.colors,
80
+ ...newData,
81
+ };
82
+
83
+ this.updateData({ colors });
84
+ },
85
+ updateDataComponents(newData: Partial<AutoCustomizeConfigDataComponents>) {
86
+ const components = {
87
+ ...data.components,
88
+ ...newData,
89
+ };
90
+
91
+ this.updateData({ components });
92
+ },
93
+ reset() {
94
+ data = autoCustomizeConfigdefaultData;
95
+ updatedAt = Date.now();
96
+
97
+ if (browser) {
98
+ localStorage.setItem(
99
+ AUTO_CUSTOMIZE_TOOL_CONFIG,
100
+ JSON.stringify(autoCustomizeConfigdefaultData),
101
+ );
102
+ }
103
+ },
104
+ };
105
+ }
106
+
107
+ export const useAutoCustomizeConfigStore = createAutoCustomizeConfigStore();
@@ -7,7 +7,7 @@
7
7
  --dodo-color-constant-black: var(--dodo-color-base-black);
8
8
  --dodo-color-constant-white: var(--dodo-color-base-white);
9
9
 
10
- /* Default color */
10
+ /* Neutral color */
11
11
  --dodo-color-neutral-50: var(--dodo-color-base-gray-50);
12
12
  --dodo-color-neutral-100: var(--dodo-color-base-gray-100);
13
13
  --dodo-color-neutral-200: var(--dodo-color-base-gray-200);
@@ -0,0 +1 @@
1
+ export type DropdownArrowPosition = false | 'before' | 'after';