mirror of
https://github.com/protesilaos/modus-themes.git
synced 2026-09-10 07:16:30 -04:00
Merge pull request #224 from shlemas/main
Improve mapping coverage for modus-themes-generate-palette + tests
This commit is contained in:
commit
a378446107
|
|
@ -7672,6 +7672,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-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-popup 'bg-dim)
|
||||
(funcall push-mapping-fn 'bg-region 'bg-active)
|
||||
(funcall push-mapping-fn 'fg-region 'fg-main)
|
||||
|
||||
|
|
@ -7718,21 +7719,26 @@ rest come from CORE-PALETTE."
|
|||
(funcall push-mapping-fn 'bg-tab-current 'bg-main)
|
||||
(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-faint 'bg-green-nuanced)
|
||||
(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-intense 'green-intense)
|
||||
|
||||
(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-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-intense 'yellow-intense)
|
||||
|
||||
(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-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-intense 'red-intense)
|
||||
|
||||
|
|
@ -7756,6 +7762,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-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))
|
||||
(new-mappings (append mappings derived-mappings))
|
||||
;; We have to add one of the core palettes to make sure
|
||||
|
|
|
|||
|
|
@ -288,6 +288,82 @@ Also see `modus-themes-test--modus-themes--hex-to-rgb'."
|
|||
(string= value "#000000"))
|
||||
(mapcar #'modus-themes-get-readable-foreground modus-vivendi-sample-foregrounds)))))
|
||||
|
||||
(mtt-define-test complete-palette-mappings
|
||||
"Ensure all built-in palettes contain entries for all palette mappings.
|
||||
This computes a complete list of mapping names from the built-in palettes
|
||||
and then cross-checks the palettes against the list. This should help ensure
|
||||
consistency and completeness where adding a new mapping in one palette will
|
||||
fail this test until it is added in all palettes."
|
||||
(let* ((operandi-names (seq-uniq (mapcar #'car modus-themes-operandi-palette)))
|
||||
(operandi-tinted-names (seq-uniq (mapcar #'car modus-themes-operandi-tinted-palette)))
|
||||
(operandi-deuteranopia-names (seq-uniq (mapcar #'car modus-themes-operandi-deuteranopia-palette)))
|
||||
(operandi-tritanopia-names (seq-uniq (mapcar #'car modus-themes-operandi-tritanopia-palette)))
|
||||
(vivendi-names (seq-uniq (mapcar #'car modus-themes-vivendi-palette)))
|
||||
(vivendi-tinted-names (seq-uniq (mapcar #'car modus-themes-vivendi-tinted-palette)))
|
||||
(vivendi-deuteranopia-names (seq-uniq (mapcar #'car modus-themes-vivendi-deuteranopia-palette)))
|
||||
(vivendi-tritanopia-names (seq-uniq (mapcar #'car modus-themes-vivendi-tritanopia-palette)))
|
||||
(all-names (seq-uniq (append operandi-names
|
||||
operandi-tinted-names
|
||||
operandi-deuteranopia-names
|
||||
operandi-tritanopia-names
|
||||
vivendi-names
|
||||
vivendi-tinted-names
|
||||
vivendi-deuteranopia-names
|
||||
vivendi-tritanopia-names))))
|
||||
(should (seq-empty-p (seq-difference all-names operandi-names)))
|
||||
(should (seq-empty-p (seq-difference all-names operandi-tinted-names)))
|
||||
(should (seq-empty-p (seq-difference all-names operandi-deuteranopia-names)))
|
||||
(should (seq-empty-p (seq-difference all-names operandi-tritanopia-names)))
|
||||
(should (seq-empty-p (seq-difference all-names vivendi-names)))
|
||||
(should (seq-empty-p (seq-difference all-names vivendi-tinted-names)))
|
||||
(should (seq-empty-p (seq-difference all-names vivendi-deuteranopia-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)
|
||||
;;; modus-themes-test.el ends here
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue