-
Notifications
You must be signed in to change notification settings - Fork 843
Add support for server side styling override for logoUrl, primaryColo… #256
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -694,11 +694,52 @@ export class A2UILayoutEditor extends SignalWatcher(LitElement) { | |||||
| async #sendAndProcessMessage(request) { | ||||||
| const messages = await this.#sendMessage(request); | ||||||
|
|
||||||
| // Apply server-side styles if present in beginRendering | ||||||
| for (const msg of messages) { | ||||||
| if ('beginRendering' in msg && msg.beginRendering.styles) { | ||||||
|
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. NIT: I think you can use a nullish coalescing operator here.
Suggested change
|
||||||
| this.#applyServerStyles(msg.beginRendering.styles); | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| this.#lastMessages = messages; | ||||||
| this.#processor.clearSurfaces(); | ||||||
| this.#processor.processMessages(messages); | ||||||
| } | ||||||
|
|
||||||
| #applyServerStyles(styles: any) { | ||||||
| const root = document.documentElement; | ||||||
|
|
||||||
| // 1. Primary Color | ||||||
| if (styles.primaryColor) { | ||||||
| root.style.setProperty('--primary-color', styles.primaryColor); | ||||||
|
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. Are we validating these styles anywhere? |
||||||
| // Generate a simple dim variant for now (could be more sophisticated) | ||||||
| root.style.setProperty('--p-60', styles.primaryColor); | ||||||
|
|
||||||
| // Update gradient to use the new primary color | ||||||
| // We'll create a gradient from a lighter version to the primary color | ||||||
| // For now, let's just use the primary color and a shifted hue for a simple dynamic gradient | ||||||
| root.style.setProperty('--primary-gradient', `linear-gradient(135deg, ${styles.primaryColor} 0%, ${styles.primaryColor}dd 100%)`); | ||||||
| } | ||||||
|
|
||||||
| // 2. Font Family | ||||||
| if (styles.font) { | ||||||
| root.style.setProperty('--bb-font-family', styles.font); | ||||||
| root.style.setProperty('font-family', styles.font); | ||||||
| } | ||||||
|
|
||||||
|
|
||||||
|
|
||||||
| // 3. Logo / Hero Image | ||||||
| if (styles.logoUrl) { | ||||||
| // Update the config dynamically to show the new hero image | ||||||
| this.config = { | ||||||
| ...this.config, | ||||||
| heroImage: styles.logoUrl, | ||||||
| heroImageDark: styles.logoUrl, // Use same for dark mode unless specified otherwise | ||||||
|
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. I don't see a way to specify otherwise, right? Should we say we're just going to set this for both until we have a way to specify that? |
||||||
| }; | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
|
|
||||||
|
|
||||||
| snackbar( | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,7 @@ | |
|
|
||
| /* Global overrides */ | ||
| * { | ||
| font-family: 'Outfit', sans-serif !important; | ||
| font-family: var(--bb-font-family, 'Outfit', sans-serif) !important; | ||
|
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. Whoa, I don't think I've encountered this file before. Why these overrides as opposed to setting this in
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. this is going to be rewired by Paul..hopefully this PR will not be needed then.. |
||
| } | ||
|
|
||
| /* Card Styling */ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you add this here, please also update the specification/0.8/a2ui_protocol.md and the JSON schema in specification/0.8/json. That should be the source of truth for the schema.
In fact, this code should probably be reading those schemas directly and not defining a copy that is likely to get out of date.