@r2digisolutions/ui 0.10.1 → 0.12.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.
@@ -9,4 +9,6 @@ import CardHeader from './ui/Card/CardHeader.svelte';
9
9
  import Avatar from './ui/Avatar/Avatar.svelte';
10
10
  import Container from './ui/Container/Container.svelte';
11
11
  import Section from './ui/Section/Section.svelte';
12
- export { Alert, TableList, Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter, Avatar, Container, Section, };
12
+ import Loading from './ui/Loading/Loading.svelte';
13
+ import Button from './ui/Button/Button.svelte';
14
+ export { Alert, Avatar, Button, Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter, Container, Section, Loading, TableList, };
@@ -9,4 +9,6 @@ import CardHeader from './ui/Card/CardHeader.svelte';
9
9
  import Avatar from './ui/Avatar/Avatar.svelte';
10
10
  import Container from './ui/Container/Container.svelte';
11
11
  import Section from './ui/Section/Section.svelte';
12
- export { Alert, TableList, Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter, Avatar, Container, Section, };
12
+ import Loading from './ui/Loading/Loading.svelte';
13
+ import Button from './ui/Button/Button.svelte';
14
+ export { Alert, Avatar, Button, Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter, Container, Section, Loading, TableList, };
@@ -0,0 +1,64 @@
1
+ <script lang="ts">
2
+ import type { ClassValue } from 'svelte/elements';
3
+ import type { Props } from './type.js';
4
+ import Loading from '../Loading/Loading.svelte';
5
+
6
+ const {
7
+ variant = 'primary',
8
+ size = 'md',
9
+ type = 'button',
10
+ isLoading = false,
11
+ children,
12
+ disabled,
13
+ ...props
14
+ }: Props = $props();
15
+
16
+ const baseClasses =
17
+ 'inline-flex items-center justify-center font-semibold rounded-md transition-all duration-300 focus:outline-none focus:ring-2 focus:ring-offset-2 transform hover:scale-[1.02] active:scale-[0.98] shadow-sm hover:shadow-md';
18
+
19
+ const variantClasses: Record<typeof variant, string> = {
20
+ primary:
21
+ 'bg-gradient-to-r from-purple-600 to-blue-600 text-white hover:from-purple-700 hover:to-blue-700 focus:ring-purple-500 shadow-purple-500/25',
22
+ secondary:
23
+ 'bg-gradient-to-r from-gray-600 to-gray-700 text-white hover:from-gray-700 hover:to-gray-800 focus:ring-gray-500 shadow-gray-500/25',
24
+ outline:
25
+ 'border-2 border-purple-600 text-purple-600 hover:bg-purple-600 hover:text-white focus:ring-purple-500 bg-white/80 backdrop-blur-sm hover:border-purple-700',
26
+ ghost:
27
+ 'text-purple-600 hover:bg-purple-50 hover:text-purple-700 focus:ring-purple-500 bg-transparent shadow-none hover:shadow-md',
28
+ gradient:
29
+ 'bg-gradient-to-r from-pink-500 via-purple-500 to-indigo-500 text-white hover:from-pink-600 hover:via-purple-600 hover:to-indigo-600 focus:ring-purple-500 shadow-purple-500/30'
30
+ };
31
+
32
+ const sizeClasses: Record<typeof size, string> = {
33
+ xs: 'px-1.5 py-0.5 text-xs gap-0.5',
34
+ sm: 'px-2 py-1 text-xs gap-1 text-xs',
35
+ md: 'px-2.5 py-1.5 text-sm gap-1.5',
36
+ lg: 'px-3 py-2 text-sm gap-2',
37
+ xl: 'px-4 py-2.5 text-base gap-2',
38
+ '2xl': 'px-5 py-3 text-base gap-3',
39
+ '3xl': 'px-6 py-3 text-base gap-3',
40
+ '4xl': 'px-7 py-3 text-base gap-3',
41
+ '5xl': 'px-8 py-3 text-base gap-3',
42
+ '6xl': 'px-9 py-3 text-base gap-3',
43
+ '7xl': 'px-10 py-3 text-base gap-3',
44
+ '8xl': 'px-11 py-3 text-base gap-3'
45
+ };
46
+
47
+ const classes: ClassValue = [
48
+ baseClasses,
49
+ variantClasses[variant],
50
+ sizeClasses[size],
51
+ disabled || isLoading ? 'opacity-50 cursor-not-allowed transform-none hover:scale-100' : '',
52
+ props.class
53
+ ];
54
+
55
+ const Tag = props.href ? 'a' : 'button';
56
+ </script>
57
+
58
+ <svelte:element this={Tag} {...props} class={classes} disabled={disabled || isLoading}>
59
+ {#if isLoading}
60
+ <Loading />
61
+ {:else}
62
+ {@render children()}
63
+ {/if}
64
+ </svelte:element>
@@ -0,0 +1,4 @@
1
+ import type { Props } from './type.js';
2
+ declare const Button: import("svelte").Component<Props, {}, "">;
3
+ type Button = ReturnType<typeof Button>;
4
+ export default Button;
@@ -0,0 +1,14 @@
1
+ import type { IBaseProps } from "../../../types/base.type.js";
2
+ import type { TSize } from "../../../types/sizes.type.js";
3
+ import type { Snippet } from "svelte";
4
+ export type TButtonVariant = 'primary' | 'secondary' | 'outline' | 'ghost' | 'gradient';
5
+ export type TButtonType = 'submit' | 'reset' | 'button';
6
+ export interface Props extends IBaseProps {
7
+ variant?: TButtonVariant;
8
+ size?: TSize;
9
+ isLoading?: boolean;
10
+ children: Snippet;
11
+ disabled?: boolean;
12
+ href?: string;
13
+ type?: Props['href'] extends string ? never : TButtonType;
14
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,17 @@
1
+ <script lang="ts">
2
+ import { Loader } from 'lucide-svelte';
3
+ import type { ClassValue } from 'svelte/elements';
4
+
5
+ const {
6
+ loadingText = 'Cargando...',
7
+ ...props
8
+ }: {
9
+ loadingText?: string;
10
+ class?: ClassValue;
11
+ } = $props();
12
+ </script>
13
+
14
+ <div class={['flex justify-center gap-2', props.class]}>
15
+ <Loader class="h-6 w-6 animate-spin" />
16
+ <span> {loadingText} </span>
17
+ </div>
@@ -0,0 +1,8 @@
1
+ import type { ClassValue } from 'svelte/elements';
2
+ type $$ComponentProps = {
3
+ loadingText?: string;
4
+ class?: ClassValue;
5
+ };
6
+ declare const Loading: import("svelte").Component<$$ComponentProps, {}, "">;
7
+ type Loading = ReturnType<typeof Loading>;
8
+ export default Loading;
@@ -7,6 +7,3 @@
7
7
  <section class={['relative flex flex-col gap-2 py-32', props.class]}>
8
8
  {@render children()}
9
9
  </section>
10
-
11
- <style>
12
- </style>
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './stores/I18n.svelte.js';
2
2
  export * from './settings/index.js';
3
+ export * from './types/index.js';
3
4
  export * from './components/index.js';
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './stores/I18n.svelte.js';
2
2
  export * from './settings/index.js';
3
+ export * from './types/index.js';
3
4
  export * from './components/index.js';
@@ -0,0 +1,2 @@
1
+ export * from './base.type.js';
2
+ export * from './sizes.type.js';
@@ -0,0 +1,2 @@
1
+ export * from './base.type.js';
2
+ export * from './sizes.type.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@r2digisolutions/ui",
3
- "version": "0.10.1",
3
+ "version": "0.12.0",
4
4
  "private": false,
5
5
  "packageManager": "bun@1.2.18",
6
6
  "publishConfig": {