Skip to content

Commit

Permalink
feat: update dynamic styles
Browse files Browse the repository at this point in the history
  • Loading branch information
anfibiacreativa committed Nov 11, 2023
1 parent 3910b3c commit 78ecd64
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
9 changes: 9 additions & 0 deletions packages/chat-component/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,15 @@ export class ChatComponent extends LitElement {

static override styles = [mainStyle];

override updated(changedProperties: Map<string | number | symbol, unknown>) {
super.updated(changedProperties);

if (changedProperties.has('customStyles')) {
this.style.setProperty('--c-accent-high', this.customStyles.AccentHigh);
this.style.setProperty('--c-accent-lighter', this.customStyles.AccentLighter);
this.style.setProperty('--c-accent-contrast', this.customStyles.AccentContrast);
}
}
// debounce dispatching must-scroll event
debounceScrollIntoView(): void {
let timeout: any = 0;
Expand Down
6 changes: 3 additions & 3 deletions packages/webapp/src/pages/chat/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ const Chat = () => {
};

const [customStyles, setCustomStyles] = useState<CustomStylesState>({
AccentHigh: '#ff0000',
AccentLighter: '#ff0000',
AccentContrast: '#ff0000',
AccentHigh: '#692b61',
AccentLighter: '#f6d5f2',
AccentContrast: '#5e3c7d',
});

const handleCustomStylesChange = (newStyles: CustomStylesState) => {
Expand Down

0 comments on commit 78ecd64

Please sign in to comment.