-
Notifications
You must be signed in to change notification settings - Fork 146
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
feat: add custom styling and branding v2 #160
feat: add custom styling and branding v2 #160
Conversation
} | ||
|
||
@customElement('chat-avatar') | ||
export class ChatAvatarComponent extends LitElement { |
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.
since there is nothing in this component that's chat specific, it's a simple linked icon, should we just call it something like that? 'link-icon'. It will make it reusable for any place an clickable icon can be used.
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.
Good suggestion. Renamed to 'link-icon'
|
||
override render() { | ||
return html` | ||
<a class="chat-avatar__link" title="${this.label}" href="${this.url}" target="_blank" rel="noopener noreferrer"> |
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.
styles inside a component are isolated and will not be impacted by outside styling of component. So you dont need a class and can style it using as a 'a' link.
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.
That's true. I did deal so much with specificity over the years I still struggle to target native elements for styling, even inside of shadow DOM. I still do believe it may pose extensibility challenges at that granular, encapsulated level. But for the sake of avoiding premature optimization, I updated.
@@ -61,12 +66,18 @@ export class ChatComponent extends LitElement { | |||
@property({ type: String, attribute: 'data-api-url' }) | |||
apiUrl = chatHttpOptions.url; | |||
|
|||
@property({ type: String, attribute: 'data-custom-branding', converter: (value) => value?.toLowerCase() === 'true' }) | |||
isCustomBranding: boolean = globalConfig.IS_CUSTOM_BRANDING; |
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.
would be good to be consistent with 'useStream' as 'useCustomBranding'
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.
use is a specific convention of react hooks. In general, booleans are named isX or hasX. I am not convinced about porting framework specific conventions to the rest of the development scope.
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.
I meant more about the already in use "useStream" property just below in this component and to keep to the same standard here and not about porting react convention. But I think hasCustomBranding actually is much better.
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.
Agreed, I'd say hasCustomBranding
would make more sense
@@ -41,6 +41,12 @@ export class ChatThreadComponent extends LitElement { | |||
@property({ type: Object }) | |||
selectedCitation: Citation | undefined = undefined; | |||
|
|||
@property({ type: Boolean }) |
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.
since you are not using the branding in the thread this can be removed. Same with the icon below.
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.
Done!
color: var(--error-color); | ||
padding: 20px; | ||
padding: var(--d-base); | ||
background: var(--error-color-background); |
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.
I think this was missed since hte name for error-color-background changed.
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.
Good catch. I tried to make sure they were all updated but missed this one.
} | ||
} | ||
.chat-history__footer { |
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.
this should be in the chat-component and not chat-thread-component
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.
Removed. This was likely a merge glitch.
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.
Moved.
border: 0; | ||
background: none; | ||
cursor: pointer; | ||
text-decoration: underline; | ||
} | ||
@keyframes chatmessageanimation { |
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.
this was moved out of here into their respective components
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.
Removed.
padding: 0; | ||
margin: 0; | ||
} | ||
.subheadline--small { |
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.
same for this I think
padding: 5px 0; | ||
font-size: small; | ||
} | ||
.chat__header { |
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.
merge issue?
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.
This is a new wrapper to better handle reusable header.
font-size: var(--font-large); | ||
border: var(--border-thin) solid var(--c-light-gray); | ||
border-radius: var(--radius-large); | ||
padding: var(--d-base); | ||
} | ||
.chat-history__footer { |
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.
looks like it's still here, but something is causing an issue for it to render...
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.
I could not see the issue, maybe it has updated?
isEnabled: boolean; | ||
} | ||
|
||
@customElement('chat-stage') |
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.
i'm not sure this needs another component. The reuse for this is pretty small...
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.
But it may get extended by customers. I think it doesn't hurt to keep it encapsulated.
}); | ||
|
||
const [customStyles, setCustomStyles] = useState(() => { | ||
const styleDefaultsLight = { |
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.
duplicated? the themes folder with default will make them shared instead.
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.
I will review this in the context of refactoring the theming, as part of this PR.
return () => { | ||
window.removeEventListener('storage', handleStorageChange); | ||
}; | ||
}, [customStyles, isBrandingEnabled, isDarkTheme, isLoading]); |
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.
do you need to replicate this in OneShot.tsx? If so, I think it might be better to move all this into it's own context. Ideally themes in React should be passed in as a context provider pattern so that root level themes can be passed in and can be updated like that across all the child components.
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.
Ok, I will also handle this as part of the theming refactoring, before making this PR ready for review.
@@ -61,12 +66,18 @@ export class ChatComponent extends LitElement { | |||
@property({ type: String, attribute: 'data-api-url' }) | |||
apiUrl = chatHttpOptions.url; | |||
|
|||
@property({ type: String, attribute: 'data-custom-branding', converter: (value) => value?.toLowerCase() === 'true' }) | |||
isCustomBranding: boolean = globalConfig.IS_CUSTOM_BRANDING; |
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.
Agreed, I'd say hasCustomBranding
would make more sense
@@ -108,6 +119,26 @@ export class ChatComponent extends LitElement { | |||
|
|||
static override styles = [chatStyle]; | |||
|
|||
override updated(changedProperties: Map<string | number | symbol, unknown>) { |
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.
More food for thoughts: maybe we could skip that part entirely and allow to directly override the CSS variables through CSS?
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.
Let's think about it. We can have a follow up to this.
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.
I opened a follow up issue, btw.
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.
I kind of disagree here, though, because it's a 'isCustomBrandingEnabled' as 'isDarkThemeEnabled'. We can assume that the app 'hasCustomBranding', wether it's on or off, regardless. But this indicates it is enabled when true.
}, [isDarkTheme, isConfigPanelOpen]); | ||
|
||
return ( | ||
<> |
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.
Is the empty container needed? Since there's already a div container
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.
removed
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.
perhaps something didn't get pushed? I still see the empty <>
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.
Sync didn't happen.
LGTM |
.chat__header--avatar { | ||
display: flex; | ||
align-items: center; | ||
} |
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.
I think this no longer is in the thread component no?
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.
removed.
Purpose
Does this introduce a breaking change?
Pull Request Type
What kind of change does this Pull Request introduce?
How to Test
What to Check
This is the custom styling and branding feature.