nwl-components 2.0.0 → 2.1.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/README.md CHANGED
@@ -204,7 +204,7 @@ top of each stylesheet it ships (`dist/style.css`, `nwl-components/base.css`,
204
204
  ```
205
205
 
206
206
  - `nwl.base`: `src/styles/base.css` (below);
207
- - `nwl.widgets`: empty for now (plain-CSS widget classes, later);
207
+ - `nwl.widgets`: `src/styles/widgets.css`, the widget classes (see "Widgets");
208
208
  - `nwl.components`: the components' styles (scoped or not), `sortable.css`, and the CSS of
209
209
  bundled dependencies (splitpanes).
210
210
 
@@ -245,6 +245,86 @@ import 'nwl-components/base.css'; // webpack 4 too (a copy at the package root)
245
245
  Outside `.app`, nothing sets font, colour or box-sizing any more: an app's own markup on a
246
246
  page that loads `dist/style.css` gets them from the app's CSS (or from being inside `.app`).
247
247
 
248
+ ## Widgets
249
+
250
+ Since 2.1.0, `src/styles/widgets.css` holds class-based widgets for markup that isn't Vue
251
+ (Mustache pages, the viewers' tool panels); the library's `Button` uses them too. They are in
252
+ `@layer nwl.widgets` and every selector is wrapped in `:where()`, so **an app rule with one
253
+ class wins** over them. Colours, borders and radii come from the semantic tokens.
254
+
255
+ State is an ARIA attribute, not a class, so screen readers get it too: `aria-pressed="true"` on
256
+ a tool button that is on, `aria-selected="true"` on a selected table row, `disabled` (or
257
+ `aria-disabled="true"` on a link) on a button. The apps' classes (`.pressed`, `.mui-pressed`,
258
+ `.selected`) don't style the widgets.
259
+
260
+ Push button (Save, Cancel): 1px `--nwl-border-strong` outline, `--nwl-radius-md`, bold, on a
261
+ `<button>`, `<a>`, `<select>` or `<input type="button|submit">`. Hover: `--nwl-bg-pressed`;
262
+ disabled: opacity .4.
263
+
264
+ ```html
265
+ <button class="nwl-push-button">Save</button>
266
+ ```
267
+
268
+ Tool button (a viewer's tool panel): 24px high, 1px `--nwl-border`, `--nwl-radius-sm`; it fills
269
+ its container's width, less its 1px margins, as the apps' div tools did. On a native `<button>`
270
+ it is in the tab order with no script. Pressed: `aria-pressed="true"` gives `--nwl-bg-pressed`.
271
+ Hover: `--nwl-bg-pressed` on a text button, opacity .5 on a button whose only element is an
272
+ icon (`img`, `svg` or `.nwl-icon`; CSS can't see text, so a button with an icon and text counts
273
+ as an icon button). `.nwl-tool-button--sub`: a tool inside a group (no border, 22px).
274
+
275
+ ```html
276
+ <div style="flex: 1"><button class="nwl-tool-button" aria-pressed="true">Sag</button></div>
277
+ <div style="flex: 1">
278
+ <button class="nwl-tool-button" aria-pressed="false" aria-label="Full screen">
279
+ <img class="nwl-icon" src="/img/fullscreen.svg" alt="">
280
+ </button>
281
+ </div>
282
+ ```
283
+
284
+ Icon button: an icon with no border; opacity .5 on hover. It shows no text, so give it an
285
+ accessible name with `aria-label`, and an empty `alt` to its image.
286
+
287
+ ```html
288
+ <button class="nwl-icon-button" aria-label="Zoom in"><img class="nwl-icon" src="/img/zoomIn.svg" alt=""></button>
289
+ ```
290
+
291
+ Icon: 16px, aligned with the text (`vertical-align: middle`), not selectable.
292
+
293
+ ```html
294
+ <img class="nwl-icon" src="/img/home.svg" alt="Home">
295
+ ```
296
+
297
+ Text field (`<input>`, `<textarea>`): its parent's font size and colour, `--nwl-bg-input`, 1px
298
+ `--nwl-border`, `--nwl-radius-sm`, no padding (as the apps' `.text`), placeholder in
299
+ `--nwl-text-placeholder`.
300
+
301
+ ```html
302
+ <input class="nwl-text-field" placeholder="Project name">
303
+ ```
304
+
305
+ Selected row: `aria-selected="true"` on a `<tr>` gives `--nwl-bg-elevated`.
306
+
307
+ ```html
308
+ <tr aria-selected="true"><td>axolotl</td></tr>
309
+ ```
310
+
311
+ Keyboard focus on the widgets shows `base.css`'s outline (2px `--nwl-focus`), also outside
312
+ `.app`. Links take `--nwl-link` (hover `--nwl-link-hover`), both the text colour: keep their
313
+ underline (the browser's) where they sit in text, so they don't depend on colour alone.
314
+
315
+ `dist/style.css` includes the widgets. A page with no bundle links the three files, in this
316
+ order (microdraw serves `node_modules/nwl-components/dist/` as `/lib/nwl-components/`):
317
+
318
+ ```html
319
+ <link rel="stylesheet" href="/lib/nwl-components/tokens.css">
320
+ <link rel="stylesheet" href="/lib/nwl-components/base.css">
321
+ <link rel="stylesheet" href="/lib/nwl-components/widgets.css">
322
+ ```
323
+
324
+ With a bundler: `import 'nwl-components/widgets.css'` after the tokens and base (webpack 4 too:
325
+ a copy at the package root). Storybook's `Library/Widgets` shows each widget in plain HTML, with
326
+ its states.
327
+
248
328
  ## Single File Components
249
329
 
250
330
  This project makes use of Vue SFCs: _Single File Components_, that have the `.vue` extension.
package/base.css CHANGED
@@ -44,11 +44,16 @@
44
44
  color: inherit;
45
45
  }
46
46
 
47
- /* links: the link colour, not the browser's blue */
47
+ /* links: the link colour, not the browser's blue. The browser's underline stays: links are
48
+ the text colour (--nwl-link), so the underline is what tells them apart (WCAG 1.4.1). */
48
49
  :where(.app a) {
49
50
  color: var(--nwl-link);
50
51
  }
51
52
 
53
+ :where(.app a:hover) {
54
+ color: var(--nwl-link-hover);
55
+ }
56
+
52
57
  /* Keyboard focus: a 2px outline in --nwl-focus. Mouse focus shows nothing (browsers match
53
58
  :focus-visible on a mouse click only for text fields). */
54
59
  :where(.app :focus-visible) {
package/dist/base.css CHANGED
@@ -44,11 +44,16 @@
44
44
  color: inherit;
45
45
  }
46
46
 
47
- /* links: the link colour, not the browser's blue */
47
+ /* links: the link colour, not the browser's blue. The browser's underline stays: links are
48
+ the text colour (--nwl-link), so the underline is what tells them apart (WCAG 1.4.1). */
48
49
  :where(.app a) {
49
50
  color: var(--nwl-link);
50
51
  }
51
52
 
53
+ :where(.app a:hover) {
54
+ color: var(--nwl-link-hover);
55
+ }
56
+
52
57
  /* Keyboard focus: a 2px outline in --nwl-focus. Mouse focus shows nothing (browsers match
53
58
  :focus-visible on a mouse click only for text fields). */
54
59
  :where(.app :focus-visible) {