Skip to content
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 feature #137

Closed
wants to merge 28 commits into from

Conversation

anfibiacreativa
Copy link
Member

@anfibiacreativa anfibiacreativa commented Nov 11, 2023

Purpose

  • ...

Does this introduce a breaking change?

[ ] Yes
[ x] No

Pull Request Type

What kind of change does this Pull Request introduce?

[ ] Bugfix
[ x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Documentation content changes
[ ] Other... Please describe:

How to Test

The feature adds an improved

  • styling system
  • custom styling configuration from dev settings
  • branding options

@anfibiacreativa anfibiacreativa changed the title Feat/add custom styling feature feat: add custom styling feature Nov 11, 2023
@anfibiacreativa anfibiacreativa marked this pull request as ready for review November 13, 2023 14:27
@anfibiacreativa anfibiacreativa changed the base branch from main to develop November 13, 2023 16:35
@anfibiacreativa anfibiacreativa marked this pull request as draft November 13, 2023 16:38
@anfibiacreativa anfibiacreativa marked this pull request as ready for review November 15, 2023 11:27
await page.goto('/');
await page.getByTestId('button__developer-settings').click();
await page.locator('label').filter({ hasText: 'Select theme' }).click();
await page.waitForTimeout(1000);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

generally timeout is prone to flakiness. It's better to wait for an element state instead. You can increase the timeout on the element check instead. (same for all the waitTimeouts below)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. We leave it also for the follow up optimization.

await page.getByTestId('button__developer-settings').click();
await page.locator('label').filter({ hasText: 'Select theme' }).click();
await page.waitForTimeout(1000);
// check if the body has the class "dark"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can use locators page.locator(".dark") instead.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are thinking about a task to improve all tests, once we have all merged in.

});

const [customStyles, setCustomStyles] = useState(() => {
const styleDefaultsLight = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should these be in their own file for easy changing?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, agreed. Let's also put it in the overall optimization task.

// Update the body class and html data-theme
localStorage.removeItem('customStyles');
document.body.classList.toggle('dark', newIsDarkTheme);
document.documentElement.dataset.theme = newIsDarkTheme ? 'dark' : '';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should probably use reactive update of the React component rather than direct class add

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's put this in the same code optimization iteration

// The following block is only necessary when you want to override the component from settings in the outside.
// Remove this block when not needed, considering that updated() is a LitElement lifecycle method
// that may be used by other components if you update this code.
override updated(changedProperties: Map<string | number | symbol, unknown>) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check out and see if styleMap directive for lit would be useful here. https://lit.dev/docs/components/styles/#dynamic-classes-and-styles

<header class="branding__banner">
<a class="branding__link" href="${globalConfig.BRANDING_URL}" target="_blank" rel="noopener noreferrer">
${unsafeSVG(iconLogo)}
</a>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reuse this.renderBrandingAvatar

@@ -694,7 +752,8 @@ export class ChatComponent extends LitElement {
<!-- Conditionally render default prompts based on hasDefaultPromptsEnabled -->
${this.hasDefaultPromptsEnabled
? html`
<div class="defaults__container">
${this.renderBrandingBanner()}
<div class="defaults__container" data-testid="chat-branding">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should probably be on the branding header and not the default container.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created a rendering function, so I'm not sure exactly what you mean here. But let's put it in the back burner to review when we have all merged in.

@@ -10,6 +10,32 @@ export const enum RetrievalMode {
Text = 'text',
}

export type CustomStylesState = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should probably not be in the api folder. Probably should be in components folder.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's refactor for best practices once we have all old PRs in.

@anfibiacreativa
Copy link
Member Author

Will need to reimplement after refactoring has been integrated.

@anfibiacreativa anfibiacreativa deleted the feat/add-custom-styling-feature branch January 19, 2024 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants