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

Implement a dark theme #5964

Closed
wants to merge 5 commits into from
Closed

Conversation

mrahhal
Copy link

@mrahhal mrahhal commented Apr 12, 2020

Description

Disclaimer: I did read the contribution guidelines, and even though I understand this might not be of any priority, I decided to have a go at it anyway. We use swagger extensively in our projects and have always thought a dark mode would be easier on the eyes for a lot of people.

This PR implements a theme system using css-theming. I do admit that the style changes are a bit shoddy, but a part of that is that swagger-ui's styles aren't made to work with themes in mind (which is of course normal), so I decided to just do a fast job instead of changing things radically to see if it could be accomplished easily. If we decide to go forward with this feature, things can be resolved in a better way.

Of course, this is a work in progress awaiting for feedback.

Notes:

  • I'm using css-theming to handle the theme switching and computing the different color variations between themes (as well as auto detecting system theme on first run).
  • I had to install dart-sass instead of node-sass and update sass-loader to latest.

Motivation and Context

Closes #5327

How Has This Been Tested?

I've used npm run dev to test the changes manually. The code change is extremely minimal.
I've run all existing tests and made sure they worked.

Screenshots:

localhost_3200_
localhost_3200_ (1)
localhost_3200_ (2)
localhost_3200_ (3)

Checklist

My PR contains...

  • No code changes (src/ is unmodified: changes to documentation, CI, metadata, etc.)
  • Dependency changes (any modification to dependencies in package.json)
  • Bug fixes (non-breaking change which fixes an issue)
  • Improvements (misc. changes to existing features)
  • Features (non-breaking change which adds functionality)

My changes...

  • are breaking changes to a public API (config options, System API, major UI change, etc).
  • are breaking changes to a private API (Redux, component props, utility functions, etc.).
  • are breaking changes to a developer API (npm script behavior changes, new dev system dependencies, etc).
  • are not breaking changes.

Documentation

  • My changes do not require a change to the project documentation.
  • My changes require a change to the project documentation.
  • If yes to above: I have updated the documentation accordingly.

Automated tests

  • My changes can not or do not need to be tested.
  • My changes can and should be tested by unit and/or integration tests.
  • If yes to above: I have added tests to cover my changes.
  • If yes to above: I have taken care to cover edge cases in my tests.
  • All new and existing tests passed.

Sorry, something went wrong.

@webron
Copy link
Contributor

webron commented Apr 18, 2020

@mrahhal Thanks for this PR. It's always great seeing such contributions from the community.

As you suspected, it'll take us time to fully review and potentially merge this PR. PRs that affect UI/UX require a more extensive review. I'm fairly certain we'll get feedback from our internal UX team about some changes, though I feel they'd be in favor of such functionality in general.

I hope you can understand why this is going to take longer for a full review, and I appreciate your patience in the matter.

@mrahhal
Copy link
Author

mrahhal commented Apr 18, 2020

Yeah I understand no worries. If at the time the team thinks this is worth it, I'll be ready to cooperate and get this PR into a good shape.

@takabayashi
Copy link

Let's solve these conflicts and merge them, guys! This will help us a lot given a new face to this old dude.

@luca0898
Copy link

any news about that? my eyes are begging hahaha

@mrahhal
Copy link
Author

mrahhal commented Sep 26, 2020

I'm ready whenever to resolve conflicts and get this into good shape, but it's hanging on the maintainers. Can't work on this more without it getting the "yes".

@Meroan
Copy link

Meroan commented Oct 1, 2020

Nice work, i work with cherwell and this would help a lot on the eyes. Thanks for the work you do.

@mathis-m
Copy link
Contributor

mathis-m commented Oct 4, 2020

Fixes #6448

@ahsteele
Copy link

ahsteele commented Oct 7, 2020

@mrahhal Thanks for this PR. It's always great seeing such contributions from the community.

As you suspected, it'll take us time to fully review and potentially merge this PR. PRs that affect UI/UX require a more extensive review. I'm fairly certain we'll get feedback from our internal UX team about some changes, though I feel they'd be in favor of such functionality in general.

I hope you can understand why this is going to take longer for a full review, and I appreciate your patience in the matter.

Any update on the review?

@tim-lai
Copy link
Contributor

tim-lai commented Oct 8, 2020

@mrahhal Thanks for the PR! Unfortunately, we are unable to accept and merge this PR. I think it is a good idea though, and I believe that a custom plugin could be used to replicate your efforts that your team (and others) can use.

@tim-lai tim-lai closed this Oct 8, 2020
@KaKi87
Copy link

KaKi87 commented Oct 8, 2020

WTF ?

This is the kind of answer that a proprietary support team would formulate. 😣

Where's the justification ?

@natalie-o-perret
Copy link

