lapikit 0.6.1 → 0.6.3

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,6 +1,19 @@
1
+ import type { Action } from 'svelte/action';
2
+ /** Accordion */
1
3
  export type AccordionOptions = {
2
4
  multiple?: boolean;
3
5
  readOnly?: boolean;
4
6
  };
5
7
  /**Modal */
6
8
  export type ModalState = boolean | 'persistent';
9
+ /**Theme */
10
+ export type ThemeOptions = {
11
+ name?: string;
12
+ key?: string;
13
+ overridden?: boolean;
14
+ };
15
+ export type ThemeAction = {
16
+ action: Action<HTMLElement, ThemeOptions | undefined>;
17
+ set: (name: string) => void;
18
+ readonly active: string;
19
+ };
@@ -2,3 +2,10 @@ export type PropValue = string | boolean | number | null | undefined;
2
2
  export type SizeType = 'default' | 'xs' | 'sm' | 'md' | 'lg' | 'xl';
3
3
  export type RoundedType = 0 | '0' | 'xs' | 'sm' | 'md' | 'lg' | 'xl';
4
4
  export type DensityType = 'none' | 'compact' | 'default' | 'comfortable';
5
+ export type ElevationType = '0' | '1' | '2' | '3' | '4' | '5';
6
+ export interface ElevationState {
7
+ base?: ElevationType;
8
+ hover?: ElevationType;
9
+ active?: ElevationType;
10
+ }
11
+ export type ElevationProps = ElevationType | ElevationState;
@@ -1,92 +1,43 @@
1
1
  <script lang="ts">
2
- let { ref = $bindable(), children, ...rest } = $props();
2
+ import { makeComponentProps } from '../../html-mapped';
3
+ import { useClassName, useStyles } from '../../utils';
4
+ import type { AppProps } from './app.types';
5
+
6
+ let {
7
+ ref = $bindable(),
8
+ children,
9
+ class: className = '',
10
+ style: styleAttr = '',
11
+ 's-class': sClass,
12
+ 's-style': sStyle,
13
+ ...rest
14
+ }: AppProps = $props();
15
+
16
+ let { classProps, styleProps, restProps } = $derived(makeComponentProps(rest));
17
+
18
+ let componentClass = $derived(
19
+ useClassName({
20
+ baseClass: 'kit-application',
21
+ className: `${className ?? ''}`.trim(),
22
+ sClass,
23
+ classProps
24
+ })
25
+ );
26
+
27
+ let componentStyle = $derived(
28
+ useStyles({
29
+ styleAttr,
30
+ sStyle,
31
+ styleProps
32
+ })
33
+ );
3
34
  </script>
4
35
 
5
- <div id="kit-app" bind:this={ref} {...rest} class={['kit-application', rest.class]}>
36
+ <div id="kit-app" bind:this={ref} class={componentClass} style={componentStyle} {...restProps}>
6
37
  {@render children?.()}
7
38
  </div>
8
39
 
9
40
  <style>
10
- .kit-application {
11
- color-scheme: light;
12
-
13
- /* Hue vars — used by components for dynamic semantic color calculations */
14
- --kit-h-neutral: 220;
15
- --kit-h-success: 145;
16
- --kit-h-warning: 35;
17
- --kit-h-danger: 5;
18
- --kit-h-info: 205;
19
-
20
- --kit-bg: hsl(0 0% 100%);
21
- --kit-fg: hsl(222 20% 10%);
22
- --kit-muted: hsl(220 10% 45%);
23
-
24
- --kit-surface-1: hsl(0 0% 100%);
25
- --kit-surface-2: hsl(220 20% 98%);
26
- --kit-surface-3: hsl(220 18% 94%);
27
-
28
- --kit-border: hsl(220 16% 88%);
29
-
30
- --kit-accent: hsl(220 90% 56%);
31
-
32
- --kit-focus: hsl(35, 90%, 56%);
33
-
34
- /* Layout */
35
- --kit-radius-1: 8px;
36
- --kit-radius-2: 12px;
37
- --kit-space-1: 6px;
38
- --kit-space-2: 10px;
39
- --kit-space-3: 14px;
40
- --kit-disabled-opacity: 0.55;
41
- --kit-font:
42
- ui-sans-serif, system-ui, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji',
43
- 'Segoe UI Symbol', 'Noto Color Emoji';
44
-
45
- /* ─── Color tokens (light mode defaults) ─────────────────────────── */
46
-
47
- /* Backgrounds */
48
- --kit-color-bg: hsl(0 0% 100%);
49
- --kit-color-bg-secondary: hsl(240 15% 96.5%);
50
- --kit-color-bg-tertiary: hsl(240 10% 93%);
51
-
52
- /* Surfaces — elevated layers (cards, sheets, popovers) */
53
- --kit-color-surface: hsl(0 0% 100%);
54
- --kit-color-surface-raised: hsl(0 0% 100%);
55
-
56
- /* Labels — text hierarchy */
57
- --kit-color-label: hsl(222 20% 10%);
58
- --kit-color-label-secondary: hsl(220 10% 40%);
59
- --kit-color-label-tertiary: hsl(220 8% 58%);
60
- --kit-color-label-quaternary: hsl(220 5% 76%);
61
-
62
- /* Fills — control & input backgrounds */
63
- --kit-color-fill: hsl(240 4% 91%);
64
- --kit-color-fill-secondary: hsl(240 8% 93%);
65
- --kit-color-fill-tertiary: hsl(240 11% 95%);
66
-
67
- /* Separator */
68
- --kit-color-separator: hsl(220 16% 88%);
69
-
70
- /* Semantic */
71
- --kit-color-accent: hsl(220 90% 56%);
72
- --kit-color-success: hsl(145 50% 38%);
73
- --kit-color-warning: hsl(35 80% 45%);
74
- --kit-color-danger: hsl(5 65% 48%);
75
- --kit-color-info: hsl(205 60% 42%);
76
- --kit-color-focus: hsl(35 90% 56%);
77
-
78
- /* ─── Backward-compat aliases (removed once components are updated) ─ */
79
- /* --kit-bg: var(--kit-color-bg);
80
- --kit-fg: var(--kit-color-label);
81
- --kit-muted: var(--kit-color-label-tertiary);
82
- --kit-surface-1: var(--kit-color-surface);
83
- --kit-surface-2: var(--kit-color-bg-secondary);
84
- --kit-surface-3: var(--kit-color-bg-tertiary);
85
- --kit-border: var(--kit-color-separator);
86
- --kit-accent: var(--kit-color-accent);
87
- --kit-focus: var(--kit-color-focus); */
88
- }
89
-
90
41
  .kit-application {
91
42
  --kit-shape-none: 0;
92
43
  --kit-shape-xs: 4px;
@@ -94,72 +45,118 @@
94
45
  --kit-shape-md: 10px;
95
46
  --kit-shape-lg: 14px;
96
47
  --kit-shape-xl: 18px;
48
+ --kit-shape-full: 9999px;
97
49
 
98
50
  --kit-space-compact: 6px;
99
51
  --kit-space-default: 10px;
100
52
  --kit-space-comfortable: 14px;
53
+
54
+ --kit-shadow-opacity: 30%;
55
+ --kit-shadow-ambiant-opacity: 15%;
101
56
  }
102
57
 
103
- /* Light — explicit override (same values as defaults, forces color-scheme) */
104
- .light {
58
+ .kit-application,
59
+ :global([data-kit-theme='light']) {
105
60
  color-scheme: light;
106
-
107
- --kit-color-bg: hsl(0 0% 100%);
108
- --kit-color-bg-secondary: hsl(240 15% 96.5%);
109
- --kit-color-bg-tertiary: hsl(240 10% 93%);
110
-
111
61
  --kit-color-surface: hsl(0 0% 100%);
112
- --kit-color-surface-raised: hsl(0 0% 100%);
62
+ --kit-color-surface-1: hsl(240 15% 96.5%);
63
+ --kit-color-surface-2: hsl(240 10% 93%);
64
+ --kit-color-surface-3: hsl(0 0% 100%);
113
65
 
114
- --kit-color-label: hsl(222 20% 10%);
115
- --kit-color-label-secondary: hsl(220 10% 40%);
116
- --kit-color-label-tertiary: hsl(220 8% 58%);
117
- --kit-color-label-quaternary: hsl(220 5% 76%);
66
+ --kit-color-text: hsl(222 20% 10%);
67
+ --kit-color-text-muted: hsl(220 10% 40%);
68
+ --kit-color-text-subtle: hsl(220 8% 58%);
69
+ --kit-color-text-disabled: hsl(220 5% 76%);
118
70
 
119
- --kit-color-fill: hsl(240 4% 91%);
120
- --kit-color-fill-secondary: hsl(240 8% 93%);
121
- --kit-color-fill-tertiary: hsl(240 11% 95%);
71
+ --kit-color-fill: hsl(240 8% 93%);
72
+ --kit-color-fill-hover: hsl(240 4% 91%);
73
+ --kit-color-fill-active: hsl(240 4% 88%);
122
74
 
123
- --kit-color-separator: hsl(220 16% 88%);
75
+ --kit-color-border: hsl(220 16% 88%);
76
+ --kit-color-shadow: hsl(240 3% 11%);
124
77
 
125
78
  --kit-color-accent: hsl(220 90% 56%);
79
+ --kit-color-on-accent: hsl(0 0% 100%);
126
80
  --kit-color-success: hsl(145 50% 38%);
81
+ --kit-color-on-success: hsl(0 0% 100%);
127
82
  --kit-color-warning: hsl(35 80% 45%);
83
+ --kit-color-on-warning: hsl(222 20% 10%);
128
84
  --kit-color-danger: hsl(5 65% 48%);
85
+ --kit-color-on-danger: hsl(0 0% 100%);
129
86
  --kit-color-info: hsl(205 60% 42%);
87
+ --kit-color-on-info: hsl(0 0% 100%);
130
88
  --kit-color-focus: hsl(35 90% 56%);
131
89
  }
132
90
 
133
- /* Dark */
134
- .dark {
91
+ :global([data-kit-theme='dark']) {
135
92
  color-scheme: dark;
136
93
 
137
- --kit-color-bg: hsl(240 3% 11%);
138
- --kit-color-bg-secondary: hsl(240 2% 17.5%);
139
- --kit-color-bg-tertiary: hsl(240 1.5% 23%);
140
-
141
- --kit-color-surface: hsl(240 2% 19%);
142
- --kit-color-surface-raised: hsl(240 1.5% 25%);
94
+ --kit-color-surface: hsl(240 3% 11%);
95
+ --kit-color-surface-1: hsl(240 2% 17.5%);
96
+ --kit-color-surface-2: hsl(240 1.5% 23%);
97
+ --kit-color-surface-3: hsl(240 1.5% 28%);
143
98
 
144
- --kit-color-label: hsl(0 0% 100%);
145
- --kit-color-label-secondary: hsl(240 3% 56%);
146
- --kit-color-label-tertiary: hsl(240 2.5% 38%);
147
- --kit-color-label-quaternary: hsl(240 1.5% 25%);
99
+ --kit-color-text: hsl(0 0% 100%);
100
+ --kit-color-text-muted: hsl(240 3% 56%);
101
+ --kit-color-text-subtle: hsl(240 2.5% 38%);
102
+ --kit-color-text-disabled: hsl(240 1.5% 25%);
148
103
 
149
- --kit-color-fill: hsl(240 2.5% 28%);
150
- --kit-color-fill-secondary: hsl(240 2.5% 24%);
151
- --kit-color-fill-tertiary: hsl(240 2% 20%);
104
+ --kit-color-fill: hsl(240 2.5% 24%);
105
+ --kit-color-fill-hover: hsl(240 2.5% 28%);
106
+ --kit-color-fill-active: hsl(240 2.5% 31%);
152
107
 
153
- --kit-color-separator: hsl(240 2% 26%);
108
+ --kit-color-border: hsl(240 2% 26%);
109
+ --kit-color-shadow: hsl(240 3% 11%);
154
110
 
155
111
  --kit-color-accent: hsl(220 85% 65%);
112
+ --kit-color-on-accent: hsl(240 3% 11%);
156
113
  --kit-color-success: hsl(145 50% 50%);
114
+ --kit-color-on-success: hsl(240 3% 11%);
157
115
  --kit-color-warning: hsl(35 85% 58%);
116
+ --kit-color-on-warning: hsl(240 3% 11%);
158
117
  --kit-color-danger: hsl(5 70% 60%);
118
+ --kit-color-on-danger: hsl(240 3% 11%);
159
119
  --kit-color-info: hsl(205 65% 58%);
120
+ --kit-color-on-info: hsl(240 3% 11%);
160
121
  --kit-color-focus: hsl(35 90% 62%);
161
122
  }
162
123
 
124
+ .kit-application {
125
+ color-scheme: light;
126
+
127
+ /* Hue vars — used by components for dynamic semantic color calculations */
128
+ --kit-h-neutral: 220;
129
+ --kit-h-success: 145;
130
+ --kit-h-warning: 35;
131
+ --kit-h-danger: 5;
132
+ --kit-h-info: 205;
133
+
134
+ --kit-bg: hsl(0 0% 100%);
135
+ --kit-fg: hsl(222 20% 10%);
136
+ --kit-muted: hsl(220 10% 45%);
137
+
138
+ --kit-surface-1: hsl(0 0% 100%);
139
+ --kit-surface-2: hsl(220 20% 98%);
140
+ --kit-surface-3: hsl(220 18% 94%);
141
+
142
+ --kit-border: hsl(220 16% 88%);
143
+
144
+ --kit-accent: hsl(220 90% 56%);
145
+
146
+ --kit-focus: hsl(35, 90%, 56%);
147
+
148
+ /* Layout */
149
+ --kit-radius-1: 8px;
150
+ --kit-radius-2: 12px;
151
+ --kit-space-1: 6px;
152
+ --kit-space-2: 10px;
153
+ --kit-space-3: 14px;
154
+ --kit-disabled-opacity: 0.55;
155
+ --kit-font:
156
+ ui-sans-serif, system-ui, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji',
157
+ 'Segoe UI Symbol', 'Noto Color Emoji';
158
+ }
159
+
163
160
  :global(.outline) {
164
161
  position: absolute;
165
162
  inset: 0;
@@ -201,6 +198,56 @@
201
198
  border-radius: var(--system-ripple-radius);
202
199
  }
203
200
 
201
+ :global([data-elevation='0']),
202
+ :global([data-elevation-hover='0']:hover),
203
+ :global([data-elevation-active='0']):active {
204
+ box-shadow: none;
205
+ }
206
+
207
+ :global([data-elevation='1']),
208
+ :global([data-elevation-hover='1']:hover),
209
+ :global([data-elevation-active='1']:active) {
210
+ box-shadow:
211
+ 0 1px 2px color-mix(in oklab, var(--kit-color-shadow) var(--kit-shadow-opacity), transparent),
212
+ 0 3px 8px -2px
213
+ color-mix(in oklab, var(--kit-color-shadow) var(--kit-shadow-ambiant-opacity), transparent);
214
+ }
215
+
216
+ :global([data-elevation='2']),
217
+ :global([data-elevation-hover='2']:hover),
218
+ :global([data-elevation-active='2']:active) {
219
+ box-shadow:
220
+ 0 1px 3px color-mix(in oklab, var(--kit-color-shadow) var(--kit-shadow-opacity), transparent),
221
+ 0 5px 12px -3px
222
+ color-mix(in oklab, var(--kit-color-shadow) var(--kit-shadow-ambiant-opacity), transparent);
223
+ }
224
+
225
+ :global([data-elevation='3']),
226
+ :global([data-elevation-hover='3']:hover),
227
+ :global([data-elevation-active='3']:active) {
228
+ box-shadow:
229
+ 0 2px 4px color-mix(in oklab, var(--kit-color-shadow) var(--kit-shadow-opacity), transparent),
230
+ 0 8px 20px -4px
231
+ color-mix(in oklab, var(--kit-color-shadow) var(--kit-shadow-ambiant-opacity), transparent);
232
+ }
233
+
234
+ :global([data-elevation='4']),
235
+ :global([data-elevation-hover='4']):hover,
236
+ :global([data-elevation-active='4']):active {
237
+ box-shadow:
238
+ 0 3px 5px color-mix(in oklab, var(--kit-color-shadow) var(--kit-shadow-opacity), transparent),
239
+ 0 11px 26px -5px
240
+ color-mix(in oklab, var(--kit-color-shadow) var(--kit-shadow-ambiant-opacity), transparent);
241
+ }
242
+
243
+ :global([data-elevation='5']),
244
+ :global([data-elevation-hover='5']:hover),
245
+ :global([data-elevation-active='5']:active) {
246
+ box-shadow:
247
+ 0 4px 6px color-mix(in oklab, var(--kit-color-shadow) var(--kit-shadow-opacity), transparent),
248
+ 0 14px 32px -6px
249
+ color-mix(in oklab, var(--kit-color-shadow) var(--kit-shadow-ambiant-opacity), transparent);
250
+ }
204
251
  @keyframes -global-animation-l-ripple {
205
252
  from {
206
253
  scale: 0;
@@ -1,6 +1,4 @@
1
- declare const App: import("svelte").Component<{
2
- ref?: any;
3
- children: any;
4
- } & Record<string, any>, {}, "ref">;
1
+ import type { AppProps } from './app.types';
2
+ declare const App: import("svelte").Component<AppProps, {}, "ref">;
5
3
  type App = ReturnType<typeof App>;
6
4
  export default App;
@@ -0,0 +1,4 @@
1
+ import type { Component } from '../../@types';
2
+ export interface AppProps extends Component {
3
+ ref?: HTMLElement | null;
4
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,5 +1,5 @@
1
1
  <script lang="ts">
2
- import { useClassName, useIsInteractive, useStyles } from '../../utils';
2
+ import { useClassName, useElevation, useIsInteractive, useStyles } from '../../utils';
3
3
  import { makeComponentProps } from '../../html-mapped';
4
4
  import { ripple } from '../../animations';
5
5
  import type { CardProps } from './card.types.js';
@@ -23,6 +23,7 @@
23
23
  noRipple,
24
24
  color,
25
25
  background,
26
+ elevation,
26
27
  ...rest
27
28
  }: CardProps = $props();
28
29
 
@@ -36,6 +37,8 @@
36
37
 
37
38
  let { classProps, styleProps, restProps } = $derived(makeComponentProps(rest));
38
39
 
40
+ let elevationState = $derived(useElevation(elevation));
41
+
39
42
  let componentClass = $derived(
40
43
  useClassName({
41
44
  baseClass: 'kit-card',
@@ -66,6 +69,9 @@
66
69
  data-variant={variant}
67
70
  data-density={density}
68
71
  data-rounded={rounded}
72
+ data-elevation={elevationState.base}
73
+ data-elevation-hover={elevationState.hover}
74
+ data-elevation-active={elevationState.active}
69
75
  data-interactive={isInteractive}
70
76
  data-active={active}
71
77
  data-disabled={isDisabled}
@@ -96,6 +102,7 @@
96
102
  border-radius: var(--kit-card-radius);
97
103
  border: 0;
98
104
  box-sizing: border-box;
105
+ padding: calc(10px * var(--kit-card-density-scale));
99
106
  transition:
100
107
  background 140ms ease,
101
108
  color 140ms ease,
@@ -143,19 +150,19 @@
143
150
  * @link https://lapikit.dev/docs/components/card#density
144
151
  */
145
152
  .kit-card[data-density='none'] {
146
- padding: 0;
153
+ --kit-card-density-scale: 0;
147
154
  }
148
155
  .kit-card[data-density='compact'] {
149
156
  --kit-card-gap: var(--kit-space-compact);
150
- padding: var(--kit-space-compact);
157
+ --kit-card-density-scale: 0.8;
151
158
  }
152
159
  .kit-card[data-density='default'] {
153
160
  --kit-card-gap: var(--kit-space-default);
154
- padding: var(--kit-space-default);
161
+ --kit-card-density-scale: 1;
155
162
  }
156
163
  .kit-card[data-density='comfortable'] {
157
164
  --kit-card-gap: var(--kit-space-comfortable);
158
- padding: var(--kit-space-comfortable);
165
+ --kit-card-density-scale: 1.15;
159
166
  }
160
167
 
161
168
  /**
@@ -163,15 +170,15 @@
163
170
  * @link https://lapikit.dev/docs/components/card#variants
164
171
  */
165
172
  .kit-card[data-variant='filled'] {
166
- --kit-card-bg: var(--kit-color-surface);
167
- --kit-card-fg: var(--kit-color-label);
173
+ --kit-card-bg: var(--kit-color-surface-1);
174
+ --kit-card-fg: var(--kit-color-text);
168
175
 
169
176
  --kit-card-hover-bg: color-mix(in oklab, var(--kit-card-bg), black 10%);
170
177
  --kit-card-active-bg: color-mix(in oklab, var(--kit-card-bg), black 16%);
171
178
  }
172
179
  .kit-card[data-variant='outline'] {
173
180
  --kit-card-bg: transparent;
174
- --kit-card-fg: var(--kit-color-label);
181
+ --kit-card-fg: var(--kit-color-text);
175
182
  --kit-card-bd: var(--kit-card-fg);
176
183
 
177
184
  --kit-card-hover-bg: color-mix(in oklab, var(--kit-card-fg), transparent 80%);
@@ -179,7 +186,7 @@
179
186
  }
180
187
  .kit-card[data-variant='text'] {
181
188
  --kit-card-bg: transparent;
182
- --kit-card-fg: var(--kit-color-label);
189
+ --kit-card-fg: var(--kit-color-text);
183
190
 
184
191
  --kit-card-hover-bg: color-mix(in oklab, var(--kit-card-fg), transparent 80%);
185
192
  --kit-card-active-bg: color-mix(in oklab, var(--kit-card-fg), transparent 92%);
@@ -192,7 +199,6 @@
192
199
  .kit-card[data-interactive='true'][data-disabled='false']:hover {
193
200
  translate: 0 -1px;
194
201
  background: var(--kit-card-hover-bg);
195
- box-shadow: 0 10px 28px hsl(220 35% 8% / 0.12);
196
202
  }
197
203
 
198
204
  .kit-card[data-variant='text'][data-interactive='true'][data-disabled='false']:hover {
@@ -203,7 +209,6 @@
203
209
  .kit-card[data-interactive='true'][data-disabled='false']:active {
204
210
  translate: 0 0;
205
211
  background: var(--kit-card-active-bg);
206
- box-shadow: 0 4px 14px hsl(220 35% 8% / 0.1);
207
212
  }
208
213
 
209
214
  .kit-card[data-variant='text'][data-interactive='true'][data-active='true'][data-disabled='false'],
@@ -1,4 +1,4 @@
1
- import type { Component, DensityType, RoundedType } from '../../@types';
1
+ import type { Component, DensityType, ElevationProps, RoundedType } from '../../@types';
2
2
  export interface CardProps extends Component {
3
3
  ref?: HTMLElement | null;
4
4
  is?: 'div' | 'article' | 'section' | 'aside' | 'a' | 'button';
@@ -7,6 +7,7 @@ export interface CardProps extends Component {
7
7
  variant?: 'filled' | 'outline' | 'text';
8
8
  density?: DensityType;
9
9
  rounded?: RoundedType;
10
+ elevation?: ElevationProps;
10
11
  interactive?: boolean;
11
12
  active?: boolean;
12
13
  disabled?: boolean;
@@ -46,6 +46,10 @@
46
46
 
47
47
  <style>
48
48
  .kit-card-title {
49
+ display: flex;
50
+ align-items: center;
51
+ gap: var(--kit-card-gap);
52
+
49
53
  font-weight: 600;
50
54
  line-height: 1.3;
51
55
  }