@streamscloud/kit 0.94.7 → 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,29 +1,24 @@
1
- <script lang="ts">const { elevation = 'flat', padding = 'md', header, footer, children, on } = $props();
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
- export {};
4
+ const contentId = $props.id();
5
+ const forwardClicks = (element) => listen(element, 'click', () => on?.click?.());
4
6
  </script>
5
7
 
6
- {#snippet inner()}
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
- {/snippet}
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 switch to button-mode — the
26
- whole card becomes a clickable target with hover and focus state, no `interactive` flag needed.
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.
27
22
  When a parent stretches the card (a grid row, a flex row), the body takes the free height, so body
28
23
  content with `block-size: 100%` can pin its own bottom row.
29
24
 
@@ -32,10 +27,10 @@ content with `block-size: 100%` can pin its own bottom row.
32
27
  |---|---|---|
33
28
  | `--sc-kit--card--background` | Body background | `var(--sc-kit--color--bg--panel)` |
34
29
  | `--sc-kit--card--border-color` | Border color | `var(--sc-kit--color--border)` |
35
- | `--sc-kit--card--border-color--hover` | Border color in button-mode on hover | `var(--sc-kit--color--border--strong)` |
30
+ | `--sc-kit--card--border-color--hover` | Border color of a clickable card on hover | `var(--sc-kit--color--border--strong)` |
36
31
  | `--sc-kit--card--border-radius` | Border radius | `var(--sc-kit--radius--lg)` |
37
32
  | `--sc-kit--card--shadow` | Box-shadow on `elevation='raised'` | `var(--sc-kit--shadow--md)` |
38
- | `--sc-kit--card--shadow--hover` | Box-shadow in button-mode on hover | `var(--sc-kit--shadow--sm)` |
33
+ | `--sc-kit--card--shadow--hover` | Box-shadow of a clickable card on hover | `var(--sc-kit--shadow--sm)` |
39
34
  | `--sc-kit--card--color` | Body text color | `var(--sc-kit--color--text--primary)` |
40
35
  | `--sc-kit--card--header--background` | Header bar background | `transparent` |
41
36
  | `--sc-kit--card--header--border-color` | Header bottom divider | `var(--sc-kit--color--border)` |
@@ -107,16 +102,24 @@ content with `block-size: 100%` can pin its own bottom row.
107
102
  border-top: 1px solid var(--_card--footer-border-color);
108
103
  }
109
104
  .card--interactive {
105
+ position: relative;
110
106
  cursor: pointer;
111
- font-family: inherit;
112
- font-size: inherit;
113
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);
114
108
  }
115
109
  .card--interactive:hover {
116
110
  --sc-kit--card--border-color: var(--_card--border-color-hover);
117
111
  box-shadow: var(--_card--shadow-hover);
118
112
  }
119
- .card--interactive:focus-visible {
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 {
120
123
  outline: 2px solid var(--sc-kit--color--border--focus);
121
- outline-offset: 2px;
124
+ outline-offset: -2px;
122
125
  }</style>
@@ -10,8 +10,9 @@ type Props = {
10
10
  footer?: Snippet;
11
11
  children: Snippet;
12
12
  /**
13
- * Presence of `on.click` switches the card to button-mode: rendered as `<button type="button">`,
14
- * gains hover/focus states. Without it the card is a plain `<div>`.
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,8 +20,8 @@ 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 switch to button-mode — the
23
- * whole card becomes a clickable target with hover and focus state, no `interactive` flag needed.
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.
24
25
  * When a parent stretches the card (a grid row, a flex row), the body takes the free height, so body
25
26
  * content with `block-size: 100%` can pin its own bottom row.
26
27
  *
@@ -29,10 +30,10 @@ type Props = {
29
30
  * |---|---|---|
30
31
  * | `--sc-kit--card--background` | Body background | `var(--sc-kit--color--bg--panel)` |
31
32
  * | `--sc-kit--card--border-color` | Border color | `var(--sc-kit--color--border)` |
32
- * | `--sc-kit--card--border-color--hover` | Border color in button-mode on hover | `var(--sc-kit--color--border--strong)` |
33
+ * | `--sc-kit--card--border-color--hover` | Border color of a clickable card on hover | `var(--sc-kit--color--border--strong)` |
33
34
  * | `--sc-kit--card--border-radius` | Border radius | `var(--sc-kit--radius--lg)` |
34
35
  * | `--sc-kit--card--shadow` | Box-shadow on `elevation='raised'` | `var(--sc-kit--shadow--md)` |
35
- * | `--sc-kit--card--shadow--hover` | Box-shadow in button-mode on hover | `var(--sc-kit--shadow--sm)` |
36
+ * | `--sc-kit--card--shadow--hover` | Box-shadow of a clickable card on hover | `var(--sc-kit--shadow--sm)` |
36
37
  * | `--sc-kit--card--color` | Body text color | `var(--sc-kit--color--text--primary)` |
37
38
  * | `--sc-kit--card--header--background` | Header bar background | `transparent` |
38
39
  * | `--sc-kit--card--header--border-color` | Header bottom divider | `var(--sc-kit--color--border)` |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamscloud/kit",
3
- "version": "0.94.7",
3
+ "version": "0.94.8",
4
4
  "author": "StreamsCloud",
5
5
  "repository": {
6
6
  "type": "git",