@hkdigital/lib-sveltekit 0.1.5 → 0.1.7

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.
@@ -26,6 +26,7 @@
26
26
  base,
27
27
  bg,
28
28
  classes,
29
+
29
30
  type = '',
30
31
  role = 'primary',
31
32
  size = 'md',
@@ -0,0 +1,30 @@
1
+ <script>
2
+ import Button from '../button/Button.svelte';
3
+
4
+ import { SteezeIcon } from '../../icons/index.js';
5
+
6
+ /**
7
+ * @type {{
8
+ * src: import('../../icons/typedef.js').IconSource,
9
+ * size?: string,
10
+ * subset?: string,
11
+ * [key: string]: any
12
+ * }}
13
+ */
14
+ const {
15
+ // Icon
16
+ src,
17
+ iconSize,
18
+ subset,
19
+
20
+ // Snippets
21
+ children,
22
+
23
+ // Attributes
24
+ ...attrs
25
+ } = $props();
26
+ </script>
27
+
28
+ <Button type="icon-steeze" {...attrs}>
29
+ <SteezeIcon {src} size={iconSize} {subset} />
30
+ </Button>
@@ -0,0 +1,16 @@
1
+ export default SteezeIconButton;
2
+ type SteezeIconButton = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<{
5
+ [key: string]: any;
6
+ src: IconSource;
7
+ size?: string;
8
+ subset?: string;
9
+ }>): void;
10
+ };
11
+ declare const SteezeIconButton: import("svelte").Component<{
12
+ [key: string]: any;
13
+ src: import("../../icons/typedef.js").IconSource;
14
+ size?: string;
15
+ subset?: string;
16
+ }, {}, "">;
@@ -1,2 +1,3 @@
1
1
  export { default as Button } from "./button/Button.svelte";
2
2
  export { default as TextButton } from "./button-text/TextButton.svelte";
3
+ export { default as SteezeIconButton } from "./button-icon-steeze/SteezeIconButton.svelte";
@@ -1,2 +1,3 @@
1
1
  export { default as Button } from './button/Button.svelte';
2
2
  export { default as TextButton } from './button-text/TextButton.svelte';
