@streamscloud/kit 0.94.6 → 0.94.8
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,39 +1,36 @@
|
|
|
1
|
-
<script lang="ts">
|
|
1
|
+
<script lang="ts">import { on as listen } from 'svelte/events';
|
|
2
|
+
const { elevation = 'flat', padding = 'md', header, footer, children, on } = $props();
|
|
2
3
|
const interactive = $derived(!!on?.click);
|
|
3
|
-
|
|
4
|
+
const contentId = $props.id();
|
|
5
|
+
const forwardClicks = (element) => listen(element, 'click', () => on?.click?.());
|
|
4
6
|
</script>
|
|
5
7
|
|
|
6
|
-
{
|
|
8
|
+
<div class="card card--{elevation} card--pad-{padding}" class:card--interactive={interactive} {@attach interactive && forwardClicks}>
|
|
9
|
+
{#if interactive}
|
|
10
|
+
<button type="button" class="card__activator" aria-labelledby={contentId}></button>
|
|
11
|
+
{/if}
|
|
7
12
|
{#if header}<div class="card__header">{@render header()}</div>{/if}
|
|
8
|
-
<div class="card__body">{@render children()}</div>
|
|
13
|
+
<div id={contentId} class="card__body">{@render children()}</div>
|
|
9
14
|
{#if footer}<div class="card__footer">{@render footer()}</div>{/if}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
{#if interactive}
|
|
13
|
-
<button type="button" class="card card--{elevation} card--pad-{padding} card--interactive" onclick={() => on?.click?.()}>
|
|
14
|
-
{@render inner()}
|
|
15
|
-
</button>
|
|
16
|
-
{:else}
|
|
17
|
-
<div class="card card--{elevation} card--pad-{padding}">
|
|
18
|
-
{@render inner()}
|
|
19
|
-
</div>
|
|
20
|
-
{/if}
|
|
15
|
+
</div>
|
|
21
16
|
|
|
22
17
|
<!--
|
|
23
18
|
@component
|
|
24
19
|
Container surface with border, panel background, and rounded corners. Optional `header` and `footer`
|
|
25
|
-
snippets render in chrome with their own dividers. Pass `on.click` to
|
|
26
|
-
|
|
20
|
+
snippets render in chrome with their own dividers. Pass `on.click` to make the whole card a clickable
|
|
21
|
+
target with hover and focus state; controls inside it (a `Checkbox`, links) keep working.
|
|
22
|
+
When a parent stretches the card (a grid row, a flex row), the body takes the free height, so body
|
|
23
|
+
content with `block-size: 100%` can pin its own bottom row.
|
|
27
24
|
|
|
28
25
|
### CSS Custom Properties
|
|
29
26
|
| Property | Description | Default |
|
|
30
27
|
|---|---|---|
|
|
31
28
|
| `--sc-kit--card--background` | Body background | `var(--sc-kit--color--bg--panel)` |
|
|
32
29
|
| `--sc-kit--card--border-color` | Border color | `var(--sc-kit--color--border)` |
|
|
33
|
-
| `--sc-kit--card--border-color--hover` | Border color
|
|
30
|
+
| `--sc-kit--card--border-color--hover` | Border color of a clickable card on hover | `var(--sc-kit--color--border--strong)` |
|
|
34
31
|
| `--sc-kit--card--border-radius` | Border radius | `var(--sc-kit--radius--lg)` |
|
|
35
32
|
| `--sc-kit--card--shadow` | Box-shadow on `elevation='raised'` | `var(--sc-kit--shadow--md)` |
|
|
36
|
-
| `--sc-kit--card--shadow--hover` | Box-shadow
|
|
33
|
+
| `--sc-kit--card--shadow--hover` | Box-shadow of a clickable card on hover | `var(--sc-kit--shadow--sm)` |
|
|
37
34
|
| `--sc-kit--card--color` | Body text color | `var(--sc-kit--color--text--primary)` |
|
|
38
35
|
| `--sc-kit--card--header--background` | Header bar background | `transparent` |
|
|
39
36
|
| `--sc-kit--card--header--border-color` | Header bottom divider | `var(--sc-kit--color--border)` |
|
|
@@ -59,7 +56,8 @@ whole card becomes a clickable target with hover and focus state, no `interactiv
|
|
|
59
56
|
--_card--header-padding: var(--sc-kit--card--header--padding, var(--sc-kit--space--3) var(--_card--chrome-padding-inline));
|
|
60
57
|
--_card--body-padding: var(--sc-kit--card--body--padding, var(--_card--body-padding-default));
|
|
61
58
|
--_card--footer-padding: var(--sc-kit--card--footer--padding, var(--sc-kit--space--3) var(--_card--chrome-padding-inline));
|
|
62
|
-
display:
|
|
59
|
+
display: flex;
|
|
60
|
+
flex-direction: column;
|
|
63
61
|
width: 100%;
|
|
64
62
|
box-sizing: border-box;
|
|
65
63
|
background: var(--_card--background);
|
|
@@ -89,6 +87,8 @@ whole card becomes a clickable target with hover and focus state, no `interactiv
|
|
|
89
87
|
--_card--chrome-padding-inline: var(--sc-kit--space--6);
|
|
90
88
|
}
|
|
91
89
|
.card__body {
|
|
90
|
+
flex: 1 1 0%;
|
|
91
|
+
min-height: 0;
|
|
92
92
|
padding: var(--_card--body-padding);
|
|
93
93
|
}
|
|
94
94
|
.card__header {
|
|
@@ -102,16 +102,24 @@ whole card becomes a clickable target with hover and focus state, no `interactiv
|
|
|
102
102
|
border-top: 1px solid var(--_card--footer-border-color);
|
|
103
103
|
}
|
|
104
104
|
.card--interactive {
|
|
105
|
+
position: relative;
|
|
105
106
|
cursor: pointer;
|
|
106
|
-
font-family: inherit;
|
|
107
|
-
font-size: inherit;
|
|
108
107
|
transition: border-color var(--sc-kit--duration--base) var(--sc-kit--ease--default), box-shadow var(--sc-kit--duration--base) var(--sc-kit--ease--default);
|
|
109
108
|
}
|
|
110
109
|
.card--interactive:hover {
|
|
111
110
|
--sc-kit--card--border-color: var(--_card--border-color-hover);
|
|
112
111
|
box-shadow: var(--_card--shadow-hover);
|
|
113
112
|
}
|
|
114
|
-
.
|
|
113
|
+
.card__activator {
|
|
114
|
+
position: absolute;
|
|
115
|
+
inset: 0;
|
|
116
|
+
padding: 0;
|
|
117
|
+
background: transparent;
|
|
118
|
+
border: none;
|
|
119
|
+
border-radius: inherit;
|
|
120
|
+
pointer-events: none;
|
|
121
|
+
}
|
|
122
|
+
.card__activator:focus-visible {
|
|
115
123
|
outline: 2px solid var(--sc-kit--color--border--focus);
|
|
116
|
-
outline-offset: 2px;
|
|
124
|
+
outline-offset: -2px;
|
|
117
125
|
}</style>
|
|
@@ -10,8 +10,9 @@ type Props = {
|
|
|
10
10
|
footer?: Snippet;
|
|
11
11
|
children: Snippet;
|
|
12
12
|
/**
|
|
13
|
-
* Presence of `on.click`
|
|
14
|
-
*
|
|
13
|
+
* Presence of `on.click` makes the whole card clickable, with hover/focus states and a keyboard-reachable
|
|
14
|
+
* activator button. Interactive content inside keeps working; a nested control that must not also
|
|
15
|
+
* trigger the card stops propagation of its own click.
|
|
15
16
|
*/
|
|
16
17
|
on?: {
|
|
17
18
|
click?: () => void;
|
|
@@ -19,18 +20,20 @@ type Props = {
|
|
|
19
20
|
};
|
|
20
21
|
/**
|
|
21
22
|
* Container surface with border, panel background, and rounded corners. Optional `header` and `footer`
|
|
22
|
-
* snippets render in chrome with their own dividers. Pass `on.click` to
|
|
23
|
-
*
|
|
23
|
+
* snippets render in chrome with their own dividers. Pass `on.click` to make the whole card a clickable
|
|
24
|
+
* target with hover and focus state; controls inside it (a `Checkbox`, links) keep working.
|
|
25
|
+
* When a parent stretches the card (a grid row, a flex row), the body takes the free height, so body
|
|
26
|
+
* content with `block-size: 100%` can pin its own bottom row.
|
|
24
27
|
*
|
|
25
28
|
* ### CSS Custom Properties
|
|
26
29
|
* | Property | Description | Default |
|
|
27
30
|
* |---|---|---|
|
|
28
31
|
* | `--sc-kit--card--background` | Body background | `var(--sc-kit--color--bg--panel)` |
|
|
29
32
|
* | `--sc-kit--card--border-color` | Border color | `var(--sc-kit--color--border)` |
|
|
30
|
-
* | `--sc-kit--card--border-color--hover` | Border color
|
|
33
|
+
* | `--sc-kit--card--border-color--hover` | Border color of a clickable card on hover | `var(--sc-kit--color--border--strong)` |
|
|
31
34
|
* | `--sc-kit--card--border-radius` | Border radius | `var(--sc-kit--radius--lg)` |
|
|
32
35
|
* | `--sc-kit--card--shadow` | Box-shadow on `elevation='raised'` | `var(--sc-kit--shadow--md)` |
|
|
33
|
-
* | `--sc-kit--card--shadow--hover` | Box-shadow
|
|
36
|
+
* | `--sc-kit--card--shadow--hover` | Box-shadow of a clickable card on hover | `var(--sc-kit--shadow--sm)` |
|
|
34
37
|
* | `--sc-kit--card--color` | Body text color | `var(--sc-kit--color--text--primary)` |
|
|
35
38
|
* | `--sc-kit--card--header--background` | Header bar background | `transparent` |
|
|
36
39
|
* | `--sc-kit--card--header--border-color` | Header bottom divider | `var(--sc-kit--color--border)` |
|