odj-svelte-ui 0.2.4 → 0.2.5

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
@@ -5,6 +5,7 @@ This is a fork from [Flowbite for Svelte 5 with Runes](https://svelte-5-ui-lib.c
5
5
  - [Original Docs](https://svelte-5-ui-lib.codewithshin.com/)
6
6
 
7
7
  ## Differences to Flowbite
8
+
8
9
  - Migration to Tailwind v4;
9
10
  - You can choose the "background" color instead of using the hard-coded `gray` color. You have to choose your colors defining `light-surface` and `dark-surface` on `app.css`;
10
11
  - Some components have the design slightly different:
@@ -31,7 +32,7 @@ This is a fork from [Flowbite for Svelte 5 with Runes](https://svelte-5-ui-lib.c
31
32
  - `Avatar` supports a `fallback` snippet to show when the image is loading or can't be loaded;
32
33
  - `Sidebar` can not be opened or closed anymore. If you want this behaviour, this component should be inside the `Drawer` component. On mobile, `Sidebar` will look like tabs;
33
34
  - `SidebarButton` has been removed. Please use the `Drawer` component to maintain the old sidebar behaviour;
34
-
35
+ - `Card` can be a button now adding `clickable` prop;
35
36
 
36
37
  ## Installation
37
38
 
@@ -46,6 +47,7 @@ bun dev
46
47
  ```
47
48
 
48
49
  Add the following to app.css:
50
+
49
51
  > 💡 TIP: Get colors' codes [here](https://tailwindcss.com/docs/colors#default-color-palette-reference).
50
52
 
51
53
  ```js
@@ -3,7 +3,7 @@
3
3
  import { onMount } from "svelte";
4
4
  import { type AvatarProps as Props, avatar, fallback as fallbackTheme } from ".";
5
5
 
6
- let { children, src, href, target, cornerStyle = "circular", border = false, stacked = false, dot, class: className, alt, size = "md", onclick, fallback, fallbackClass: fallbackClassName, ...restProps }: Props = $props();
6
+ let { children, src, href, target, cornerStyle = "circular", border = false, stacked = false, dot, class: className, alt, size = "md", onclick, fallback, fallbackClass: fallbackClassName, placeholderClass, ...restProps }: Props = $props();
7
7
 
8
8
  dot = dot && { placement: "top-right", color: "red", size: "lg", ...dot };
9
9
 
@@ -56,7 +56,7 @@
56
56
  {:else if children}
57
57
  {@render children()}
58
58
  {:else}
59
- <svg class="h-full w-full {cornerStyle === 'circular' ? 'rounded-full' : 'rounded-sm'}" fill="currentColor" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
59
+ <svg class="h-full w-full {placeholderClass} {cornerStyle === 'circular' ? 'rounded-full' : 'rounded-sm'}" fill="currentColor" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
60
60
  <path fill-rule="evenodd" d="M8 9a3 3 0 100-6 3 3 0 000 6zm-7 9a7 7 0 1114 0H3z" clip-rule="evenodd"></path>
61
61
  </svg>
62
62
  {/if}
@@ -14,5 +14,6 @@ interface AvatarProps extends HTMLAttributes<HTMLDivElement> {
14
14
  border?: boolean;
15
15
  fallback?: Snippet;
16
16
  fallbackClass?: string;
17
+ placeholderClass?: string;
17
18
  }
18
19
  export { type AvatarProps };
@@ -1,8 +1,8 @@
1
1
  <script lang="ts">
2
2
  import { card, type CardProps as Props } from ".";
3
- import type { HTMLAttributes, HTMLAnchorAttributes } from "svelte/elements";
3
+ import type { HTMLAttributes, HTMLAnchorAttributes, HTMLButtonAttributes } from "svelte/elements";
4
4
 
5
- let { children, href, color = "gray", horizontal = false, shadow = "md", reverse = false, img, padding = "lg", size = "sm", class: className, imgClass, contentClass, ...restProps }: Props = $props();
5
+ let { children, href, color = "default", horizontal = false, shadow = "md", reverse = false, img, padding = "lg", size = "sm", clickable, class: className, imgClass, contentClass, ...restProps }: Props = $props();
6
6
 
7
7
  const { base, image, content } = $derived(
8
8
  card({
@@ -12,7 +12,7 @@
12
12
  padding,
13
13
  horizontal,
14
14
  reverse,
15
- href: !!href
15
+ href: !!href || !!clickable
16
16
  })
17
17
  );
18
18
 
@@ -27,6 +27,10 @@
27
27
  href
28
28
  });
29
29
 
30
+ const buttonProps: HTMLButtonAttributes = $derived({
31
+ ...commonProps
32
+ });
33
+
30
34
  const divProps: HTMLAttributes<HTMLDivElement> = $derived({
31
35
  ...commonProps
32
36
  });
@@ -49,6 +53,10 @@
49
53
  <a {...anchorProps}>
50
54
  {@render childSlot()}
51
55
  </a>
56
+ {:else if clickable}
57
+ <button {...buttonProps}>
58
+ {@render childSlot()}
59
+ </button>
52
60
  {:else}
53
61
  <div {...divProps}>
54
62
  {@render childSlot()}
@@ -138,7 +138,9 @@ export declare const card: import("tailwind-variants").TVReturnType<{
138
138
  };
139
139
  };
