From 69107b7b84928d37fe86b42fdd7319d62539fd4d Mon Sep 17 00:00:00 2001 From: fretuks Date: Sun, 1 Nov 2026 21:25:01 +0100 Subject: [PATCH] Add feedback, layout, button, and interaction utilities --- CHANGELOG.md | 13 ++++++++++++ README.md | 51 +++++++++++++++++++++++++++++++++++++++++++++ components.css | 34 ++++++++++++++++++++++++++++++ controls.css | 16 ++++++++++++++ examples/index.html | 28 ++++++++++++++++++++++++- layout.css | 10 +++++++++ package.json | 2 +- tokens.css | 11 ++++++++++ 8 files changed, 163 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7991809..aea879f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/README.md b/README.md index 24da453..50730d0 100644 --- a/README.md +++ b/README.md @@ -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 ``` +## 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 +
+ + +
+ + + +
+
+ Saved successfully. + +
+
+``` + +Tooltips use `data-frost-tooltip` and should supplement, never replace, an accessible label: + +```html + +``` + +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: diff --git a/components.css b/components.css index 2ac179d..8497f60 100644 --- a/components.css +++ b/components.css @@ -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, diff --git a/controls.css b/controls.css index 549c7ed..e184ad5 100644 --- a/controls.css +++ b/controls.css @@ -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; } } } diff --git a/examples/index.html b/examples/index.html index 1304e81..675e2ea 100644 --- a/examples/index.html +++ b/examples/index.html @@ -3,7 +3,7 @@ - Frost v0.1 example + Frost v0.4 example