@mrahhal Thanks for the PR! Unfortunately, we are unable to accept and merge this PR. I think it is a good idea though, and I believe that a custom plugin could be used to replicate your efforts that your team (and others) can use.

Based -- on -- what?

@Atulin
Copy link

Atulin commented Mar 21, 2022

Based on fuck knows what. Unfortunately, some developers absolutely loathe improvements to their projects.

@webron
Copy link
Contributor

webron commented Mar 21, 2022

@Atulin that kind of language is uncalled for. The decision was mine when I was still working on the project. Even though I'm not anymore, I'm not going to go into the details as to why not, even though they were justified (and still are). An alternative suggestion was given (and there's nothing wrong with it), and with time, the decision will likely to be clear.

@Atulin
Copy link

Atulin commented Mar 21, 2022

>they were justified and still are
>refuses to justify

Aight

@webron
Copy link
Contributor

webron commented Mar 21, 2022

Yes, you're not owed an explanation.

@KaKi87
Copy link

KaKi87 commented Mar 21, 2022

In that case, you might as well make the project proprietary.

@gumbarros
Copy link

@tim-lai please consider this PR. There is literally no explanation!

@gumbarros
Copy link

Generated a simple dark theme using Dark Reader, if anyone are interessed:

https://github.com/gumbarros/swagger-dark-theme

@morremeyer
Copy link

@tim-lai

Unfortunately, we are unable to accept and merge this PR

@webron

The decision was mine when I was still working on the project. Even though I'm not anymore, I'm not going to go into the details as to why not, even though they were justified (and still are).

Thanks for letting the community know, could you please elaborate on the reasons why?

While I’m aware of @webron's later comment

Yes, you're not owed an explanation.

and agree with it - after all, we all can decide what to do with our own time - letting the community know why this could (or still can't) be merged will enable other potential contributors to decide if they should invest time in this issue or not.

Without any explanation, this is not possible.

For example, if it is a general problem with the amount of maintenance required (which is a valid decision that other projects have made in the past), this would let everyone know to create a community-maintained dark mode extension.

If it is however any other issue, e.g. the style of the code, this would serve as encouragement for others who want this feature to tackle it.

It would be very helpful for everyone here and everyone eventually finding this PR to know why it was rejected, so would you please be able to provide us with additional context for this decision?

@tim-lai
Copy link
Contributor

tim-lai commented Aug 1, 2022

Theming can be a very subjective experience, and what works for some may not work for others. There are many users with different SwaggerUI needs, which expands beyond branding and theming. As such, users can customize their experience by leveraging SwaggerUI's plugin system.

Thanks all for the passion, so let's all keep it friendly and nice here, even if we disagree with certain decisions or how they may have come across.

@morremeyer
Copy link

@tim-lai Thank you for clarifying!

@KaKi87
Copy link

KaKi87 commented Aug 1, 2022

Well, according to this logic, the Swagger UI should be fully unstyled (CSS-less) when running without plugin, so that even the current base theme would need to be added as a plugin.

@morremeyer
Copy link

@KaKi87 If that's what you take from it, you're welcome to apply this to any project of your own.

But the current theme is what the swagger UI includes, which is the classic 80% solution: Sufficient for most cases. Maintaining two themes that should only differ by color scheme is an overhead that not every project can or wants to afford.

@Atulin
Copy link

Atulin commented Aug 1, 2022

Well, glad we at least got an explanation instead of "get bent lmao"

@KaKi87
Copy link

KaKi87 commented Aug 2, 2022

you're welcome to apply this to any project of your own

I won't follow this logic, so I won't do that.

the current theme is what the swagger UI includes, which is the classic 80% solution: Sufficient for most cases

If that was true, then the Swagger UI would be dark-only, considering the following stats :

@morremeyer
Copy link

@KaKi87 The statistics you posted are not relevant to swagger as they are about completely different projects/software.

The maintainers have pointed out why this will not be happening.

I can understand why people are unhappy about it, but unless there are significant new arguments here, I do not see why they should change their mind.

This will be my last comment on this issue as there is nothing further to discuss here.

Anyone who disagrees with a decision someone makes about how they use their free time (or how a company decides to use the time they pay their employees for) on an open source project is welcome to fork it.

That being said, a good day to everyone here and thanks to the maintainers for maintaining this project.

@KaKi87
Copy link

KaKi87 commented Aug 2, 2022

The maintainers have pointed out why this will not be happening.

I have pointed out why that logic is invalid.

The statistics you posted are not relevant to swagger as they are about completely different projects/software.

Actually, dev-specific surveys show even higher dark mode usage stats.

unless there are significant new arguments here, I do not see why they should change their mind

Why would new arguments be needed ? It's simple : Swagger UI users are the kind of people who mostly prefer dark UIs. And there's no point in doing open source if you don't want to listen to users.

@lonix1
Copy link

lonix1 commented Aug 2, 2022

@tim-lai

Theming can be a very subjective experience, and what works for some may not work for others.

Why not integrate a widely-used upstream theme? Other apps simply use one of the major dark themes: "dracula", "nord dark", etc. These are very popular and would satisfy almost every dark mode user. And since the theme would be based on a third-party theme, you wouldn't have to entertain "please change this button or colour" requests - you could tell people to create theme plugins if they want to tweak it.

It's a compromise, and would be easier to maintain long-term, as the maintenance is done by the upstream project.

(@mrahhal No offense to you buddy, I personally like your theme... I would use it!)

@mrahhal
Copy link
Author

mrahhal commented Aug 2, 2022

None taken. I wasn't planning to comment on this since now I just resort to using Dark Reader as the easy way out (won't beat a well designed dark theme, but good enough). I still can't take a single look at the light theme, and a lot of people just won't be using Dark Reader or user styles, so I think this issue still stands.

Personally though, I understand how much of a maintanance effort merging this PR would require because of how swagger-ui was originally written (I made this clear in my first comment), which is why I didn't comment after. I consider this a good enough reason to close this, but I'm confused why none of the maintainers tried to explain the right reasons (this reason). Saying users have different needs isn't convincing in the least especially when the majority prefers dark themes nowadays.

In any case, thank you for taking a look at this. For anyone else still struggling, try and use Dark Reader (hint, you can make it so that it's active only on websites you define), it'll help with those remaining apps that don't offer a theme that doesn't strain the eyes.

@idonov8
Copy link

idonov8 commented Sep 1, 2022

@mrahhal Did you end up turning into a plugin like @tim-lai suggested?

@mrahhal
Copy link
Author

mrahhal commented Sep 1, 2022

Nope, that isn't easy work (the work in this PR was far from complete) and honestly not worth it if it's not going to be part of the project proper.

@sephentos
Copy link

Why would new arguments be needed ? It's simple : Swagger UI users are the kind of people who mostly prefer dark UIs. And there's no point in doing open source if you don't want to listen to users.

The dark sides of open source.

I never thought that the desire for an optional dark theme would generate such a response and attitude from the developers/contributors.

@ghost
Copy link

ghost commented Sep 29, 2022

The problem with just using Dark Reader directly is that you can't set it to run on a per-path basis, only per-domain. For example, Gitea supports dark mode natively, so I don't want Dark Reader messing with the theme, but the Swagger API docs don't.

For anyone interested, I've made a userscript that automatically applies @gumbarros's stylesheet on any Swagger API documentation page (checking for the presence of the #swagger-ui element): https://greasyfork.org/en/scripts/452248-swagger-dark-mode

@gumbarros
Copy link

The problem with just using Dark Reader directly is that you can't set it to run on a per-path basis, only per-domain. For example, Gitea supports dark mode natively, so I don't want Dark Reader messing with the theme, but the Swagger API docs don't.

For anyone interested, I've made a userscript that automatically aplies @gumbarros's stylesheet on any Swagger API documentation page (checking for the presence of the #swagger-ui element): https://greasyfork.org/en/scripts/452248-swagger-dark-mode

If the application with Swagger source code is yours, you can also download the .css and inject it like I said on README.

@ghost
Copy link

ghost commented Sep 30, 2022

If the application with Swagger source code is yours, you can also download the .css and inject it like I said on README.

Yep, I'll do that as well, just thought I'd make a more universal userscript for sites I don't control.

@KaKi87
Copy link

KaKi87 commented Sep 30, 2022

Gitea supports dark mode natively, so I don't want Dark Reader messing with the theme, but the Swagger API docs don't.
For anyone interested, I've made a userscript that automatically aplies @gumbarros's stylesheet on any Swagger API documentation page

Doesn't work there.

@ghost
Copy link

ghost commented Sep 30, 2022

@KaKi87 Works for me with Violentmonkey in Chrome. What browser and userscript manager are you using?

@KaKi87
Copy link

KaKi87 commented Sep 30, 2022

Same extension on Chromium-browser browsers even if not Google Chrome itself, so pretty much the same.

However, I did find out the issue : why did you put a @run-at directive ?

If the script runs too soon, the DOM isn't ready yet.

Removing it (i.e. using the default document-end value) fixes my issue.

@ghost
Copy link

ghost commented Oct 4, 2022

@KaKi87 Fixed, I was just concerned about potential white flashes but it doesn't seem to flash even if I remove that value.

@landsman
Copy link

@tim-lai why? what are the requirements? optional configuration via UI?

@vibonacci
Copy link

This should be on the top of the priority list.

@mateusdata
Copy link

Gerei um tema escuro simples usando o Dark Reader, caso alguém esteja interessado:

https://github.com/gumbarros/swagger-dark-theme

Obrigrado ajudou de mais, meus olhos já estavam rachados de tanto ver cor branca na tela.

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.

[Feature Request] Dark mode