-
Notifications
You must be signed in to change notification settings - Fork 14
Add dark mode #164
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
Add dark mode #164
Conversation
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.
Awesome!
- How is it going to be for VuePress website that does not the dark mode allowed, for example our docs?
- Does it work with https://github.com/tolking/vuepress-theme-default-prefers-color-scheme as the issue Ask for dark mode #127 mentions it?
This shouln't be necessary as the playground is already connected to its root folder that contains the plugin.
There is no |
|
In the module.exports = {
title: 'Welcome to the Playground!',
plugins: [
[
require('../../index.js'),
{
// Testing with MeiliSearch documentation content (https://docs.meilisearch.com/)
hostUrl: 'https://docs-search-bar.meilisearch.com',
apiKey:
'd79226ae89f29d4dadba8d0c30c240e435f584fb83a7ae573b13eb62edec35cd',
indexUid: 'docs'
// "maxSuggestions": 10,
// "placeholder": "Search as you type..."
}
]
]
} not the plugin that is in the package.json. The plugin in the package.json should not have any impact in the playground since it is not used in the config file |
|
Ok I got it. I'm updating the body of the PR according 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.
Can you update the README according to your new feature? 🙂
It's already done 🤩 |
My bad! I completely missed it in the middle of the files 😅 |
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 approve because I don't want to block the PR, but of course we need to wait for @bidoubiwa approval 🙂
@mdubus, you have write access to this repo, you don't need to work on your fork anymore 🙂
Thanks a lot!!!
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.
Everything looks super fine except for one thing. When you remove the following line from playground/.vuepress/config.js
the app throws an error.
theme: 'default-prefers-color-scheme',
The following error is thrown:
vue.runtime.esm.js?2b0e:619 [Vue warn]: Failed to resolve async component: function Layout() {
return Promise.all(/*! import() */[__webpack_require__.e(0), __webpack_require__.e(1)]).then(__webpack_require__.bind(null, /*! ./node_modules/@vuepress/theme-default/layouts/Layout.vue */ "./node_modules/@vuepress/theme-default/layouts/Layout.vue"));
}
Reason: Error: Module build failed (from ./node_modules/stylus-loader/index.js):
Error: vuepress-plugin-meilisearch/playground/node_modules/stylus/lib/functions/index.styl:133:3
129|
130| // lighten by the given amount
131|
132| lighten(color, amount)
133| adjust(color, 'lightness', amount)
----------^
134|
135| // decrease opacity by amount
136|
Thanks for pointing this error ! I added a new variable $msDropdownBgDarkColor
to resolve this problem ❤️
Co-authored-by: Clémentine Urquizar <[email protected]>
Co-authored-by: Clémentine Urquizar <[email protected]>
I looked at the default palette of vuepress and it seems it is using the variable used by See Styling in VuePress. Furthermore there is a default palette provided by vuepress. I think it is possible to rely on these values to have default values. As an example, if we look at the default search bar component that is provided by vuepress it lets us tweak with the following variable.
Because of that, I think we should be consistent with these variable naming and our variables by just adding |
So I tried with and without the dark theme and it worked, I'm not sure what provoked the bug the first time around: Update $accentDarkColor ?= $accentColor
$inputDarkBgColor ?= #444d52
$textDarkColor ?= #eaeaea
$borderDarkColor ?= lighten($inputDarkBgColor, 10%)
$dropdownBgDarkColor ?= darken($inputDarkBgColor, 25%) Play with // No need to define accentColor, works in both cases
$accentDarkColor = $accentColor // $accentColor comes from default vuepress theme see link below
$inputDarkBgColor = #444d52
$textDarkColor = #eaeaea
// $borderDarkColor needs to have inputDarkBgColor defined as information goes down to the plugin palette, so it is not aware that this variable exists since it does not exists in both the default palette and the palette from the dark-theme
$borderDarkColor = lighten($inputDarkBgColor, 10%) Other changes this emply:
Unless there is another reason not to go with these variable names? |
We agreed with @bidoubiwa to rename the style variables by removing the |
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.
LGTM 🔥🔥🔥
bors merge |
🔒 Permission denied Existing reviewers: click here to make mdubus a reviewer |
bors merge |
Build succeeded: |
Closes #127
What's inside this PR ?
Dark mode support as requested in #127.
3 more changes were made :
docs-searchbar
version inside thepackage.json
(v1.3.0).search-box
div according to this PRdebug
option which was available indocs-searchbar
but not in this pluginHow to test ?
Run the playground
You can run the playground with
yarn serve
Change the color palette
If you want to change the color palette, you can do so by changing the colors inside the
playground/.vuepress/styles/palette.styl
fileEnable / disable dark mode
You can also enable/disable the dark mode (disabled by default) by adding/removing the

enableDarkMode
option in theplayground/.vuepress/config.js
file (don't forget to restart the server !):Screenshots
Column layout (default)

Simple layout

Change

$accentDarkColor
to#a29bfe
(full change of the dark theme, cohabitation with thevuepress-theme-default-prefers-color-scheme
plugin)