lapikit 0.7.1 → 0.7.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.
- package/dist/@types/props.d.ts +5 -0
- package/dist/animations/ripple.js +27 -17
- package/dist/components/app/app.svelte +6 -2
- package/dist/components/card/card.svelte +213 -176
- package/dist/components/card/card.types.d.ts +6 -3
- package/dist/components/card/modules/card-actions.svelte +11 -35
- package/dist/components/card/modules/card-container.svelte +9 -33
- package/dist/components/card/modules/card-content.svelte +15 -44
- package/dist/components/card/modules/card-media.svelte +10 -34
- package/dist/components/card/modules/card-title.svelte +19 -48
- package/dist/labs/sheet/sheet.svelte +196 -13
- package/dist/labs/sheet/sheet.svelte.d.ts +2 -8
- package/dist/labs/sheet/sheet.types.d.ts +16 -0
- package/dist/labs/sheet/sheet.types.js +1 -0
- package/dist/utils/color.d.ts +4 -0
- package/dist/utils/color.js +40 -0
- package/dist/utils/components.d.ts +10 -4
- package/dist/utils/components.js +11 -4
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/package.json +1 -1
package/dist/@types/props.d.ts
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
const triggerEvents = ['pointerdown', '
|
|
2
|
-
const cancelEvents = ['
|
|
1
|
+
const triggerEvents = ['pointerdown', 'keydown'];
|
|
2
|
+
const cancelEvents = ['pointerleave', 'pointercancel', 'dragleave', 'pointerup', 'keyup', 'blur'];
|
|
3
|
+
const activationKeys = ['Enter', ' '];
|
|
4
|
+
const nestedControls = 'a[href], button, input, select, textarea, summary, [role="button"], [role="link"]';
|
|
5
|
+
const hosts = new WeakMap();
|
|
3
6
|
function resolveDuration(options) {
|
|
4
7
|
return options.duration && options.duration > 0 ? options.duration : undefined;
|
|
5
8
|
}
|
|
6
|
-
function getCoords(e) {
|
|
7
|
-
if (window.TouchEvent && e instanceof TouchEvent) {
|
|
8
|
-
return { x: e.touches[0].clientX, y: e.touches[0].clientY };
|
|
9
|
-
}
|
|
10
|
-
return { x: e.clientX, y: e.clientY };
|
|
11
|
-
}
|
|
12
9
|
export function ripple(el, options = {}) {
|
|
13
10
|
// created on first interaction, removed once every ripple has faded out
|
|
14
11
|
let rippleContainer;
|
|
@@ -16,6 +13,16 @@ export function ripple(el, options = {}) {
|
|
|
16
13
|
function isAriaDisabled() {
|
|
17
14
|
return el.getAttribute('aria-disabled') === 'true';
|
|
18
15
|
}
|
|
16
|
+
/** The click starts in a child that handles it itself: an enabled ripple (a btn in a card) or a native control */
|
|
17
|
+
function isFromNestedControl(target) {
|
|
18
|
+
let node = target instanceof Element ? target : null;
|
|
19
|
+
while (node && node !== el) {
|
|
20
|
+
if (hosts.get(node)?.() || node.matches(nestedControls))
|
|
21
|
+
return true;
|
|
22
|
+
node = node.parentElement;
|
|
23
|
+
}
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
19
26
|
function applyOptions(container) {
|
|
20
27
|
if (options.component) {
|
|
21
28
|
container.style.setProperty('--system-ripple-radius', `var(--kit-${options.component}-radius)`);
|
|
@@ -55,22 +62,23 @@ export function ripple(el, options = {}) {
|
|
|
55
62
|
applyOptions(rippleContainer);
|
|
56
63
|
}
|
|
57
64
|
}
|
|
58
|
-
function createRipple(e
|
|
65
|
+
function createRipple(e) {
|
|
59
66
|
if (options.disabled || isAriaDisabled()) {
|
|
60
67
|
return;
|
|
61
68
|
}
|
|
62
|
-
|
|
63
|
-
|
|
69
|
+
const isKeyboard = e instanceof KeyboardEvent;
|
|
70
|
+
if (isKeyboard) {
|
|
71
|
+
if (!activationKeys.includes(e.key) || e.repeat || e.target !== el) {
|
|
64
72
|
return;
|
|
65
73
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
createRipple(click, true);
|
|
74
|
+
}
|
|
75
|
+
else if (e.button !== 0 || isFromNestedControl(e.target)) {
|
|
69
76
|
return;
|
|
70
77
|
}
|
|
71
|
-
const container = mountContainer(
|
|
78
|
+
const container = mountContainer(isKeyboard);
|
|
72
79
|
const rect = el.getBoundingClientRect();
|
|
73
|
-
const
|
|
80
|
+
const clientX = isKeyboard ? rect.left + rect.width / 2 : e.clientX;
|
|
81
|
+
const clientY = isKeyboard ? rect.top + rect.height / 2 : e.clientY;
|
|
74
82
|
const x = clientX - rect.left > el.offsetWidth / 2 ? 0 : el.offsetWidth;
|
|
75
83
|
const y = clientY - rect.top > el.offsetHeight / 2 ? 0 : el.offsetHeight;
|
|
76
84
|
const radius = Math.hypot(x - (clientX - rect.left), y - (clientY - rect.top));
|
|
@@ -105,9 +113,11 @@ export function ripple(el, options = {}) {
|
|
|
105
113
|
activeRipples.add(cleanup);
|
|
106
114
|
cancelEvents.forEach((event) => el.addEventListener(event, removeRipple, { passive: true }));
|
|
107
115
|
}
|
|
108
|
-
|
|
116
|
+
hosts.set(el, () => !options.disabled && !isAriaDisabled());
|
|
117
|
+
triggerEvents.forEach((event) => el.addEventListener(event, createRipple, { passive: true }));
|
|
109
118
|
return {
|
|
110
119
|
destroy() {
|
|
120
|
+
hosts.delete(el);
|
|
111
121
|
triggerEvents.forEach((event) => {
|
|
112
122
|
el.removeEventListener(event, createRipple);
|
|
113
123
|
});
|
|
@@ -45,6 +45,8 @@
|
|
|
45
45
|
--kit-shape-lg: 0.875rem;
|
|
46
46
|
--kit-shape-xl: 1.125rem;
|
|
47
47
|
--kit-shape-full: 9999px;
|
|
48
|
+
--kit-animation-component: 150ms;
|
|
49
|
+
--kit-outline-weight: 1px;
|
|
48
50
|
}
|
|
49
51
|
|
|
50
52
|
:global html {
|
|
@@ -56,9 +58,11 @@
|
|
|
56
58
|
--kit-space-compact: 2px;
|
|
57
59
|
--kit-space-default: 4px;
|
|
58
60
|
--kit-space-comfortable: 6px;
|
|
61
|
+
--kit-density-dense: -8px;
|
|
59
62
|
--kit-density-compact: -4px;
|
|
60
63
|
--kit-density-default: 0px;
|
|
61
64
|
--kit-density-comfortable: 4px;
|
|
65
|
+
--kit-density-spacious: 8px;
|
|
62
66
|
--kit-shadow-opacity: 30%;
|
|
63
67
|
--kit-shadow-ambient-opacity: 15%;
|
|
64
68
|
--kit-disabled-opacity: 0.55;
|
|
@@ -183,7 +187,7 @@
|
|
|
183
187
|
:global .outline {
|
|
184
188
|
position: absolute;
|
|
185
189
|
inset: 0;
|
|
186
|
-
border:
|
|
190
|
+
border: var(--kit-outline-weight) solid var(--outline-color);
|
|
187
191
|
border-radius: inherit;
|
|
188
192
|
box-sizing: border-box;
|
|
189
193
|
z-index: 1;
|
|
@@ -199,7 +203,7 @@
|
|
|
199
203
|
animation: animation-l-ripple var(--system-animation-ripple-duration, 0.4s) cubic-bezier(0.4, 0, 0.2, 1);
|
|
200
204
|
border-radius: 50%;
|
|
201
205
|
}
|
|
202
|
-
:global .kit-ripple--center {
|
|
206
|
+
:global .kit-ripple--center > .kit-ripple {
|
|
203
207
|
top: 50% !important;
|
|
204
208
|
left: 50% !important;
|
|
205
209
|
translate: -50% -50% !important;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
import { makeComponentProps } from '../../html-mapped';
|
|
2
|
+
import { useComponentAttrs, useElevation, useIsInteractive } from '../../utils';
|
|
4
3
|
import { ripple } from '../../animations';
|
|
5
4
|
import type { CardProps } from './card.types.js';
|
|
6
5
|
|
|
@@ -8,8 +7,8 @@
|
|
|
8
7
|
ref = $bindable(),
|
|
9
8
|
is = 'div',
|
|
10
9
|
children,
|
|
11
|
-
class: className
|
|
12
|
-
style: styleAttr
|
|
10
|
+
class: className,
|
|
11
|
+
style: styleAttr,
|
|
13
12
|
's-class': sClass,
|
|
14
13
|
's-style': sStyle,
|
|
15
14
|
href,
|
|
@@ -17,61 +16,37 @@
|
|
|
17
16
|
variant = 'filled',
|
|
18
17
|
density = 'default',
|
|
19
18
|
rounded = 'md',
|
|
20
|
-
interactive
|
|
19
|
+
interactive,
|
|
21
20
|
active = false,
|
|
22
21
|
disabled = false,
|
|
23
22
|
noRipple,
|
|
24
23
|
color,
|
|
25
|
-
background,
|
|
26
24
|
elevation,
|
|
27
25
|
...rest
|
|
28
26
|
}: CardProps = $props();
|
|
29
27
|
|
|
30
28
|
let tag = $derived((href && 'a') || is);
|
|
31
|
-
|
|
29
|
+
// undefined: detected (a, button, onclick...), true: forced, false: no visual feedback (still clickable)
|
|
30
|
+
let isInteractive = $derived(interactive ?? useIsInteractive(rest, tag, ['a', 'button']));
|
|
32
31
|
let isDisabled = $derived(!!disabled);
|
|
33
32
|
let resolvedHref = $derived(tag === 'a' && !isDisabled ? href : undefined);
|
|
34
33
|
let resolvedType = $derived(tag === 'button' ? (type ?? 'button') : undefined);
|
|
35
34
|
let resolvedDisabled = $derived(tag === 'button' ? isDisabled : undefined);
|
|
36
35
|
let resolvedTabIndex = $derived(tag === 'a' && isDisabled ? -1 : undefined);
|
|
37
36
|
|
|
38
|
-
let
|
|
39
|
-
|
|
40
|
-
let elevationState = $derived(useElevation(elevation));
|
|
41
|
-
|
|
42
|
-
let componentClass = $derived(
|
|
43
|
-
useClassName({
|
|
44
|
-
baseClass: 'kit-card',
|
|
45
|
-
className: `${className ?? ''}`.trim(),
|
|
46
|
-
sClass,
|
|
47
|
-
classProps
|
|
48
|
-
})
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
let componentStyle = $derived(
|
|
52
|
-
useStyles({
|
|
53
|
-
styleAttr,
|
|
54
|
-
sStyle,
|
|
55
|
-
styleProps
|
|
56
|
-
})
|
|
57
|
-
);
|
|
58
|
-
|
|
59
|
-
let resolvedStyle = $derived(
|
|
60
|
-
[
|
|
61
|
-
componentStyle,
|
|
62
|
-
color ? `--kit-card-fg:${color && `var(--kit-color-${color})`}` : '',
|
|
63
|
-
background ? `--kit-card-bg:${background && `var(--kit-color-${background})`}` : ''
|
|
64
|
-
]
|
|
65
|
-
.filter(Boolean)
|
|
66
|
-
.join('; ')
|
|
37
|
+
let attrs = $derived(
|
|
38
|
+
useComponentAttrs('kit-card', { className, sClass, styleAttr, sStyle, color, active }, rest)
|
|
67
39
|
);
|
|
40
|
+
let elevationState = $derived(useElevation(elevation));
|
|
41
|
+
// the border is drawn over the content, so the outline and surface variants keep the same box
|
|
42
|
+
let hasOutline = $derived(variant === 'outline' || variant === 'surface');
|
|
68
43
|
</script>
|
|
69
44
|
|
|
70
45
|
<svelte:element
|
|
71
46
|
this={tag}
|
|
72
47
|
bind:this={ref}
|
|
73
|
-
class={
|
|
74
|
-
style={
|
|
48
|
+
class={attrs.class}
|
|
49
|
+
style={attrs.style}
|
|
75
50
|
href={resolvedHref}
|
|
76
51
|
type={resolvedType}
|
|
77
52
|
disabled={resolvedDisabled}
|
|
@@ -88,149 +63,211 @@
|
|
|
88
63
|
aria-disabled={isDisabled || undefined}
|
|
89
64
|
use:ripple={{
|
|
90
65
|
component: 'card',
|
|
91
|
-
disabled: noRipple ||
|
|
66
|
+
disabled: noRipple || isDisabled || !isInteractive
|
|
92
67
|
}}
|
|
93
|
-
{...
|
|
68
|
+
{...attrs.rest}
|
|
94
69
|
>
|
|
95
|
-
{#if
|
|
70
|
+
{#if hasOutline}
|
|
96
71
|
<span class="outline"></span>
|
|
97
72
|
{/if}
|
|
98
73
|
|
|
99
74
|
{@render children?.()}
|
|
100
75
|
</svelte:element>
|
|
101
76
|
|
|
102
|
-
<style
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
77
|
+
<style>.kit-card {
|
|
78
|
+
--kit-card-color: initial;
|
|
79
|
+
--kit-card-on-color: initial;
|
|
80
|
+
--kit-card-active-fg: initial;
|
|
81
|
+
--kit-card-active-shade: initial;
|
|
82
|
+
--kit-card-hover-fg: initial;
|
|
83
|
+
--kit-card-pressed-fg: initial;
|
|
84
|
+
--kit-card-bg: var(--kit-card-color, var(--kit-color-surface-1));
|
|
85
|
+
--kit-card-fg: var(--kit-card-on-color, var(--kit-card-contrast, var(--kit-color-text)));
|
|
86
|
+
--kit-card-ink: var(--kit-card-color, var(--kit-color-text));
|
|
87
|
+
--kit-card-hover: color-mix(in oklab, var(--kit-card-bg), var(--kit-card-fg) 8%);
|
|
88
|
+
--kit-card-pressed: color-mix(in oklab, var(--kit-card-bg), var(--kit-card-fg) 14%);
|
|
89
|
+
--kit-card-soft: color-mix(in oklab, var(--kit-card-bg) 16%, transparent);
|
|
90
|
+
--kit-card-border: color-mix(in oklab, var(--kit-card-bg), var(--kit-card-fg) 20%);
|
|
91
|
+
--kit-card-active: color-mix(
|
|
92
|
+
in oklab,
|
|
93
|
+
var(--kit-card-color),
|
|
94
|
+
var(--kit-card-fg) var(--kit-card-active-shade, 14%)
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
@supports (color: color(from red srgb-linear r g b)) {
|
|
98
|
+
.kit-card {
|
|
99
|
+
--kit-card-contrast: color(from var(--kit-card-color) srgb-linear clamp(0, (0.1791 - (0.2126 * r + 0.7152 * g + 0.0722 * b)) * 100000, 1) clamp(0, (0.1791 - (0.2126 * r + 0.7152 * g + 0.0722 * b)) * 100000, 1) clamp(0, (0.1791 - (0.2126 * r + 0.7152 * g + 0.0722 * b)) * 100000, 1)/1);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
.kit-card {
|
|
103
|
+
--kit-card-gap: calc(var(--kit-space-default) + var(--kit-card-density-offset) / 2);
|
|
104
|
+
--kit-card-padding: calc(10px + var(--kit-card-density-offset) / 2);
|
|
105
|
+
display: flex;
|
|
106
|
+
position: relative;
|
|
107
|
+
flex-direction: column;
|
|
108
|
+
gap: var(--kit-card-gap);
|
|
109
|
+
background-color: var(--kit-card-bg);
|
|
110
|
+
color: var(--kit-card-fg);
|
|
111
|
+
border-radius: var(--kit-card-radius);
|
|
112
|
+
border: 0;
|
|
113
|
+
box-sizing: border-box;
|
|
114
|
+
padding: var(--kit-card-padding);
|
|
115
|
+
transition-property: background-color, color, border-color, box-shadow;
|
|
116
|
+
transition-duration: var(--kit-animation-component);
|
|
117
|
+
transition-timing-function: ease;
|
|
118
|
+
}
|
|
119
|
+
@media (prefers-reduced-motion: reduce) {
|
|
120
|
+
.kit-card {
|
|
121
|
+
transition: none;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/* native resets: no background here, it would beat the background of .kit-card */
|
|
126
|
+
a.kit-card {
|
|
127
|
+
text-decoration: none;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
button.kit-card {
|
|
131
|
+
appearance: none;
|
|
132
|
+
border: 0;
|
|
133
|
+
font: inherit;
|
|
134
|
+
text-align: inherit;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* variant
|
|
139
|
+
* @link https://lapikit.dev/docs/components/card#variants
|
|
140
|
+
*/
|
|
141
|
+
.kit-card[data-variant=tonal] {
|
|
142
|
+
--kit-card-bg: color-mix(in oklab, var(--kit-card-ink) 16%, transparent);
|
|
143
|
+
--kit-card-fg: var(--kit-card-ink);
|
|
144
|
+
--kit-card-border: transparent;
|
|
145
|
+
--kit-card-active: color-mix(in oklab, var(--kit-card-ink) 28%, transparent);
|
|
146
|
+
--kit-card-active-fg: var(--kit-card-ink);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.kit-card[data-variant=text] {
|
|
150
|
+
--kit-card-bg: transparent;
|
|
151
|
+
--kit-card-fg: var(--kit-card-ink);
|
|
152
|
+
--kit-card-border: transparent;
|
|
153
|
+
--kit-card-active: color-mix(in oklab, var(--kit-card-ink) 14%, transparent);
|
|
154
|
+
--kit-card-active-fg: var(--kit-card-ink);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
.kit-card[data-variant=plain] {
|
|
158
|
+
--kit-card-bg: transparent;
|
|
159
|
+
--kit-card-fg: var(--kit-card-ink);
|
|
160
|
+
--kit-card-border: transparent;
|
|
161
|
+
--kit-card-hover: transparent;
|
|
162
|
+
--kit-card-pressed: transparent;
|
|
163
|
+
--kit-card-hover-fg: color-mix(in oklab, var(--kit-card-fg) 72%, transparent);
|
|
164
|
+
--kit-card-pressed-fg: color-mix(in oklab, var(--kit-card-fg) 56%, transparent);
|
|
165
|
+
--kit-card-active: transparent;
|
|
166
|
+
--kit-card-active-fg: var(--kit-card-color, var(--kit-color-accent));
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
.kit-card[data-variant=outline] {
|
|
170
|
+
--kit-card-bg: transparent;
|
|
171
|
+
--kit-card-fg: var(--kit-card-ink);
|
|
172
|
+
--kit-card-border: var(--kit-card-color, var(--kit-color-border));
|
|
173
|
+
--kit-card-active: color-mix(in oklab, var(--kit-card-ink) 14%, transparent);
|
|
174
|
+
--kit-card-active-fg: var(--kit-card-ink);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.kit-card[data-variant=surface] {
|
|
178
|
+
--kit-card-bg: color-mix(in oklab, var(--kit-card-ink) 8%, transparent);
|
|
179
|
+
--kit-card-fg: var(--kit-card-ink);
|
|
180
|
+
--kit-card-border: color-mix(in oklab, var(--kit-card-ink) 35%, transparent);
|
|
181
|
+
--kit-card-active: color-mix(in oklab, var(--kit-card-ink) 18%, transparent);
|
|
182
|
+
--kit-card-active-fg: var(--kit-card-ink);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
.kit-card .outline {
|
|
186
|
+
--outline-color: var(--kit-card-border);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.kit-card[data-active=true] {
|
|
190
|
+
--kit-card-bg: var(--kit-card-active, var(--kit-color-accent));
|
|
191
|
+
--kit-card-fg: var(
|
|
192
|
+
--kit-card-active-fg,
|
|
193
|
+
var(--kit-card-on-color, var(--kit-card-contrast, var(--kit-color-on-accent)))
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* interactive: hover, pressed, focus-visible and disabled
|
|
199
|
+
*/
|
|
200
|
+
.kit-card[data-interactive=true]:not([data-disabled=true]) {
|
|
201
|
+
cursor: pointer;
|
|
202
|
+
}
|
|
203
|
+
.kit-card[data-interactive=true]:not([data-disabled=true]):hover {
|
|
204
|
+
background-color: var(--kit-card-hover);
|
|
205
|
+
color: var(--kit-card-hover-fg, var(--kit-card-fg));
|
|
206
|
+
}
|
|
207
|
+
.kit-card[data-interactive=true]:not([data-disabled=true]):active {
|
|
208
|
+
background-color: var(--kit-card-pressed);
|
|
209
|
+
color: var(--kit-card-pressed-fg, var(--kit-card-fg));
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
.kit-card:not([data-disabled=true]):focus-visible {
|
|
213
|
+
outline: 2px solid var(--kit-color-focus);
|
|
214
|
+
outline-offset: 2px;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
.kit-card[data-disabled=true] {
|
|
218
|
+
opacity: var(--kit-disabled-opacity, 0.55);
|
|
219
|
+
pointer-events: none;
|
|
220
|
+
user-select: none;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* rounded
|
|
225
|
+
* @link https://lapikit.dev/docs/customize
|
|
226
|
+
*/
|
|
227
|
+
.kit-card[data-rounded="0"] {
|
|
228
|
+
--kit-card-radius: var(--kit-shape-none);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
.kit-card[data-rounded=xs] {
|
|
232
|
+
--kit-card-radius: var(--kit-shape-xs);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
.kit-card[data-rounded=sm] {
|
|
236
|
+
--kit-card-radius: var(--kit-shape-sm);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
.kit-card[data-rounded=md] {
|
|
240
|
+
--kit-card-radius: var(--kit-shape-md);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
.kit-card[data-rounded=lg] {
|
|
244
|
+
--kit-card-radius: var(--kit-shape-lg);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
.kit-card[data-rounded=xl] {
|
|
248
|
+
--kit-card-radius: var(--kit-shape-xl);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* density
|
|
253
|
+
* @link https://lapikit.dev/docs/components/card#density
|
|
254
|
+
*/
|
|
255
|
+
.kit-card[data-density=dense] {
|
|
256
|
+
--kit-card-density-offset: var(--kit-density-dense);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
.kit-card[data-density=compact] {
|
|
260
|
+
--kit-card-density-offset: var(--kit-density-compact);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
.kit-card[data-density=default] {
|
|
264
|
+
--kit-card-density-offset: var(--kit-density-default);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
.kit-card[data-density=comfortable] {
|
|
268
|
+
--kit-card-density-offset: var(--kit-density-comfortable);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
.kit-card[data-density=spacious] {
|
|
272
|
+
--kit-card-density-offset: var(--kit-density-spacious);
|
|
273
|
+
}</style>
|
|
@@ -1,25 +1,28 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ColorProps, Component, 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';
|
|
5
5
|
href?: string;
|
|
6
6
|
type?: 'button' | 'submit' | 'reset';
|
|
7
|
-
variant?: 'filled' | 'outline' | 'text';
|
|
8
|
-
density?:
|
|
7
|
+
variant?: 'filled' | 'tonal' | 'outline' | 'text' | 'plain' | 'surface';
|
|
8
|
+
density?: 'dense' | 'compact' | 'default' | 'comfortable' | 'spacious';
|
|
9
9
|
rounded?: RoundedType;
|
|
10
10
|
elevation?: ElevationProps;
|
|
11
11
|
interactive?: boolean;
|
|
12
12
|
active?: boolean;
|
|
13
13
|
disabled?: boolean;
|
|
14
14
|
noRipple?: boolean;
|
|
15
|
+
color?: ColorProps;
|
|
15
16
|
}
|
|
16
17
|
export interface CardTitleProps extends Component {
|
|
17
18
|
ref?: HTMLElement | null;
|
|
18
19
|
is?: 'div' | 'p' | 'span' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
20
|
+
color?: string;
|
|
19
21
|
}
|
|
20
22
|
export interface CardContentProps extends Component {
|
|
21
23
|
ref?: HTMLElement | null;
|
|
22
24
|
is?: 'div' | 'p' | 'span' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
25
|
+
color?: string;
|
|
23
26
|
}
|
|
24
27
|
export interface CardMediaProps extends Component {
|
|
25
28
|
ref?: HTMLElement | null;
|
|
@@ -1,53 +1,29 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { CardActionsProps } from '../card.types';
|
|
3
|
-
import {
|
|
4
|
-
import { useClassName, useStyles } from '../../../utils';
|
|
3
|
+
import { useComponentAttrs } from '../../../utils';
|
|
5
4
|
|
|
6
5
|
let {
|
|
7
6
|
ref = $bindable(),
|
|
8
7
|
is = 'div',
|
|
9
8
|
children,
|
|
10
|
-
class: className
|
|
11
|
-
style: styleAttr
|
|
9
|
+
class: className,
|
|
10
|
+
style: styleAttr,
|
|
12
11
|
's-class': sClass,
|
|
13
12
|
's-style': sStyle,
|
|
14
13
|
...rest
|
|
15
14
|
}: CardActionsProps = $props();
|
|
16
15
|
|
|
17
|
-
let
|
|
18
|
-
|
|
19
|
-
let componentClass = $derived(
|
|
20
|
-
useClassName({
|
|
21
|
-
baseClass: 'kit-card-actions',
|
|
22
|
-
className: `${className ?? ''}`.trim(),
|
|
23
|
-
sClass,
|
|
24
|
-
classProps
|
|
25
|
-
})
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
let componentStyle = $derived(
|
|
29
|
-
useStyles({
|
|
30
|
-
styleAttr,
|
|
31
|
-
sStyle,
|
|
32
|
-
styleProps
|
|
33
|
-
})
|
|
16
|
+
let attrs = $derived(
|
|
17
|
+
useComponentAttrs('kit-card-actions', { className, sClass, styleAttr, sStyle }, rest)
|
|
34
18
|
);
|
|
35
19
|
</script>
|
|
36
20
|
|
|
37
|
-
<svelte:element
|
|
38
|
-
this={is}
|
|
39
|
-
bind:this={ref}
|
|
40
|
-
class={componentClass}
|
|
41
|
-
style={componentStyle}
|
|
42
|
-
{...restProps}
|
|
43
|
-
>
|
|
21
|
+
<svelte:element this={is} bind:this={ref} class={attrs.class} style={attrs.style} {...attrs.rest}>
|
|
44
22
|
{@render children?.()}
|
|
45
23
|
</svelte:element>
|
|
46
24
|
|
|
47
|
-
<style
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
</style>
|
|
25
|
+
<style>.kit-card-actions {
|
|
26
|
+
display: inline-flex;
|
|
27
|
+
align-items: center;
|
|
28
|
+
gap: var(--kit-card-gap);
|
|
29
|
+
}</style>
|