ng-hub-ui-forms 22.29.0 → 22.30.0
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/README.md +58 -0
- package/fesm2022/ng-hub-ui-forms.mjs +37 -7
- package/fesm2022/ng-hub-ui-forms.mjs.map +1 -1
- package/package.json +1 -1
- package/styles/_field.scss +69 -0
- package/styles/_tokens.scss +20 -0
- package/types/ng-hub-ui-forms.d.ts +31 -2
package/README.md
CHANGED
|
@@ -210,6 +210,64 @@ provideHubForms({
|
|
|
210
210
|
});
|
|
211
211
|
```
|
|
212
212
|
|
|
213
|
+
#### Plain-text fields
|
|
214
|
+
|
|
215
|
+
`readonly` and `plaintext` are the two halves of a shut field, and the difference is who the
|
|
216
|
+
field is for. `readonly` is a *state* of a field somebody is still filling in, and a theme can
|
|
217
|
+
give it a box — `--hub-input-readonly-bg`, `--hub-input-readonly-border-color`, `-color` and
|
|
218
|
+
`-cursor` exist to be set. `plaintext` is for a value that is merely being *shown*: a record
|
|
219
|
+
open for consultation, a figure the server settled, a field a plan has locked. There the box is
|
|
220
|
+
noise, and having none is what `plaintext` is rather than a colour it happens to wear.
|
|
221
|
+
|
|
222
|
+
> **At the shipped defaults `readonly` already draws no box** — both those token defaults are
|
|
223
|
+
> `transparent`, deliberately: a read-only value is there to be read and loses only the chrome
|
|
224
|
+
> that promises you can type in it. Untouched, the two differ in the horizontal padding (12px
|
|
225
|
+
> against 0), the inline border width, the cursor, and the affordances. Set the two tokens and
|
|
226
|
+
> read-only takes the boxed look Bootstrap's own `readonly` ships with, while `plaintext` stays
|
|
227
|
+
> flat:
|
|
228
|
+
>
|
|
229
|
+
> ```css
|
|
230
|
+
> .hub-field--readonly {
|
|
231
|
+
> --hub-input-readonly-bg: var(--hub-sys-surface-sunken);
|
|
232
|
+
> --hub-input-readonly-border-color: var(--hub-sys-border-subtle);
|
|
233
|
+
> }
|
|
234
|
+
> ```
|
|
235
|
+
|
|
236
|
+
The value steps back a shade. Inside a box the box does the separating; with it gone, label and
|
|
237
|
+
value were the same colour and two pixels apart in size, so a column of them read as
|
|
238
|
+
undifferentiated lines. The label is left exactly as every other field's — same tokens, same
|
|
239
|
+
weight, because a form's labels keep one rhythm whatever state each field is in — and
|
|
240
|
+
`--hub-input-plaintext-color` moves the value instead, to `gray-700` against the editable
|
|
241
|
+
`gray-900`, with `--hub-input-plaintext-font-weight` one step lighter so it does not compete
|
|
242
|
+
with its own label.
|
|
243
|
+
|
|
244
|
+
The vertical padding moves rather than shrinks, through `--hub-input-plaintext-padding-block`:
|
|
245
|
+
none above, the field's whole vertical padding below. Nothing above puts the value directly under
|
|
246
|
+
its label — a label and its value are one thing and should read as a pair — while twice the
|
|
247
|
+
padding below holds the control at exactly an editable field's height, so a grid mixing the two
|
|
248
|
+
still lines up. Replace it with a single value and you give up one of the two.
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
```html
|
|
252
|
+
<!-- being filled in, so it keeps the box -->
|
|
253
|
+
<hub-input formControlName="reference" label="Reference" [readonly]="true" />
|
|
254
|
+
|
|
255
|
+
<!-- merely being read, so the box goes -->
|
|
256
|
+
<hub-input formControlName="customer" label="Customer" [plaintext]="true" />
|
|
257
|
+
<hub-textarea formControlName="notes" label="Notes" [rows]="3" [plaintext]="true" />
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
Modelled on Bootstrap's `.form-control-plaintext`, deliberately: the control stays a real
|
|
261
|
+
`<input>` / `<textarea>`, so the `<label for>` still points at something labelable and the text
|
|
262
|
+
stays selectable. A `<span>` would have broken both while going on looking right.
|
|
263
|
+
|
|
264
|
+
The horizontal padding goes and the border turns transparent **without losing its width**, so a
|
|
265
|
+
plain-text value lands on the same baseline as an editable neighbour and a form mixing the two
|
|
266
|
+
does not stagger. `plaintext` implies `readonly` and the two presentations are exclusive, so
|
|
267
|
+
they can never be passed in disagreement. Every affordance goes with the box — the clear button,
|
|
268
|
+
a projected caret, a datepicker icon, and a textarea's character counter, which tells you how
|
|
269
|
+
much room is left to type and so promises typing.
|
|
270
|
+
|
|
213
271
|
### Select
|
|
214
272
|
|
|
215
273
|
```html
|