ScenicFramework / scenic

Core Scenic library
Apache License 2.0
1.99k stars 137 forks source link

Add support for library themes #252

Open vacarsu opened 3 years ago

vacarsu commented 3 years ago

Description

The pull request adds support for registering library themes, similar to static assets.

Themes are now registered and validated within scenic from Scenic.Themes.

Motivation and Context

Before the theme module was on Scenic.Primitive.Style.Theme, which felt like it would only be used in the context of primitives/components. However, it was imported everywhere that theme validation was needed, and had all the themes directly on that module. This means Scenic would not be able to validate custom themes that were not a map.

Also, there were times when scenic would pass around :dark, :light atoms, you had to know this ahead of time and know to validate or get the preset via Scenic.Primitive.Style.Theme. With all themes now registered through a single module, you can now fetch presets and validate any theme from Scenic.Themes.

Types of changes

Todos

vacarsu commented 3 years ago

Added a way to add additional keys to be validated for custom themes.

vacarsu commented 3 years ago

With these changes we can now validate once during compile. We shouldn't need to validate in the viewport anymore. Is my thinking here correct?

boydm commented 3 years ago

Love the Palettte module. lets do a call so you can walk me through the rest. Is a bit much to wrap my head around.

vacarsu commented 2 years ago

Okay, made the changes you requested. Moved the functions with logic out of the macro, and it will now fallback to Scenic.Themes as a default if no themes config is set.