@codenhub/styles 0.4.0 → 0.6.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 +7 -7
- package/dist/aesthetics/chunky-tile.css +1 -1
- package/dist/aesthetics/cyber.css +1 -1
- package/dist/aesthetics/glass.css +1 -1
- package/dist/aesthetics/index.css +1 -1
- package/dist/aesthetics/neobrutalism.css +1 -1
- package/dist/aesthetics/pixel.css +1 -1
- package/dist/aesthetics/sketch.css +1 -0
- package/dist/components.css +1 -1
- package/dist/index.css +1 -1
- package/dist/native.css +1 -1
- package/dist/palette.css +1 -1
- package/dist/theme.css +1 -1
- package/dist/tw/aesthetics/chunky-tile.css +144 -128
- package/dist/tw/aesthetics/cyber.css +138 -96
- package/dist/tw/aesthetics/glass.css +332 -66
- package/dist/tw/aesthetics/index.css +3 -1
- package/dist/tw/aesthetics/neobrutalism.css +113 -54
- package/dist/tw/aesthetics/pixel.css +137 -87
- package/dist/tw/aesthetics/sketch.css +333 -0
- package/dist/tw/box.css +139 -52
- package/dist/tw/components/button.css +67 -28
- package/dist/tw/components/feedback.css +85 -67
- package/dist/tw/components/form.css +300 -230
- package/dist/tw/components/index.css +17 -9
- package/dist/tw/components/loader.css +38 -30
- package/dist/tw/components/surface.css +89 -129
- package/dist/tw/components/tooltip.css +91 -47
- package/dist/tw/corner.css +26 -0
- package/dist/tw/elevation.css +19 -28
- package/dist/tw/index.css +15 -19
- package/dist/tw/intent.css +47 -32
- package/dist/tw/native.css +58 -42
- package/dist/tw/palette.css +455 -446
- package/dist/tw/presentation.css +20 -29
- package/dist/tw/reset.css +21 -28
- package/dist/tw/surface.css +61 -0
- package/dist/tw/theme.css +156 -153
- package/dist/tw/utilities/content.css +283 -205
- package/dist/tw/utilities/layout.css +17 -27
- package/docs/accessibility.md +63 -46
- package/docs/changelog/0.5.0.md +38 -0
- package/docs/changelog/0.6.0.md +52 -0
- package/docs/changelog/index.md +2 -0
- package/docs/concepts.md +6 -6
- package/docs/index.md +12 -3
- package/docs/integrating/nextjs.md +1 -1
- package/docs/integrating/tailwind.md +14 -6
- package/docs/setup.md +28 -8
- package/docs/usage/aesthetics.md +88 -18
- package/docs/usage/buttons.md +14 -14
- package/docs/usage/composing.md +12 -12
- package/docs/usage/content-and-layout.md +25 -24
- package/docs/usage/customizing.md +92 -55
- package/docs/usage/feedback.md +5 -3
- package/docs/usage/forms.md +61 -45
- package/docs/usage/theming.md +41 -42
- package/docs/usage/tooltips.md +37 -17
- package/llms-full.txt +590 -304
- package/llms.txt +6 -0
- package/package.json +15 -5
package/docs/usage/tooltips.md
CHANGED
|
@@ -6,24 +6,25 @@ order: 8
|
|
|
6
6
|
|
|
7
7
|
# Tooltips
|
|
8
8
|
|
|
9
|
-
| Class or Attribute | Purpose
|
|
10
|
-
| -------------------------------------- |
|
|
11
|
-
| `.tooltip` | Wrapper around a trigger and a bubble. Paints nothing itself.
|
|
12
|
-
| `.tooltip-bubble` | The message. A real element, styled like any other surface.
|
|
13
|
-
| `.tooltip-icon` |
|
|
14
|
-
| `[data-tooltip-position="top"]` | Positions the bubble above the trigger, on `.tooltip`.
|
|
15
|
-
| `[data-tooltip-position="bottom"]` | Positions the bubble below the trigger, on `.tooltip`.
|
|
16
|
-
| `[data-tooltip-position="left"]` | Positions the bubble left of the trigger, on `.tooltip`.
|
|
17
|
-
| `[data-tooltip-position="right"]` | Positions the bubble right of the trigger, on `.tooltip`.
|
|
18
|
-
| No `data-tooltip-position` | Defaults to top placement.
|
|
19
|
-
| `[data-state="open"]` | Shows the bubble without hover, on `.tooltip`.
|
|
20
|
-
|
|
|
21
|
-
|
|
22
|
-
|
|
9
|
+
| Class or Attribute | Purpose |
|
|
10
|
+
| -------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
11
|
+
| `.tooltip` | Wrapper around a trigger and a bubble. Paints nothing itself. |
|
|
12
|
+
| `.tooltip-bubble` | The message. A real element, styled like any other surface. |
|
|
13
|
+
| `.tooltip-icon` | Round icon-style trigger, for a message with nothing else to hang on. It takes the aesthetic's corner: square under `.neobrutalism` and `.pixel`, a diamond under `.cyber`. |
|
|
14
|
+
| `[data-tooltip-position="top"]` | Positions the bubble above the trigger, on `.tooltip`. |
|
|
15
|
+
| `[data-tooltip-position="bottom"]` | Positions the bubble below the trigger, on `.tooltip`. |
|
|
16
|
+
| `[data-tooltip-position="left"]` | Positions the bubble left of the trigger, on `.tooltip`. |
|
|
17
|
+
| `[data-tooltip-position="right"]` | Positions the bubble right of the trigger, on `.tooltip`. |
|
|
18
|
+
| No `data-tooltip-position` | Defaults to top placement. |
|
|
19
|
+
| `[data-state="open"]` | Shows the bubble without hover, on `.tooltip`. |
|
|
20
|
+
| `[data-state="closed"]` | Hides the bubble even while hovered or focused, on `.tooltip`. For an Escape handler. |
|
|
21
|
+
| `.tooltip-bubble.raised` / `.floating` | Adds one or two units of depth. The bubble is flat by default. |
|
|
22
|
+
|
|
23
|
+
A tooltip is composition, not a single class: `.tooltip` wraps a trigger element and a `.tooltip-bubble`, and shows the bubble on hover or focus within the wrapper. The bubble is a real element because CSS generated content is not reliably exposed to assistive tech and cannot be the target of an `aria-describedby`, which needs a real element with a real `id`. Wire the association yourself: give the bubble an `id`, give the trigger `aria-describedby` pointing at it, and put `role="tooltip"` on the bubble.
|
|
23
24
|
|
|
24
25
|
A tooltip bubble's fill, ground color, and floor behavior are covered in [Composing → Presentation](./composing.md#presentation), and its material follows whichever [aesthetic](./aesthetics.md) is in scope. Intent, presentation, aesthetic, and elevation classes go on `.tooltip-bubble` — the element that actually paints — not on `.tooltip`, the same rule every component in this package follows: put the class on the element that shows it.
|
|
25
26
|
|
|
26
|
-
The bubble rests flat. It draws no shadow of its own on a plain page, and zeroes an aesthetic's part-based depth (such as `.neobrutalism`'s slab) the same way `.flat` does elsewhere. Add [`.raised` or `.floating`](./composing.md#elevation) to lift it, on the bubble itself
|
|
27
|
+
The bubble rests flat. It draws no shadow of its own on a plain page, and zeroes an aesthetic's part-based depth (such as `.neobrutalism`'s slab) the same way `.flat` does elsewhere. Add [`.raised` or `.floating`](./composing.md#elevation) to lift it, on the bubble itself. An aesthetic whose shadow is a complete value, like `.glass`, still reaches the bubble as it reaches any surface.
|
|
27
28
|
|
|
28
29
|
Intent works on a tooltip bubble the same way it works on a filled component: `.tooltip-bubble.primary` fills the bubble with the primary color, black text on a light page and white on a dark one; `.tooltip-bubble.destructive` is a red bubble with the same logic. With no intent, the bubble uses `--color-tooltip`, a plate chosen per theme rather than derived from an intent; see [Composing → Presentation](./composing.md#presentation) for why.
|
|
29
30
|
|
|
@@ -51,15 +52,34 @@ Intent works on a tooltip bubble the same way it works on a filled component: `.
|
|
|
51
52
|
</span>
|
|
52
53
|
|
|
53
54
|
<span class="tooltip" data-tooltip-position="right">
|
|
54
|
-
<
|
|
55
|
+
<button type="button" class="tooltip-icon" aria-label="More details" aria-describedby="icon-bubble">?</button>
|
|
55
56
|
<span class="tooltip-bubble" role="tooltip" id="icon-bubble">More details</span>
|
|
56
57
|
</span>
|
|
57
58
|
```
|
|
58
59
|
|
|
59
60
|
The first two show plain triggers with default (top) and explicit bottom placement. The third combines an intent with `.raised` on the bubble to show they compose freely — the intent decides the bubble's fill, `.raised` decides whether it casts depth. The fourth uses `data-state="open"` on the wrapper to keep a tooltip visible without a hover or focus interaction, useful for a tooltip that should be demonstrated or tested without simulating pointer input. The fifth uses `.tooltip-icon` as the trigger, for a message with no other element to hang it on.
|
|
60
61
|
|
|
61
|
-
`.tooltip` composes with any trigger: wrap an existing `.btn` or `.badge` in it and both keep their own look, gaining a bubble beside them. `.tooltip-icon` is only the
|
|
62
|
+
`.tooltip` composes with any trigger: wrap an existing `.btn` or `.badge` in it and both keep their own look, gaining a bubble beside them. `.tooltip-icon` is only the round chip for the case where there is nothing else to be the trigger.
|
|
62
63
|
|
|
63
64
|
Showing and hiding the bubble is CSS-only — `:hover` and `:focus-within` on `.tooltip` — but that is presentational. It is not a complete accessible tooltip implementation by itself: provide the `id`/`aria-describedby`/`role="tooltip"` association outside the CSS; see [Accessibility](../accessibility.md).
|
|
64
65
|
|
|
66
|
+
The bubble is hoverable, as WCAG 1.4.13 asks of content that appears on hover: once the pointer leaves the trigger, the bubble stays for `--tooltip-linger` (`300ms`, set on `.tooltip`) and then fades, so the pointer can cross the gap onto it, and it stays open for as long as the pointer is over it. A closed bubble is `visibility: hidden`, so it is nothing under the pointer. It stays in the accessibility tree through `aria-describedby`, which reads hidden content, but a bubble with no `aria-describedby` pointing at it is no longer read in place while hidden.
|
|
67
|
+
|
|
68
|
+
1.4.13 also asks that the message can be dismissed without moving the pointer or focus, which takes a key handler. Write `data-state="closed"` on `.tooltip` on Escape, and clear it when the pointer and focus leave:
|
|
69
|
+
|
|
70
|
+
```js
|
|
71
|
+
for (const tooltip of document.querySelectorAll(".tooltip")) {
|
|
72
|
+
const reopen = () => tooltip.removeAttribute("data-state");
|
|
73
|
+
tooltip.addEventListener("pointerleave", reopen);
|
|
74
|
+
tooltip.addEventListener("focusout", reopen);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
document.addEventListener("keydown", (event) => {
|
|
78
|
+
if (event.key !== "Escape") return;
|
|
79
|
+
for (const tooltip of document.querySelectorAll(".tooltip:hover, .tooltip:focus-within")) {
|
|
80
|
+
tooltip.dataset.state = "closed";
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
```
|
|
84
|
+
|
|
65
85
|
Next: [Content and layout](./content-and-layout.md) covers layout helpers, content chips and tables, surfaces, and typography utilities.
|