Add more mappings to modus-themes-generate-palette + test

This commit is contained in:
Shawn LeMaster 2026-06-27 17:24:23 -05:00
parent c981ca60ae
commit 50c42fe90d
2 changed files with 81 additions and 0 deletions

View file

@ -7671,6 +7671,7 @@ rest come from CORE-PALETTE."
(funcall push-mapping-fn 'bg-hl-line (if prefers-cool-p 'bg-cyan-nuanced 'bg-yellow-nuanced)) (funcall push-mapping-fn 'bg-hl-line (if prefers-cool-p 'bg-cyan-nuanced 'bg-yellow-nuanced))
(funcall push-mapping-fn 'bg-paren-match (if prefers-cool-p 'bg-green-intense 'bg-yellow-subtle)) (funcall push-mapping-fn 'bg-paren-match (if prefers-cool-p 'bg-green-intense 'bg-yellow-subtle))
(funcall push-mapping-fn 'bg-paren-expression (if prefers-cool-p 'bg-green-nuanced 'bg-yellow-nuanced)) (funcall push-mapping-fn 'bg-paren-expression (if prefers-cool-p 'bg-green-nuanced 'bg-yellow-nuanced))
(funcall push-mapping-fn 'bg-popup 'bg-dim)
(funcall push-mapping-fn 'bg-region 'bg-active) (funcall push-mapping-fn 'bg-region 'bg-active)
(funcall push-mapping-fn 'fg-region 'fg-main) (funcall push-mapping-fn 'fg-region 'fg-main)
@ -7717,21 +7718,26 @@ rest come from CORE-PALETTE."
(funcall push-mapping-fn 'bg-tab-current 'bg-main) (funcall push-mapping-fn 'bg-tab-current 'bg-main)
(funcall push-mapping-fn 'bg-tab-other 'bg-inactive) (funcall push-mapping-fn 'bg-tab-other 'bg-inactive)
(funcall push-mapping-fn 'bg-diff-context 'bg-dim)
(funcall push-mapping-fn 'bg-added 'bg-green-subtle) (funcall push-mapping-fn 'bg-added 'bg-green-subtle)
(funcall push-mapping-fn 'bg-added-faint 'bg-green-nuanced) (funcall push-mapping-fn 'bg-added-faint 'bg-green-nuanced)
(funcall push-mapping-fn 'bg-added-refine 'bg-green-intense) (funcall push-mapping-fn 'bg-added-refine 'bg-green-intense)
(funcall push-mapping-fn 'bg-added-fringe 'green)
(funcall push-mapping-fn 'fg-added 'green-faint) (funcall push-mapping-fn 'fg-added 'green-faint)
(funcall push-mapping-fn 'fg-added-intense 'green-intense) (funcall push-mapping-fn 'fg-added-intense 'green-intense)
(funcall push-mapping-fn 'bg-changed 'bg-yellow-subtle) (funcall push-mapping-fn 'bg-changed 'bg-yellow-subtle)
(funcall push-mapping-fn 'bg-changed-faint 'bg-yellow-nuanced) (funcall push-mapping-fn 'bg-changed-faint 'bg-yellow-nuanced)
(funcall push-mapping-fn 'bg-changed-refine 'bg-yellow-intense) (funcall push-mapping-fn 'bg-changed-refine 'bg-yellow-intense)
(funcall push-mapping-fn 'bg-changed-fringe 'yellow)
(funcall push-mapping-fn 'fg-changed 'yellow-faint) (funcall push-mapping-fn 'fg-changed 'yellow-faint)
(funcall push-mapping-fn 'fg-changed-intense 'yellow-intense) (funcall push-mapping-fn 'fg-changed-intense 'yellow-intense)
(funcall push-mapping-fn 'bg-removed 'bg-red-subtle) (funcall push-mapping-fn 'bg-removed 'bg-red-subtle)
(funcall push-mapping-fn 'bg-removed-faint 'bg-red-nuanced) (funcall push-mapping-fn 'bg-removed-faint 'bg-red-nuanced)
(funcall push-mapping-fn 'bg-removed-refine 'bg-red-intense) (funcall push-mapping-fn 'bg-removed-refine 'bg-red-intense)
(funcall push-mapping-fn 'bg-removed-fringe 'red)
(funcall push-mapping-fn 'fg-removed 'red-faint) (funcall push-mapping-fn 'fg-removed 'red-faint)
(funcall push-mapping-fn 'fg-removed-intense 'red-intense) (funcall push-mapping-fn 'fg-removed-intense 'red-intense)
@ -7755,6 +7761,36 @@ rest come from CORE-PALETTE."
(funcall push-mapping-fn 'fg-term-white (if bg-main-dark-p 'fg-dim 'bg-active)) (funcall push-mapping-fn 'fg-term-white (if bg-main-dark-p 'fg-dim 'bg-active))
(funcall push-mapping-fn 'fg-term-white-bright (if bg-main-dark-p 'fg-main 'bg-main)) (funcall push-mapping-fn 'fg-term-white-bright (if bg-main-dark-p 'fg-main 'bg-main))
(funcall push-mapping-fn 'rust 'red-faint)
(funcall push-mapping-fn 'gold 'yellow-faint)
(funcall push-mapping-fn 'olive 'green-faint)
(funcall push-mapping-fn 'slate 'cyan-faint)
(funcall push-mapping-fn 'indigo 'blue-warmer)
(funcall push-mapping-fn 'maroon 'magenta-warmer)
(funcall push-mapping-fn 'pink 'magenta-faint)
(funcall push-mapping-fn 'bg-clay 'bg-red-nuanced)
(funcall push-mapping-fn 'fg-clay 'red-cooler)
(funcall push-mapping-fn 'bg-ochre 'bg-yellow-nuanced)
(funcall push-mapping-fn 'fg-ochre 'yellow-cooler)
(funcall push-mapping-fn 'bg-lavender 'bg-magenta-nuanced)
(funcall push-mapping-fn 'fg-lavender 'magenta-cooler)
(funcall push-mapping-fn 'bg-sage 'bg-green-nuanced)
(funcall push-mapping-fn 'fg-sage 'green-cooler)
(funcall push-mapping-fn 'bg-graph-red-0 (if bg-main-dark-p 'bg-red-intense bg-red-subtle))
(funcall push-mapping-fn 'bg-graph-red-1 (if bg-main-dark-p 'bg-red-subtle bg-red-intense))
(funcall push-mapping-fn 'bg-graph-green-0 (if bg-main-dark-p 'bg-green-intense bg-green-subtle))
(funcall push-mapping-fn 'bg-graph-green-1 (if bg-main-dark-p 'bg-green-subtle bg-green-intense))
(funcall push-mapping-fn 'bg-graph-yellow-0 (if bg-main-dark-p 'bg-yellow-intense bg-yellow-subtle))
(funcall push-mapping-fn 'bg-graph-yellow-1 (if bg-main-dark-p 'bg-yellow-subtle bg-yellow-intense))
(funcall push-mapping-fn 'bg-graph-blue-0 (if bg-main-dark-p 'bg-blue-intense bg-blue-subtle))
(funcall push-mapping-fn 'bg-graph-blue-1 (if bg-main-dark-p 'bg-blue-subtle bg-blue-intense))
(funcall push-mapping-fn 'bg-graph-magenta-0 (if bg-main-dark-p 'bg-magenta-intense bg-magenta-subtle))
(funcall push-mapping-fn 'bg-graph-magenta-1 (if bg-main-dark-p 'bg-magenta-subtle bg-magenta-intense))
(funcall push-mapping-fn 'bg-graph-cyan-0 (if bg-main-dark-p 'bg-cyan-intense bg-cyan-subtle))
(funcall push-mapping-fn 'bg-graph-cyan-1 (if bg-main-dark-p 'bg-cyan-subtle bg-cyan-intense))
(let* ((new-colors (append base-colors derived-colors)) (let* ((new-colors (append base-colors derived-colors))
(new-mappings (append mappings derived-mappings)) (new-mappings (append mappings derived-mappings))
;; We have to add one of the core palettes to make sure ;; We have to add one of the core palettes to make sure

View file

@ -319,6 +319,51 @@ fail this test until it is added in all palettes."
(should (seq-empty-p (seq-difference all-names vivendi-deuteranopia-names))) (should (seq-empty-p (seq-difference all-names vivendi-deuteranopia-names)))
(should (seq-empty-p (seq-difference all-names vivendi-tritanopia-names))))) (should (seq-empty-p (seq-difference all-names vivendi-tritanopia-names)))))
(mtt-define-test modus-themes-generate-palette
"Ensure `modus-themes-generate-palette' provides enough mapping coverage
such that the generated palette does not inherit explicit color values
from a parent core palette."
(let* ((generated-palette (modus-themes-generate-palette
'((fg-main "#ffffff")
(bg-main "#000000")
(red "#ff0000")
(green "#00ff00")
(yellow "#ffff00")
(blue "#0000ff")
(magenta "#ff00ff")
(cyan "#00ffff"))))
;; These are colors we expect to have an explicit hex value,
;; either because they were provided explicitly in the call to
;; `modus-themes-generate-palette' above, or because we expect
;; `modus-themes-generate-palette' to generate the color.
(explicit-colors '( fg-main bg-main
fg-alt fg-dim bg-inactive bg-active bg-dim border
;; cyan
cyan bg-cyan-nuanced bg-cyan-subtle bg-cyan-intense
cyan-intense cyan-faint cyan-cooler cyan-warmer
;; magenta
magenta bg-magenta-nuanced bg-magenta-subtle bg-magenta-intense
magenta-intense magenta-faint magenta-cooler magenta-warmer
;; blue
blue bg-blue-nuanced bg-blue-subtle bg-blue-intense
blue-intense blue-faint blue-cooler blue-warmer
;; yellow
yellow bg-yellow-nuanced bg-yellow-subtle bg-yellow-intense
yellow-intense yellow-faint yellow-cooler yellow-warmer
;; green
green bg-green-nuanced bg-green-subtle bg-green-intense
green-intense green-faint green-cooler green-warmer
;; red
red bg-red-nuanced bg-red-subtle bg-red-intense
red-intense red-faint red-cooler red-warmer)))
;; Ensure all other colors in the palette map to a color name and not an
;; explicit hex value. If this check fails, the offending color should
;; be mapped to an appropriate color name in `modus-themes-generate-palette'.
(should (seq-empty-p (seq-remove (lambda (elem)
(or (member (car elem) explicit-colors)
(symbolp (cadr elem))))
generated-palette)))))
(provide 'modus-themes-test) (provide 'modus-themes-test)
;;; modus-themes-test.el ends here ;;; modus-themes-test.el ends here