-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Provide a dark theme
for GraphiQL
#129
Comments
If someone wants to tackle this, it should be as simple as writing a new css file to include - but this isn't something we're going to prioritize on our team. |
@asiandrummer Are you interested in doing this? If so, I will help you out ;-) |
I've written a custom theme for my own implementation elsewhere. It's pretty easy to override the current theme via stronger css selectors. Would it be better to expose an interface via I think documenting how to override the current theme might suffice in place of widening an API surface area. |
@Brene - This continues to be a low priority item on our list of feature requests, so I'm not sure if our team could tackle this in a near future. I'd love to review and help merging this if you'd like to give a hand 😄 @joelgriffith - Documentation for how to customize would be appreciated, but since I think some users of GraphiQL aren't as familiar with css rules, they would also like to have a stock-version of dark theme if it could be as easy as doing |
I can likely implement something like this then (and add docs on how to implement your own theme). |
#200 a |
Spilling over from my initial PR for this: there's so many color definitions and they're redefined nearly 2x throughout the css. This makes it hard for folks to bolt on their themes (combined with the fact that we don't expose setting a CodeMirror theme). I feel that if we want to accomplish this for future cases, we should:
Thoughts? @leebyron @asiandrummer |
There are 160 colour definitions. 81 unique colours. Rough sorting... http://codepen.io/anon/pen/PWQWBg I feel like making it "easy" to maintain these themes would somewhat require using a preprocessor? Is that something you would accept a PR for? |
@AndreasHeiberg that's something that I was advocating for, but I think the consensus is that this project needs to be as lite as possible. |
I added a preprocessor in aed3bd9 (specifically for auto-prefixing), so there is already some precedent for preprocessing the CSS. It seems that it would be desirable to do some or all of the following:
Potentially adding a prop to select a specific CodeMirror theme, like @joelgriffith suggested above, would be worth considering too. I think that list runs from least to most contentious, so we should start with "1." and work down from there. |
@wincent good shout didn't look at build.sh truth be told I should probably look at how our GraphiQL is setup and what assets it's using. I think keeping the project lite is a very valuable thing indeed. The other way of solving this would be to have classes for each color essentially. But all you're really saving is for the theme dev to having to duplicate color declarations. I might have a look at actually writing a theme and see where the pain points are. |
I agree with @wincent on the proposal. I've themed GraphiQL in AppNexus' usage, and it was simply just the classic "more-specific selectors" approach. It wasn't all that painful of an operation, but maybe a simple document would suffice? Other forces come into play once you add a |
I would like to, at least, expose a top-level prop for the codemirror theme. That'd be a quick win towards customization that'd be practically cost-free |
That sounds reasonable to me. |
Not sure if this is still relevant but in making my personal site I created a material theme: |
...this is still open and I haven't found much out there that looks good. Made a quick CSS override that gives me what I want. Pulled colors from Atom's One Dark theme. Needed it. Was the only window open that wasn't dark and it was making my eyes bleed. Quick and dirty source: https://gist.github.com/bkeating/cfe0d5e72bd3f9f1f77e1a2ff2309972 (relies on !important attribute(?) which is not ideal) |
I tried to adapt the above CSS into a UserStyle for use with Stylus, but it seems that, at least with the GraphiQL setup included with Apollo's server, the class names for the sidepanel are all minified/generated. E.g. This means that even the built-in dark theme appears with a stark white Schema sidepanel, and that it's quite hard (and probably not very robust) to style it with these generated class names. I think I'll go ahead and style the most important bits even with the minified class names, but I'd be interested in knowing if this is intentional/if there's a comfortable way to style GiQL to one's liking/what exactly is producing the class names. Edit: here's a gist with some CSS for a darker sidebar, using said minified names. It isn't ideal at all, but I don't have too much time making it pretty right now, and it's more pleasant on the eyes than a dark theme with white sidebar at least. |
@asiandrummer @leebyron would you be open to a PR for this which allowed for overriding the default classnames? Changes to the render method of
Allowing consumers to override the default styles by doing something like:
This would open the styling up for cssModules or css-in-js. |
We plan on providing much better options for custom theming in Version 1.x. Styled components with a theme provider is one proposal. We can discuss whether this is possible in 0.x., trying not to add too much as we prepare for 1.x |
@acao makes total sense to wait for v1.x, thanks for the quick response 👍 |
* Support directives hints for schema definitions * Test directives hints for schema definitions
How can one use this theme ? |
to note, GraphiQL still supports overriding the codemirror theme at least check out the new storybook of components and theming system we’ve built! should be integrating it in the next month as we finally have the codebase ready for plugins |
I would suggest using dark reader plugin for now, but yes this can be achieved with some hacky css overrides and by using the Theming system will come in 2.0.0 |
Just a quick hack using css filter: https://gist.github.com/xvaara/771d3c92a62d4149fa4e4b6d629b1b2b |
Hopefully someone will get to it, we are seeking new maintainers if you’re interested! |
@mcnaveen would you like to open a PR to implement the new theming system that supports dark mode variants? the roadmap is ready for folks to execute on. the theme provider is ready. We don't have any active contributors towards 2.x unfortunately, so it can't move until people from the community start helping! |
The new designs as planned in v2 include a dark mode! This should resolve this issue. For more details about this effort see #2328. |
|
Is there a property to activate this from the react component? My whole app has a theme, it would be nice if they could sync. Is this not exposed as an attribute on ? |
Hey @factoidforrest 👋 there currently isn't a prop to control the theme, though I believe it'd make sense to add that. Feel free to open an issue for that! (Please double check that there isn't an existing one before doing so.) As a workaround for now you can do
|
Probably a low-priority item (wishlist even), but a dark UI theme has been requested - I'm documenting as an issue here.
The text was updated successfully, but these errors were encountered: