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
|
@@ -1,51 +1,27 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { CardContainerProps } 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
|
}: CardContainerProps = $props();
|
|
16
15
|
|
|
17
|
-
let
|
|
18
|
-
|
|
19
|
-
let componentClass = $derived(
|
|
20
|
-
useClassName({
|
|
21
|
-
baseClass: 'kit-card-container',
|
|
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-container', { 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
|
-
</style>
|
|
25
|
+
<style>.kit-card-container {
|
|
26
|
+
gap: var(--kit-card-gap);
|
|
27
|
+
}</style>
|
|
@@ -1,64 +1,35 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { CardContentProps } 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
|
color,
|
|
15
14
|
...rest
|
|
16
15
|
}: CardContentProps = $props();
|
|
17
16
|
|
|
18
|
-
let
|
|
19
|
-
|
|
20
|
-
let componentClass = $derived(
|
|
21
|
-
useClassName({
|
|
22
|
-
baseClass: 'kit-card-content',
|
|
23
|
-
className: `${className ?? ''}`.trim(),
|
|
24
|
-
sClass,
|
|
25
|
-
classProps
|
|
26
|
-
})
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
let componentStyle = $derived(
|
|
30
|
-
useStyles({
|
|
31
|
-
styleAttr,
|
|
32
|
-
sStyle,
|
|
33
|
-
styleProps
|
|
34
|
-
})
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
let resolvedStyle = $derived(
|
|
38
|
-
[componentStyle, color ? `--kit-card-content-fg:${color && `var(--kit-color-${color})`}` : '']
|
|
39
|
-
.filter(Boolean)
|
|
40
|
-
.join('; ')
|
|
17
|
+
let attrs = $derived(
|
|
18
|
+
useComponentAttrs('kit-card-content', { className, sClass, styleAttr, sStyle, color }, rest)
|
|
41
19
|
);
|
|
42
20
|
</script>
|
|
43
21
|
|
|
44
|
-
<svelte:element
|
|
45
|
-
this={is}
|
|
46
|
-
bind:this={ref}
|
|
47
|
-
class={componentClass}
|
|
48
|
-
style={resolvedStyle}
|
|
49
|
-
{...restProps}
|
|
50
|
-
>
|
|
22
|
+
<svelte:element this={is} bind:this={ref} class={attrs.class} style={attrs.style} {...attrs.rest}>
|
|
51
23
|
{@render children?.()}
|
|
52
24
|
</svelte:element>
|
|
53
25
|
|
|
54
|
-
<style
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
26
|
+
<style>.kit-card-content {
|
|
27
|
+
--kit-card-content-color: initial;
|
|
28
|
+
color: var(--kit-card-content-color, currentColor);
|
|
29
|
+
display: block;
|
|
30
|
+
line-height: 1.45;
|
|
31
|
+
}
|
|
60
32
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
</style>
|
|
33
|
+
.kit-card-content > :global(*) {
|
|
34
|
+
margin: 0;
|
|
35
|
+
}</style>
|
|
@@ -1,52 +1,28 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { CardMediaProps } 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
|
}: CardMediaProps = $props();
|
|
16
15
|
|
|
17
|
-
let
|
|
18
|
-
|
|
19
|
-
let componentClass = $derived(
|
|
20
|
-
useClassName({
|
|
21
|
-
baseClass: 'kit-card-media',
|
|
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-media', { 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
|
-
</style>
|
|
25
|
+
<style>.kit-card-media {
|
|
26
|
+
overflow: hidden;
|
|
27
|
+
border-radius: min(var(--kit-card-radius), max(var(--kit-card-radius) - var(--kit-card-padding), var(--kit-shape-xs)));
|
|
28
|
+
}</style>
|
|
@@ -1,67 +1,38 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { CardTitleProps } 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
|
color,
|
|
15
14
|
...rest
|
|
16
15
|
}: CardTitleProps = $props();
|
|
17
16
|
|
|
18
|
-
let
|
|
19
|
-
|
|
20
|
-
let componentClass = $derived(
|
|
21
|
-
useClassName({
|
|
22
|
-
baseClass: 'kit-card-title',
|
|
23
|
-
className: `${className ?? ''}`.trim(),
|
|
24
|
-
sClass,
|
|
25
|
-
classProps
|
|
26
|
-
})
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
let componentStyle = $derived(
|
|
30
|
-
useStyles({
|
|
31
|
-
styleAttr,
|
|
32
|
-
sStyle,
|
|
33
|
-
styleProps
|
|
34
|
-
})
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
let resolvedStyle = $derived(
|
|
38
|
-
[componentStyle, color ? `--kit-card-title-fg:${color && `var(--kit-color-${color})`}` : '']
|
|
39
|
-
.filter(Boolean)
|
|
40
|
-
.join('; ')
|
|
17
|
+
let attrs = $derived(
|
|
18
|
+
useComponentAttrs('kit-card-title', { className, sClass, styleAttr, sStyle, color }, rest)
|
|
41
19
|
);
|
|
42
20
|
</script>
|
|
43
21
|
|
|
44
|
-
<svelte:element
|
|
45
|
-
this={is}
|
|
46
|
-
bind:this={ref}
|
|
47
|
-
class={componentClass}
|
|
48
|
-
style={resolvedStyle}
|
|
49
|
-
{...restProps}
|
|
50
|
-
>
|
|
22
|
+
<svelte:element this={is} bind:this={ref} class={attrs.class} style={attrs.style} {...attrs.rest}>
|
|
51
23
|
{@render children?.()}
|
|
52
24
|
</svelte:element>
|
|
53
25
|
|
|
54
|
-
<style
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
</style>
|
|
26
|
+
<style>.kit-card-title {
|
|
27
|
+
--kit-card-title-color: initial;
|
|
28
|
+
display: flex;
|
|
29
|
+
align-items: center;
|
|
30
|
+
gap: var(--kit-card-gap);
|
|
31
|
+
color: var(--kit-card-title-color, currentColor);
|
|
32
|
+
font-weight: 600;
|
|
33
|
+
line-height: 1.3;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.kit-card-title > :global(*) {
|
|
37
|
+
margin: 0;
|
|
38
|
+
}</style>
|
|
@@ -3,10 +3,15 @@
|
|
|
3
3
|
* Sheet component
|
|
4
4
|
* @description A simple sheet component for experimentation for developers Lapikit. Please don't use it in production.
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
import {
|
|
6
|
+
import { useComponentAttrs, useElevation, useIsInteractive } from '../../utils';
|
|
7
|
+
import { ripple } from '../../animations';
|
|
8
|
+
import type { SheetProps } from './sheet.types.js';
|
|
8
9
|
|
|
9
10
|
let {
|
|
11
|
+
ref = $bindable(),
|
|
12
|
+
is = 'div',
|
|
13
|
+
href,
|
|
14
|
+
type,
|
|
10
15
|
class: className,
|
|
11
16
|
style: styleAttr,
|
|
12
17
|
children,
|
|
@@ -14,47 +19,201 @@
|
|
|
14
19
|
's-style': sStyle,
|
|
15
20
|
elevation,
|
|
16
21
|
rounded,
|
|
22
|
+
density = 'default',
|
|
23
|
+
variant = 'filled',
|
|
17
24
|
active,
|
|
25
|
+
color,
|
|
26
|
+
interactive,
|
|
27
|
+
disabled = false,
|
|
28
|
+
noRipple,
|
|
18
29
|
...rest
|
|
19
|
-
} = $props();
|
|
30
|
+
}: SheetProps = $props();
|
|
20
31
|
|
|
32
|
+
// states
|
|
21
33
|
let attrs = $derived(
|
|
22
|
-
useComponentAttrs('kit-sheet', { className, sClass, styleAttr, sStyle }, rest)
|
|
34
|
+
useComponentAttrs('kit-sheet', { className, sClass, styleAttr, sStyle, color, active }, rest)
|
|
23
35
|
);
|
|
24
|
-
|
|
25
36
|
let elevationState = $derived(useElevation(elevation));
|
|
37
|
+
let tag = $derived((href && 'a') || is);
|
|
38
|
+
// undefined: detected (a, button, onclick...), true: forced, false: no visual feedback (still clickable)
|
|
39
|
+
let isInteractive = $derived(interactive ?? useIsInteractive(rest, tag, ['a', 'button']));
|
|
40
|
+
let isDisabled = $derived(!!disabled);
|
|
41
|
+
let resolvedHref = $derived(tag === 'a' && !isDisabled ? href : undefined);
|
|
42
|
+
let resolvedType = $derived(tag === 'button' ? (type ?? 'button') : undefined);
|
|
43
|
+
let resolvedDisabled = $derived(tag === 'button' ? isDisabled : undefined);
|
|
44
|
+
let resolvedTabIndex = $derived(tag === 'a' && isDisabled ? -1 : undefined);
|
|
26
45
|
</script>
|
|
27
46
|
|
|
28
|
-
<
|
|
47
|
+
<svelte:element
|
|
48
|
+
this={tag}
|
|
49
|
+
bind:this={ref}
|
|
29
50
|
class={attrs.class}
|
|
30
51
|
style={attrs.style}
|
|
52
|
+
href={resolvedHref}
|
|
53
|
+
type={resolvedType}
|
|
54
|
+
disabled={resolvedDisabled}
|
|
55
|
+
tabindex={resolvedTabIndex}
|
|
31
56
|
data-rounded={rounded}
|
|
57
|
+
data-density={density}
|
|
58
|
+
data-variant={variant}
|
|
32
59
|
data-elevation={elevationState.base}
|
|
33
60
|
data-elevation-hover={elevationState.hover}
|
|
34
61
|
data-elevation-active={elevationState.active}
|
|
35
62
|
data-active={active}
|
|
63
|
+
data-interactive={isInteractive}
|
|
64
|
+
data-disabled={isDisabled}
|
|
65
|
+
aria-disabled={isDisabled || undefined}
|
|
66
|
+
use:ripple={{
|
|
67
|
+
component: 'sheet',
|
|
68
|
+
disabled: noRipple || isDisabled || !isInteractive
|
|
69
|
+
}}
|
|
36
70
|
{...attrs.rest}
|
|
37
71
|
>
|
|
38
|
-
{@render children()}
|
|
39
|
-
</
|
|
72
|
+
{@render children?.()}
|
|
73
|
+
</svelte:element>
|
|
40
74
|
|
|
41
75
|
<style>.kit-sheet {
|
|
76
|
+
--kit-sheet-color: initial;
|
|
77
|
+
--kit-sheet-on-color: initial;
|
|
78
|
+
--kit-sheet-active-fg: initial;
|
|
79
|
+
--kit-sheet-active-shade: initial;
|
|
80
|
+
--kit-sheet-hover-fg: initial;
|
|
81
|
+
--kit-sheet-pressed-fg: initial;
|
|
82
|
+
--kit-sheet-bg: var(--kit-sheet-color, var(--kit-color-surface-1));
|
|
83
|
+
--kit-sheet-fg: var(--kit-sheet-on-color, var(--kit-sheet-contrast, var(--kit-color-text)));
|
|
84
|
+
--kit-sheet-ink: var(--kit-sheet-color, var(--kit-color-text));
|
|
85
|
+
--kit-sheet-hover: color-mix(in oklab, var(--kit-sheet-bg), var(--kit-sheet-fg) 8%);
|
|
86
|
+
--kit-sheet-pressed: color-mix(in oklab, var(--kit-sheet-bg), var(--kit-sheet-fg) 14%);
|
|
87
|
+
--kit-sheet-soft: color-mix(in oklab, var(--kit-sheet-bg) 16%, transparent);
|
|
88
|
+
--kit-sheet-border: color-mix(in oklab, var(--kit-sheet-bg), var(--kit-sheet-fg) 20%);
|
|
89
|
+
--kit-sheet-active: color-mix(
|
|
90
|
+
in oklab,
|
|
91
|
+
var(--kit-sheet-color),
|
|
92
|
+
var(--kit-sheet-fg) var(--kit-sheet-active-shade, 14%)
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
@supports (color: color(from red srgb-linear r g b)) {
|
|
96
|
+
.kit-sheet {
|
|
97
|
+
--kit-sheet-contrast: color(from var(--kit-sheet-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);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
.kit-sheet {
|
|
101
|
+
--kit-sheet-p: 12px;
|
|
42
102
|
display: flex;
|
|
43
|
-
|
|
44
|
-
|
|
103
|
+
position: relative;
|
|
104
|
+
gap: calc(var(--kit-space-default) + var(--kit-sheet-density-offset) / 2);
|
|
105
|
+
padding: calc(var(--kit-sheet-p) + var(--kit-sheet-density-offset) / 2);
|
|
106
|
+
background-color: var(--kit-sheet-bg);
|
|
107
|
+
color: var(--kit-sheet-fg);
|
|
45
108
|
border-radius: var(--kit-sheet-radius);
|
|
109
|
+
transition-property: background-color, color, border-color, box-shadow;
|
|
110
|
+
transition-duration: var(--kit-animation-component);
|
|
111
|
+
transition-timing-function: ease;
|
|
112
|
+
}
|
|
113
|
+
@media (prefers-reduced-motion: reduce) {
|
|
114
|
+
.kit-sheet {
|
|
115
|
+
transition: none;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/* native resets: no background here, it would beat the background of .kit-sheet */
|
|
120
|
+
a.kit-sheet {
|
|
121
|
+
text-decoration: none;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
button.kit-sheet {
|
|
125
|
+
appearance: none;
|
|
126
|
+
border: 0;
|
|
127
|
+
padding: 0;
|
|
128
|
+
font: inherit;
|
|
129
|
+
text-align: inherit;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.kit-sheet[data-variant=tonal] {
|
|
133
|
+
--kit-sheet-bg: color-mix(in oklab, var(--kit-sheet-ink) 16%, transparent);
|
|
134
|
+
--kit-sheet-fg: var(--kit-sheet-ink);
|
|
135
|
+
--kit-sheet-border: transparent;
|
|
136
|
+
--kit-sheet-active: color-mix(in oklab, var(--kit-sheet-ink) 28%, transparent);
|
|
137
|
+
--kit-sheet-active-fg: var(--kit-sheet-ink);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.kit-sheet[data-variant=text] {
|
|
141
|
+
--kit-sheet-bg: transparent;
|
|
142
|
+
--kit-sheet-fg: var(--kit-sheet-ink);
|
|
143
|
+
--kit-sheet-border: transparent;
|
|
144
|
+
--kit-sheet-active: color-mix(in oklab, var(--kit-sheet-ink) 14%, transparent);
|
|
145
|
+
--kit-sheet-active-fg: var(--kit-sheet-ink);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.kit-sheet[data-variant=plain] {
|
|
149
|
+
--kit-sheet-bg: transparent;
|
|
150
|
+
--kit-sheet-fg: var(--kit-sheet-ink);
|
|
151
|
+
--kit-sheet-border: transparent;
|
|
152
|
+
--kit-sheet-hover: transparent;
|
|
153
|
+
--kit-sheet-pressed: transparent;
|
|
154
|
+
--kit-sheet-hover-fg: color-mix(in oklab, var(--kit-sheet-fg) 72%, transparent);
|
|
155
|
+
--kit-sheet-pressed-fg: color-mix(in oklab, var(--kit-sheet-fg) 56%, transparent);
|
|
156
|
+
--kit-sheet-active: transparent;
|
|
157
|
+
--kit-sheet-active-fg: var(--kit-sheet-color, var(--kit-color-accent));
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.kit-sheet[data-variant=outline] {
|
|
161
|
+
--kit-sheet-bg: transparent;
|
|
162
|
+
--kit-sheet-fg: var(--kit-sheet-ink);
|
|
163
|
+
--kit-sheet-border: var(--kit-sheet-color, var(--kit-color-border));
|
|
164
|
+
--kit-sheet-active: color-mix(in oklab, var(--kit-sheet-ink) 14%, transparent);
|
|
165
|
+
--kit-sheet-active-fg: var(--kit-sheet-ink);
|
|
166
|
+
border: var(--kit-outline-weight) solid var(--kit-sheet-border);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
.kit-sheet[data-variant=surface] {
|
|
170
|
+
--kit-sheet-bg: color-mix(in oklab, var(--kit-sheet-ink) 8%, transparent);
|
|
171
|
+
--kit-sheet-fg: var(--kit-sheet-ink);
|
|
172
|
+
--kit-sheet-border: color-mix(in oklab, var(--kit-sheet-ink) 35%, transparent);
|
|
173
|
+
--kit-sheet-active: color-mix(in oklab, var(--kit-sheet-ink) 18%, transparent);
|
|
174
|
+
--kit-sheet-active-fg: var(--kit-sheet-ink);
|
|
175
|
+
border: var(--kit-outline-weight) solid var(--kit-sheet-border);
|
|
46
176
|
}
|
|
47
177
|
|
|
48
178
|
.kit-sheet[data-active=true] {
|
|
49
|
-
|
|
50
|
-
|
|
179
|
+
--kit-sheet-bg: var(--kit-sheet-active, var(--kit-color-accent));
|
|
180
|
+
--kit-sheet-fg: var(
|
|
181
|
+
--kit-sheet-active-fg,
|
|
182
|
+
var(--kit-sheet-on-color, var(--kit-sheet-contrast, var(--kit-color-on-accent)))
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* interactive: hover, pressed, focus-visible and disabled
|
|
188
|
+
*/
|
|
189
|
+
.kit-sheet[data-interactive=true]:not([data-disabled=true]) {
|
|
190
|
+
cursor: pointer;
|
|
191
|
+
}
|
|
192
|
+
.kit-sheet[data-interactive=true]:not([data-disabled=true]):hover {
|
|
193
|
+
background-color: var(--kit-sheet-hover);
|
|
194
|
+
color: var(--kit-sheet-hover-fg, var(--kit-sheet-fg));
|
|
195
|
+
}
|
|
196
|
+
.kit-sheet[data-interactive=true]:not([data-disabled=true]):active {
|
|
197
|
+
background-color: var(--kit-sheet-pressed);
|
|
198
|
+
color: var(--kit-sheet-pressed-fg, var(--kit-sheet-fg));
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
.kit-sheet:not([data-disabled=true]):focus-visible {
|
|
202
|
+
outline: 2px solid var(--kit-color-focus);
|
|
203
|
+
outline-offset: 2px;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
.kit-sheet[data-disabled=true] {
|
|
207
|
+
opacity: var(--kit-disabled-opacity, 0.55);
|
|
208
|
+
pointer-events: none;
|
|
209
|
+
user-select: none;
|
|
51
210
|
}
|
|
52
211
|
|
|
53
212
|
/**
|
|
54
213
|
* rounded
|
|
55
214
|
* @link https://lapikit.dev/docs/customize
|
|
56
215
|
*/
|
|
57
|
-
.kit-sheet[data-rounded=
|
|
216
|
+
.kit-sheet[data-rounded="0"] {
|
|
58
217
|
--kit-sheet-radius: var(--kit-shape-none);
|
|
59
218
|
}
|
|
60
219
|
|
|
@@ -80,4 +239,28 @@
|
|
|
80
239
|
|
|
81
240
|
.kit-sheet[data-rounded=full] {
|
|
82
241
|
--kit-sheet-radius: var(--kit-shape-full);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* density
|
|
246
|
+
* @link https://lapikit.dev/docs/customize
|
|
247
|
+
*/
|
|
248
|
+
.kit-sheet[data-density=dense] {
|
|
249
|
+
--kit-sheet-density-offset: var(--kit-density-dense);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
.kit-sheet[data-density=compact] {
|
|
253
|
+
--kit-sheet-density-offset: var(--kit-density-compact);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
.kit-sheet[data-density=default] {
|
|
257
|
+
--kit-sheet-density-offset: var(--kit-density-default);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
.kit-sheet[data-density=comfortable] {
|
|
261
|
+
--kit-sheet-density-offset: var(--kit-density-comfortable);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
.kit-sheet[data-density=spacious] {
|
|
265
|
+
--kit-sheet-density-offset: var(--kit-density-spacious);
|
|
83
266
|
}</style>
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
style: any;
|
|
4
|
-
children: any;
|
|
5
|
-
elevation: any;
|
|
6
|
-
rounded: any;
|
|
7
|
-
active: any;
|
|
8
|
-
} & Record<string, any>, {}, "">;
|
|
1
|
+
import type { SheetProps } from './sheet.types.ts';
|
|
2
|
+
declare const Sheet: import("svelte").Component<SheetProps, {}, "ref">;
|
|
9
3
|
type Sheet = ReturnType<typeof Sheet>;
|
|
10
4
|
export default Sheet;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ColorProps, Component, ElevationProps, RoundedType } from '../../@types';
|
|
2
|
+
export interface SheetProps extends Component {
|
|
3
|
+
ref?: HTMLElement | null;
|
|
4
|
+
is?: 'div' | 'article' | 'section' | 'aside' | 'a' | 'button';
|
|
5
|
+
href?: string;
|
|
6
|
+
type?: 'button' | 'submit' | 'reset';
|
|
7
|
+
variant?: 'filled' | 'tonal' | 'outline' | 'text' | 'plain' | 'surface';
|
|
8
|
+
rounded?: RoundedType | 'full';
|
|
9
|
+
density?: 'dense' | 'compact' | 'default' | 'comfortable' | 'spacious';
|
|
10
|
+
elevation?: ElevationProps;
|
|
11
|
+
active?: boolean;
|
|
12
|
+
color?: ColorProps;
|
|
13
|
+
interactive?: boolean;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
noRipple?: boolean;
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ColorProps } from '../@types';
|
|
2
|
+
export declare function resolveColor(color: string | null | undefined): string | undefined;
|
|
3
|
+
export declare function resolveOnColor(color: string | null | undefined): string | undefined;
|
|
4
|
+
export declare function colorStyle(name: string, color: ColorProps | null | undefined, active?: boolean): string;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { DEV } from 'esm-env';
|
|
2
|
+
const paletteName = /^[a-zA-Z][\w-]*$/;
|
|
3
|
+
const unsafe = /[;{}]/;
|
|
4
|
+
function clean(color) {
|
|
5
|
+
const value = color?.trim();
|
|
6
|
+
if (!value)
|
|
7
|
+
return undefined;
|
|
8
|
+
if (unsafe.test(value)) {
|
|
9
|
+
if (DEV)
|
|
10
|
+
console.warn(`[lapikit] color "${value}" is ignored: it cannot hold ; { or }`);
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
return value;
|
|
14
|
+
}
|
|
15
|
+
export function resolveColor(color) {
|
|
16
|
+
const value = clean(color);
|
|
17
|
+
if (!value)
|
|
18
|
+
return undefined;
|
|
19
|
+
return paletteName.test(value) ? `var(--kit-color-${value}, ${value})` : value;
|
|
20
|
+
}
|
|
21
|
+
export function resolveOnColor(color) {
|
|
22
|
+
const value = clean(color);
|
|
23
|
+
if (!value || !paletteName.test(value))
|
|
24
|
+
return undefined;
|
|
25
|
+
return `var(--kit-color-on-${value})`;
|
|
26
|
+
}
|
|
27
|
+
export function colorStyle(name, color, active = false) {
|
|
28
|
+
const exact = active && typeof color === 'object' && !!clean(color?.active);
|
|
29
|
+
const current = typeof color === 'object' ? (exact ? color?.active : color?.base) : color;
|
|
30
|
+
const value = resolveColor(current);
|
|
31
|
+
if (!name || !value)
|
|
32
|
+
return '';
|
|
33
|
+
const styles = [`--${name}-color: ${value}`];
|
|
34
|
+
const onColor = resolveOnColor(current);
|
|
35
|
+
if (onColor)
|
|
36
|
+
styles.push(`--${name}-on-color: ${onColor}`);
|
|
37
|
+
if (exact)
|
|
38
|
+
styles.push(`--${name}-active-shade: 0%`);
|
|
39
|
+
return styles.join('; ');
|
|
40
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ComponentAttrs, ElevationProps, ElevationState, PropValue, SStyleProp, useClassNameProps, useStylesProps } from '../@types';
|
|
1
|
+
import type { ColorProps, ComponentAttrs, ElevationProps, ElevationState, PropValue, SStyleProp, useClassNameProps, useStylesProps } from '../@types';
|
|
2
2
|
import type { ClassValue } from 'svelte/elements';
|
|
3
3
|
/**
|
|
4
4
|
* The classes of the s-class_xxx directives (class:xxx on a kit tag):
|
|
@@ -42,13 +42,19 @@ export declare function useElevation(elevation?: ElevationProps | null): Elevati
|
|
|
42
42
|
* ({ active: isActive } -> active). The s-class_xxx directives (class:xxx on a kit tag) keep their
|
|
43
43
|
* rule: class:gap={4} -> gap-4.
|
|
44
44
|
*
|
|
45
|
-
* @param baseClass - The class of the component ('kit-btn
|
|
46
|
-
*
|
|
45
|
+
* @param baseClass - The class of the component ('kit-btn'), '' for none.
|
|
46
|
+
* The color prop gives the --{baseClass}-color / --{baseClass}-on-color variables, read by the
|
|
47
|
+
* color mixin; they come before the style, so the style attribute still wins.
|
|
48
|
+
* With { base, active }, active picks the color of the active state.
|
|
49
|
+
*
|
|
50
|
+
* @param props - The class, s-class, style, s-style, color and active props of the component.
|
|
47
51
|
* @param rest - The rest of the props: the s-class_xxx / s-style_xxx directives are taken out of it.
|
|
48
52
|
*/
|
|
49
|
-
export declare function useComponentAttrs(baseClass: string, { className, sClass, styleAttr, sStyle }: {
|
|
53
|
+
export declare function useComponentAttrs(baseClass: string, { className, sClass, styleAttr, sStyle, color, active }: {
|
|
50
54
|
className?: ClassValue;
|
|
51
55
|
sClass?: ClassValue;
|
|
52
56
|
styleAttr?: string;
|
|
53
57
|
sStyle?: SStyleProp;
|
|
58
|
+
color?: ColorProps | null;
|
|
59
|
+
active?: boolean;
|
|
54
60
|
}, rest: Record<string, unknown>): ComponentAttrs;
|