@tuspe/components 1.7.4 → 1.7.6

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/README.md CHANGED
@@ -2,6 +2,17 @@
2
2
 
3
3
  [Tuspe Design](https://tuspe.com/en) builds websites and online stores for small and large businesses. This component library includes essential elements for forms, modals, breadcrumbs, and images. It also offers utility functions for price display, VAT calculations, and validations for tables and strings.
4
4
 
5
+ ## Example of required style specifications
6
+
7
+ ```CSS
8
+ :root {
9
+ --color-border: #bbb;
10
+ --color-content: #362e26;
11
+ --color-primary: #20a3cb;
12
+ --color-secondary: #263927;
13
+ }
14
+ ```
15
+
5
16
  ## Breadcrumbs
6
17
 
7
18
  A breadcrumb navigation provide links back to previous pages, and shows the user's current location in a website. The component complies with [Google standards](https://developers.google.com/search/docs/appearance/structured-data/breadcrumb).
@@ -79,8 +90,11 @@ Close button for modals and other dismissible elements.
79
90
 
80
91
  ```TypeScript
81
92
  interface Props {
82
- onclick: () => any
93
+ ariaLabel?: string
83
94
  color?: string
95
+ hover?: 'black' | 'primary' | 'secondary' | 'success' | 'transparent'
96
+ hoverText?: 'black' | 'primary' | 'secondary' | 'white'
97
+ onclick: () => any
84
98
  }
85
99
  ```
86
100
 
@@ -113,6 +127,7 @@ A versatile image component supporting various aspect ratios and object fit opti
113
127
  }
114
128
 
