-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[lit] Wire A2UI primaryColor on basic catalog elements. #1343
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
bb824c3
93db0b0
91e2d47
c5c3870
b45475c
36237bf
f68e294
9fd30bd
375a2e6
f65cd8b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,7 +16,7 @@ | |
|
|
||
| import {ComponentApi} from '@a2ui/web_core/v0_9'; | ||
| import {A2uiLitElement} from '../../a2ui-lit-element.js'; | ||
| import {injectBasicCatalogStyles} from '@a2ui/web_core/v0_9/basic_catalog'; | ||
| import {injectBasicCatalogStyles, computeColorVariant} from '@a2ui/web_core/v0_9/basic_catalog'; | ||
|
|
||
| /** | ||
| * A base class for A2UI basic catalog components. | ||
|
|
@@ -33,13 +33,39 @@ export abstract class BasicCatalogA2uiLitElement< | |
| injectBasicCatalogStyles(); | ||
| } | ||
|
|
||
| updated(changedProperties: Map<PropertyKey, unknown>) { | ||
| super.updated(changedProperties); | ||
| willUpdate(changedProperties: Map<string, any>) { | ||
| super.willUpdate(changedProperties); | ||
|
|
||
| const props = this.controller?.props as any; | ||
| if (props && props.weight !== undefined) { | ||
| this.style.flex = String(props.weight); | ||
| } else { | ||
| this.style.removeProperty('flex'); | ||
| } | ||
|
|
||
| const primaryColor = this.context?.theme?.primaryColor; | ||
| if (primaryColor) { | ||
|
ditman marked this conversation as resolved.
|
||
| this.style.setProperty('--a2ui-color-primary', primaryColor); | ||
| this.style.setProperty( | ||
| '--a2ui-color-primary-light', | ||
| computeColorVariant('light', {colorVar: '--a2ui-color-primary'}), | ||
| ); | ||
| this.style.setProperty( | ||
| '--a2ui-color-primary-dark', | ||
| computeColorVariant('dark', {colorVar: '--a2ui-color-primary'}), | ||
| ); | ||
| this.style.setProperty( | ||
| '--a2ui-color-primary-hover', | ||
| computeColorVariant('hover', { | ||
| darkVar: '--a2ui-color-primary-dark', | ||
| lightVar: '--a2ui-color-primary-light', | ||
| }), | ||
| ); | ||
| } else { | ||
| this.style.removeProperty('--a2ui-color-primary'); | ||
| this.style.removeProperty('--a2ui-color-primary-light'); | ||
| this.style.removeProperty('--a2ui-color-primary-dark'); | ||
| this.style.removeProperty('--a2ui-color-primary-hover'); | ||
|
Comment on lines
+66
to
+68
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now that we can compute light/dark/hover programmatically, would it make sense to remove them from the core stylesheet, and let the components that need light/dark/hover variants of a color use the formulas inline with per-widget overrides? That would simplify this a lot, and make the set of CSS variables exposed from web_core smaller. WDYT @josemontespg?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds good to me. Would that affect React also?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @josemontespg once we land the formulas to compute light/dark/hover modes for the colors, we'd go into each basic catalog implementation and use that based on the defined |
||
| } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.