@flightlesslabs/dodo-ui 0.21.0 → 0.22.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 (35) hide show
  1. package/dist/components/Layout/Card/Card.svelte +1 -1
  2. package/dist/components/Layout/Card/Card.svelte.d.ts +1 -1
  3. package/dist/components/Layout/Grid/Column/Column.scss +78 -0
  4. package/dist/components/Layout/Grid/Column/Column.stories.svelte +66 -0
  5. package/dist/components/Layout/Grid/Column/Column.stories.svelte.d.ts +22 -0
  6. package/dist/components/Layout/Grid/Column/Column.svelte +79 -0
  7. package/dist/components/Layout/Grid/Column/Column.svelte.d.ts +33 -0
  8. package/dist/components/Layout/Grid/Grid.scss +8 -0
  9. package/dist/components/Layout/Grid/Grid.stories.svelte +177 -0
  10. package/dist/components/Layout/Grid/Grid.stories.svelte.d.ts +22 -0
  11. package/dist/components/Layout/Grid/Grid.svelte +32 -0
  12. package/dist/components/Layout/Grid/Grid.svelte.d.ts +12 -0
  13. package/dist/components/Layout/Grid/Row/Row.scss +7 -0
  14. package/dist/components/Layout/Grid/Row/Row.stories.svelte +39 -0
  15. package/dist/components/Layout/Grid/Row/Row.stories.svelte.d.ts +22 -0
  16. package/dist/components/Layout/Grid/Row/Row.svelte +21 -0
  17. package/dist/components/Layout/Grid/Row/Row.svelte.d.ts +10 -0
  18. package/dist/index.d.ts +6 -0
  19. package/dist/index.js +6 -0
  20. package/dist/styles/components.css +455 -0
  21. package/dist/styles/components.css.map +1 -1
  22. package/dist/styles/components.scss +3 -0
  23. package/package.json +1 -1
  24. package/src/lib/components/Layout/Card/Card.svelte +1 -1
  25. package/src/lib/components/Layout/Grid/Column/Column.scss +78 -0
  26. package/src/lib/components/Layout/Grid/Column/Column.stories.svelte +66 -0
  27. package/src/lib/components/Layout/Grid/Column/Column.svelte +79 -0
  28. package/src/lib/components/Layout/Grid/Grid.scss +8 -0
  29. package/src/lib/components/Layout/Grid/Grid.stories.svelte +177 -0
  30. package/src/lib/components/Layout/Grid/Grid.svelte +32 -0
  31. package/src/lib/components/Layout/Grid/Row/Row.scss +7 -0
  32. package/src/lib/components/Layout/Grid/Row/Row.stories.svelte +39 -0
  33. package/src/lib/components/Layout/Grid/Row/Row.svelte +21 -0
  34. package/src/lib/index.ts +17 -0
  35. package/src/lib/styles/components.scss +3 -0
