diff --git a/forced-colors.css b/forced-colors.css new file mode 100644 index 0000000..eb49b46 --- /dev/null +++ b/forced-colors.css @@ -0,0 +1,207 @@ +@layer frost.forced-colors { + @media (prefers-contrast: more) and (forced-colors: none) { + :where(.frost-button, .frost-input, .frost-select, .frost-textarea, .frost-card, .frost-surface, .frost-notice, .frost-alert, .frost-toast, .frost-dropdown__menu, .frost-popover__content, .frost-modal__content, .frost-pagination__item) { + border-width: 2px; + } + + :where(.frost-button--danger, .frost-badge--danger, .frost-notice--danger, .frost-alert--danger, .frost-toast--danger, .frost-input[aria-invalid="true"], .frost-select[aria-invalid="true"], .frost-textarea[aria-invalid="true"]) { + border-style: dashed; + } + + :where(.frost-badge--warning, .frost-notice--warning, .frost-alert--warning, .frost-toast--warning, .frost-input--warning, .frost-select--warning, .frost-textarea--warning) { + border-width: 3px; + border-style: double; + } + + :where(.frost-button:disabled, .frost-button[aria-disabled="true"], .frost-input:disabled, .frost-select:disabled, .frost-textarea:disabled, .frost-field--disabled) { + border-style: dotted; + opacity: 1; + } + + :where(.frost-help, .frost-text-muted, .frost-alert__body, .frost-navbar__link, .frost-breadcrumbs, .frost-tabs__tab) { + color: var(--frost-color-text); + } + + :where(.frost-tabs__tab[aria-selected="true"]) { border-block-end-width: 3px; } + :where(.frost-pagination__item[aria-current="page"], .frost-navbar__link[aria-current="page"]) { outline: 2px solid currentColor; outline-offset: 2px; } + :where(:focus-visible) { outline-width: max(3px, var(--frost-focus-width)); outline-offset: max(3px, var(--frost-focus-offset)); } + } + + @media (forced-colors: active) { + :where(html) { forced-color-adjust: auto; } + :where(body) { background: Canvas; color: CanvasText; } + :where(a) { color: LinkText; } + + :where(.frost-button) { + border-color: ButtonText; + background: ButtonFace; + color: ButtonText; + box-shadow: none; + filter: none; + forced-color-adjust: none; + } + + :where(.frost-button--primary, .frost-button--success) { + border-color: Highlight; + background: Highlight; + color: HighlightText; + } + + :where(.frost-button--danger) { + border-color: Highlight; + border-style: dashed; + border-width: 2px; + background: Canvas; + color: CanvasText; + } + + :where(.frost-button--ghost, .frost-button--link) { + border-color: ButtonText; + background: Canvas; + color: LinkText; + } + + :where(.frost-button:hover:not(:disabled):not([aria-disabled="true"])) { + border-color: Highlight; + background: Highlight; + color: HighlightText; + } + + :where(.frost-button:active:not(:disabled):not([aria-disabled="true"])) { + border-style: double; + transform: none; + } + + :where(.frost-button:disabled, .frost-button[aria-disabled="true"]) { + border-color: GrayText; + background: ButtonFace; + color: GrayText; + opacity: 1; + } + + :where(.frost-input, .frost-select, .frost-textarea) { + border-color: ButtonText; + background: Canvas; + background-image: none; + color: CanvasText; + box-shadow: none; + forced-color-adjust: none; + } + + :where(.frost-input::placeholder, .frost-textarea::placeholder) { color: GrayText; } + :where(.frost-input:disabled, .frost-select:disabled, .frost-textarea:disabled, .frost-input--readonly, .frost-input[readonly]) { + border-color: GrayText; + background: ButtonFace; + color: GrayText; + opacity: 1; + } + + :where(.frost-input[aria-invalid="true"], .frost-select[aria-invalid="true"], .frost-textarea[aria-invalid="true"]) { + border: 2px dashed Highlight; + } + + :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: 3px double CanvasText; + } + + :where(.frost-input--warning, .frost-select--warning, .frost-textarea--warning) { + border: 3px double Highlight; + } + + :where(.frost-field--disabled) { opacity: 1; } + :where(.frost-help) { color: GrayText; } + :where(.frost-error, .frost-warning) { color: Highlight; } + :where(.frost-success) { color: CanvasText; text-decoration: underline double; } + + :where(.frost-card, .frost-surface, .frost-notice, .frost-alert, .frost-toast, .frost-dropdown__menu, .frost-popover__content, .frost-modal__content) { + border-color: CanvasText; + background: Canvas; + color: CanvasText; + box-shadow: none; + forced-color-adjust: none; + transition: none; + } + + :where(.frost-card--interactive:hover, .frost-card--interactive:focus-within) { + border: 2px solid Highlight; + box-shadow: none; + transform: none; + } + + :where(.frost-badge) { + border-color: CanvasText; + background: Canvas; + color: CanvasText; + forced-color-adjust: none; + } + + :where(.frost-badge--danger, .frost-notice--danger, .frost-alert--danger, .frost-toast--danger) { border-width: 2px; border-style: dashed; } + :where(.frost-badge--warning, .frost-notice--warning, .frost-alert--warning, .frost-toast--warning) { border-width: 3px; border-style: double; } + :where(.frost-badge--success, .frost-notice--success, .frost-alert--success, .frost-toast--success) { border-width: 2px; } + :where(.frost-alert__body) { color: CanvasText; } + + :where(.frost-dropdown__item) { color: ButtonText; forced-color-adjust: none; } + :where(.frost-dropdown__item:hover, .frost-dropdown__item:focus-visible) { background: Highlight; color: HighlightText; } + + :where(.frost-tooltip::after) { + border: 1px solid Canvas; + background: CanvasText; + color: Canvas; + forced-color-adjust: none; + } + + :where(.frost-backdrop, dialog.frost-modal::backdrop) { + background: CanvasText; + opacity: 0.72; + forced-color-adjust: none; + } + + :where(.frost-navbar__link, .frost-breadcrumbs, .frost-breadcrumbs__item[aria-current="page"]) { color: CanvasText; } + :where(.frost-navbar__link[aria-current="page"]) { outline: 2px solid Highlight; background: Canvas; } + :where(.frost-tabs) { border-color: CanvasText; } + :where(.frost-tabs__tab) { color: ButtonText; forced-color-adjust: none; } + :where(.frost-tabs__tab:hover, .frost-tabs__tab[aria-selected="true"]) { + border-block-end: 3px solid Highlight; + background: Canvas; + color: CanvasText; + } + + :where(.frost-accordion, .frost-accordion__item) { border-color: CanvasText; } + :where(.frost-accordion__trigger) { color: ButtonText; forced-color-adjust: none; } + + :where(.frost-pagination__item) { + border-color: ButtonText; + background: ButtonFace; + color: LinkText; + forced-color-adjust: none; + } + + :where(.frost-pagination__item:hover, .frost-pagination__item[aria-current="page"]) { + border: 2px solid Highlight; + background: Highlight; + color: HighlightText; + } + + :where(.frost-table, .frost-table th, .frost-table td) { border-color: CanvasText; } + :where(.frost-table th, .frost-table tbody tr:hover) { background: Canvas; color: CanvasText; } + :where(.frost-table-wrap:focus-visible) { outline-color: Highlight; } + + :where(.frost-spinner) { + border-color: GrayText; + border-block-start-color: Highlight; + forced-color-adjust: none; + } + + :where(.frost-skip-link) { + border-color: ButtonText; + background: ButtonFace; + color: ButtonText; + forced-color-adjust: none; + } + + :where(:focus-visible) { + outline: max(3px, var(--frost-focus-width)) solid Highlight; + outline-offset: max(3px, var(--frost-focus-offset)); + } + } +}