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

feature: add hideDarkMode option to control the toggle #123

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

LukerSpringtree
Copy link

Description

Add a configuration option: hideDarkMode, which can control the visibility of the Dark Mode toggle button.

The background is that the Vue DevTools project has a bug (#737) and issue #339. The main idea is that DevTools wants its theme to be isolated from the project’s theme. However, since vite-plugin-inspect uses VueUse's useDark method, it causes issues with theme isolation and also triggers bug #737. The best solution is to hide this button in DevTools, and this PR implements that functionality.

Linked Issues

vuejs/devtools#737 (comment)
vuejs/devtools#736
vuejs/devtools#339

Additional context

The method I used to modify the route is not very elegant. I tried many approaches, but none of them worked perfectly due to various issues. The main reason is that the __inspect page itself is a static resource, and it's difficult to make the hideDarkMode configuration penetrate into Inspect through Vite’s configuration.

Therefore, I decided to differentiate at the stage when the static web resource server starts. It is hard to achieve this requirement through environment variables or other Vite-injected variables. If anyone has a better solution, I would appreciate your guidance. Thank you!

@@ -43,6 +43,7 @@ export default defineConfig({
Inspect({
build: true,
open: true,
hideDarkMode: false,
Copy link
Member

Choose a reason for hiding this comment

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

We could use embedded instead

Copy link
Author

Choose a reason for hiding this comment

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

Thank you very much for your reply. Do you mean 'embedding a <script> tag directly in the HTML file,' or should I change the name 'hideDarkMode' to 'embedded'?

Sorry for the confusion.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah I was suggesting the naming. hideDarkMode is a bit too specific, while for embedded in the future we could also add other features etc. Also we should go for ? embedded in the query

Copy link
Author

Choose a reason for hiding this comment

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

image

Using embedded and configuring its value as a query parameter is extremely difficult for me. The reason is that in the Inspect project, the static resources use hash routing, which makes it impossible to correctly switch the position of query parameters. Additionally, when opening the modal, a nested routing approach within a single page is used, which prevents switching to WebHistory routing.

In summary, using query parameters is too difficult for me.

😭

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