DEV: Move color definition functions to mixins (PR #12511)

So they can be used in themes, plugins, etc. Also adds a test to prevent regressions.

GitHub