@makolabs/ripple 0.0.1-dev.36 → 0.0.1-dev.38

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.
@@ -1,93 +1,71 @@
1
1
  <script lang="ts">
2
- import { cn } from '../../helper/cls.js';
2
+ import { twMerge } from 'tailwind-merge';
3
3
  import { accordion } from './accordion.js';
4
4
  import type { AccordionProps } from '../../index.js';
5
- import { Color } from '../../variants.js';
6
5
 
7
6
  let {
8
7
  title,
9
8
  description,
9
+ id,
10
+ bordered,
11
+ color,
12
+ open,
13
+ onexpand,
14
+ oncollapse,
15
+ class: className,
16
+ summary,
10
17
  children,
11
- custom,
12
- open = $bindable(false),
13
- color = Color.DEFAULT,
14
- class: className = '',
15
- titleclass: titleClass = '',
16
- bodyclass: bodyClass = '',
17
- headerclass: headerClass = '',
18
- icon: Icon = undefined,
19
- iconPosition = 'start',
20
- bordered = true,
21
- id = 'accordion-item',
22
- onexpand = () => {},
23
- oncollapse = () => {}
18
+ icon: Icon
24
19
  }: AccordionProps = $props();
25
20
 
26
21
  const {
27
22
  base,
28
23
  header,
29
- title: titleSlot,
30
- body,
31
- icon: iconSlot,
32
- description: descriptionSlot
33
- } = $derived(
34
- accordion({
35
- color,
36
- open,
37
- bordered,
38
- iconPosition
39
- })
40
- );
24
+ title: titleClass,
25
+ description: descriptionClass,
26
+ body
27
+ } = accordion({ color, open, bordered });
41
28
 
42
- const baseClass = $derived(cn(base(), className));
43
- const headerClasses = $derived(cn(header(), headerClass));
44
- const titleClasses = $derived(cn(titleSlot(), titleClass));
45
- const bodyClasses = $derived(cn(body(), bodyClass));
46
- const iconClasses = $derived(cn(iconSlot()));
47
- const descriptionClasses = $derived(cn(descriptionSlot()));
48
-
49
- function handleToggle() {
29
+ function handleClick() {
50
30
  open = !open;
51
- if (open) {
31
+ if (open && onexpand) {
52
32
  onexpand();
53
- } else {
33
+ } else if (!open && oncollapse) {
54
34
  oncollapse();
55
35
  }
56
36
  }
37
+
38
+ const baseClasses = $derived(twMerge(base(), className));
57
39
  </script>
58
40
 
59
- <div class={baseClass}>
60
- <button class={headerClasses} onclick={handleToggle} aria-expanded={open} aria-controls={`${id}-content`} aria-label={open ? 'Collapse' : 'Expand'} >
61
- <div class="flex flex-1 items-center">
62
- {#if Icon && iconPosition === 'start'}
63
- <div class="mr-3">
64
- <Icon class={iconClasses} />
65
- </div>
41
+ <div class={baseClasses}>
42
+ <button
43
+ class={twMerge(header(), 'flex gap-3')}
44
+ aria-expanded={open}
45
+ aria-controls={id}
46
+ onclick={handleClick}
47
+ >
48
+ <div class="flex items-start justify-start gap-3">
49
+ {#if Icon}
50
+ <Icon class="text-default-500 size-5" />
66
51
  {/if}
67
-
68
- <div class="flex-1">
52
+ <div class="flex flex-col">
69
53
  {#if title}
70
- <h3 class={titleClasses}>{title}</h3>
54
+ <h3 class={titleClass()}>{title}</h3>
71
55
  {/if}
72
56
  {#if description}
73
- <p class={descriptionClasses}>{description}</p>
57
+ <p class={descriptionClass()}>{description}</p>
74
58
  {/if}
75
59
  </div>
76
-
77
- {#if Icon && iconPosition === 'end'}
78
- <div class="ml-3">
79
- <Icon class={iconClasses} />
80
- </div>
81
- {/if}
82
60
  </div>
83
-
84
- <div class="ml-3 flex items-center">
61
+ <div class="flex items-center">
62
+ {@render summary?.()}
85
63
  <svg
86
64
  xmlns="http://www.w3.org/2000/svg"
87
65
  width="20"
88
66
  height="20"
89
67
  viewBox="0 0 20 20"
90
- class="text-default-500 transition-transform duration-200"
68
+ class="text-default-500 size-5 transition-transform duration-200"
91
69
  class:rotate-180={open}
92
70
  >
93
71
  <path
@@ -97,14 +75,9 @@
97
75
  </svg>
98
76
  </div>
99
77
  </button>
100
-
101
78
  {#if open}
102
- <div class={bodyClasses}>
103
- {#if custom}
104
- {@render custom()}
105
- {:else if children}
106
- {@render children()}
107
- {/if}
79
+ <div class={body()} {id}>
80
+ {@render children()}
108
81
  </div>
109
82
  {/if}
110
83
  </div>
@@ -1,4 +1,4 @@
1
1
  import type { AccordionProps } from '../../index.js';
2
- declare const Accordion: import("svelte").Component<AccordionProps, {}, "open">;
2
+ declare const Accordion: import("svelte").Component<AccordionProps, {}, "">;
3
3
  type Accordion = ReturnType<typeof Accordion>;
4
4
  export default Accordion;
@@ -1,7 +1,9 @@
1
- export const accordion: import("tailwind-variants").TVReturnType<{
1
+ import { Color } from '../../variants.js';
2
+ export declare const accordion: import("tailwind-variants").TVReturnType<{
2
3
  color: {
3
4
  [Color.DEFAULT]: {
4
5
  base: string;
6
+ header: string;
5
7
  body: string;
6
8
  };
7
9
  [Color.PRIMARY]: {
@@ -63,11 +65,11 @@ export const accordion: import("tailwind-variants").TVReturnType<{
63
65
  title: string;
64
66
  description: string;
65
67
  body: string;
66
- icon: string;
67
68
  }, undefined, {
68
69
  color: {
69
70
  [Color.DEFAULT]: {
70
71
  base: string;
72
+ header: string;
71
73
  body: string;
72
74
  };
73
75
  [Color.PRIMARY]: {
@@ -129,11 +131,11 @@ export const accordion: import("tailwind-variants").TVReturnType<{
129
131
  title: string;
130
132
  description: string;
131
133
  body: string;
132
- icon: string;
133
134
  }, import("tailwind-variants").TVReturnType<{
134
135
  color: {
135
136
  [Color.DEFAULT]: {
136
137
  base: string;
138
+ header: string;
137
139
  body: string;
138
140
  };
139
141
  [Color.PRIMARY]: {
@@ -195,6 +197,4 @@ export const accordion: import("tailwind-variants").TVReturnType<{
195
197
  title: string;
196
198
  description: string;
197
199
  body: string;
198
- icon: string;
199
200
  }, undefined, unknown, unknown, undefined>>;
200
- import { Color } from '../../variants.js';
@@ -1,88 +1,86 @@
1
1
  import { tv } from '../../helper/cls.js';
2
2
  import { Color } from '../../variants.js';
3
-
4
3
  export const accordion = tv({
5
- slots: {
6
- base: 'relative overflow-hidden rounded-lg',
7
- header: 'flex cursor-pointer items-center justify-between border-default-200 p-4',
8
- title: 'text-default-900 text-base font-medium',
9
- description: 'text-default-500 text-sm',
10
- body: 'border-default-200 p-4 pt-0',
11
- icon: 'size-5'
12
- },
13
- variants: {
14
- color: {
15
- [Color.DEFAULT]: {
16
- base: 'bg-white',
17
- body: ''
18
- },
19
- [Color.PRIMARY]: {
20
- base: 'bg-primary-50',
21
- header: 'text-primary-700',
22
- title: 'text-primary-700'
23
- },
24
- [Color.SECONDARY]: {
25
- base: 'bg-secondary-50',
26
- header: 'text-secondary-700',
27
- title: 'text-secondary-700'
28
- },
29
- [Color.SUCCESS]: {
30
- base: 'bg-success-50',
31
- header: 'text-success-700',
32
- title: 'text-success-700'
33
- },
34
- [Color.WARNING]: {
35
- base: 'bg-warning-50',
36
- header: 'text-warning-700',
37
- title: 'text-warning-700'
38
- },
39
- [Color.DANGER]: {
40
- base: 'bg-danger-50',
41
- header: 'text-danger-700',
42
- title: 'text-danger-700'
43
- },
44
- [Color.INFO]: {
45
- base: 'bg-info-50',
46
- header: 'text-info-700',
47
- title: 'text-info-700'
48
- }
49
- },
50
- open: {
51
- true: {
52
- base: 'ring-1 ring-default-200',
53
- title: 'text-default-900'
54
- },
55
- false: {
56
- base: ''
57
- }
58
- },
59
- bordered: {
60
- true: {
61
- base: 'border border-default-200 ring-1 ring-default-200/50',
62
- body: 'border-t'
63
- },
64
- false: {
65
- base: 'shadow-sm'
66
- }
67
- },
68
- iconPosition: {
69
- start: {},
70
- end: {}
71
- }
72
- },
73
- compoundVariants: [
74
- {
75
- open: true,
76
- bordered: true,
77
- class: {
78
- base: 'shadow-sm'
79
- }
80
- }
81
- ],
82
- defaultVariants: {
83
- color: Color.DEFAULT,
84
- open: false,
85
- bordered: true,
86
- iconPosition: 'start'
87
- }
88
- });
4
+ slots: {
5
+ base: 'w-full relative overflow-hidden rounded-xl transition-all duration-200 hover:shadow-md bg-white border border-default-200',
6
+ header: 'w-full flex cursor-pointer items-center justify-between p-4 transition-colors duration-200 hover:bg-default-50',
7
+ title: 'flex text-default-900 text-sm font-medium leading-tight',
8
+ description: 'text-default-500 text-xs',
9
+ body: 'w-full border-t border-default-200 p-4 pt-3 transition-all',
10
+ },
11
+ variants: {
12
+ color: {
13
+ [Color.DEFAULT]: {
14
+ base: 'bg-white hover:border-default-300',
15
+ header: 'hover:bg-default-50',
16
+ body: ''
17
+ },
18
+ [Color.PRIMARY]: {
19
+ base: 'bg-primary-50/50 hover:border-primary-300',
20
+ header: 'text-primary-700 hover:bg-primary-50',
21
+ title: 'text-primary-700'
22
+ },
23
+ [Color.SECONDARY]: {
24
+ base: 'bg-secondary-50/50 hover:border-secondary-300',
25
+ header: 'text-secondary-700 hover:bg-secondary-50',
26
+ title: 'text-secondary-700'
27
+ },
28
+ [Color.SUCCESS]: {
29
+ base: 'bg-success-50/50 hover:border-success-300',
30
+ header: 'text-success-700 hover:bg-success-50',
31
+ title: 'text-success-700'
32
+ },
33
+ [Color.WARNING]: {
34
+ base: 'bg-warning-50/50 hover:border-warning-300',
35
+ header: 'text-warning-700 hover:bg-warning-50',
36
+ title: 'text-warning-700'
37
+ },
38
+ [Color.DANGER]: {
39
+ base: 'bg-danger-50/50 hover:border-danger-300',
40
+ header: 'text-danger-700 hover:bg-danger-50',
41
+ title: 'text-danger-700'
42
+ },
43
+ [Color.INFO]: {
44
+ base: 'bg-info-50/50 hover:border-info-300',
45
+ header: 'text-info-700 hover:bg-info-50',
46
+ title: 'text-info-700'
47
+ }
48
+ },
49
+ open: {
50
+ true: {
51
+ base: 'shadow-sm',
52
+ title: 'text-default-900'
53
+ },
54
+ false: {
55
+ base: ''
56
+ }
57
+ },
58
+ bordered: {
59
+ true: {
60
+ base: 'border border-default-200',
61
+ body: 'border-t'
62
+ },
63
+ false: {
64
+ base: 'shadow-sm'
65
+ }
66
+ },
67
+ iconPosition: {
68
+ start: {},
69
+ end: {}
70
+ }
71
+ },
72
+ compoundVariants: [
73
+ {
74
+ open: true,
75
+ class: {
76
+ header: 'border-b-0'
77
+ }
78
+ }
79
+ ],
80
+ defaultVariants: {
81
+ color: Color.DEFAULT,
82
+ open: false,
83
+ bordered: true,
84
+ iconPosition: 'start'
85
+ }
86
+ });
package/dist/index.d.ts CHANGED
@@ -163,6 +163,7 @@ export type AlertProps = {
163
163
  class?: string;
164
164
  onclose?: () => void;
165
165
  footer?: Snippet;
166
+ icon?: Component;
166
167
  };
167
168
  export type StatsCardProps = {
168
169
  label?: string;
@@ -725,8 +726,8 @@ export type AccordionProps = {
725
726
  id?: string;
726
727
  title?: string;
727
728
  description?: string;
728
- children?: Snippet;
729
- custom?: Snippet;
729
+ children: Snippet;
730
+ summary?: Snippet;
730
731
  open?: boolean;
731
732
  color?: VariantColors;
732
733
  class?: ClassValue;
@@ -1,10 +1,7 @@
1
1
  <script lang="ts">
2
- import NavGroup from './NavGroup.svelte';
3
- import NavItem from './NavItem.svelte';
4
2
  import { setContext } from 'svelte';
5
3
  import type { MenuBar, NavigationItem, SidebarProps, ParentItem, LinkItem } from '../../index.js';
6
4
  import clsx from 'clsx';
7
- import { cn } from '../../helper/cls.js';
8
5
  import { isRouteActive } from '../../helper/nav.svelte.js';
9
6
 
10
7
  let { items = [], logo }: SidebarProps = $props();
@@ -52,78 +49,116 @@
52
49
  const navigationItems = $derived(items.map((item) => processNavigationItem(item)));
53
50
 
54
51
  const sidebarClasses = $derived(
55
- clsx(
56
- `flex min-h-screen max-h-screen overflow-y-auto flex-col gap-y-1 overflow-y-auto
57
- border-r border-default-800 bg-default-900 px-3 duration-300 sticky top-0`,
58
- {
59
- 'w-16': menubar.collapsed,
60
- 'w-16 xl:w-72 shrink-0': !menubar.collapsed
61
- }
62
- )
52
+ clsx(`min-h-screen flex flex-col bg-gradient-to-b from-gray-900 to-default-900 h-full`, {
53
+ 'w-16': menubar.collapsed,
54
+ 'w-16 xl:w-64 shrink-0': !menubar.collapsed
55
+ })
63
56
  );
64
57
 
65
58
  const logoTextClasses = $derived(
66
- clsx('text-xl font-semibold hidden text-white truncate', { 'xl:block': !menubar.collapsed })
59
+ clsx('text-xl font-bold text-white', {
60
+ 'xl:block': !menubar.collapsed,
61
+ hidden: menubar.collapsed
62
+ })
67
63
  );
68
64
 
69
65
  const logoWrapperClasses = $derived(
70
- clsx('flex shrink-0 items-center justify-between mt-3 flex-col', {
71
- 'xl:mt-0 xl:h-16 flex-row': !menubar.collapsed
72
- })
66
+ clsx(
67
+ 'flex items-center h-16 flex-shrink-0 px-4 bg-gradient-to-r from-gray-900 to-default-900/50 border-b border-white/10',
68
+ {
69
+ 'justify-between': !menubar.collapsed,
70
+ 'justify-center': menubar.collapsed
71
+ }
72
+ )
73
73
  );
74
74
  </script>
75
75
 
76
76
  <div class={sidebarClasses}>
77
77
  <div class={logoWrapperClasses}>
78
78
  <div class="flex items-center gap-x-1">
79
- {#if logo.src}
79
+ {#if logo.src && !menubar.collapsed}
80
80
  <img src={logo.src} alt={logo.title} class="size-8 shrink-0" />
81
81
  {/if}
82
- {#if logo.title}
82
+ {#if logo.title && !menubar.collapsed}
83
83
  <h1 class={logoTextClasses}>{logo.title}</h1>
84
84
  {/if}
85
85
  </div>
86
- <button onclick={toggle} class="hidden cursor-pointer xl:block" aria-label="Toggle Sidebar">
86
+ <button
87
+ onclick={toggle}
88
+ class="hidden cursor-pointer text-white xl:block"
89
+ aria-label="Toggle Sidebar"
90
+ >
87
91
  {@render ToggleIcon()}
88
92
  </button>
89
93
  </div>
90
- <nav class="flex flex-1 flex-col">
91
- <ul role="list" class="flex flex-1 flex-col gap-y-1">
94
+
95
+ <div class="flex flex-1 flex-col overflow-y-auto bg-gradient-to-b from-transparent to-black/20">
96
+ <nav class="flex-1 space-y-6 px-2 py-4">
92
97
  {#each navigationItems as item, index (index)}
93
98
  {#if 'type' in item && item.type === 'horizontal-divider'}
94
- <li class="my-3 border-t border-default-700"></li>
99
+ <li class="my-2 border-t border-white/10"></li>
95
100
  {:else if 'children' in item}
96
- <NavGroup active={item.active}>
97
- {#snippet labelArea(classes)}
98
- <span class={classes}>{item.label}</span>
99
- {/snippet}
100
- {#each item.children as child (child.label)}
101
- <NavItem href={child.href} active={child.active}>
102
- {#if child.Icon}
103
- {@const Icon = child.Icon}
104
- <Icon class="size-6 shrink-0 text-default-600" />
105
- {/if}
106
- <span class="truncate">{child.label}</span>
107
- </NavItem>
108
- {/each}
109
- </NavGroup>
101
+ <div>
102
+ {#if !menubar.collapsed}
103
+ <h3 class="text-default-200 px-3 text-xs font-semibold tracking-wider uppercase">
104
+ {item.label}
105
+ </h3>
106
+ {/if}
107
+ <div class={menubar.collapsed ? '' : 'mt-2 space-y-1'}>
108
+ {#each item.children as child (child.label)}
109
+ <button
110
+ class="group hover:bg-default-500/10 flex w-full cursor-pointer items-center rounded-md px-3 py-2 text-sm font-medium transition-all duration-150 ease-in-out hover:text-white {child.active
111
+ ? 'bg-default-500/20'
112
+ : ''} {menubar.collapsed ? 'justify-center' : ''}"
113
+ class:text-white={child.active}
114
+ class:text-gray-300={!child.active}
115
+ onclick={() => (window.location.href = child.href)}
116
+ title={menubar.collapsed ? child.label : ''}
117
+ >
118
+ {#if child.Icon}
119
+ {@const Icon = child.Icon}
120
+ <Icon
121
+ class="h-5 w-5 flex-shrink-0 {child.active
122
+ ? 'text-default-200'
123
+ : 'text-gray-400'} {menubar.collapsed ? '' : 'mr-3'}"
124
+ />
125
+ {/if}
126
+ {#if !menubar.collapsed}
127
+ <span class="truncate">{child.label}</span>
128
+ {/if}
129
+ </button>
130
+ {/each}
131
+ </div>
132
+ </div>
110
133
  {:else if 'href' in item}
111
- <NavItem href={item.href} active={item.active}>
112
- {#snippet children(classes)}
113
- {#if item.Icon}
114
- {@const Icon = item.Icon}
115
- <Icon class="size-6 shrink-0 text-default-600" />
116
- {/if}
117
- <span class={cn(classes)}>{item.label}</span>
118
- {/snippet}
119
- </NavItem>
134
+ <button
135
+ class="group hover:bg-default-500/10 flex w-full cursor-pointer items-center rounded-md px-3 py-2 text-sm font-medium transition-all duration-150 ease-in-out hover:text-white {item.active
136
+ ? 'bg-default-500/20'
137
+ : ''} {menubar.collapsed ? 'justify-center' : ''}"
138
+ class:text-white={item.active}
139
+ class:text-gray-300={!item.active}
140
+ onclick={() => (window.location.href = item.href)}
141
+ title={menubar.collapsed ? item.label : ''}
142
+ >
143
+ {#if item.Icon}
144
+ {@const Icon = item.Icon}
145
+ <Icon
146
+ class="h-5 w-5 flex-shrink-0 {item.active
147
+ ? 'text-default-200'
148
+ : 'text-gray-400'} {menubar.collapsed ? '' : 'mr-3'}"
149
+ />
150
+ {/if}
151
+ {#if !menubar.collapsed}
152
+ <span class="truncate">{item.label}</span>
153
+ {/if}
154
+ </button>
120
155
  {/if}
121
156
  {/each}
122
- </ul>
123
- </nav>
157
+ </nav>
158
+ </div>
124
159
  </div>
125
160
 
126
- {#snippet ToggleIcon(classes = 'size-6 shrink-0 text-default-600')}
161
+ {#snippet ToggleIcon(classes = 'size-6 shrink-0 text-default-200')}
127
162
  <svg
128
163
  xmlns="http://www.w3.org/2000/svg"
129
164
  width="0.8em"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@makolabs/ripple",
3
- "version": "0.0.1-dev.36",
3
+ "version": "0.0.1-dev.38",
4
4
  "description": "Simple Svelte 5 powered component library ✨",
5
5
  "repository": {
6
6
  "type": "git",