115
129
  interface Props {
130
+ ariaHidden?: boolean
116
131
  aspect?: '3:4' | '4:3' | 'square' | 'video'
117
132
  ball?: boolean
118
133
  border?: boolean
@@ -195,10 +210,15 @@ A simple `Modal` component that displays a popup with customizable content.
195
210
  ```TypeScript
196
211
  interface Props {
197
212
  children: Snippet
213
+ buttonAriaLabel?: string
214
+ colorButton?: string
215
+ colorBg?: string
216
+ headerClass?: string
198
217
  innerClass?: string
199
218
  open?: boolean
200
219
  outerClass?: string
201
220
  title?: string
221
+ titleClass?: string
202
222
  }
203
223
  ```
204
224
 
@@ -224,7 +244,7 @@ Formats a number or string as a price with two decimal places, spaces as thousan
224
244
 
225
245
  Retrieves or stores values in the cache; keys are slugified, and values are updated or returned if they exist. This ensures that `+page.ts` and other pages only retrieve data from the backend once and that the WordPress frontend uses the product list data on the product page without retrieving the same page again.
226
246
 
227
- ## preventDefault
247
+ ### preventDefault
228
248
 
229
249
  Previously, Svelte handled form submission without reloading the page. However, the `preventDefault` function is no longer supported by Svelte v5, so this function handles form submission without loading the page.
230
250
 
@@ -1,12 +1,21 @@
1
1
  <script lang="ts">
2
2
  import Button from './Button.svelte'
3
- let {color = 'black', onclick} = $props()
3
+
4
+ interface Props {
5
+ ariaLabel?: string
6
+ color?: string
7
+ hover?: 'black' | 'primary' | 'secondary' | 'success' | 'transparent'
8
+ hoverText?: 'black' | 'primary' | 'secondary' | 'white'
9
+ onclick?: any
10
+ }
11
+
12
+ let {ariaLabel, color = 'white', hover = 'transparent', onclick}: Props = $props()
4
13
  </script>
5
14
 
6
15
  <div class="close-button">
7
- <Button {color} {onclick} control fill>
8
- <svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24">
9
- <title>Sulje ikkuna</title>
16
+ <Button {ariaLabel} {color} {onclick} control fill {hover}>
17
+ <svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" aria-hidden="true" fill={color}>
18
+ <title>Close</title>
10
19
  <path
11
20
  d="M12 2c5.514 0 10 4.486 10 10s-4.486 10-10 10-10-4.486-10-10 4.486-10 10-10zm0-2c-6.627 0-12 5.373-12 12s5.373 12 12 12 12-5.373 12-12-5.373-12-12-12zm5 15.538l-3.592-3.548 3.546-3.587-1.416-1.403-3.545 3.589-3.588-3.543-1.405 1.405 3.593 3.552-3.547 3.592 1.405 1.405 3.555-3.596 3.591 3.55 1.403-1.416z"
12
21
  />
@@ -1,6 +1,10 @@
1
- declare const ButtonClose: import("svelte").Component<{
1
+ interface Props {
2
+ ariaLabel?: string;
2
3
  color?: string;
3
- onclick: any;
4
- }, {}, "">;
4
+ hover?: 'black' | 'primary' | 'secondary' | 'success' | 'transparent';
5
+ hoverText?: 'black' | 'primary' | 'secondary' | 'white';
6
+ onclick?: any;
7
+ }
8
+ declare const ButtonClose: import("svelte").Component<Props, {}, "">;
5
9
  type ButtonClose = ReturnType<typeof ButtonClose>;
6
10
  export default ButtonClose;
package/dist/Image.svelte CHANGED
@@ -2,6 +2,7 @@
2
2
  import type {ImageData} from './'
3
3
 
4
4
  interface Props {
5
+ ariaHidden?: boolean
5
6
  aspect?: '3:4' | '4:3' | 'square' | 'video'
6
7
  ball?: boolean
7
8
  border?: boolean
@@ -13,7 +14,7 @@
13
14
  objectFit?: 'contain' | 'cover'
14
15
  }
15
16
 
16
- let {aspect, ball = false, border, center = false, extraClasses, fullWidth, image, loading = 'lazy', objectFit}: Props = $props()
17
+ let {ariaHidden, aspect, ball = false, border, center = false, extraClasses, fullWidth, image, loading = 'lazy', objectFit}: Props = $props()
17
18
 
18
19
  let classes = $state('')
19
20
  if (aspect) {
@@ -40,7 +41,16 @@
40
41
  </script>
41
42
 
42
43
  {#if image?.src}
43
- <img alt={image.alt} class={classes} decoding="async" height={image.height} {loading} src={image.src} width={image.width} />
44
+ <img
45
+ {loading}
46
+ alt={image.alt}
47
+ aria-hidden={ariaHidden}
48
+ class={classes}
49
+ decoding="async"
50
+ height={image.height}
51
+ src={image.src}
52
+ width={image.width}
53
+ />
44
54
  {/if}
45
55
 
46
56
  <style scoped>
@@ -1,5 +1,6 @@
1
1
  import type { ImageData } from './';
2
2
  interface Props {
3
+ ariaHidden?: boolean;
3
4
  aspect?: '3:4' | '4:3' | 'square' | 'video';
4
5
  ball?: boolean;
5
6
  border?: boolean;
package/dist/Modal.svelte CHANGED
@@ -3,24 +3,39 @@
3
3
  import ButtonClose from './ButtonClose.svelte'
4
4
  interface Props {
5
5
  children: Snippet
6
+ buttonAriaLabel?: string
7
+ colorButton?: string
8
+ colorBg?: string
9
+ headerClass?: string
6
10
  innerClass?: string
7
11
  open?: boolean
8
12
  outerClass?: string
9
13
  title?: string
14
+ titleClass?: string
10
15
  }
11
- let {children, innerClass, open = $bindable(), outerClass, title}: Props = $props()
16
+ let {
17
+ children,
18
+ buttonAriaLabel,
19
+ colorButton = 'white',
20
+ headerClass = 'bg-primary',
21
+ innerClass,
22
+ open = $bindable(),
23
+ outerClass = 'bg-white text-content',
24
+ title = 'text-white',
25
+ titleClass
26
+ }: Props = $props()
12
27
  const handleClose = () => {
13
28
  open = false
14
29
  }
15
30
  </script>
16
31
 
17
32
  <div id="modal" class:hidden={!open}>
18
- <div id="modal-content" class={outerClass}>
19
- <header>
33
+ <div id="modal-content" class={outerClass} aria-live="polite">
34
+ <header class={headerClass}>
20
35
  {#if title}
21
- <h2>{title}</h2>
36
+ <h2 class={titleClass}>{title}</h2>
22
37
  {/if}
23
- <ButtonClose color="black" onclick={handleClose} />
38
+ <ButtonClose ariaLabel={buttonAriaLabel} onclick={handleClose} color={colorButton} hover="transparent" />
24
39
  </header>
25
40
  <div id="modal-body" class={innerClass}>
26
41
  {@render children?.()}
@@ -48,9 +63,9 @@
48
63
  visibility: hidden;
49
64
  }
50
65
  #modal-content {
51
- background-color: #fff;
52
66
  border-radius: 1rem;
53
67
  border: 2px solid var(--color-primary);
68
+ color: var(--color-content);
54
69
  margin-left: auto;
55
70
  margin-right: auto;
56
71
  max-width: 95vw;
@@ -73,4 +88,16 @@
73
88
  line-height: 1;
74
89
  margin: 0;
75
90
  }
91
+ .bg-primary {
92
+ background-color: var(--color-primary);
93
+ }
94
+ .bg-white {
95
+ background-color: #fff;
96
+ }
97
+ .text-content {
98
+ color: var(--color-content);
99
+ }
100
+ .text-white {
101
+ color: #fff;
102
+ }
76
103
  </style>
@@ -1,10 +1,15 @@
1
1
  import type { Snippet } from 'svelte';
2
2
  interface Props {
3
3
  children: Snippet;
4
+ buttonAriaLabel?: string;
5
+ colorButton?: string;
6
+ colorBg?: string;
7
+ headerClass?: string;
4
8
  innerClass?: string;
5
9
  open?: boolean;
6
10
  outerClass?: string;
7
11
  title?: string;
12
+ titleClass?: string;
8
13
  }
9
14
  declare const Modal: import("svelte").Component<Props, {}, "open">;
10
15
  type Modal = ReturnType<typeof Modal>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tuspe/components",
3
- "version": "1.7.4",
3
+ "version": "1.7.6",
4
4
  "description": "A reusable SvelteKit component library for form elements, breadcrumbs, prices and images.",
5
5
  "keywords": [
6
6
  "svelteKit",
@@ -14,7 +14,8 @@
14
14
  "input",
15
15
  "checkbox",
16
16
  "select",
17
- "preventDefault"
17
+ "preventDefault",
18
+ "validation"
18
19
  ],
19
20
  "homepage": "https://github.com/TuspeDesign/svelte-components",
20
21
  "license": "MIT",