@@ -0,0 +1,79 @@
1
+ <script lang="ts" module>
2
+ import type { Snippet } from 'svelte';
3
+
4
+ export const GRID_COLUMN_BREAKPOINT = {
5
+ numerical: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
6
+ flex: ['flex'],
7
+ } as const;
8
+
9
+ export type GridColumnSizeNumerical = (typeof GRID_COLUMN_BREAKPOINT.numerical)[number];
10
+ type GridColumnSizeFlex = (typeof GRID_COLUMN_BREAKPOINT.flex)[number];
11
+ export type GridColumnSize = GridColumnSizeNumerical | GridColumnSizeFlex;
12
+
13
+ export const gridColumnSizeOptions = [
14
+ ...GRID_COLUMN_BREAKPOINT.numerical,
15
+ ...GRID_COLUMN_BREAKPOINT.flex,
16
+ ] as const satisfies readonly GridColumnSize[];
17
+
18
+ export const gridColumnSizeNumericalOptions = GRID_COLUMN_BREAKPOINT.numerical;
19
+
20
+ export interface GridColumnProps {
21
+ /** Custom CSS class names */
22
+ class?: string;
23
+
24
+ /** Column contents go here */
25
+ children?: Snippet;
26
+
27
+ /** GridColumn ref */
28
+ ref?: HTMLDivElement | null;
29
+
30
+ /** Breakpoint: size (default unit) */
31
+ size?: GridColumnSize;
32
+
33
+ /** Breakpoint: sm */
34
+ sm?: GridColumnSize;
35
+
36
+ /** Breakpoint: md */
37
+ md?: GridColumnSize;
38
+
39
+ /** Breakpoint: lg */
40
+ lg?: GridColumnSize;
41
+
42
+ /** Breakpoint: xl */
43
+ xl?: GridColumnSize;
44
+
45
+ /** Breakpoint: xxl */
46
+ xxl?: GridColumnSize;
47
+ }
48
+ </script>
49
+
50
+ <script lang="ts">
51
+ let {
52
+ class: className = '',
53
+ ref = $bindable(null),
54
+ children,
55
+ size = 12,
56
+ sm,
57
+ md,
58
+ lg,
59
+ xl,
60
+ xxl,
61
+ }: GridColumnProps = $props();
62
+
63
+ const classes = $derived(
64
+ [
65
+ 'dodo-ui-Grid-Column',
66
+ `column-size--default--${size}`,
67
+ sm ? `column-size--sm--${sm}` : '',
68
+ md ? `column-size--md--${md}` : '',
69
+ lg ? `column-size--lg--${lg}` : '',
70
+ xl ? `column-size--xl--${xl}` : '',
71
+ xxl ? `column-size--xxl--${xxl}` : '',
72
+ className,
73
+ ].filter(Boolean),
74
+ );
75
+ </script>
76
+
77
+ <div class={classes.join(' ')} bind:this={ref}>
78
+ {@render children?.()}
79
+ </div>
@@ -0,0 +1,8 @@
1
+ // Grid
2
+
3
+ .dodo-ui-Grid {
4
+ display: flex;
5
+ width: 100%;
6
+ flex-wrap: wrap;
7
+ margin: calc(calc(var(--dodo-ui-space) * var(--Grid-gap)) * -1);
8
+ }
@@ -0,0 +1,177 @@
1
+ <script module lang="ts">
2
+ import { defineMeta } from '@storybook/addon-svelte-csf';
3
+ import Grid from './Grid.svelte';
4
+ import type { GridProps } from './Grid.svelte';
5
+ import type { ArgTypes } from 'storybook/internal/csf';
6
+ import Column from './Column/Column.svelte';
7
+ import Card from '../Card/Card.svelte';
8
+ import Row from './Row/Row.svelte';
9
+
10
+ // ------------------------------
11
+ // Storybook ArgTypes
12
+ // ------------------------------
13
+ export const storyGridArgTypes: Partial<ArgTypes<GridProps>> = {
14
+ // ------------------------------
15
+ // Core
16
+ // ------------------------------
17
+ children: { table: { category: 'API', subcategory: 'Base' } },
18
+ class: { table: { category: 'API', subcategory: 'Base' } },
19
+ gap: { table: { category: 'API', subcategory: 'Base', defaultValue: { summary: '1' } } },
20
+ };
21
+
22
+ // ------------------------------
23
+ // Storybook Meta
24
+ // ------------------------------
25
+ const { Story } = defineMeta({
26
+ component: Grid,
27
+ tags: ['autodocs'],
28
+ argTypes: storyGridArgTypes,
29
+ });
30
+ </script>
31
+
32
+ <!-- ------------------------------ -->
33
+ <!-- Stories -->
34
+ <!-- ------------------------------ -->
35
+
36
+ <!-- Basic 12 column grid -->
37
+ <Story name="Default">
38
+ <Column sm={4}>Hello there</Column>
39
+ <Column sm={4}>Hello there</Column>
40
+ <Column sm={4}>Hello there</Column>
41
+ <Column sm={4}>Hello there</Column>
42
+ <Column sm={4}>Hello there</Column>
43
+ </Story>
44
+
45
+ <Story name="Example">
46
+ <Column sm={4}>
47
+ <Card color="primary">
48
+ <p>Hello there</p>
49
+ </Card>
50
+ </Column>
51
+ <Column sm={4}>
52
+ <Card color="primary">
53
+ <p>Hello there</p>
54
+ </Card>
55
+ </Column>
56
+ <Column sm={4}>
57
+ <Card color="primary">
58
+ <p>Hello there</p>
59
+ </Card>
60
+ </Column>
61
+ <Column sm={4}>
62
+ <Card color="primary">
63
+ <p>Hello there</p>
64
+ </Card>
65
+ </Column>
66
+ </Story>
67
+
68
+ <Story name="Grid Row">
69
+ <Row>
70
+ <Column sm={6} md={4} lg={3}>
71
+ <Card color="primary">
72
+ <p>Hello there</p>
73
+ </Card>
74
+ </Column>
75
+ <Column sm={6} md={4} lg={3}>
76
+ <Card color="primary">
77
+ <p>Hello there</p>
78
+ </Card>
79
+ </Column>
80
+ <Column sm={6} md={4} lg={3}>
81
+ <Card color="primary">
82
+ <p>Hello there</p>
83
+ </Card>
84
+ </Column>
85
+ </Row>
86
+ <Row>
87
+ <Column sm={6} md={4} lg={3}>
88
+ <Card color="primary">
89
+ <p>Hello there</p>
90
+ </Card>
91
+ </Column>
92
+ <Column sm={6} md={4} lg={3}>
93
+ <Card color="primary">
94
+ <p>Hello there</p>
95
+ </Card>
96
+ </Column>
97
+ <Column sm={6} md={4} lg={3}>
98
+ <Card color="primary">
99
+ <p>Hello there</p>
100
+ </Card>
101
+ </Column>
102
+ </Row>
103
+ </Story>
104
+
105
+ <Story name="Gap" args={{ gap: 2 }}>
106
+ <Column sm={4}>
107
+ <Card color="primary">
108
+ <p>Hello there</p>
109
+ </Card>
110
+ </Column>
111
+ <Column sm={4}>
112
+ <Card color="primary">
113
+ <p>Hello there</p>
114
+ </Card>
115
+ </Column>
116
+ <Column sm={4}>
117
+ <Card color="primary">
118
+ <p>Hello there</p>
119
+ </Card>
120
+ </Column>
121
+ <Column sm={4}>
122
+ <Card color="primary">
123
+ <p>Hello there</p>
124
+ </Card>
125
+ </Column>
126
+ </Story>
127
+
128
+ <Story name="Responsive">
129
+ <Column sm={6} md={4} lg={3}>
130
+ <Card color="primary">
131
+ <p>Hello there</p>
132
+ </Card>
133
+ </Column>
134
+ <Column sm={6} md={4} lg={3}>
135
+ <Card color="primary">
136
+ <p>Hello there</p>
137
+ </Card>
138
+ </Column>
139
+ <Column sm={6} md={4} lg={3}>
140
+ <Card color="primary">
141
+ <p>Hello there</p>
142
+ </Card>
143
+ </Column>
144
+ <Column sm={6} md={4} lg={3}>
145
+ <Card color="primary">
146
+ <p>Hello there</p>
147
+ </Card>
148
+ </Column>
149
+ <Column sm={6} md={4} lg={3}>
150
+ <Card color="primary">
151
+ <p>Hello there</p>
152
+ </Card>
153
+ </Column>
154
+ <Column sm={6} md={4} lg={3}>
155
+ <Card color="primary">
156
+ <p>Hello there</p>
157
+ </Card>
158
+ </Column>
159
+ </Story>
160
+
161
+ <Story name="Flex">
162
+ <Column md="flex">
163
+ <Card color="primary">
164
+ <p>Hello there</p>
165
+ </Card>
166
+ </Column>
167
+ <Column md={2}>
168
+ <Card color="primary">
169
+ <p>Hello there</p>
170
+ </Card>
171
+ </Column>
172
+ <Column md={2}>
173
+ <Card color="primary">
174
+ <p>Hello there</p>
175
+ </Card>
176
+ </Column>
177
+ </Story>
@@ -0,0 +1,32 @@
1
+ <script lang="ts" module>
2
+ import type { Snippet } from 'svelte';
3
+
4
+ export interface GridProps {
5
+ /** Custom CSS class names */
6
+ class?: string;
7
+
8
+ /** Grid contents go here*/
9
+ children?: Snippet;
10
+
11
+ /** Grid spacing, affects Coulumns */
12
+ gap?: number;
13
+ }
14
+ </script>
15
+
16
+ <script lang="ts">
17
+ let { class: className = '', gap = 1, children }: GridProps = $props();
18
+
19
+ function normalizeGap(value: number) {
20
+ return value === 0 ? 0 : value / 2;
21
+ }
22
+
23
+ const gapHalf = $derived(normalizeGap(gap));
24
+
25
+ const classes = $derived(['dodo-ui-Grid', className].filter(Boolean));
26
+
27
+ const inlineStyles = $derived([`--Grid-gap: ${gapHalf}`].filter(Boolean));
28
+ </script>
29
+
30
+ <div class={classes.join(' ')} style={inlineStyles.join(';')}>
31
+ {@render children?.()}
32
+ </div>
@@ -0,0 +1,7 @@
1
+ // Grid-Row
2
+
3
+ .dodo-ui-Grid-Row {
4
+ display: flex;
5
+ width: 100%;
6
+ flex-wrap: wrap;
7
+ }
@@ -0,0 +1,39 @@
1
+ <script module lang="ts">
2
+ import { defineMeta } from '@storybook/addon-svelte-csf';
3
+ import Row from './Row.svelte';
4
+ import type { GridRowProps } from './Row.svelte';
5
+ import type { ArgTypes } from 'storybook/internal/csf';
6
+ import Column from '../Column/Column.svelte';
7
+
8
+ // ------------------------------
9
+ // Storybook ArgTypes
10
+ // ------------------------------
11
+ export const storyRowArgTypes: Partial<ArgTypes<GridRowProps>> = {
12
+ // ------------------------------
13
+ // Core
14
+ // ------------------------------
15
+ children: { table: { category: 'API', subcategory: 'Base' } },
16
+ class: { table: { category: 'API', subcategory: 'Base' } },
17
+ };
18
+
19
+ // ------------------------------
20
+ // Storybook Meta
21
+ // ------------------------------
22
+ const { Story } = defineMeta({
23
+ component: Row,
24
+ tags: ['autodocs'],
25
+ argTypes: storyRowArgTypes,
26
+ });
27
+ </script>
28
+
29
+ <!-- ------------------------------ -->
30
+ <!-- Stories -->
31
+ <!-- ------------------------------ -->
32
+
33
+ <Story name="Default">
34
+ <Column sm={4}>Hello there</Column>
35
+ <Column sm={4}>Hello there</Column>
36
+ <Column sm={4}>Hello there</Column>
37
+ <Column sm={4}>Hello there</Column>
38
+ <Column sm={4}>Hello there</Column>
39
+ </Story>
@@ -0,0 +1,21 @@
1
+ <script lang="ts" module>
2
+ import type { Snippet } from 'svelte';
3
+
4
+ export interface GridRowProps {
5
+ /** Custom CSS class names */
6
+ class?: string;
7
+
8
+ /** GridRow contents go here*/
9
+ children?: Snippet;
10
+ }
11
+ </script>
12
+
13
+ <script lang="ts">
14
+ let { class: className = '', children }: GridRowProps = $props();
15
+
16
+ const classes = $derived(['dodo-ui-Grid-Row', className].filter(Boolean));
17
+ </script>
18
+
19
+ <div class={classes.join(' ')}>
20
+ {@render children?.()}
21
+ </div>
package/src/lib/index.ts CHANGED
@@ -120,6 +120,23 @@ export {
120
120
  type CardProps,
121
121
  } from './components/Layout/Card/Card.svelte';
122
122
 
123
+ /**
124
+ * Grid component and related prop types.
125
+ */
126
+ export { default as Grid, type GridProps } from './components/Layout/Grid/Grid.svelte';
127
+
128
+ export {
129
+ GRID_COLUMN_BREAKPOINT,
130
+ default as Column,
131
+ gridColumnSizeOptions,
132
+ gridColumnSizeNumericalOptions,
133
+ type GridColumnProps,
134
+ type GridColumnSizeNumerical,
135
+ type GridColumnSize,
136
+ } from './components/Layout/Grid/Column/Column.svelte';
137
+
138
+ export { default as Row, type GridRowProps } from './components/Layout/Grid/Row/Row.svelte';
139
+
123
140
  // =====================================================
124
141
  // Info Components – Public API
125
142
  // =====================================================
@@ -12,3 +12,6 @@
12
12
  @use '../components/Form/Switch/Switch.scss';
13
13
  @use '../components/Form/Select/Select.scss';
14
14
  @use '../components/Form/DatePicker/DatePicker.scss';
15
+ @use '../components/Layout/Grid/Grid.scss';
16
+ @use '../components/Layout/Grid/Column/Column.scss';
17
+ @use '../components/Layout/Grid/Row/Row.scss';