3
+ export { default as SteezeIconButton } from './button-icon-steeze/SteezeIconButton.svelte';
@@ -0,0 +1,96 @@
1
+ <script>
2
+ /**
3
+ * Steeze like icon component
4
+ * The main difference with the original Steeze svelte component is that
5
+ * the component follows the conventions used for components in this library
6
+ *
7
+ * @see https://github.com/steeze-ui/icons
8
+ *
9
+ * Install icons
10
+ * For icon packs @see https://github.com/steeze-ui/icons
11
+ *
12
+ * @eg install Hero Icons
13
+ *
14
+ * pnpm add -D @steeze-ui/heroicons
15
+ */
16
+
17
+ /**
18
+ * Properties
19
+ * ----------
20
+ * src - icon component
21
+ * size - width and height of the icon as percentage (..%) or in pixels
22
+ * subset - name of the icon subset (e.g. 'solid' or 'outline')
23
+ *
24
+ * @type {{
25
+ * src: import('./typedef.js').IconSource,
26
+ * size?: string,
27
+ * subset?: string,
28
+ * base?: string,
29
+ * classes?: string
30
+ * } & { [attr: string]: any }}
31
+ */
32
+ let {
33
+ // Style
34
+ base,
35
+ classes,
36
+
37
+ size = 'md',
38
+ variant = '',
39
+
40
+ // Functional
41
+ src,
42
+ subset = 'default', // icon subset 'default'|'solid'|'outline'...
43
+
44
+ // States
45
+ // ...
46
+
47
+ // Attributes
48
+ ...attrs
49
+ } = $props();
50
+
51
+ /** @type {any} */
52
+ let icon = $state();
53
+
54
+ $effect(() => {
55
+ icon = src?.[subset] ?? src?.['default'] ?? Object.values(src)?.[0];
56
+ });
57
+
58
+ // if (size !== '100%') {
59
+ // if (size.slice(-1) !== '%') {
60
+ // try {
61
+ // size = parseInt(size, 10) + 'px';
62
+ // } catch (error) {
63
+ // size = '100%';
64
+ // }
65
+ // }
66
+ // }
67
+ </script>
68
+
69
+ <svg
70
+ data-component="icon"
71
+ data-type="steeze"
72
+ data-size={size}
73
+ {...icon?.a}
74
+ xmlns="http://www.w3.org/2000/svg"
75
+ class="{base} {classes}"
76
+ {...attrs}
77
+ >
78
+ {#each icon?.path ?? [] as a}
79
+ <path {...a} />
80
+ {/each}
81
+ {#each icon?.rect ?? [] as a}
82
+ <rect {...a} />
83
+ {/each}
84
+ {#each icon?.circle ?? [] as a}
85
+ <circle {...a} />
86
+ {/each}
87
+ {#each icon?.polygon ?? [] as a}
88
+ <polygon {...a} />
89
+ {/each}
90
+ {#each icon?.polyline ?? [] as a}
91
+ <polyline {...a} />
92
+ {/each}
93
+ {#each icon?.line ?? [] as a}
94
+ <line {...a} />
95
+ {/each}
96
+ </svg>
@@ -0,0 +1,22 @@
1
+ export default SteezeIcon;
2
+ type SteezeIcon = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<{
5
+ src: IconSource;
6
+ size?: string;
7
+ subset?: string;
8
+ base?: string;
9
+ classes?: string;
10
+ } & {
11
+ [attr: string]: any;
12
+ }>): void;
13
+ };
14
+ declare const SteezeIcon: import("svelte").Component<{
15
+ src: import("./typedef.js").IconSource;
16
+ size?: string;
17
+ subset?: string;
18
+ base?: string;
19
+ classes?: string;
20
+ } & {
21
+ [attr: string]: any;
22
+ }, {}, "">;
@@ -1,3 +1,4 @@
1
1
  export { default as HkIcon } from "./HkIcon.svelte";
2
2
  export { default as HkTabIcon } from "./HkTabIcon.svelte";
3
+ export { default as SteezeIcon } from "./SteezeIcon.svelte";
3
4
  export * from "./typedef.js";
@@ -1,4 +1,6 @@
1
1
  export { default as HkIcon } from './HkIcon.svelte';
2
2
  export { default as HkTabIcon } from './HkTabIcon.svelte';
3
3
 
4
+ export { default as SteezeIcon } from './SteezeIcon.svelte';
5
+
4
6
  export * from './typedef.js';
@@ -4,7 +4,7 @@
4
4
 
5
5
  import { Star, ExclamationTriangle, CheckCircle } from '@steeze-ui/heroicons';
6
6
 
7
- import { HkIcon } from '../../icon/index.js';
7
+ import { HkIcon } from '../../icons/index.js';
8
8
 
9
9
  import {
10
10
  PRISTINE,
@@ -1,5 +1,5 @@
1
1
  type Tab = {
2
- icon: import("../icon/typedef.js").IconSource;
2
+ icon: any;
3
3
  label?: string;
4
4
  route?: string;
5
5
  routePrefix?: string;
@@ -3,19 +3,28 @@
3
3
  * Using CSS Custom Properties (variables) for consistent scaling
4
4
  *
5
5
  * @note
6
- * Make sure to import scaling.vars.postcss in your application.
7
- * It contains CSS variables used by the Tailwind theme extensions defined
8
- * below
6
+ * The tailwind theme extensions require CSS custom
7
+ * properties (variables) to be set at the root level
8
+ * of your application to function properly.
9
9
  *
10
+ * @example Implementation in SvelteKit +layout.svelte
11
+ * <script>
12
+ * import { onMount } from 'svelte';
10
13
  *
14
+ * import '../app.postcss';
11
15
  *
12
- * FIXME>>>
16
+ * let { children } = $props();
13
17
  *
14
- * e.g. in your app.postcss:
18
+ * import { DESIGN, CLAMPING }
19
+ * from './design-config.js';
15
20
  *
16
- * // @import "../src/lib/tailwind/extend/scaling/vars.postcss";
21
+ * import { rootDesignVarsHTML }
22
+ * from '@hkdigital/lib-sveltekit/util/design-system/index.js';
23
+ * </script>
17
24
  *
18
- * <<<FIXME
25
+ * <svelte:head>
26
+ * {@html rootDesignVarsHTML(DESIGN, CLAMPING)}
27
+ * </svelte:head>
19
28
  *
20
29
  * Base units:
21
30
  * --scale-w: 0.052vw (Viewport Width Point)
@@ -0,0 +1,22 @@
1
+ @define-mixin component-button-icon-steeze {
2
+
3
+ /* @note using CSS vars defined in the parent button postcss */
4
+
5
+ /* Type-based styling for text buttons */
6
+ [data-component="button"][data-type="icon-steeze"] {
7
+
8
+ /*&[data-size="sm"] {
9
+ @apply px-8ut py-8ut;
10
+ }
11
+
12
+ &[data-size="md"] {
13
+ @apply px-16ut py-12ut;
14
+ }
15
+
16
+ &[data-size="lg"] {
17
+ @apply px-32ut py-16ut;
18
+ }*/
19
+
20
+ }
21
+
22
+ }
@@ -0,0 +1,22 @@
1
+ @define-mixin component-icon-steeze {
2
+
3
+ /* @note using CSS vars defined in the parent button postcss */
4
+
5
+ /* Type-based styling for text buttons */
6
+ [data-component="icon"][data-type="steeze"] {
7
+
8
+ &[data-size="sm"] {
9
+ @apply w-16ct h-16ct;
10
+ }
11
+
12
+ &[data-size="md"] {
13
+ @apply w-28ct h-28ct;
14
+ }
15
+
16
+ &[data-size="lg"] {
17
+ @apply w-50ct h-50ct;
18
+ }
19
+
20
+ }
21
+
22
+ }
@@ -2,7 +2,6 @@
2
2
 
3
3
  /* Panels */
4
4
  /*@import "./components/panels/plain-panel.postcss";*/
5
- /*@import "./components/panels/speech-bubble.postcss";*/
6
5
 
7
6
  /* Rows */
8
7
  /*@import "./components/rows/panel-grid-row.postcss";*/
@@ -11,9 +10,13 @@
11
10
  /* Buttons */
12
11
  @import "./components/buttons/button.postcss";
13
12
  @import "./components/buttons/button-text.postcss";
13
+ @import "./components/buttons/button-icon-steeze.postcss";
14
14
 
15
15
  /*@import "./components/buttons/skip-button.postcss";*/
16
16
 
17
+ /* Icons */
18
+ @import "./components/icons/icon-steeze.postcss";
19
+
17
20
  /* Inputs */
18
21
  @import "./components/inputs/text-input.postcss";
19
22
 
@@ -41,8 +44,11 @@
41
44
  /* Buttons */
42
45
  @mixin component-button;
43
46
  @mixin component-button-text;
44
-
47
+ @mixin component-button-icon-steeze;
45
48
  /* @mixin buttons-skip-button;*/
49
+
50
+ @mixin component-icon-steeze;
51
+
46
52
  @mixin text_block;
47
53
 
48
54
  /* Inputs */
@@ -9,9 +9,9 @@ export function getClampParams(varName: string): any;
9
9
  /**
10
10
  * CSS clamp function implementation
11
11
  *
12
+ * @param {number} value - Value to clamp
12
13
  * @param {number} min - Minimum value
13
- * @param {number} val - Value to clamp
14
14
  * @param {number} max - Maximum value
15
15
  * @returns {number} Clamped value
16
16
  */
17
- export function clamp(min: number, val: number, max: number): number;
17
+ export function clamp(value: number, min: number, max: number): number;
@@ -56,11 +56,11 @@ export function getClampParams(varName) {
56
56
  /**
57
57
  * CSS clamp function implementation
58
58
  *
59
+ * @param {number} value - Value to clamp
59
60
  * @param {number} min - Minimum value
60
- * @param {number} val - Value to clamp
61
61
  * @param {number} max - Maximum value
62
62
  * @returns {number} Clamped value
63
63
  */
64
- export function clamp(min, val, max) {
65
- return Math.max(min, Math.min(val, max));
64
+ export function clamp(value, min, max) {
65
+ return Math.max(min, Math.min(value, max));
66
66
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hkdigital/lib-sveltekit",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "author": {
5
5
  "name": "HKdigital",
6
6
  "url": "https://hkdigital.nl"
File without changes
File without changes
File without changes