etaf-ui/etaf-ui-style.el
2026-08-31 15:17:30 +08:00

72 lines
2.2 KiB
EmacsLisp

;;; etaf-ui-style.el --- Internal styling for ETAF UI Components -*- lexical-binding: t; -*-
;; SPDX-License-Identifier: GPL-3.0-or-later
;;; Commentary:
;; Private catalog styling. ETAF owns Theme; this module only supplies
;; fallback values for the semantic tokens consumed by official Components.
;;; Code:
(require 'cl-lib)
(require 'etaf)
(defconst etaf-ui--style-palette
'(:ui-fg "#252A2E"
:ui-bg "#FFFDF8"
:ui-border "#687386"
:ui-muted-fg "#526174"
:ui-danger-fg "#FF6B6B"
:ui-success-fg "#2F6B43"
:ui-disabled-fg "#687386"
:ui-disabled-bg "#E5E7EB"
:ui-disabled-border "#9CA3AF"
:ui-button-primary-fg "#FFFFFF"
:ui-button-primary-bg "#2F6B43"
:ui-button-primary-border "#2F6B43"
:ui-button-secondary-fg "#142235"
:ui-button-secondary-bg "#D9EEEA"
:ui-button-secondary-border "#2E8B83"
:ui-button-ghost-fg "#142235"
:ui-button-ghost-bg "#FFFDF8"
:ui-button-ghost-border "#C8C1B6"
:ui-checkbox-enabled-fg "#252A2E"
:ui-checkbox-enabled-bg "#DCEBDD"
:ui-checkbox-enabled-border "#6D8A73"
:ui-checkbox-disabled-fg "#6B7280"
:ui-checkbox-disabled-bg "#EEEAE2"
:ui-checkbox-disabled-border "#9CA3AF"
:ui-table-border "#687386"
:ui-table-selected-fg "#2F6B43"
:ui-table-selected-bg "#DCEBDD"
:ui-data-grid-error-fg "#FF6B6B"
:ui-pagination-muted-fg "#526174"
:ui-panel-fg "#252A2E"
:ui-panel-bg "#FFFDF8"
:ui-panel-border "#687386")
"Fallback values for semantic tokens used by ETAF UI Components.")
(defun etaf-ui--style-tokens (&rest keys)
"Return deferred ETAF Theme values for private catalog token KEYS."
(let (result)
(dolist (key keys result)
(setq result
(plist-put
result key
(etaf-theme-token key (plist-get etaf-ui--style-palette key)))))))
(defun etaf-ui--style-border (value)
"Return canonical border VALUE from a semantic ETAF Theme value."
(cond
((etaf-theme-token-p value)
(etaf-theme-token (nth 1 value) (nth 2 value)
#'etaf-ui--style-border))
((and (stringp value)
(string-match-p "\\`#[[:xdigit:]]+\\'" value))
(list 1 'solid value))
(t value)))
(provide 'etaf-ui-style)
;;; etaf-ui-style.el ends here