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/dark theme #200

Closed
wants to merge 2 commits into from

Conversation

joelgriffith
Copy link

Super hot dark theme, super slick css, all in one nice PR:

screen shot 2016-11-08 at 1 52 11 pm

@facebook-github-bot
Copy link

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at cla@fb.com. Thanks!

If you are contributing on behalf of someone else (eg your employer): the individual CLA is not sufficient - use https://developers.facebook.com/opensource/cla?type=company instead. Contact cla@fb.com if you have any questions.

@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@@ -120,7 +122,9 @@ export class GraphiQL extends React.Component {
onEditVariables: PropTypes.func,
onEditOperationName: PropTypes.func,
onToggleDocs: PropTypes.func,
getDefaultFieldNames: PropTypes.func
getDefaultFieldNames: PropTypes.func,
theme: PropTypes.oneOf([ 'dark' ]),
Copy link
Author

Choose a reason for hiding this comment

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

Figured we could keep this open to future theme(s)

@leebyron
Copy link
Contributor

Could this be done in a simpler way? For example, if there are more themes in the future - this sets a precedent that they can only be added by PR to this repo. Ideally anyone can write and share their own themes and host them in whatever repo they like.

What do we need to do for GraphiQL to enable that? Are the CSS class names descriptive enough that the only necessary thing is to just add another CSS file to the page? Do we need the ability to set an additional classname on the GraphiQL root node?

@joelgriffith
Copy link
Author

I think it's easy enough to add your own body/html class and overwrite the current theme via css selector specificity. I've already done this myself in a few implementations. We could also expose an optional className prop to make this more explicit to users. Mostly this just needs to be documented and, potentially, we have a pre-done dark theme for users.

My final thought is that colors and other backgrounds are defined in numerous places, so theming can be kind of painful since you have to overwrite numerous selectors. This begs for either refactoring the css to make theming easier, or implement some preprocessor so consumers can overwrite variables and generate the css themselves.

@joelgriffith
Copy link
Author

I'm going to close this PR and work on another branch that more descriptively shows how to theme, and offers a dark theme as an example

@joelgriffith
Copy link
Author

Hrm, doing some digging on color definitions:

ack '\#.*;' css | grep -o '\#.*;' | sort | uniq | tee >(wc -l) => results in around 72 unique color definitions.

Dropping the uniq in my command shows that each color is defined around ~2 times: 139. I'm not sure what the threshold is in moving to a css-preprocessor, but this amount of colors and definitions makes it hard(er) for consumers to apply custom themes as there's a ton of rules to rewrite.

@swyxio
Copy link
Contributor

swyxio commented Oct 13, 2017

i would be interested in this

@rjrobinson
Copy link

And another year later

acao pushed a commit to acao/graphiql that referenced this pull request Jun 1, 2019
acao pushed a commit to acao/graphiql that referenced this pull request Jun 5, 2019
@prakashn27
Copy link

And two more years later...

@acao
Copy link
Member

acao commented Oct 10, 2020

@joelgriffith did you ever re-open this PR? this accidentally was cross referenced when merging other repos

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants