Add feedback, layout, button, and interaction utilities

This commit is contained in:
2026-11-01 21:25:01 +01:00
parent 1944cb8f5a
commit 69107b7b84
8 changed files with 163 additions and 2 deletions
+13
View File
@@ -1,5 +1,18 @@
# Changelog
## 0.4.0
- Added semantic success, danger, warning, backdrop, popover, and toast tokens.
- Added dropdown, popover, tooltip, alert, toast, drawer, and fullscreen modal primitives.
- Added success, link, block, large, and loading button/control states.
- Added responsive cluster, dense grid, visibility, and overflow layout utilities.
- Expanded the example page and documentation with framework-independent interaction patterns.
## 0.3.0
- Published the Frost foundation used by the Penguin-chat and Portfolio3 migrations.
- Promoted the 0.2.0 theme, control, modal, and accessibility APIs as the current stable package surface.
## 0.2.0
- Added semantic `--frost-color-selection` and `--frost-color-overlay` tokens for project-defined themes.
+51
View File
@@ -102,6 +102,19 @@ body.theme-blue {
`--frost-color-selection` and `--frost-color-overlay` are available for theme-specific selection and overlay colors. Frost's modal primitives provide visual structure only; opening, closing, focus management, and ARIA behavior remain application responsibilities.
Frost's tokens are semantic and intentionally overridable. Add an application theme by setting the roles on a wrapper or document root; component selectors do not need to be redefined:
```css
[data-theme="ocean"] {
--frost-color-bg: #071a2b;
--frost-color-surface: #0d2a40;
--frost-color-text: #e8f5ff;
--frost-color-accent: #55b9ff;
--frost-color-accent-hover: #8bd1ff;
--frost-color-border: #24516b;
}
```
```html
<div class="frost-backdrop" hidden></div>
<section class="frost-modal" role="dialog" aria-modal="true" aria-labelledby="dialog-title" hidden>
@@ -113,6 +126,44 @@ body.theme-blue {
</section>
```
## Menus, popovers, and feedback
Frost supplies visual primitives while application code owns state, positioning updates, and keyboard behavior. Use native buttons, `aria-expanded`, `aria-controls`, and `hidden` so the same markup works with vanilla JavaScript or a framework:
```html
<div class="frost-dropdown">
<button class="frost-button frost-button--secondary" aria-expanded="false" aria-controls="account-menu">Account</button>
<div id="account-menu" class="frost-dropdown__menu" hidden>
<a class="frost-dropdown__item" href="/profile">Profile</a>
<button class="frost-dropdown__item" type="button">Sign out</button>
</div>
</div>
<div class="frost-alert frost-alert--warning" role="alert">
<strong class="frost-alert__title">Check your details</strong>
<span class="frost-alert__body">Some fields need attention.</span>
</div>
<div class="frost-toast-region" aria-live="polite" aria-atomic="true">
<div class="frost-toast frost-toast--success" role="status">
<span>Saved successfully.</span>
<button class="frost-button frost-button--icon" aria-label="Dismiss">×</button>
</div>
</div>
```
Tooltips use `data-frost-tooltip` and should supplement, never replace, an accessible label:
```html
<button class="frost-button frost-button--icon frost-tooltip" data-frost-tooltip="Copy link" aria-label="Copy link">⧉</button>
```
Modal, drawer, dropdown, and popover behavior is deliberately separate from CSS. A behavior layer should toggle `hidden`, synchronize `aria-expanded`, move focus into dialogs, return focus to the trigger, and close on Escape where appropriate. For modal dialogs, use `role="dialog" aria-modal="true"` and a labelled heading.
## Responsive utilities
`frost-cluster` is a wrapping flex row for actions, while `frost-hide-mobile`, `frost-show-mobile`, `frost-hide-desktop`, and `frost-responsive` cover common responsive composition needs. Layout components expose local properties such as `--frost-grid-min` and `--frost-cluster-gap` so applications can tune them without new framework classes.
## Customization
Override semantic tokens in the project layer:
+34
View File
@@ -37,6 +37,31 @@
.frost-notice--warning { border-color: var(--frost-color-warning); }
.frost-notice--danger { border-color: var(--frost-color-danger); }
.frost-alert { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: start; gap: var(--frost-space-3); padding: var(--frost-space-4); border: 1px solid var(--frost-color-border); border-radius: var(--frost-radius-md); background: var(--frost-color-surface); color: var(--frost-color-text); }
.frost-alert--info { border-color: var(--frost-color-info); }
.frost-alert--success { border-color: var(--frost-color-success); }
.frost-alert--warning { border-color: var(--frost-color-warning); }
.frost-alert--danger { border-color: var(--frost-color-danger); }
.frost-alert__title { font-weight: 700; }
.frost-alert__body { color: var(--frost-color-text-muted); }
.frost-toast-region { position: fixed; inset: var(--frost-space-4) var(--frost-space-4) auto auto; z-index: var(--frost-z-toast); display: grid; width: min(26rem, calc(100vw - 2rem)); gap: var(--frost-space-3); }
.frost-toast { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--frost-space-3); padding: var(--frost-space-4); border: 1px solid var(--frost-color-border-strong); border-radius: var(--frost-radius-md); background: var(--frost-color-surface); color: var(--frost-color-text); box-shadow: var(--frost-shadow-lg); }
.frost-toast--success { border-inline-start: 0.3rem solid var(--frost-color-success); }
.frost-toast--warning { border-inline-start: 0.3rem solid var(--frost-color-warning); }
.frost-toast--danger { border-inline-start: 0.3rem solid var(--frost-color-danger); }
.frost-dropdown, .frost-popover { position: relative; display: inline-block; }
.frost-dropdown__menu, .frost-popover__content { position: absolute; top: calc(100% + var(--frost-space-2)); left: 0; z-index: var(--frost-z-popover); min-width: 12rem; padding: var(--frost-space-2); border: 1px solid var(--frost-color-border-strong); border-radius: var(--frost-radius-md); background: var(--frost-color-surface); color: var(--frost-color-text); box-shadow: var(--frost-shadow-md); }
.frost-dropdown__menu[hidden], .frost-popover__content[hidden] { display: none; }
.frost-dropdown__menu--end, .frost-popover__content--end { right: 0; left: auto; }
.frost-dropdown__item { display: block; width: 100%; padding: var(--frost-space-2) var(--frost-space-3); border: 0; border-radius: var(--frost-radius-sm); background: transparent; color: inherit; text-align: start; text-decoration: none; }
.frost-dropdown__item:hover, .frost-dropdown__item:focus-visible { background: var(--frost-color-surface-hover); }
.frost-tooltip { position: relative; }
.frost-tooltip::after { position: absolute; bottom: calc(100% + var(--frost-space-2)); left: 50%; z-index: var(--frost-z-popover); width: max-content; max-width: 16rem; padding: var(--frost-space-2) var(--frost-space-3); border-radius: var(--frost-radius-sm); background: var(--frost-color-text); color: var(--frost-color-bg); content: attr(data-frost-tooltip); font-size: var(--frost-font-size-sm); line-height: 1.3; opacity: 0; pointer-events: none; transform: translate(-50%, 0.25rem); transition: opacity var(--frost-duration-fast) var(--frost-ease-out), transform var(--frost-duration-fast) var(--frost-ease-out); }
.frost-tooltip:hover::after, .frost-tooltip:focus-visible::after, .frost-tooltip:focus-within::after { opacity: 1; transform: translate(-50%, 0); }
.frost-backdrop {
position: fixed;
inset: 0;
@@ -53,6 +78,10 @@
z-index: var(--frost-z-modal);
}
dialog.frost-modal { width: 100%; max-width: none; height: 100%; max-height: none; margin: 0; border: 0; background: transparent; }
dialog.frost-modal::backdrop { background: var(--frost-color-backdrop); }
dialog.frost-modal[open] { display: grid; }
.frost-modal__content {
width: min(100%, 32rem);
max-height: min(90vh, 42rem);
@@ -70,6 +99,11 @@
.frost-modal__header { justify-content: space-between; margin-block-end: var(--frost-space-4); }
.frost-modal__body { display: grid; gap: var(--frost-space-4); }
.frost-modal__footer { justify-content: flex-end; margin-block-start: var(--frost-space-4); }
.frost-modal--fullscreen .frost-modal__content { width: 100%; max-height: 100%; min-height: 100%; border-radius: 0; }
.frost-modal--drawer { place-items: stretch end; padding: 0; }
.frost-modal--drawer .frost-modal__content { width: min(100%, 28rem); max-height: none; height: 100%; border-radius: var(--frost-radius-lg) 0 0 var(--frost-radius-lg); }
[data-theme="dark"] .frost-tooltip::after { background: var(--frost-color-surface-soft); color: var(--frost-color-text); }
@media (prefers-reduced-motion: reduce) {
.frost-card--interactive:hover,
+16
View File
@@ -20,10 +20,16 @@
:where(.frost-button--secondary) { border-color: var(--frost-color-border-strong); background: var(--frost-color-surface); color: var(--frost-color-text); }
:where(.frost-button--ghost) { border-color: transparent; color: var(--frost-color-accent); }
:where(.frost-button--danger) { border-color: var(--frost-color-danger); background: var(--frost-color-danger); color: #fff; }
:where(.frost-button--success) { border-color: var(--frost-color-success); background: var(--frost-color-success); color: var(--frost-color-on-success); }
:where(.frost-button--link) { min-height: auto; padding: 0; border-color: transparent; color: var(--frost-color-accent); text-decoration: underline; text-underline-offset: 0.15em; }
:where(.frost-button--block) { width: 100%; }
:where(.frost-button--lg) { min-height: 3rem; padding: var(--frost-space-3) var(--frost-space-5); font-size: var(--frost-font-size-lg); }
:where(.frost-button--primary:hover:not(:disabled):not([aria-disabled="true"])) { background: var(--frost-color-accent-hover); border-color: var(--frost-color-accent-hover); }
:where(.frost-button--secondary:hover:not(:disabled):not([aria-disabled="true"])) { background: var(--frost-color-surface-hover); }
:where(.frost-button--ghost:hover:not(:disabled):not([aria-disabled="true"])) { background: var(--frost-color-surface-soft); }
:where(.frost-button--danger:hover:not(:disabled):not([aria-disabled="true"])) { filter: brightness(0.92); }
:where(.frost-button--success:hover:not(:disabled):not([aria-disabled="true"])) { filter: brightness(0.92); }
:where(.frost-button--link:hover:not(:disabled):not([aria-disabled="true"])) { background: var(--frost-color-surface-soft); }
:where(.frost-button:active:not(:disabled):not([aria-disabled="true"])) { transform: translateY(1px); }
:where(.frost-button:disabled, .frost-button[aria-disabled="true"]) { opacity: 0.55; cursor: not-allowed; }
:where(.frost-button--sm) { min-height: 2rem; padding: var(--frost-space-1) var(--frost-space-2); font-size: var(--frost-font-size-sm); }
@@ -47,11 +53,21 @@
:where(.frost-input:focus, .frost-select:focus, .frost-textarea:focus) { border-color: var(--frost-focus-color); box-shadow: 0 0 0 var(--frost-focus-width) rgb(37 99 235 / 0.22); box-shadow: 0 0 0 var(--frost-focus-width) color-mix(in srgb, var(--frost-focus-color) 22%, transparent); }
:where(.frost-input:disabled, .frost-select:disabled, .frost-textarea:disabled) { background: var(--frost-color-surface-soft); opacity: 0.65; }
:where(.frost-input[aria-invalid="true"], .frost-select[aria-invalid="true"], .frost-textarea[aria-invalid="true"]) { border-color: var(--frost-color-danger); }
:where(.frost-input[aria-invalid="true"]:focus, .frost-select[aria-invalid="true"]:focus, .frost-textarea[aria-invalid="true"]:focus) { box-shadow: 0 0 0 var(--frost-focus-width) color-mix(in srgb, var(--frost-color-danger) 22%, transparent); }
:where(.frost-input[aria-busy="true"], .frost-select[aria-busy="true"], .frost-textarea[aria-busy="true"]) { background-image: linear-gradient(90deg, transparent, var(--frost-color-surface-soft), transparent); background-size: 200% 100%; animation: frost-control-loading 1.2s linear infinite; }
:where(.frost-input--success, .frost-select--success, .frost-textarea--success, .frost-input[aria-invalid="false"], .frost-select[aria-invalid="false"], .frost-textarea[aria-invalid="false"]) { border-color: var(--frost-color-success); }
:where(.frost-input--warning, .frost-select--warning, .frost-textarea--warning) { border-color: var(--frost-color-warning); }
:where(.frost-input--readonly, .frost-input[readonly]) { background: var(--frost-color-surface-soft); }
:where(.frost-field--disabled) { opacity: 0.65; }
.frost-field { display: grid; gap: var(--frost-space-2); }
.frost-label { color: var(--frost-color-text); font-weight: 650; }
.frost-help, .frost-error { font-size: var(--frost-font-size-sm); }
.frost-help { color: var(--frost-color-text-muted); }
.frost-error { color: var(--frost-color-danger); }
.frost-success { color: var(--frost-color-success); }
.frost-warning { color: var(--frost-color-warning); }
@keyframes frost-control-loading { to { background-position: -200% 0; } }
}
+27 -1
View File
@@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Frost v0.1 example</title>
<title>Frost v0.4 example</title>
<link rel="stylesheet" href="../frost.css">
<style>
body { padding-block: var(--frost-space-8); }
@@ -40,6 +40,25 @@
</div>
</section>
<section class="example-section frost-stack">
<h2>Feedback and menus</h2>
<div class="frost-alert frost-alert--warning" role="alert">
<strong class="frost-alert__title">Heads up</strong>
<span class="frost-alert__body">This is a dismissible-style alert primitive; your behavior layer controls dismissal.</span>
</div>
<div class="frost-cluster">
<div class="frost-dropdown">
<button class="frost-button frost-button--secondary" id="menu-trigger" type="button" aria-expanded="false" aria-controls="example-menu">Open menu</button>
<div class="frost-dropdown__menu" id="example-menu" hidden>
<a class="frost-dropdown__item" href="#main">Overview</a>
<button class="frost-dropdown__item" type="button">A menu action</button>
</div>
</div>
<button class="frost-button frost-button--primary frost-tooltip" data-frost-tooltip="A CSS-only tooltip" aria-label="Tooltip demo">Hover or focus</button>
</div>
<div class="frost-toast frost-toast--success" role="status"><span>Changes saved successfully.</span><button class="frost-button frost-button--icon" type="button" aria-label="Dismiss example toast">×</button></div>
</section>
<section class="example-section frost-stack">
<h2>Buttons and badges</h2>
<div class="frost-row">
@@ -73,6 +92,13 @@
document.querySelector('#theme-toggle').addEventListener('click', () => {
document.documentElement.dataset.theme = document.documentElement.dataset.theme === 'dark' ? 'light' : 'dark';
});
document.querySelector('#menu-trigger').addEventListener('click', (event) => {
const trigger = event.currentTarget;
const menu = document.querySelector('#example-menu');
const open = trigger.getAttribute('aria-expanded') === 'true';
trigger.setAttribute('aria-expanded', String(!open));
menu.hidden = open;
});
</script>
</body>
</html>
+11 -1
View File
@@ -50,9 +50,19 @@
.frost-main { min-width: 0; }
.frost-cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--frost-cluster-gap, var(--frost-space-3)); }
.frost-grid--dense { --frost-grid-gap: var(--frost-space-3); }
.frost-hide-mobile { display: initial; }
.frost-show-mobile { display: none; }
.frost-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media (max-width: 48rem) {
.frost-sidebar-layout { grid-template-columns: 1fr; }
.frost-sidebar { position: static; min-height: auto; }
}
.frost-hide-mobile { display: none; }
.frost-show-mobile { display: initial; }
}
@media (min-width: 48.01rem) { .frost-hide-desktop { display: none; } }
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@fretuks/frost",
"version": "0.2.0",
"version": "0.4.0",
"description": "A compact, semantic CSS foundation for websites and web applications.",
"style": "./frost.css",
"exports": {
+11
View File
@@ -18,6 +18,10 @@
--frost-color-warning: #9a5b00;
--frost-color-danger: #b42318;
--frost-color-info: #1769aa;
--frost-color-on-danger: #ffffff;
--frost-color-on-success: #ffffff;
--frost-color-on-warning: #172027;
--frost-color-backdrop: var(--frost-color-overlay);
--frost-space-1: 0.25rem;
--frost-space-2: 0.5rem;
@@ -27,6 +31,8 @@
--frost-space-6: 1.5rem;
--frost-space-8: 2rem;
--frost-space-10: 2.5rem;
--frost-space-12: 3rem;
--frost-space-16: 4rem;
--frost-radius-sm: 0.375rem;
--frost-radius-md: 0.625rem;
@@ -63,6 +69,8 @@
--frost-focus-offset: 3px;
--frost-z-overlay: 1000;
--frost-z-modal: 1001;
--frost-z-popover: 1010;
--frost-z-toast: 1020;
}
@media (prefers-color-scheme: dark) {
@@ -85,6 +93,9 @@
--frost-color-warning: #f3bd63;
--frost-color-danger: #ff9388;
--frost-color-info: #7fc4ff;
--frost-color-on-danger: #2a0907;
--frost-color-on-success: #062818;
--frost-color-on-warning: #2a1a04;
--frost-shadow-sm: 0 1px 2px rgb(0 0 0 / 0.25);
--frost-shadow-md: 0 4px 14px rgb(0 0 0 / 0.28);
--frost-shadow-lg: 0 16px 45px rgb(0 0 0 / 0.38);