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

fix: change input selector to id #264

Merged
merged 5 commits into from
Oct 4, 2022
Merged

Conversation

ColinFrick
Copy link
Contributor

Pull Request

Related issue

Fixes #263

What does this PR do?

  • Change the selector to the input id, therefor applying the styling even before the docs-searchbar.js is initialized.

This does require a change in meilisearch/documentation because this does not handle @media (prefers-color-scheme: dark)

PR checklist

Please check if your PR fulfills the following requirements:

  • Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)?
  • Have you read the contributing guidelines?
  • Have you made sure that the title is accurate and descriptive of the changes?

Thank you so much for contributing to Meilisearch!

@bidoubiwa
Copy link
Contributor

bidoubiwa commented Oct 3, 2022

Hey @ColinFrick thanks again for contributing :)
Unfortunately if it is not compatible with the dark mode we cannot add it. Do you think this is something that can be done?

@ColinFrick
Copy link
Contributor Author

@bidoubiwa the inconsistencies result from the different types of applying the dark / light mode styling in docs-searchbar.js and the documentation CSS. docs-searchbar.js uses [data-ds-theme] to determine the theme, while the documentation page uses (prefers-color-scheme: dark) directly.

Hm, because we set the theme through the plugin, it should be possible to apply the corresponding theme on the plugin tag directly without waiting for docs-searchbar.js to be initialized.

The theme class is set according the enableDarkMode setting (auto, light, dark)
@ColinFrick
Copy link
Contributor Author

@bidoubiwa I have changed the PR. This should cover any combination of prefers-color-scheme / enableDarkMode, and does not require any changes in the documentation repository.

@bidoubiwa
Copy link
Contributor

docs-searchbar.js uses [data-ds-theme] to determine the theme, while the documentation page uses (prefers-color-scheme: dark) directly.

Do you think it is worth to change that in docs-searchbar.js ? As it is not exposed to the user.

@ColinFrick
Copy link
Contributor Author

Even if we change docs-searchbar.js we still would need it here. It really comes down to that split second between rendering the DOM (with Vue component) and wrapping the component with docs-searchbar.js

ezgif-3-2ba7f0c446

MeiliSearchBox.vue Outdated Show resolved Hide resolved
Comment on lines +84 to +91
updateTheme(options) {
if (options.enableDarkMode === true) {
this.theme = 'dark'
} else if (options.enableDarkMode === false) {
this.theme = 'light'
} else {
this.theme = 'auto'
}
Copy link
Contributor

@bidoubiwa bidoubiwa Oct 4, 2022

Choose a reason for hiding this comment

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

This is always going to be true.
I tried auto and a light theme on my computer and it is still dark mode

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm this does work for me (macOS Monterey 12.6, Firefox 105.0.1)

enableDarkMode: 'auto'
image
image

enableDarkMode: false
image

enableDarkMode: true
image

How are you testing it?

Copy link
Contributor

Choose a reason for hiding this comment

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

Mmh, with the same computer but on chrome. Let me try again on firefox

Copy link
Contributor

@bidoubiwa bidoubiwa Oct 4, 2022

Choose a reason for hiding this comment

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

My bad! I forgot to change the value of enableDarkMode 🤦 Can you change it in the playground to auto ?
A bit to many reviews to do during this hacktoberfest, I'm losing focus. Sorry for that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

enableDarkMode is already 'auto' in the playground

Take your time, no rush 😉

Copy link
Contributor

@bidoubiwa bidoubiwa left a comment

Choose a reason for hiding this comment

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

LGTM 🔥🔥

@bidoubiwa
Copy link
Contributor

bors merge

@bidoubiwa
Copy link
Contributor

bors r-

@bidoubiwa
Copy link
Contributor

bors merge

@meili-bors
Copy link
Contributor

meili-bors bot commented Oct 4, 2022

Build succeeded:

@meili-bors meili-bors bot merged commit 4d5590a into meilisearch:main Oct 4, 2022
@bidoubiwa
Copy link
Contributor

Thanks again for contributing with Meilisearch ❤️
If you are participating in Hacktoberfest, and you would like to receive a small gift from Meilisearch too, don't forget to fill this form.

@ColinFrick ColinFrick deleted the fix/263 branch October 12, 2022 11:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Meilisearch docs glitches on refreshes
2 participants