@filipgutica/design-system 1.0.9 → 1.0.10
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 +1 -1
- package/language/components.html +17 -11
- package/language/components.md +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Filip's design language for any framework: the spec, the tokens, the component catalogue, and the editor themes. It ships as the npm package `@filipgutica/design-system`.
|
|
4
4
|
|
|
5
|
-
- **Agents** get `language/` at `~/design-language` through filip-stack host config.
|
|
5
|
+
- **Agents** get `language/` at `~/design-language` through filip-stack host config, or by copying it from the package; the site's [Agents](https://filipgutica.github.io/design-system/#agents) section has both.
|
|
6
6
|
- **Vue apps** use [`@filipgutica/ui`](https://github.com/filipgutica/ui), which implements this design language.
|
|
7
7
|
- **Site:** <https://filipgutica.github.io/design-system/> has the Overview, Foundations, and Components pages, with `index.json` and `llms.txt` for agents.
|
|
8
8
|
|
package/language/components.html
CHANGED
|
@@ -1693,6 +1693,7 @@
|
|
|
1693
1693
|
});
|
|
1694
1694
|
|
|
1695
1695
|
// Full size: open the selected capture in a named modal; the native dialog restores focus to the trigger.
|
|
1696
|
+
// Safari does not focus a button on click, so the trigger takes focus first and the dialog has it to return to.
|
|
1696
1697
|
const viewer = document.getElementById('capture-viewer');
|
|
1697
1698
|
document.querySelectorAll('[data-full-size]').forEach((button) => button.addEventListener('click', () => {
|
|
1698
1699
|
const panel = button.closest('.capture').querySelector('.tabpanel:not([hidden])');
|
|
@@ -1701,6 +1702,7 @@
|
|
|
1701
1702
|
const screen = panel.querySelector('.screen').cloneNode(true);
|
|
1702
1703
|
screen.setAttribute('aria-label', `${name} capture, full size`);
|
|
1703
1704
|
document.getElementById('capture-viewer-body').replaceChildren(screen, panel.querySelector('.capture-caption').cloneNode(true));
|
|
1705
|
+
button.focus({ preventScroll: true });
|
|
1704
1706
|
viewer.showModal();
|
|
1705
1707
|
}));
|
|
1706
1708
|
|
|
@@ -1739,6 +1741,20 @@
|
|
|
1739
1741
|
button.focus();
|
|
1740
1742
|
document.getElementById(button.dataset.open).showModal();
|
|
1741
1743
|
}));
|
|
1744
|
+
// A tap or click on the backdrop, which belongs to the dialog element, lands outside the dialog's box and
|
|
1745
|
+
// closes it. closedby="any" would do this, but Safari does not support it. Only a press that starts outside
|
|
1746
|
+
// counts, so a drag out of the dialog keeps it open. It closes on the click, not the press: a dialog that
|
|
1747
|
+
// closes at once would otherwise pass the release and its click to the page behind.
|
|
1748
|
+
const closeOnBackdrop = (dialog, close) => {
|
|
1749
|
+
const outside = (e) => {
|
|
1750
|
+
const box = dialog.getBoundingClientRect();
|
|
1751
|
+
return e.clientX < box.left || e.clientX > box.right || e.clientY < box.top || e.clientY > box.bottom;
|
|
1752
|
+
};
|
|
1753
|
+
let pressedOutside = false;
|
|
1754
|
+
dialog.addEventListener('pointerdown', (e) => { pressedOutside = outside(e); });
|
|
1755
|
+
dialog.addEventListener('click', (e) => { if (pressedOutside && e.target === dialog && outside(e)) close(); });
|
|
1756
|
+
};
|
|
1757
|
+
document.querySelectorAll('dialog.dialog').forEach((dialog) => closeOnBackdrop(dialog, () => dialog.close()));
|
|
1742
1758
|
// Following an in-page link closes the drawer, then focus moves to the destination instead of the trigger.
|
|
1743
1759
|
// Every close path slides the drawer out first. Under reduced motion there is no animation, so it closes at once.
|
|
1744
1760
|
// A slide that is cancelled, such as by turning on reduced motion mid-slide, still closes the drawer.
|
|
@@ -1759,17 +1775,7 @@
|
|
|
1759
1775
|
};
|
|
1760
1776
|
drawer.addEventListener('cancel', (e) => { e.preventDefault(); slideOut(); });
|
|
1761
1777
|
drawer.querySelector('form[method="dialog"]')?.addEventListener('submit', (e) => { e.preventDefault(); slideOut(); });
|
|
1762
|
-
|
|
1763
|
-
// closes it. closedby="any" would do this, but Safari does not support it. Only a press that starts outside
|
|
1764
|
-
// counts, so a drag out of the drawer keeps it open. It closes on the click, not the press: a drawer that
|
|
1765
|
-
// closes at once, under reduced motion, would otherwise pass the release and its click to the page behind.
|
|
1766
|
-
const outside = (e) => {
|
|
1767
|
-
const box = drawer.getBoundingClientRect();
|
|
1768
|
-
return e.clientX < box.left || e.clientX > box.right || e.clientY < box.top || e.clientY > box.bottom;
|
|
1769
|
-
};
|
|
1770
|
-
let pressedOutside = false;
|
|
1771
|
-
drawer.addEventListener('pointerdown', (e) => { pressedOutside = outside(e); });
|
|
1772
|
-
drawer.addEventListener('click', (e) => { if (pressedOutside && e.target === drawer && outside(e)) slideOut(); });
|
|
1778
|
+
closeOnBackdrop(drawer, slideOut);
|
|
1773
1779
|
drawer.addEventListener('click', (e) => {
|
|
1774
1780
|
const link = e.target.closest('a[href^="#"]');
|
|
1775
1781
|
if (!link || e.button !== 0 || e.metaKey || e.ctrlKey || e.altKey || e.shiftKey) return;
|
package/language/components.md
CHANGED
|
@@ -279,6 +279,7 @@ Layer: Core. ui: `UiDialog`.
|
|
|
279
279
|
- **Do.** Use a dialog for a short task the reader must finish or cancel before the page continues, such as confirming a deletion. Title it with that task.
|
|
280
280
|
- **Don't.** A dialog that opens without the reader asking, such as on page load, or one that holds a long form. A long form gets its own page.
|
|
281
281
|
- **Keyboard and screen reader.** `role="dialog"`, `aria-modal="true"`, named by its title. Focus moves in on open and is trapped. Escape closes it, and focus returns to the trigger. A native `<dialog>` opened with `showModal()` provides most of this.
|
|
282
|
+
- **Backdrop.** A tap or click on the backdrop, outside the dialog, closes it, the same way Escape does, and focus returns to the trigger. Only a press that starts outside counts: a drag that starts inside the dialog and ends outside leaves it open. Safari does not support `closedby="any"`, so a script closes it.
|
|
282
283
|
- **Motion.** None: it opens and closes at once. Only the drawer slides, because it enters from an edge.
|
|
283
284
|
- **Forced colors.** The shadow drops and the transparent border draws as the system edge, so the dialog keeps its outline over the page.
|
|
284
285
|
|