@uncinq/css-components 1.27.2 → 1.27.4

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,4 +1,17 @@
1
1
  /* components/form.css */
2
+ /*
3
+ * .form — responsive grid of one or two columns, and its layout helpers.
4
+ *
5
+ * Structure:
6
+ * form.form[.is-submitting|.is-success|.has-error]
7
+ * p.required (meaning of the asterisk, before the first field: RGAA 11.10)
8
+ * div[.full]* (fields)
9
+ * .alert[hidden] (answer of an async submission)
10
+ * div.actions (submit, legal)
11
+ *
12
+ * States, set by the script that submits the form asynchronously:
13
+ * .is-submitting, .is-success (only the .alert remains), .has-error
14
+ */
2
15
  @layer components {
3
16
  .form {
4
17
  display: grid;
@@ -14,10 +27,18 @@
14
27
  }
15
28
 
16
29
  .actions,
17
- .full {
30
+ .alert,
31
+ .full,
32
+ .required {
18
33
  grid-column: 1 / -1;
19
34
  }
20
-
35
+
36
+ /* Aligned with the labels, whatever the alignment of the container */
37
+ .required {
38
+ margin-block: 0;
39
+ text-align: start;
40
+ }
41
+
21
42
  .actions {
22
43
  align-items: start;
23
44
  display: flex;
@@ -28,6 +49,15 @@
28
49
  }
29
50
  }
30
51
 
52
+ &.is-submitting {
53
+ cursor: progress;
54
+ }
55
+
56
+ /* Once sent, only the answer remains (direct children only, so that the
57
+ content of the .alert stays) */
58
+ &.is-success > :not(.alert) {
59
+ display: none;
60
+ }
31
61
  }
32
62
 
33
63
  .form-check {
@@ -41,6 +41,18 @@
41
41
  }
42
42
  }
43
43
 
44
+ .media-contain {
45
+ img {
46
+ object-fit: contain;
47
+ }
48
+ }
49
+
50
+ .media-cover {
51
+ img {
52
+ object-fit: cover;
53
+ }
54
+ }
55
+
44
56
  .media-icon {
45
57
  --media-ratio: none;
46
58
  --media-color-background: transparent;
@@ -55,15 +55,38 @@ Change the floor with `--form-col-min-width`. Raising it past 50% forces a singl
55
55
  | `.full` | Spans both columns, `grid-column: 1 / -1` |
56
56
  | `.actions` | Spans both columns and stacks its children vertically |
57
57
  | `.help` | Help text under a field |
58
+ | `.required` | Spans both columns, aligned to the start, no block margin |
59
+ | `.alert` | Spans both columns |
58
60
 
59
61
  `.actions` is a column flex container aligned to the start, with `--gap` between its children and their block margins flattened. So a submit button, a consent line and a legal note stack in the order written without fighting each other's margins.
60
62
 
61
63
  `.help` reads `--help-*` for colour, size, weight, margin and alignment. Pair it with `aria-describedby`, or it is seen and never announced.
62
64
 
65
+ `.required` is the line explaining the asterisk of the required fields. Put it before the first field: the RGAA wants the meaning of a non-textual indication such as `*` given before its first use, visually and in the source order. It stays aligned with the labels even in a centred container.
66
+
67
+ ## Async submission
68
+
69
+ A script that submits the form without leaving the page shows its answer in an `.alert` placed among the fields, `hidden` until then, and sets these states on the form:
70
+
71
+ | State | Effect |
72
+ | --- | --- |
73
+ | `.is-submitting` | `cursor: progress` while the request runs |
74
+ | `.is-success` | Hides every direct child but the `.alert`, so only the answer remains |
75
+ | `.has-error` | No rule: the fields stay, the `.alert` (e.g. `.alert-danger`) carries the error |
76
+
77
+ ```html
78
+ <form class="form is-success">
79
+ <p class="required">* Required fields</p>
80
+ <div>…</div>
81
+ <p class="alert alert-success" role="status" tabindex="-1">Thank you!</p>
82
+ <div class="actions">…</div>
83
+ </form>
84
+ ```
85
+
63
86
  ## Field spacing
64
87
 
65
88
  Both axes use `--gap`, the same token the grid uses for its column calculation. That is why the two-column cap subtracts `var(--gap) / 2`: the track width and the gutter come from one value, so changing it cannot desynchronise them.
66
89
 
67
90
  ## Controls are not styled here
68
91
 
69
- Inputs, selects, textareas and their focus and invalid states come from [css-base](../../../css-base/base/form/), applied to the native elements. This file adds layout and nothing else, which is why a form built without `.form` still looks right, it is simply stacked.
92
+ Inputs, selects, textareas and their focus and invalid states come from [css-base](../../../css-base/base/form/), applied to the native elements. This file adds layout and the submission states, nothing else, which is why a form built without `.form` still looks right, it is simply stacked.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uncinq/css-components",
3
- "version": "1.27.2",
3
+ "version": "1.27.4",
4
4
  "description": "Framework-agnostic CSS component implementations.",
5
5
  "license": "MIT",
6
6
  "repository": {