@flightlesslabs/dodo-ui 0.11.1 → 0.12.1
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/dist/index.d.ts +3 -0
- package/dist/index.js +2 -0
- package/dist/stories/components/Form/Button/Button.svelte +18 -18
- package/dist/stories/components/Form/Button/utils/scss/mixins.scss +3 -3
- package/dist/stories/components/Form/NumericInput/Roundness/Roundness.stories.svelte +20 -0
- package/dist/stories/components/Form/NumericInput/Roundness/Roundness.stories.svelte.d.ts +26 -0
- package/dist/stories/components/Form/NumericInput/Size/Size.stories.svelte +16 -0
- package/dist/stories/components/Form/NumericInput/Size/Size.stories.svelte.d.ts +26 -0
- package/dist/stories/components/Form/NumericInput/WithIcon/WithIcon.stories.svelte +31 -0
- package/dist/stories/components/Form/NumericInput/WithIcon/WithIcon.stories.svelte.d.ts +26 -0
- package/dist/stories/components/Form/RangeSlider/Color/Color.stories.svelte +19 -0
- package/dist/stories/components/Form/RangeSlider/Color/Color.stories.svelte.d.ts +26 -0
- package/dist/stories/components/Form/RangeSlider/Events/Events.stories.svelte +59 -0
- package/dist/stories/components/Form/RangeSlider/Events/Events.stories.svelte.d.ts +18 -0
- package/dist/stories/components/Form/RangeSlider/RangeSlider.stories.svelte +64 -0
- package/dist/stories/components/Form/RangeSlider/RangeSlider.stories.svelte.d.ts +21 -0
- package/dist/stories/components/Form/RangeSlider/RangeSlider.svelte +525 -0
- package/dist/stories/components/Form/RangeSlider/RangeSlider.svelte.d.ts +48 -0
- package/dist/stories/components/Form/RangeSlider/Roundness/Roundness.stories.svelte +30 -0
- package/dist/stories/components/Form/RangeSlider/Roundness/Roundness.stories.svelte.d.ts +26 -0
- package/dist/stories/components/Form/RangeSlider/Size/Size.stories.svelte +16 -0
- package/dist/stories/components/Form/RangeSlider/Size/Size.stories.svelte.d.ts +26 -0
- package/dist/stories/components/Form/RangeSlider/WithIcon/WithIcon.stories.svelte +30 -0
- package/dist/stories/components/Form/RangeSlider/WithIcon/WithIcon.stories.svelte.d.ts +18 -0
- package/dist/stories/components/Form/RangeSlider/utils/scss/mixins.scss +91 -0
- package/dist/stories/developer tools/directives/drag/drag.d.ts +3 -0
- package/dist/stories/developer tools/directives/drag/drag.js +40 -0
- package/dist/styles/_components.css +5 -0
- package/package.json +11 -11
- package/src/lib/index.ts +4 -0
- package/src/lib/stories/components/Form/Button/utils/scss/mixins.scss +3 -3
- package/src/lib/stories/components/Form/NumericInput/Roundness/Roundness.stories.svelte +20 -0
- package/src/lib/stories/components/Form/NumericInput/Size/Size.stories.svelte +16 -0
- package/src/lib/stories/components/Form/NumericInput/WithIcon/WithIcon.stories.svelte +31 -0
- package/src/lib/stories/components/Form/RangeSlider/Color/Color.stories.svelte +19 -0
- package/src/lib/stories/components/Form/RangeSlider/Events/Events.stories.svelte +63 -0
- package/src/lib/stories/components/Form/RangeSlider/RangeSlider.stories.svelte +69 -0
- package/src/lib/stories/components/Form/RangeSlider/RangeSlider.svelte +476 -0
- package/src/lib/stories/components/Form/RangeSlider/Roundness/Roundness.stories.svelte +30 -0
- package/src/lib/stories/components/Form/RangeSlider/Size/Size.stories.svelte +16 -0
- package/src/lib/stories/components/Form/RangeSlider/WithIcon/WithIcon.stories.svelte +33 -0
- package/src/lib/stories/components/Form/RangeSlider/utils/scss/mixins.scss +91 -0
- package/src/lib/stories/developer tools/directives/drag/drag.ts +47 -0
- package/src/lib/styles/_components.css +5 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<script module lang="ts">import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
2
|
+
import RangeSlider from '../RangeSlider.svelte';
|
|
3
|
+
import { storyRangeSliderArgTypes } from '../RangeSlider.stories.svelte';
|
|
4
|
+
import Icon from '@iconify/svelte';
|
|
5
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
6
|
+
const { Story } = defineMeta({
|
|
7
|
+
component: RangeSlider,
|
|
8
|
+
tags: ['autodocs'],
|
|
9
|
+
argTypes: storyRangeSliderArgTypes,
|
|
10
|
+
});
|
|
11
|
+
let value = $state(30);
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<!-- RangeSlider icon in front. -->
|
|
15
|
+
<Story name="Icon Before" asChild>
|
|
16
|
+
<RangeSlider {value}>
|
|
17
|
+
{#snippet before()}
|
|
18
|
+
<Icon icon="material-symbols:content-copy" />
|
|
19
|
+
{/snippet}
|
|
20
|
+
</RangeSlider>
|
|
21
|
+
</Story>
|
|
22
|
+
|
|
23
|
+
<!-- RangeSlider icon in front. -->
|
|
24
|
+
<Story name="Icon After" asChild>
|
|
25
|
+
<RangeSlider {value}>
|
|
26
|
+
{#snippet after()}
|
|
27
|
+
<Icon icon="material-symbols:download-2" />
|
|
28
|
+
{/snippet}
|
|
29
|
+
</RangeSlider>
|
|
30
|
+
</Story>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
2
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
|
+
$$bindings?: Bindings;
|
|
4
|
+
} & Exports;
|
|
5
|
+
(internal: unknown, props: {
|
|
6
|
+
$$events?: Events;
|
|
7
|
+
$$slots?: Slots;
|
|
8
|
+
}): Exports & {
|
|
9
|
+
$set?: any;
|
|
10
|
+
$on?: any;
|
|
11
|
+
};
|
|
12
|
+
z_$$bindings?: Bindings;
|
|
13
|
+
}
|
|
14
|
+
declare const WithIcon: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
15
|
+
[evt: string]: CustomEvent<any>;
|
|
16
|
+
}, {}, {}, string>;
|
|
17
|
+
type WithIcon = InstanceType<typeof WithIcon>;
|
|
18
|
+
export default WithIcon;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/// Mixin: generate-dodo-ui-range-slider-colors
|
|
2
|
+
/// Generates CSS custom properties for Dodo UI range-slider styles (text & solid)
|
|
3
|
+
/// across different interaction states (default, hover, active).
|
|
4
|
+
/// @param {String} $color-name - The theme color name (e.g., "primary", "safe", etc.)
|
|
5
|
+
@mixin generate-dodo-ui-range-slider-colors($color-name) {
|
|
6
|
+
--dodo-ui-RangeSlider-thumb-#{$color-name}-bg: var(--dodo-color-#{$color-name}-500);
|
|
7
|
+
--dodo-ui-RangeSlider-thumb-#{$color-name}-hover-bg: var(--dodo-color-#{$color-name}-600);
|
|
8
|
+
--dodo-ui-RangeSlider-thumb-#{$color-name}-active-bg: var(--dodo-color-#{$color-name}-700);
|
|
9
|
+
|
|
10
|
+
--dodo-ui-RangeSlider-track-filled-#{$color-name}-bg: var(--dodo-color-#{$color-name}-500);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/// Mixin: generate-dodo-ui-range-slider-colors
|
|
14
|
+
/// Generates CSS custom properties for Dodo UI range-slider styles (text & solid)
|
|
15
|
+
/// across different interaction states (default, hover, active).
|
|
16
|
+
/// @param {String} $color-name - The theme color name (e.g., "primary", "safe", etc.)
|
|
17
|
+
@mixin generate-dodo-ui-range-slider-colors-dark($color-name) {
|
|
18
|
+
--dodo-ui-RangeSlider-thumb-#{$color-name}-bg: var(--dodo-color-#{$color-name}-500);
|
|
19
|
+
--dodo-ui-RangeSlider-thumb-#{$color-name}-hover-bg: var(--dodo-color-#{$color-name}-400);
|
|
20
|
+
--dodo-ui-RangeSlider-thumb-#{$color-name}-active-bg: var(--dodo-color-#{$color-name}-300);
|
|
21
|
+
|
|
22
|
+
--dodo-ui-RangeSlider-track-filled-#{$color-name}-bg: var(--dodo-color-#{$color-name}-500);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/// Mixin: generate-dodo-ui-range-slider-color
|
|
26
|
+
/// Auto-generates .color--[theme] > .variant--text & .variant--solid styles
|
|
27
|
+
/// @param {String} $theme - e.g., default, safe, danger, etc.
|
|
28
|
+
@mixin generate-dodo-ui-range-slider-color($theme) {
|
|
29
|
+
&--#{$theme} {
|
|
30
|
+
.NativeRangeSlider {
|
|
31
|
+
&::-webkit-slider-runnable-track {
|
|
32
|
+
background-color: var(--dodo-ui-RangeSlider-track-#{$theme}-bg);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
&::-moz-range-track {
|
|
36
|
+
background-color: var(--dodo-ui-RangeSlider-track-#{$theme}-bg);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
&:focus-visible {
|
|
40
|
+
&::-webkit-slider-thumb {
|
|
41
|
+
background: var(--dodo-ui-RangeSlider-thumb-#{$theme}-active-bg);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
&::-moz-range-thumb {
|
|
45
|
+
background: var(--dodo-ui-RangeSlider-thumb-#{$theme}-active-bg);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
&::-webkit-slider-runnable-track {
|
|
50
|
+
background: linear-gradient(
|
|
51
|
+
to right,
|
|
52
|
+
var(--dodo-ui-RangeSlider-track-filled-#{$theme}-bg) 0%,
|
|
53
|
+
var(--dodo-ui-RangeSlider-track-filled-#{$theme}-bg)
|
|
54
|
+
calc(var(--dodo-ui-RangeSlider-value-percent, 50%) * 1%),
|
|
55
|
+
var(--dodo-ui-RangeSlider-track-bg)
|
|
56
|
+
calc(var(--dodo-ui-RangeSlider-value-percent, 50%) * 1%),
|
|
57
|
+
var(--dodo-ui-RangeSlider-track-bg) 100%
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
&::-moz-range-progress {
|
|
62
|
+
background: var(--dodo-ui-RangeSlider-track-filled-#{$theme}-bg);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Thumb
|
|
66
|
+
&::-webkit-slider-thumb {
|
|
67
|
+
background: var(--dodo-ui-RangeSlider-thumb-#{$theme}-bg);
|
|
68
|
+
|
|
69
|
+
&:hover {
|
|
70
|
+
background: var(--dodo-ui-RangeSlider-thumb-#{$theme}-hover-bg);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
&:active {
|
|
74
|
+
background: var(--dodo-ui-RangeSlider-thumb-#{$theme}-active-bg);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
&::-moz-range-thumb {
|
|
79
|
+
background: var(--dodo-ui-RangeSlider-thumb-#{$theme}-bg);
|
|
80
|
+
|
|
81
|
+
&:hover {
|
|
82
|
+
background: var(--dodo-ui-RangeSlider-thumb-#{$theme}-hover-bg);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
&:active {
|
|
86
|
+
background: var(--dodo-ui-RangeSlider-thumb-#{$theme}-active-bg);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export function drag(node) {
|
|
2
|
+
let dragging = false;
|
|
3
|
+
function getX(e) {
|
|
4
|
+
return 'touches' in e ? e.touches[0].clientX : e.clientX;
|
|
5
|
+
}
|
|
6
|
+
function handleStart(e) {
|
|
7
|
+
dragging = true;
|
|
8
|
+
const x = getX(e);
|
|
9
|
+
node.dispatchEvent(new CustomEvent('dragstart', { detail: { x } }));
|
|
10
|
+
window.addEventListener('mousemove', handleMove);
|
|
11
|
+
window.addEventListener('mouseup', handleEnd);
|
|
12
|
+
window.addEventListener('touchmove', handleMove);
|
|
13
|
+
window.addEventListener('touchend', handleEnd);
|
|
14
|
+
}
|
|
15
|
+
function handleMove(e) {
|
|
16
|
+
if (!dragging)
|
|
17
|
+
return;
|
|
18
|
+
const x = getX(e);
|
|
19
|
+
node.dispatchEvent(new CustomEvent('dragging', { detail: { x } }));
|
|
20
|
+
}
|
|
21
|
+
function handleEnd(e) {
|
|
22
|
+
if (!dragging)
|
|
23
|
+
return;
|
|
24
|
+
dragging = false;
|
|
25
|
+
const x = getX(e);
|
|
26
|
+
node.dispatchEvent(new CustomEvent('dragend', { detail: { x } }));
|
|
27
|
+
window.removeEventListener('mousemove', handleMove);
|
|
28
|
+
window.removeEventListener('mouseup', handleEnd);
|
|
29
|
+
window.removeEventListener('touchmove', handleMove);
|
|
30
|
+
window.removeEventListener('touchend', handleEnd);
|
|
31
|
+
}
|
|
32
|
+
node.addEventListener('mousedown', handleStart);
|
|
33
|
+
node.addEventListener('touchstart', handleStart, { passive: true });
|
|
34
|
+
return {
|
|
35
|
+
destroy() {
|
|
36
|
+
node.removeEventListener('mousedown', handleStart);
|
|
37
|
+
node.removeEventListener('touchstart', handleStart);
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
}
|
|
@@ -4,6 +4,11 @@
|
|
|
4
4
|
--dodo-ui-element-height-normal: 40px;
|
|
5
5
|
--dodo-ui-element-height-large: 50px;
|
|
6
6
|
|
|
7
|
+
/* Size Thin elements */
|
|
8
|
+
--dodo-ui-track-element-height-small: 6px;
|
|
9
|
+
--dodo-ui-track-element-height-normal: 8px;
|
|
10
|
+
--dodo-ui-track-element-height-large: 10px;
|
|
11
|
+
|
|
7
12
|
/* Roundness */
|
|
8
13
|
--dodo-ui-element-roundness-1: 0.4375em;
|
|
9
14
|
--dodo-ui-element-roundness-2: 0.8125em;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flightlesslabs/dodo-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.1",
|
|
4
4
|
"homepage": "https://flightlesslabs.github.io/dodo-ui",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -38,10 +38,10 @@
|
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@chromatic-com/storybook": "4.0.0",
|
|
40
40
|
"@eslint/compat": "^1.3.0",
|
|
41
|
-
"@eslint/js": "^9.
|
|
41
|
+
"@eslint/js": "^9.29.0",
|
|
42
42
|
"@storybook/addon-svelte-csf": "5.0.3",
|
|
43
|
-
"@storybook/svelte": "^9.0.
|
|
44
|
-
"@storybook/sveltekit": "^9.0.
|
|
43
|
+
"@storybook/svelte": "^9.0.10",
|
|
44
|
+
"@storybook/sveltekit": "^9.0.10",
|
|
45
45
|
"@sveltejs/adapter-static": "^3.0.8",
|
|
46
46
|
"@sveltejs/kit": "^2.21.5",
|
|
47
47
|
"@sveltejs/package": "^2.3.11",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"@vitest/browser": "^3.2.3",
|
|
50
50
|
"@vitest/coverage-v8": "^3.2.3",
|
|
51
51
|
"@vueless/storybook-dark-mode": "^9.0.5",
|
|
52
|
-
"eslint": "^9.
|
|
52
|
+
"eslint": "^9.29.0",
|
|
53
53
|
"eslint-config-prettier": "^10.1.5",
|
|
54
54
|
"eslint-plugin-svelte": "^3.9.2",
|
|
55
55
|
"globals": "^16.2.0",
|
|
@@ -58,26 +58,26 @@
|
|
|
58
58
|
"prettier-plugin-svelte": "^3.4.0",
|
|
59
59
|
"publint": "^0.3.12",
|
|
60
60
|
"sass": "^1.89.2",
|
|
61
|
-
"storybook": "^9.0.
|
|
62
|
-
"svelte": "^5.34.
|
|
61
|
+
"storybook": "^9.0.10",
|
|
62
|
+
"svelte": "^5.34.3",
|
|
63
63
|
"svelte-check": "^4.2.1",
|
|
64
64
|
"svelte-preprocess": "^6.0.3",
|
|
65
65
|
"typescript": "^5.8.3",
|
|
66
66
|
"typescript-eslint": "^8.34.0",
|
|
67
67
|
"vite": "^6.3.5",
|
|
68
|
-
"vitest": "^3.2.3"
|
|
68
|
+
"vitest": "^3.2.3",
|
|
69
|
+
"@storybook/addon-docs": "^9.0.10",
|
|
70
|
+
"@storybook/addon-vitest": "^9.0.10"
|
|
69
71
|
},
|
|
70
72
|
"keywords": [
|
|
71
73
|
"svelte"
|
|
72
74
|
],
|
|
73
75
|
"volta": {
|
|
74
76
|
"node": "22.15.1",
|
|
75
|
-
"pnpm": "10.
|
|
77
|
+
"pnpm": "10.12.1"
|
|
76
78
|
},
|
|
77
79
|
"dependencies": {
|
|
78
80
|
"@iconify/svelte": "^5.0.0",
|
|
79
|
-
"@storybook/addon-docs": "^9.0.9",
|
|
80
|
-
"@storybook/addon-vitest": "^9.0.9",
|
|
81
81
|
"dayjs": "^1.11.13"
|
|
82
82
|
},
|
|
83
83
|
"scripts": {
|
package/src/lib/index.ts
CHANGED
|
@@ -122,6 +122,10 @@ export type {
|
|
|
122
122
|
DatePickerCalendarIconPosition,
|
|
123
123
|
} from '$lib/stories/components/Form/DatePicker/DatePicker.svelte';
|
|
124
124
|
|
|
125
|
+
/** Form: RangeSlider */
|
|
126
|
+
export { default as RangeSlider } from '$lib/stories/components/Form/RangeSlider/RangeSlider.svelte';
|
|
127
|
+
export type { RangeSliderProps } from '$lib/stories/components/Form/RangeSlider/RangeSlider.svelte';
|
|
128
|
+
|
|
125
129
|
/** Layout: Paper */
|
|
126
130
|
export { default as Paper } from '$lib/stories/components/Layout/Paper/Paper.svelte';
|
|
127
131
|
export type { PaperColor, PaperProps } from '$lib/stories/components/Layout/Paper/Paper.svelte';
|
|
@@ -41,9 +41,9 @@
|
|
|
41
41
|
#fff
|
|
42
42
|
);
|
|
43
43
|
|
|
44
|
-
--dodo-ui-Button-solid-#{$color-name}-bg: var(--dodo-color-#{$color-name}-
|
|
45
|
-
--dodo-ui-Button-solid-#{$color-name}-hover-bg: var(--dodo-color-#{$color-name}-
|
|
46
|
-
--dodo-ui-Button-solid-#{$color-name}-active-bg: var(--dodo-color-#{$color-name}-
|
|
44
|
+
--dodo-ui-Button-solid-#{$color-name}-bg: var(--dodo-color-#{$color-name}-400);
|
|
45
|
+
--dodo-ui-Button-solid-#{$color-name}-hover-bg: var(--dodo-color-#{$color-name}-300);
|
|
46
|
+
--dodo-ui-Button-solid-#{$color-name}-active-bg: var(--dodo-color-#{$color-name}-200);
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
/// Mixin: generate-dodo-ui-button-color
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<script module>
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import NumericInput from '../NumericInput.svelte';
|
|
4
|
+
import { storyNumericInputArgTypes } from '../NumericInput.stories.svelte';
|
|
5
|
+
|
|
6
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
7
|
+
const { Story } = defineMeta({
|
|
8
|
+
component: NumericInput,
|
|
9
|
+
tags: ['autodocs'],
|
|
10
|
+
argTypes: storyNumericInputArgTypes,
|
|
11
|
+
});
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<Story name="Roundness 1" />
|
|
15
|
+
|
|
16
|
+
<Story name="Roundness 2" args={{ roundness: 2 }} />
|
|
17
|
+
|
|
18
|
+
<Story name="Roundness 3" args={{ roundness: 3 }} />
|
|
19
|
+
|
|
20
|
+
<Story name="Roundness 0" args={{ roundness: 0 }} />
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<script module>
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import NumericInput from '../NumericInput.svelte';
|
|
4
|
+
import { storyNumericInputArgTypes } from '../NumericInput.stories.svelte';
|
|
5
|
+
|
|
6
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
7
|
+
const { Story } = defineMeta({
|
|
8
|
+
component: NumericInput,
|
|
9
|
+
tags: ['autodocs'],
|
|
10
|
+
argTypes: storyNumericInputArgTypes,
|
|
11
|
+
});
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<Story name="Normal" />
|
|
15
|
+
<Story name="Small" args={{ size: 'small' }} />
|
|
16
|
+
<Story name="Large" args={{ size: 'large' }} />
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<script module>
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import NumericInput from '../NumericInput.svelte';
|
|
4
|
+
import { storyNumericInputArgTypes } from '../NumericInput.stories.svelte';
|
|
5
|
+
import Icon from '@iconify/svelte';
|
|
6
|
+
|
|
7
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
8
|
+
const { Story } = defineMeta({
|
|
9
|
+
component: NumericInput,
|
|
10
|
+
tags: ['autodocs'],
|
|
11
|
+
argTypes: storyNumericInputArgTypes,
|
|
12
|
+
});
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<!-- NumericInput icon in front. -->
|
|
16
|
+
<Story name="Icon Before" asChild>
|
|
17
|
+
<NumericInput>
|
|
18
|
+
{#snippet before()}
|
|
19
|
+
<Icon icon="material-symbols:content-copy" />
|
|
20
|
+
{/snippet}
|
|
21
|
+
</NumericInput>
|
|
22
|
+
</Story>
|
|
23
|
+
|
|
24
|
+
<!-- NumericInput icon in front. -->
|
|
25
|
+
<Story name="Icon After" asChild>
|
|
26
|
+
<NumericInput>
|
|
27
|
+
{#snippet after()}
|
|
28
|
+
<Icon icon="material-symbols:download-2" />
|
|
29
|
+
{/snippet}
|
|
30
|
+
</NumericInput>
|
|
31
|
+
</Story>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<script module>
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import RangeSlider from '../RangeSlider.svelte';
|
|
4
|
+
import { storyRangeSliderArgTypes } from '../RangeSlider.stories.svelte';
|
|
5
|
+
|
|
6
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
7
|
+
const { Story } = defineMeta({
|
|
8
|
+
component: RangeSlider,
|
|
9
|
+
tags: ['autodocs'],
|
|
10
|
+
argTypes: storyRangeSliderArgTypes,
|
|
11
|
+
});
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<Story name="Primary" />
|
|
15
|
+
<Story name="Secondary" args={{ color: 'secondary' }} />
|
|
16
|
+
<Story name="Neutral" args={{ color: 'neutral' }} />
|
|
17
|
+
<Story name="Safe" args={{ color: 'safe' }} />
|
|
18
|
+
<Story name="Warning" args={{ color: 'warning' }} />
|
|
19
|
+
<Story name="Danger" args={{ color: 'danger' }} />
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import { storyRangeSliderArgTypes } from '../RangeSlider.stories.svelte';
|
|
4
|
+
import RangeSlider from '../RangeSlider.svelte';
|
|
5
|
+
import type { TextInputFocusEvent } from '../../TextInput/TextInput.svelte';
|
|
6
|
+
|
|
7
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
8
|
+
const { Story } = defineMeta({
|
|
9
|
+
component: RangeSlider,
|
|
10
|
+
tags: ['autodocs'],
|
|
11
|
+
argTypes: storyRangeSliderArgTypes,
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
let value = $state<number>(0);
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<Story
|
|
18
|
+
name="Input"
|
|
19
|
+
args={{
|
|
20
|
+
value,
|
|
21
|
+
oninput: (e: Event) => {
|
|
22
|
+
const target = e.target as HTMLInputElement;
|
|
23
|
+
|
|
24
|
+
console.log('Input Event', target.value);
|
|
25
|
+
},
|
|
26
|
+
}}
|
|
27
|
+
/>
|
|
28
|
+
|
|
29
|
+
<Story
|
|
30
|
+
name="Change"
|
|
31
|
+
args={{
|
|
32
|
+
value,
|
|
33
|
+
onchange: (e: Event) => {
|
|
34
|
+
const target = e.target as HTMLInputElement;
|
|
35
|
+
|
|
36
|
+
console.log('onChange Event', target.value);
|
|
37
|
+
},
|
|
38
|
+
}}
|
|
39
|
+
/>
|
|
40
|
+
|
|
41
|
+
<Story
|
|
42
|
+
name="Focus"
|
|
43
|
+
args={{
|
|
44
|
+
value,
|
|
45
|
+
onfocus: (e: TextInputFocusEvent) => {
|
|
46
|
+
const target = e.target as HTMLInputElement;
|
|
47
|
+
|
|
48
|
+
console.log('onfocus Event', target);
|
|
49
|
+
},
|
|
50
|
+
}}
|
|
51
|
+
/>
|
|
52
|
+
|
|
53
|
+
<Story
|
|
54
|
+
name="Blur"
|
|
55
|
+
args={{
|
|
56
|
+
value,
|
|
57
|
+
onblur: (e: TextInputFocusEvent) => {
|
|
58
|
+
const target = e.target as HTMLInputElement;
|
|
59
|
+
|
|
60
|
+
console.log('onblur Event', target);
|
|
61
|
+
},
|
|
62
|
+
}}
|
|
63
|
+
/>
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import RangeSlider from './RangeSlider.svelte';
|
|
4
|
+
import type { StoryBookArgTypes } from '$lib/storybook-types.js';
|
|
5
|
+
import { componentRoundnessArray } from '$lib/types/roundness.js';
|
|
6
|
+
import { componentSizeArray } from '$lib/types/size.js';
|
|
7
|
+
import { componentColorArray } from '$lib/types/colors.js';
|
|
8
|
+
|
|
9
|
+
export const storyRangeSliderArgTypes: StoryBookArgTypes = {
|
|
10
|
+
color: {
|
|
11
|
+
control: { type: 'select' },
|
|
12
|
+
options: componentColorArray,
|
|
13
|
+
},
|
|
14
|
+
roundness: {
|
|
15
|
+
control: { type: 'select' },
|
|
16
|
+
options: componentRoundnessArray,
|
|
17
|
+
},
|
|
18
|
+
thumbRoundness: {
|
|
19
|
+
control: { type: 'select' },
|
|
20
|
+
options: componentRoundnessArray,
|
|
21
|
+
},
|
|
22
|
+
size: {
|
|
23
|
+
control: { type: 'select' },
|
|
24
|
+
options: componentSizeArray,
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
29
|
+
const { Story } = defineMeta({
|
|
30
|
+
component: RangeSlider,
|
|
31
|
+
tags: ['autodocs'],
|
|
32
|
+
argTypes: storyRangeSliderArgTypes,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
let value = $state<number>(30);
|
|
36
|
+
</script>
|
|
37
|
+
|
|
38
|
+
<!-- RangeSlider with default style -->
|
|
39
|
+
<Story
|
|
40
|
+
name="Default"
|
|
41
|
+
args={{
|
|
42
|
+
value,
|
|
43
|
+
}}
|
|
44
|
+
/>
|
|
45
|
+
|
|
46
|
+
<Story
|
|
47
|
+
name="Step"
|
|
48
|
+
args={{
|
|
49
|
+
value,
|
|
50
|
+
step: 10,
|
|
51
|
+
}}
|
|
52
|
+
/>
|
|
53
|
+
|
|
54
|
+
<Story
|
|
55
|
+
name="MinMax"
|
|
56
|
+
args={{
|
|
57
|
+
value,
|
|
58
|
+
min: 0,
|
|
59
|
+
max: 1500,
|
|
60
|
+
}}
|
|
61
|
+
/>
|
|
62
|
+
|
|
63
|
+
<Story
|
|
64
|
+
name="Disabled"
|
|
65
|
+
args={{
|
|
66
|
+
value: 30,
|
|
67
|
+
disabled: true,
|
|
68
|
+
}}
|
|
69
|
+
/>
|