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

Dark theme #1

Closed
pawamoy opened this issue Jun 12, 2022 · 4 comments
Closed

Dark theme #1

pawamoy opened this issue Jun 12, 2022 · 4 comments

Comments

@pawamoy
Copy link

pawamoy commented Jun 12, 2022

Hi! Did you try with the slate theme of Material for MkDocs enabled?

I actually integrated the Swagger UI in some projects docs (with a few lines of Javascript), and it looks nice with a light theme, but is unreadable with a dark theme. Maybe you found a way to improve that.

@blueswen
Copy link
Owner

Yes, I have tried with the slate theme of Material for MkDocs, then I found it was unreadable. So I add a body background color(default: white) to prevent Swagger UI's transparent background as a workaround.

dark-mode-demo

I also have tried some dark mode css for Swagger UI, but they does not look good for me. Maybe swagger-api/swagger-ui#5964 could solve this. I will try this PR's css latter.

@pawamoy
Copy link
Author

pawamoy commented Jun 13, 2022

I see, thanks! Feel free to close 🙂

@blueswen
Copy link
Owner

@pawamoy Swagger UI Tag supports synchronized dark mode with mkdocs-material in v0.2.1 🎉. I used the Swagger UI dark mode css from Amoenus Swagger Dark Theme and modified some value to fit slate theme of Material.

dark-mode

Since Material changes body's attribute data-md-color-scheme to switch light mode and dark mode. I observe data-md-color-scheme value to trigger enable or disable dark mode css in iframe.
https://github.com/blueswen/mkdocs-swagger-ui-tag/blob/v0.2.1/mkdocs_swagger_ui_tag/swagger-ui/swagger.html#L38
https://github.com/blueswen/mkdocs-swagger-ui-tag/blob/v0.2.1/mkdocs_swagger_ui_tag/plugin.py#L134

@pawamoy
Copy link
Author

pawamoy commented Jun 14, 2022

Woohoo, great job! Looks nice 🙂 Closing 😄 !

@pawamoy pawamoy closed this as completed Jun 14, 2022
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

No branches or pull requests

2 participants