@threadlabs/looma 0.45.0 → 0.45.1

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.
@@ -2,22 +2,32 @@
2
2
  <defs>
3
3
  <prop name="heading" type="string" default=""
4
4
  >The section's heading, an h2. Leave it empty for a section with no visible heading, and name the section with aria-label.</prop>
5
- <prop name="variant" type="keyword" values="plain, card, divided" default="plain"
5
+ <prop name="variant" type="keyword" values="plain, card, divided, fieldset" default="plain"
6
6
  >How the section is set apart. plain is a heading and content in the flow of the page; card sits it on a bordered surface, for a settings group; divided
7
- rules it off from the section before it, for a long form.</prop>
7
+ rules it off from the section before it, for a long form. fieldset joins the heading to a bordered frame using a native legend.</prop>
8
8
  <prop name="tone" type="keyword" values="neutral, danger" default="neutral"
9
- >danger marks a section of destructive actions (a danger zone): its heading and a card's border take the danger colour.</prop>
9
+ >danger marks a section of destructive actions (a danger zone): its heading and a framed section's border take the danger colour.</prop>
10
10
  </defs>
11
- <section>
12
- <span class="head">
13
- <span class="copy">
14
- <h2 class="heading" from:hidden="not $heading">{$heading}</h2>
15
- <span class="description"><slot name="description"></slot></span>
11
+ <template $match>
12
+ <fieldset $when="$variant = 'fieldset'">
13
+ <legend class="legend" from:hidden="not $heading"><h2 class="heading">{$heading}</h2></legend>
14
+ <span class="head">
15
+ <span class="copy"><span class="description"><slot name="description"></slot></span></span>
16
+ <span class="actions"><slot name="actions"></slot></span>
16
17
  </span>
17
- <span class="actions"><slot name="actions"></slot></span>
18
- </span>
19
- <span class="body"><slot></slot></span>
20
- </section>
18
+ <span class="body"><slot></slot></span>
19
+ </fieldset>
20
+ <section $else>
21
+ <span class="head">
22
+ <span class="copy">
23
+ <h2 class="heading" from:hidden="not $heading">{$heading}</h2>
24
+ <span class="description"><slot name="description"></slot></span>
25
+ </span>
26
+ <span class="actions"><slot name="actions"></slot></span>
27
+ </span>
28
+ <span class="body"><slot></slot></span>
29
+ </section>
30
+ </template>
21
31
  <style>
22
32
  /* A part of a view: a heading, an optional line under it, actions for the whole section at its
23
33
  end, and the content. Sections space themselves out through the Stack around them. */
@@ -28,7 +38,8 @@
28
38
  min-inline-size: 0;
29
39
  }
30
40
 
31
- :host([variant="card"]) {
41
+ :host([variant="card"]),
42
+ :host([variant="fieldset"]) {
32
43
  --_ui-selection-context-surface: initial;
33
44
  --_ui-selection-context-border: initial;
34
45
  --_ui-selection-context-text: initial;
@@ -38,12 +49,40 @@
38
49
  background: var(--ui-surface-raised);
39
50
  }
40
51
 
52
+ :host([variant="fieldset"]) {
53
+ display: block !important;
54
+ box-sizing: border-box !important;
55
+ margin: 0 !important;
56
+ padding-block-start: var(--ui-space-4) !important;
57
+ }
58
+
59
+ .legend {
60
+ max-inline-size: 100%;
61
+ box-sizing: border-box !important;
62
+ padding-inline: var(--ui-space-2) !important;
63
+ margin-inline-start: calc(-1 * var(--ui-space-2)) !important;
64
+ overflow-wrap: anywhere;
65
+ }
66
+
67
+ .legend .heading {
68
+ font-size: var(--ui-font-size-md);
69
+ }
70
+
71
+ :host([variant="fieldset"]) .head {
72
+ margin-block-end: var(--ui-space-4) !important;
73
+ }
74
+
75
+ :host([variant="fieldset"]) .head:has(.description:empty):has(.actions:empty) {
76
+ display: none !important;
77
+ }
78
+
41
79
  :host([variant="divided"]) {
42
80
  padding-block-start: var(--ui-space-6) !important;
43
81
  border-block-start: var(--ui-border-width) solid var(--ui-border-divider);
44
82
  }
45
83
 
46
- :host([variant="card"][tone="danger"]) {
84
+ :host([variant="card"][tone="danger"]),
85
+ :host([variant="fieldset"][tone="danger"]) {
47
86
  --_ui-selection-context-surface: light-dark(
48
87
  oklch(from var(--ui-danger-soft) calc(l - 0.045) calc(max(c, min(0.045, c * 3))) h),
49
88
  oklch(from var(--ui-danger-soft) calc(l + 0.045) calc(max(c, min(0.045, c * 3))) h)