@gravionlabs/helix-ui 22.9.1 → 22.10.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.
- package/core.css +13 -1
- package/fesm2022/gravionlabs-helix-ui.mjs +21 -1
- package/fesm2022/gravionlabs-helix-ui.mjs.map +1 -1
- package/package.json +3 -2
- package/styleguide/STYLEGUIDE.md +99 -0
- package/styleguide/color.md +122 -0
- package/styleguide/components.md +150 -0
- package/styleguide/dialogs.md +120 -0
- package/styleguide/form-patterns.md +196 -0
- package/styleguide/forms.md +174 -0
- package/styleguide/platform.md +118 -0
- package/styleguide/ux-review-rubric.md +114 -0
- package/styleguide/ux-rules.md +92 -0
- package/styles.css +13 -1
- package/tokens.css +1 -1
- package/types/gravionlabs-helix-ui.d.ts +11 -2
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
# Form patterns
|
|
2
|
+
|
|
3
|
+
Example of the [UX style guide](STYLEGUIDE.md): read it when you build a dialog with a form. A "Clone vault" dialog
|
|
4
|
+
that follows the rules of [forms.md](forms.md) and [dialogs.md](dialogs.md); the demo page
|
|
5
|
+
`uikit/form-patterns` of `helix-demo` runs it.
|
|
6
|
+
|
|
7
|
+
## What each part shows
|
|
8
|
+
|
|
9
|
+
| Part of the example | Rule |
|
|
10
|
+
| -------------------------------------------------------------------------- | ------------------------------------------------------------------- |
|
|
11
|
+
| `header` and `size="md"`, no CSS width | [Header and size](dialogs.md#header-and-size) |
|
|
12
|
+
| `hx-field` with `label`, `hint` and `error` around the URL | [Field anatomy](forms.md#field-anatomy) |
|
|
13
|
+
| "HTTPS or SSH" as `hint`, no example value as placeholder | [Placeholders](forms.md#placeholders) |
|
|
14
|
+
| `hx-input-group` with a read-only input and a "Browse…" button | [Path pickers](forms.md#path-pickers) |
|
|
15
|
+
| `<label for>` and `hx-message` of the folder, `aria-required` on its input | [Controls outside `hx-field`](forms.md#controls-outside-hx-field) |
|
|
16
|
+
| `.form` and `.path-picker` gaps from `--h-space-*` | [Vertical rhythm](forms.md#vertical-rhythm) |
|
|
17
|
+
| Validators of `@gravionlabs/helix-ui/validators` with their messages | [Validators](forms.md#validators) |
|
|
18
|
+
| "Clone" is never disabled for an invalid form; `markAllAsTouched()` | [Validation](forms.md#validation) |
|
|
19
|
+
| `[loading]` on "Clone", the other buttons disabled while it runs | [Feedback by duration](ux-rules.md#feedback-by-duration) |
|
|
20
|
+
| Two `hxDialogFooter` buttons: Cancel (text, secondary), then "Clone" | [Footer](dialogs.md#footer) |
|
|
21
|
+
| The URL is the first tabbable element of the content, no `focus()` call | [Default focus](dialogs.md#default-focus) |
|
|
22
|
+
| `<form id>` and `type="submit"` with `form`: Enter submits | [Enter](dialogs.md#enter) |
|
|
23
|
+
| Escape closes; with changes it is off and Cancel asks | [Escape and unsaved changes](dialogs.md#escape-and-unsaved-changes) |
|
|
24
|
+
| "Discard" and "Keep editing", `acceptSeverity: 'danger'` | [Confirmations](dialogs.md#confirmations) |
|
|
25
|
+
| The result is a toast | [Which element for what](ux-rules.md#which-element-for-what) |
|
|
26
|
+
|
|
27
|
+
## Template
|
|
28
|
+
|
|
29
|
+
The button that opens the dialog is `<button hx-button type="button" (click)="show()">Clone vault…</button>`.
|
|
30
|
+
|
|
31
|
+
```html
|
|
32
|
+
<hx-dialog
|
|
33
|
+
header="Clone vault"
|
|
34
|
+
size="md"
|
|
35
|
+
[visible]="open()"
|
|
36
|
+
(visibleChange)="open.set($event)"
|
|
37
|
+
[closable]="!form.dirty"
|
|
38
|
+
[closeOnEscape]="!form.dirty"
|
|
39
|
+
>
|
|
40
|
+
<form id="clone-vault-form" class="form" [formGroup]="form" (ngSubmit)="clone()">
|
|
41
|
+
<hx-field
|
|
42
|
+
label="Repository URL"
|
|
43
|
+
hint="HTTPS or SSH"
|
|
44
|
+
[error]="form.controls.url.errors?.['Required']"
|
|
45
|
+
required
|
|
46
|
+
>
|
|
47
|
+
<input hx-input formControlName="url" autocomplete="off" spellcheck="false" />
|
|
48
|
+
</hx-field>
|
|
49
|
+
|
|
50
|
+
<div class="path-picker">
|
|
51
|
+
<label for="clone-vault-folder">Target folder</label>
|
|
52
|
+
<hx-input-group>
|
|
53
|
+
<input
|
|
54
|
+
hx-input
|
|
55
|
+
id="clone-vault-folder"
|
|
56
|
+
formControlName="folder"
|
|
57
|
+
readonly
|
|
58
|
+
aria-required="true"
|
|
59
|
+
[attr.aria-invalid]="folderError() ? 'true' : null"
|
|
60
|
+
[attr.aria-describedby]="folderError() ? 'clone-vault-folder-error' : null"
|
|
61
|
+
/>
|
|
62
|
+
<button
|
|
63
|
+
hx-button
|
|
64
|
+
type="button"
|
|
65
|
+
severity="secondary"
|
|
66
|
+
[disabled]="saving()"
|
|
67
|
+
(click)="browse()"
|
|
68
|
+
>
|
|
69
|
+
Browse…
|
|
70
|
+
</button>
|
|
71
|
+
</hx-input-group>
|
|
72
|
+
@if (folderError(); as error) {
|
|
73
|
+
<hx-message id="clone-vault-folder-error" severity="error" variant="simple" size="small">
|
|
74
|
+
{{ error }}
|
|
75
|
+
</hx-message>
|
|
76
|
+
}
|
|
77
|
+
</div>
|
|
78
|
+
</form>
|
|
79
|
+
|
|
80
|
+
<button
|
|
81
|
+
hxDialogFooter
|
|
82
|
+
hx-button
|
|
83
|
+
type="button"
|
|
84
|
+
variant="text"
|
|
85
|
+
severity="secondary"
|
|
86
|
+
[disabled]="saving()"
|
|
87
|
+
(click)="cancel()"
|
|
88
|
+
>
|
|
89
|
+
Cancel
|
|
90
|
+
</button>
|
|
91
|
+
<button hxDialogFooter hx-button type="submit" form="clone-vault-form" [loading]="saving()">
|
|
92
|
+
Clone
|
|
93
|
+
</button>
|
|
94
|
+
</hx-dialog>
|
|
95
|
+
|
|
96
|
+
<hx-confirm-dialog />
|
|
97
|
+
<hx-toast />
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Component
|
|
101
|
+
|
|
102
|
+
The imports are `ReactiveFormsModule`, `HxButton`, `HxConfirmDialog`, `HxDialog`, `HxField`, `HxInput`,
|
|
103
|
+
`HxInputGroup`, `HxMessage` and `HxToast`; `Validators` comes from `@gravionlabs/helix-ui/validators`. The `timeout`
|
|
104
|
+
stands for the request, and `browse()` for the file dialog of the platform.
|
|
105
|
+
|
|
106
|
+
```ts
|
|
107
|
+
/** How long the pretended clone takes. */
|
|
108
|
+
const CLONE_DURATION_MS = 1500;
|
|
109
|
+
|
|
110
|
+
/** What the file dialog of the platform would answer: a browser app cannot ask for a folder path. */
|
|
111
|
+
const PICKED_FOLDER = '/home/ada/Vaults';
|
|
112
|
+
|
|
113
|
+
export class FormPatternsDemo {
|
|
114
|
+
readonly #confirmation = inject(HxConfirmationService);
|
|
115
|
+
readonly #messages = inject(HxMessageService);
|
|
116
|
+
|
|
117
|
+
readonly open = signal(false);
|
|
118
|
+
readonly saving = signal(false);
|
|
119
|
+
readonly form = inject(FormBuilder).nonNullable.group({
|
|
120
|
+
url: ['', Validators.required('Enter a repository URL')],
|
|
121
|
+
folder: ['', Validators.required('Choose a target folder')],
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
#timer?: ReturnType<typeof setTimeout>;
|
|
125
|
+
|
|
126
|
+
constructor() {
|
|
127
|
+
inject(DestroyRef).onDestroy(() => clearTimeout(this.#timer));
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** The path picker is outside `hx-field`, so it shows its error itself: once invalid and touched. */
|
|
131
|
+
folderError(): string | null {
|
|
132
|
+
const folder = this.form.controls.folder;
|
|
133
|
+
return folder.touched ? (folder.errors?.['Required'] ?? null) : null;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
show(): void {
|
|
137
|
+
this.form.reset();
|
|
138
|
+
this.open.set(true);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** A desktop app opens the file dialog of the platform here. */
|
|
142
|
+
browse(): void {
|
|
143
|
+
const folder = this.form.controls.folder;
|
|
144
|
+
folder.setValue(PICKED_FOLDER);
|
|
145
|
+
// A value set in code is a change of the user here: closing would lose it.
|
|
146
|
+
folder.markAsDirty();
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
clone(): void {
|
|
150
|
+
if (this.saving()) return;
|
|
151
|
+
if (this.form.invalid) {
|
|
152
|
+
this.form.markAllAsTouched();
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
const { folder } = this.form.getRawValue();
|
|
156
|
+
this.saving.set(true);
|
|
157
|
+
this.#timer = setTimeout(() => {
|
|
158
|
+
this.saving.set(false);
|
|
159
|
+
this.form.reset();
|
|
160
|
+
this.open.set(false);
|
|
161
|
+
this.#messages.add({ severity: 'success', summary: 'Vault cloned', detail: folder });
|
|
162
|
+
}, CLONE_DURATION_MS);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
async cancel(): Promise<void> {
|
|
166
|
+
const discard =
|
|
167
|
+
!this.form.dirty ||
|
|
168
|
+
(await this.#confirmation.confirmAsync({
|
|
169
|
+
header: 'Discard changes',
|
|
170
|
+
message: 'The vault is not cloned yet.',
|
|
171
|
+
acceptLabel: 'Discard',
|
|
172
|
+
rejectLabel: 'Keep editing',
|
|
173
|
+
acceptSeverity: 'danger',
|
|
174
|
+
}));
|
|
175
|
+
if (!discard) return;
|
|
176
|
+
this.form.reset();
|
|
177
|
+
this.open.set(false);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## Styles
|
|
183
|
+
|
|
184
|
+
```css
|
|
185
|
+
.form {
|
|
186
|
+
display: flex;
|
|
187
|
+
flex-direction: column;
|
|
188
|
+
gap: var(--h-space-4);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.path-picker {
|
|
192
|
+
display: flex;
|
|
193
|
+
flex-direction: column;
|
|
194
|
+
gap: var(--h-space-1);
|
|
195
|
+
}
|
|
196
|
+
```
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
# Forms
|
|
2
|
+
|
|
3
|
+
Deep dive of the [UX style guide](STYLEGUIDE.md): read it when you add or change a form. It says how a form is
|
|
4
|
+
built from Helix parts. Dialog layout is in [dialogs.md](dialogs.md).
|
|
5
|
+
|
|
6
|
+
## Field anatomy
|
|
7
|
+
|
|
8
|
+
[`hx-field`](https://gravionlabs.github.io/helix/components/form-field) holds one `hx-input` (input or textarea), `hx-checkbox`, `hx-radio`,
|
|
9
|
+
`hx-switch` or `hx-select`.
|
|
10
|
+
|
|
11
|
+
- Each of these controls sits in its own `hx-field` with a `label`. The label is visible; `aria-label` does not
|
|
12
|
+
replace it.
|
|
13
|
+
- Help text is the `hint` input: it shows below the control in `--h-text-muted-color`. The app writes no help
|
|
14
|
+
element of its own.
|
|
15
|
+
- Error text is the `error` input (signal forms: or the `message` of the rule). `hx-field` shows it once the control
|
|
16
|
+
is invalid and touched.
|
|
17
|
+
- Inside a field the app writes no `<label for>`, no message id, no `aria-invalid` and no condition on the error:
|
|
18
|
+
`hx-field` sets `aria-invalid`, `aria-describedby` and `aria-required`.
|
|
19
|
+
- A required field shows the marker of `hx-field`: from `Validators.required` of `@angular/forms`, a signal forms
|
|
20
|
+
`required()` rule, or the `required` attribute of the control or the field. No label carries a hand-written `*`.
|
|
21
|
+
|
|
22
|
+
```html
|
|
23
|
+
<hx-field label="Repository URL" hint="HTTPS or SSH" [error]="form.controls.url.errors?.['Required']" required>
|
|
24
|
+
<input hx-input formControlName="url" />
|
|
25
|
+
</hx-field>
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Controls outside `hx-field`
|
|
29
|
+
|
|
30
|
+
`hx-field` does not wire other controls, such as `hx-input-number`, `hx-password`, `hx-multi-select`,
|
|
31
|
+
`hx-auto-complete`, `hx-date-picker` or `hx-input-group`.
|
|
32
|
+
|
|
33
|
+
- Each has a visible `<label for>` that points at its `inputId` (a native `hx-input` in a group: at its `id`).
|
|
34
|
+
- Its error is an `hx-message severity="error"` below it, shown while the control is invalid and touched.
|
|
35
|
+
|
|
36
|
+
```html
|
|
37
|
+
<label for="retries">Retries</label>
|
|
38
|
+
<hx-input-number inputId="retries" formControlName="retries" [min]="0" [max]="10" />
|
|
39
|
+
@if (form.controls.retries.touched && form.controls.retries.errors; as errors) {
|
|
40
|
+
<hx-message severity="error" variant="simple" size="small">{{ errors['Required'] }}</hx-message>
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Vertical rhythm
|
|
45
|
+
|
|
46
|
+
The app lays out its own wrapper elements; it does not restyle `hx-field` or `hx-fieldset`.
|
|
47
|
+
|
|
48
|
+
| Between | Gap |
|
|
49
|
+
| ------------------------------------------ | ------------- |
|
|
50
|
+
| Label, control, hint and error of a field | `hx-field` |
|
|
51
|
+
| A `<label for>`, its control and its error | `--h-space-1` |
|
|
52
|
+
| Fields of one group | `--h-space-4` |
|
|
53
|
+
| Groups of a form | `--h-space-6` |
|
|
54
|
+
|
|
55
|
+
A form is a column of groups. A group is an `hx-fieldset` or, without a legend, a block of fields; a form with one
|
|
56
|
+
group is that block alone.
|
|
57
|
+
|
|
58
|
+
```css
|
|
59
|
+
.form,
|
|
60
|
+
.group {
|
|
61
|
+
display: flex;
|
|
62
|
+
flex-direction: column;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.form {
|
|
66
|
+
gap: var(--h-space-6);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.group {
|
|
70
|
+
gap: var(--h-space-4);
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Groups
|
|
75
|
+
|
|
76
|
+
- Fields that answer one question (an address, the choices of a radio group) sit in an
|
|
77
|
+
[`hx-fieldset`](https://gravionlabs.github.io/helix/components/fieldset) with a `legend`. No heading element stands in for the legend.
|
|
78
|
+
- A fieldset that holds a required field is not `toggleable`: a collapsed group hides its errors.
|
|
79
|
+
|
|
80
|
+
```html
|
|
81
|
+
<hx-fieldset legend="Protocol">
|
|
82
|
+
<div class="group">
|
|
83
|
+
<hx-field label="HTTPS"><input type="radio" hx-radio formControlName="protocol" value="https" /></hx-field>
|
|
84
|
+
<hx-field label="SSH"><input type="radio" hx-radio formControlName="protocol" value="ssh" /></hx-field>
|
|
85
|
+
</div>
|
|
86
|
+
</hx-fieldset>
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Placeholders
|
|
90
|
+
|
|
91
|
+
- The `placeholder` of `hx-input`, `hx-select` or another control is never its only label.
|
|
92
|
+
- A placeholder is a short hint on what to do ("Search branches", "Select a city"). It is never an example value
|
|
93
|
+
such as `https://github.com/org/repo.git`, which reads as filled in. A format or an example goes in the `hint` of
|
|
94
|
+
`hx-field`.
|
|
95
|
+
|
|
96
|
+
## Path pickers
|
|
97
|
+
|
|
98
|
+
A file or folder path is chosen, not typed: an [`hx-input-group`](https://gravionlabs.github.io/helix/components/input-group) with a read-only
|
|
99
|
+
`hx-input` and an `hx-button` that opens the file dialog.
|
|
100
|
+
|
|
101
|
+
- The input has the `readonly` attribute and a visible `<label for>`.
|
|
102
|
+
- The browse button is `type="button"` with `severity="secondary"`. With an icon only, it is `iconOnly` with an
|
|
103
|
+
`aria-label` and an `hx-tooltip`.
|
|
104
|
+
- Its error is wired as `hx-field` would: `aria-invalid`, and `aria-describedby` with the id of the `hx-message`.
|
|
105
|
+
|
|
106
|
+
```html
|
|
107
|
+
<label for="folder">Target folder</label>
|
|
108
|
+
<hx-input-group>
|
|
109
|
+
<input
|
|
110
|
+
hx-input
|
|
111
|
+
id="folder"
|
|
112
|
+
formControlName="folder"
|
|
113
|
+
readonly
|
|
114
|
+
[attr.aria-invalid]="folderError() ? 'true' : null"
|
|
115
|
+
[attr.aria-describedby]="folderError() ? 'folder-error' : null"
|
|
116
|
+
/>
|
|
117
|
+
<button hx-button type="button" severity="secondary" (click)="browse()">Browse…</button>
|
|
118
|
+
</hx-input-group>
|
|
119
|
+
@if (folderError(); as error) {
|
|
120
|
+
<hx-message id="folder-error" severity="error" variant="simple" size="small">{{ error }}</hx-message>
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Validation
|
|
125
|
+
|
|
126
|
+
- The primary `hx-button` of a form is `type="submit"` and is never `[disabled]` because the form is invalid or
|
|
127
|
+
untouched. A press on it shows what is missing.
|
|
128
|
+
- Submit marks every field as touched, so each invalid field shows its error: reactive and template-driven forms
|
|
129
|
+
call `markAllAsTouched()`, signal forms use `submit()` of `@angular/forms/signals`.
|
|
130
|
+
- A field also shows its error when the user leaves it invalid: `hx-field` does this on touch, the app adds no blur
|
|
131
|
+
handler.
|
|
132
|
+
- While the form is being sent, the submit button has `[loading]`.
|
|
133
|
+
- A message about the whole form (the server refused it) is an `hx-message severity="error"` above the submit
|
|
134
|
+
button. A server answer about one field is set as an error on that control.
|
|
135
|
+
|
|
136
|
+
```ts
|
|
137
|
+
save(): void {
|
|
138
|
+
if (this.form.invalid) {
|
|
139
|
+
this.form.markAllAsTouched();
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
this.send(this.form.getRawValue());
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### Validators
|
|
147
|
+
|
|
148
|
+
Reactive forms take the validators of
|
|
149
|
+
[`@gravionlabs/helix-ui/validators`](https://gravionlabs.github.io/helix/HELIX-UI#validators): each carries its message, under its
|
|
150
|
+
`ValidatorKey`, so the text lives with the rule and `error` reads it.
|
|
151
|
+
|
|
152
|
+
- Every validator has a message that says what to enter ("Enter a repository URL").
|
|
153
|
+
- With the Helix `required`, set `required` on the `hx-field`: the field finds only the Angular validator by itself.
|
|
154
|
+
- A checkbox that must be checked takes `Validators.requiredTrue` of `@angular/forms`: the Helix `required` accepts
|
|
155
|
+
`false`.
|
|
156
|
+
|
|
157
|
+
## Which control for which value
|
|
158
|
+
|
|
159
|
+
| Value | Control |
|
|
160
|
+
| ------------------------------------------ | ---------------------------------------------------------------------------------------- |
|
|
161
|
+
| One line of text | `input[hx-input]` |
|
|
162
|
+
| Several lines of text | `textarea[hx-input]` |
|
|
163
|
+
| A password or secret | [`hx-password`](https://gravionlabs.github.io/helix/components/password) |
|
|
164
|
+
| A number | [`hx-input-number`](https://gravionlabs.github.io/helix/components/input-number) with `min` and `max` where they exist |
|
|
165
|
+
| A number on a range, where roughly will do | [`hx-slider`](https://gravionlabs.github.io/helix/components/slider) |
|
|
166
|
+
| Yes or no, saved with the form | `input[type=checkbox][hx-checkbox]` |
|
|
167
|
+
| On or off, in effect at once | `input[type=checkbox][hx-switch]` |
|
|
168
|
+
| One of 2 to 5 choices, all visible | `input[type=radio][hx-radio]` in an `hx-fieldset` |
|
|
169
|
+
| One of 6 or more, or of a loaded list | [`hx-select`](https://gravionlabs.github.io/helix/components/select), with `filter` from 10 options |
|
|
170
|
+
| Several of a list | [`hx-multi-select`](https://gravionlabs.github.io/helix/components/multi-select) |
|
|
171
|
+
| Free text with suggestions | [`hx-auto-complete`](https://gravionlabs.github.io/helix/components/auto-complete) |
|
|
172
|
+
| A day or a range of days | [`hx-date-picker`](https://gravionlabs.github.io/helix/components/date-picker) |
|
|
173
|
+
| A file or folder path | [Path picker](#path-pickers) |
|
|
174
|
+
| The content of files | [`hx-file-upload`](https://gravionlabs.github.io/helix/components/file-upload) |
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# Platform
|
|
2
|
+
|
|
3
|
+
Deep dive of the [UX style guide](STYLEGUIDE.md): read it when you show or handle a keyboard shortcut, write CSS for a
|
|
4
|
+
desktop app, or change a Tauri app that runs on Linux (WebKitGTK) or Windows (WebView2). The platform switch is that
|
|
5
|
+
of [Helix Desktop](https://gravionlabs.github.io/helix/HELIX-DESKTOP) ([ADR 0005](https://github.com/GravionLabs/helix/blob/main/docs/adr/0005-helix-desktop-package.md)), key caps are
|
|
6
|
+
[`hx-kbd`](https://gravionlabs.github.io/helix/components/kbd) ([ADR 0006](https://github.com/GravionLabs/helix/blob/main/docs/adr/0006-key-cap-component-and-tooltip-shortcut.md)).
|
|
7
|
+
|
|
8
|
+
## Platform switch
|
|
9
|
+
|
|
10
|
+
- A Tauri app on `@gravionlabs/helix-desktop` has `providePlatform()` of `@gravionlabs/helix-desktop/tauri` in its
|
|
11
|
+
bootstrap providers. It sets `data-platform` to `macos`, `windows`, `linux`, `ios`, `android` or `web`.
|
|
12
|
+
- TypeScript branches on the platform with `getHxPlatform()`, CSS with `:root[data-platform='…']`. The app reads no
|
|
13
|
+
`navigator.userAgent` or `navigator.platform` for this.
|
|
14
|
+
- The shell is picked as in [HxMobileShell](https://gravionlabs.github.io/helix/HELIX-DESKTOP#hxmobileshell-and-hxbottombar), never by window width.
|
|
15
|
+
|
|
16
|
+
## Ctrl and Cmd
|
|
17
|
+
|
|
18
|
+
"Apple" below means `getHxPlatform()` returns `macos` or `ios`. A browser build returns `web` on every operating
|
|
19
|
+
system, so the switch decides this for Tauri apps only.
|
|
20
|
+
|
|
21
|
+
| Key | Label in `keys` on Apple | Label elsewhere | `aria-keyshortcuts` |
|
|
22
|
+
| ------- | ------------------------ | --------------- | ------------------- |
|
|
23
|
+
| Command | `⌘` | none | `Meta` |
|
|
24
|
+
| Control | `⌃` | `Ctrl` | `Control` |
|
|
25
|
+
| Alt | `⌥` | `Alt` | `Alt` |
|
|
26
|
+
| Shift | `⇧` | `Shift` | `Shift` |
|
|
27
|
+
|
|
28
|
+
- The main modifier of an app shortcut is Command on Apple and Control elsewhere. The label, `aria-keyshortcuts` and
|
|
29
|
+
the key handler (`event.metaKey` or `event.ctrlKey`) of one shortcut take it from the same `getHxPlatform()` value.
|
|
30
|
+
- `keys` lists the modifiers before the key; on Apple in the order `⌃`, `⌥`, `⇧`, `⌘`.
|
|
31
|
+
- The app sets no `separator` on `hx-kbd`: the default is none on macOS and `+` elsewhere.
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
const apple = ['macos', 'ios'].includes(getHxPlatform());
|
|
35
|
+
const searchKeys = [apple ? '⌘' : 'Ctrl', 'K'];
|
|
36
|
+
const searchAria = apple ? 'Meta+K' : 'Control+K';
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Shortcut labels
|
|
40
|
+
|
|
41
|
+
- A tooltip shows a shortcut through `hxTooltipShortcut`, every other place (palette, help, empty state) through
|
|
42
|
+
`hx-kbd`. No shortcut is written into a text, a label or a `title`.
|
|
43
|
+
- Only an implemented shortcut is shown: each shown `keys` array has a handler that runs the action on that platform.
|
|
44
|
+
- The control that runs the action has `aria-keyshortcuts` with the names of the table.
|
|
45
|
+
|
|
46
|
+
```html
|
|
47
|
+
<button
|
|
48
|
+
hx-button
|
|
49
|
+
iconOnly
|
|
50
|
+
aria-label="Search"
|
|
51
|
+
hx-tooltip="Search"
|
|
52
|
+
[hxTooltipShortcut]="searchKeys"
|
|
53
|
+
[attr.aria-keyshortcuts]="searchAria"
|
|
54
|
+
(click)="search()"
|
|
55
|
+
>
|
|
56
|
+
<span class="hx-button-icon pi pi-search" aria-hidden="true"></span>
|
|
57
|
+
</button>
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## WebKitGTK and WebView2
|
|
61
|
+
|
|
62
|
+
A Tauri app renders in WebKitGTK on Linux, in WebView2 on Windows and in WKWebView on macOS. A change of app CSS or of
|
|
63
|
+
a shortcut can look right in one and wrong in another.
|
|
64
|
+
|
|
65
|
+
### Font rendering
|
|
66
|
+
|
|
67
|
+
- An app with the `helix-shell` stylesheet loads the Inter font file (`@fontsource-variable/inter`) that
|
|
68
|
+
`--helix-font-sans` names first. Without it each system draws another fallback font.
|
|
69
|
+
- Font smoothing is set by the `globals.css` of `helix-shell`; app CSS sets no `-webkit-font-smoothing` and no
|
|
70
|
+
`text-rendering`. `-webkit-font-smoothing` changes nothing on Linux and Windows.
|
|
71
|
+
|
|
72
|
+
### Scrollbars and native controls
|
|
73
|
+
|
|
74
|
+
- `tokens.css` sets `color-scheme` for light and dark, so the scrollbars the web view draws follow the theme. App CSS
|
|
75
|
+
sets no `color-scheme`.
|
|
76
|
+
|
|
77
|
+
Whether a scrollbar takes layout space differs between the web views and the system settings.
|
|
78
|
+
|
|
79
|
+
### Focus
|
|
80
|
+
|
|
81
|
+
Helix controls draw their own ring, and the rules for an element of the app that takes focus are in
|
|
82
|
+
[Focus](color.md#focus). They hold on every web view.
|
|
83
|
+
|
|
84
|
+
### Backdrop blur
|
|
85
|
+
|
|
86
|
+
- App CSS sets no `backdrop-filter`. The blur of an overlay is that of its component token (`--h-toast-blur`,
|
|
87
|
+
`--h-image-toolbar-blur`).
|
|
88
|
+
- Older WebKit versions read only `-webkit-backdrop-filter`, so a blur may not show on Linux. Text on an overridden
|
|
89
|
+
`--h-toast-*` background keeps at least 4.5:1 without the blur.
|
|
90
|
+
|
|
91
|
+
## Known quirks
|
|
92
|
+
|
|
93
|
+
Found in the Helix apps. They are notes, not rules.
|
|
94
|
+
|
|
95
|
+
| Web view | Quirk | Found in |
|
|
96
|
+
| --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------- |
|
|
97
|
+
| all | A release build renders without component and grid styles unless the [content security policy](https://gravionlabs.github.io/helix/HELIX-DESKTOP#tauri-content-security-policy) is set. | helix-desktop |
|
|
98
|
+
| all | `tauri dev` applies no policy while `devCsp` is `null`, so a policy problem shows only in an installed build. | helix-desktop, gantry |
|
|
99
|
+
| all | The Enter that ends an IME composition has `isComposing` or `keyCode` 229; a key handler that tests neither saves too early. | poimen |
|
|
100
|
+
| all | The drag-and-drop events of Tauri give the position in physical pixels, not in CSS pixels. | poimen |
|
|
101
|
+
| WebKit | Events do not reach a sandboxed `iframe` without `allow-scripts` ([WebKit bug 218086](https://bugs.webkit.org/show_bug.cgi?id=218086)). | nixe |
|
|
102
|
+
| WebKitGTK | Printing ignores the CSS `@page` size and margin; the GTK page setup sets them. | nixe |
|
|
103
|
+
| WebKitGTK | The headless PDF export job in CI (`xvfb-run`) runs with `WEBKIT_DISABLE_DMABUF_RENDERER=1`. | nixe |
|
|
104
|
+
| WebView2 | Printing lays out the CSS `@page` size on the paper of the print settings. | nixe |
|
|
105
|
+
| WebView2 | A Mermaid flowchart exported from the command line was laid out far too wide on a CI runner. | nixe |
|
|
106
|
+
| WKWebView | The native menu owns the Command shortcuts; a key handler of the page that also takes them runs the action twice. | poimen |
|
|
107
|
+
|
|
108
|
+
## Not carried yet
|
|
109
|
+
|
|
110
|
+
These have no Helix carrier and are therefore no rule yet:
|
|
111
|
+
|
|
112
|
+
- Resolving Command or Control for labels, `aria-keyshortcuts` and handlers, also in a browser build:
|
|
113
|
+
[#1245](https://github.com/GravionLabs/helix/issues/1245).
|
|
114
|
+
- A shortcut label on an `hx-menu` or `hx-menubar` item:
|
|
115
|
+
[#1259](https://github.com/GravionLabs/helix/issues/1259).
|
|
116
|
+
- The width and color of scrollbars: [#1260](https://github.com/GravionLabs/helix/issues/1260).
|
|
117
|
+
- A UI font for apps without the `helix-shell` stylesheet:
|
|
118
|
+
[#1247](https://github.com/GravionLabs/helix/issues/1247).
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# UX review rubric
|
|
2
|
+
|
|
3
|
+
Deep dive of the [UX style guide](STYLEGUIDE.md): read it when you review a changed screen, a screenshot or a
|
|
4
|
+
prototype. Walk the screen with the questions below and report in the [fixed output](#output). Each question checks the
|
|
5
|
+
rule it links; the rule decides, not the question. Name the highest-impact friction first, then the concrete change.
|
|
6
|
+
|
|
7
|
+
A finding of this rubric is a note. It blocks only when an acceptance criterion names it
|
|
8
|
+
([ADR 0008](https://github.com/GravionLabs/helix/blob/main/docs/adr/0008-ux-style-guide-a-helix-base-guide-that-app-guides-extend.md), decision 6).
|
|
9
|
+
|
|
10
|
+
## Questions
|
|
11
|
+
|
|
12
|
+
### Forms
|
|
13
|
+
|
|
14
|
+
- Does every control have a visible label, wired by `hx-field` or a `<label for>`?
|
|
15
|
+
([Field anatomy](forms.md#field-anatomy), [Controls outside `hx-field`](forms.md#controls-outside-hx-field))
|
|
16
|
+
- Is a placeholder only a hint, never the label or an example value? ([Placeholders](forms.md#placeholders))
|
|
17
|
+
- Are related fields grouped, with the gaps of the vertical rhythm?
|
|
18
|
+
([Groups](forms.md#groups), [Vertical rhythm](forms.md#vertical-rhythm))
|
|
19
|
+
- Is each value entered with the control for its kind, and is a path chosen with a path picker?
|
|
20
|
+
([Which control for which value](forms.md#which-control-for-which-value), [Path pickers](forms.md#path-pickers))
|
|
21
|
+
- Can an invalid form be submitted so that each missing field shows an error that says what to enter?
|
|
22
|
+
([Validation](forms.md#validation), [Validators](forms.md#validators))
|
|
23
|
+
|
|
24
|
+
### Dialogs
|
|
25
|
+
|
|
26
|
+
- Is a dialog used only for a decision that blocks the app, and a popover, toast or inline message otherwise?
|
|
27
|
+
([Which element for what](ux-rules.md#which-element-for-what))
|
|
28
|
+
- Is a modal decision an `hx-dialog` with its actions in `hxDialogFooter`? ([Components](STYLEGUIDE.md#components))
|
|
29
|
+
- Does the `size` of the dialog fit what it holds? ([Dialog sizes](https://gravionlabs.github.io/helix/components/dialog#sizes))
|
|
30
|
+
- Does an action that cannot be undone ask through `HxConfirmationService` with an accept button that names it, and
|
|
31
|
+
does a reversible one run and offer Undo? ([Confirm or undo](ux-rules.md#confirm-or-undo))
|
|
32
|
+
|
|
33
|
+
### Buttons
|
|
34
|
+
|
|
35
|
+
- Does the view or dialog have at most one filled primary button, and does each action have the `variant` and
|
|
36
|
+
`severity` of its job? ([Button hierarchy](components.md#button-hierarchy))
|
|
37
|
+
- Is `danger` used only for destructive actions, never for Cancel? ([Danger](color.md#danger))
|
|
38
|
+
- Does each icon-only button have an `aria-label` and an `hx-tooltip` with the same text?
|
|
39
|
+
([Icon-only buttons](components.md#icon-only-buttons))
|
|
40
|
+
- Are several actions of one place combined with the component for that need?
|
|
41
|
+
([Several actions together](components.md#several-actions-together))
|
|
42
|
+
- Do the controls of a row have the size of that row? ([Button size](components.md#button-size))
|
|
43
|
+
- Is each control a Helix component or directive, and is a list of things to open or choose an `hx-list`?
|
|
44
|
+
([Reuse before building](components.md#reuse-before-building),
|
|
45
|
+
[Which primitive replaces which raw element](components.md#which-primitive-replaces-which-raw-element),
|
|
46
|
+
[Lists](components.md#lists))
|
|
47
|
+
|
|
48
|
+
### Color
|
|
49
|
+
|
|
50
|
+
- Is every color a role token or a `color-mix()` of one, with no literal and no palette step?
|
|
51
|
+
([Literals and tints](color.md#literals-and-tints))
|
|
52
|
+
- Do each background and its text come from the same surface role?
|
|
53
|
+
([Surfaces and their foregrounds](color.md#surfaces-and-their-foregrounds))
|
|
54
|
+
- Does primary mark only the affirmative action and link text? ([Primary](color.md#primary))
|
|
55
|
+
- Does each status show a text or icon next to its color? ([Status](color.md#status))
|
|
56
|
+
|
|
57
|
+
### Typography and spacing
|
|
58
|
+
|
|
59
|
+
- Is every font size a `--h-font-size-*` step, at most four on the screen, with body text of at least
|
|
60
|
+
`--h-font-size-sm`? ([Typography and spacing](STYLEGUIDE.md#typography-and-spacing))
|
|
61
|
+
- Are gaps, padding, radii and shadows tokens? ([Tokens](STYLEGUIDE.md#tokens))
|
|
62
|
+
- Are toolbar actions in `hx-toolbar` and rows in `hx-list-row`, with density set for the whole app only?
|
|
63
|
+
([Typography and spacing](STYLEGUIDE.md#typography-and-spacing))
|
|
64
|
+
- Are texts in sentence case, without "please", "simply" or "just"?
|
|
65
|
+
([UX rules](STYLEGUIDE.md#ux-rules))
|
|
66
|
+
|
|
67
|
+
### Keyboard
|
|
68
|
+
|
|
69
|
+
- Is every action a native control that works from the keyboard? ([Cross-platform](STYLEGUIDE.md#cross-platform))
|
|
70
|
+
- Does Enter submit a form through its `type="submit"` primary button? ([Validation](forms.md#validation))
|
|
71
|
+
- Does a dialog focus the first control of its content, close with Escape and return the focus? Does a confirmation
|
|
72
|
+
start on the reject button?
|
|
73
|
+
([Dialog accessibility](https://gravionlabs.github.io/helix/components/dialog#service), [Confirm or undo](ux-rules.md#confirm-or-undo))
|
|
74
|
+
- Does everything focusable show the focus ring, and nothing else use it? ([Focus](color.md#focus))
|
|
75
|
+
- Is each shown shortcut implemented, labelled for the platform and set in `aria-keyshortcuts`?
|
|
76
|
+
([Shortcut labels](platform.md#shortcut-labels), [Ctrl and Cmd](platform.md#ctrl-and-cmd))
|
|
77
|
+
|
|
78
|
+
### States
|
|
79
|
+
|
|
80
|
+
- Does the control that starts an action disable at once, and does a longer action show a spinner, steps or progress?
|
|
81
|
+
([Feedback by duration](ux-rules.md#feedback-by-duration))
|
|
82
|
+
- Does every data view have a loading, an empty and an error state? ([UX rules](STYLEGUIDE.md#ux-rules))
|
|
83
|
+
- Does each empty or error state name the next action, also when only a part of the screen failed to load?
|
|
84
|
+
([Empty and error states](ux-rules.md#empty-and-error-states))
|
|
85
|
+
- Does an error the user has to read, retry or copy stay inline until it is solved, not in a toast?
|
|
86
|
+
([Which element for what](ux-rules.md#which-element-for-what))
|
|
87
|
+
- Do tooltips hold no text the user must read, and does no labelled control have one? ([Tooltips](ux-rules.md#tooltips))
|
|
88
|
+
- Does every movement have a `prefers-reduced-motion` variant? ([Motion](ux-rules.md#motion))
|
|
89
|
+
|
|
90
|
+
## Output
|
|
91
|
+
|
|
92
|
+
Report under these five headings, in this order. Write "None" under a heading with nothing to report. Name the affected
|
|
93
|
+
element in each finding.
|
|
94
|
+
|
|
95
|
+
### Top fixes
|
|
96
|
+
|
|
97
|
+
The three changes that would most improve the screen, the most important first.
|
|
98
|
+
|
|
99
|
+
### Friction notes
|
|
100
|
+
|
|
101
|
+
Specific problems of clutter, alignment, copy, focus or flow.
|
|
102
|
+
|
|
103
|
+
### Suggested changes
|
|
104
|
+
|
|
105
|
+
The exact change to layout, hierarchy, controls, copy or states, with the Helix component or token that carries it.
|
|
106
|
+
|
|
107
|
+
### Keyboard and speed check
|
|
108
|
+
|
|
109
|
+
Whether the main task can be done by keyboard and in few steps, with the focus where it starts and what Enter and
|
|
110
|
+
Escape do.
|
|
111
|
+
|
|
112
|
+
### Follow-up states (loading, empty, error, partial)
|
|
113
|
+
|
|
114
|
+
States that are missing or give the user no next action.
|