140
140
  href: {
141
- true: string;
141
+ true: {
142
+ base: string;
143
+ };
142
144
  false: string;
143
145
  };
144
146
  hasImage: {
@@ -289,7 +291,9 @@ export declare const card: import("tailwind-variants").TVReturnType<{
289
291
  };
290
292
  };
291
293
  href: {
292
- true: string;
294
+ true: {
295
+ base: string;
296
+ };
293
297
  false: string;
294
298
  };
295
299
  hasImage: {
@@ -436,7 +440,9 @@ export declare const card: import("tailwind-variants").TVReturnType<{
436
440
  };
437
441
  };
438
442
  href: {
439
- true: string;
443
+ true: {
444
+ base: string;
445
+ };
440
446
  false: string;
441
447
  };
442
448
  hasImage: {
@@ -583,7 +589,9 @@ export declare const card: import("tailwind-variants").TVReturnType<{
583
589
  };
584
590
  };
585
591
  href: {
586
- true: string;
592
+ true: {
593
+ base: string;
594
+ };
587
595
  false: string;
588
596
  };
589
597
  hasImage: {
@@ -734,7 +742,9 @@ export declare const card: import("tailwind-variants").TVReturnType<{
734
742
  };
735
743
  };
736
744
  href: {
737
- true: string;
745
+ true: {
746
+ base: string;
747
+ };
738
748
  false: string;
739
749
  };
740
750
  hasImage: {
@@ -885,7 +895,9 @@ export declare const card: import("tailwind-variants").TVReturnType<{
885
895
  };
886
896
  };
887
897
  href: {
888
- true: string;
898
+ true: {
899
+ base: string;
900
+ };
889
901
  false: string;
890
902
  };
891
903
  hasImage: {
@@ -1032,7 +1044,9 @@ export declare const card: import("tailwind-variants").TVReturnType<{
1032
1044
  };
1033
1045
  };
1034
1046
  href: {
1035
- true: string;
1047
+ true: {
1048
+ base: string;
1049
+ };
1036
1050
  false: string;
1037
1051
  };
1038
1052
  hasImage: {
@@ -1,7 +1,7 @@
1
1
  import { tv } from "tailwind-variants";
2
2
  export const card = tv({
3
3
  slots: {
4
- base: "w-full flex max-w-sm bg-white border border-gray-200 rounded-lg dark:bg-gray-800 dark:border-gray-700",
4
+ base: "w-full flex max-w-sm bg-white border border-light-surface-200 rounded-lg dark:bg-dark-surface-700 dark:border-light-surface-600",
5
5
  image: "rounded-t-lg",
6
6
  content: ""
7
7
  },
@@ -64,7 +64,9 @@ export const card = tv({
64
64
  false: { base: "flex-col", image: "rounded-t-lg" }
65
65
  },
66
66
  href: {
67
- true: "",
67
+ true: {
68
+ base: "cursor-pointer focus-visible:outline-hidden focus-visible:ring-4 focus-visible:ring-primary-300 dark:focus-visible:ring-primary-800 hover:bg-dark-surface-100 dark:hover:bg-dark-surface-600 dark:hover:border-dark-surface-500"
69
+ },
68
70
  false: ""
69
71
  },
70
72
  hasImage: {
@@ -20,6 +20,7 @@ interface BaseCardProps {
20
20
  size?: CardSizeType;
21
21
  class?: string;
22
22
  imgClass?: string;
23
+ clickable?: boolean;
23
24
  contentClass?: string;
24
25
  }
25
26
  type CardProps = BaseCardProps & (({
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "odj-svelte-ui",
3
3
  "author": "orbitadajogatina",
4
- "version": "0.2.4",
4
+ "version": "0.2.5",
5
5
  "description": "This is a fork from Flowbite Svelte 5 with Runes. I just made some changes that fits better my taste.",
6
6
  "license": "MIT",
7
7
  "main": "dist/index.js",