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

Easy way to set style to body #701

Comments

@sapegin
Copy link
Member

sapegin commented Nov 24, 2017

  • Find a way to do that (I guess via styles option, it may be already supported)
  • Do not add new options
  • Document in the cookbook
@sapegin
Copy link
Member Author

sapegin commented Nov 24, 2017

It’s already possible but undocumented:

module.exports = {
	components: 'src/components/**/[A-Z]*.js',
	styles: {
		StyleGuide: {
			'@global body': {
				fontFamily: 'Helvetica',
			},
		},
	},
};

@sapegin sapegin added the good first issue Good for newcomers label Nov 27, 2017
@sanjsanj
Copy link
Contributor

sanjsanj commented Dec 1, 2017

@sapegin Is this issue still open and has the scope just changed to document the feature instead?

@sapegin
Copy link
Member Author

sapegin commented Dec 2, 2017

@sanjsanj Exactly!

@sanjsanj
Copy link
Contributor

sanjsanj commented Dec 2, 2017

@sapegin Perhaps I could pick it up then if you don't mind :)

No idea what to do but I'll fork the repo and have a look.

@sapegin
Copy link
Member Author

sapegin commented Dec 3, 2017

I think the best way is to expand this question with an example from my comment above: https://react-styleguidist.js.org/docs/cookbook.html#how-to-add-custom-javascript-and-css-or-polyfills

@sanjsanj
Copy link
Contributor

sanjsanj commented Dec 3, 2017

Cheers! I'll look at that now. I have been looking at this issue and will come back to you with further questions asap.

@sanjsanj
Copy link
Contributor

sanjsanj commented Dec 3, 2017

@sapegin Apologies for the hassle but I have some questions:

(This is my first time using your package and at first it wasn't clear that themes uses your own API and styles uses the CSSinJS API.)

  • Since you are using '@global' does this mean that JSS-global is also available? It's not listed in the available plugins in that section.

  • Sorry but I have no context as to why this issue was flagged up, is there a particular use case we could reference?

  • You say that for this component <LogoRenderer><h1 className="logo-524678444"> you would use this styles object:

styles: {
    Logo: {
        logo: {
            animation: 'blink ease-in-out 300ms infinite'
        }
    }
}

Should Logo be LogoRenderer instead or am I missing something?

@sapegin
Copy link
Member Author

sapegin commented Dec 3, 2017

Would it make sense to include this in the #how-to-change-styles-of-a-style-guide section, and expand a little bit more on how to reference the CSSinJS API to construct styles here?

No, it won’t change style guide styles, only style of user components.

Since you are using '@global' does this mean that JSS-global is also available? It's not listed in the available plugins in that section.

Nice catch! We should add it to the list. Here is the full list of available plugins:

import global from 'jss-global';
import isolate from 'jss-isolate';
import nested from 'jss-nested';
import camelCase from 'jss-camel-case';
import defaultUnit from 'jss-default-unit';
import compose from 'jss-compose';

Sorry but I have no context as to why this issue was flagged up, is there a particular use case we could reference?

I think the most common would be setting a font face, otherwise, if you don’t set font face explicitly in each component, they will be rendered with the browser default font.

Should Logo be LogoRenderer instead or am I missing something?

No, we strip Renderer part before applying styles, because only *Render components may have styles:

const componentName = WrappedComponent.name.replace(/Renderer$/, '');

sanjsanj added a commit to sanjsanj/react-styleguidist that referenced this issue Dec 3, 2017
@sanjsanj
Copy link
Contributor

sanjsanj commented Dec 3, 2017

Just opened a PR, not sure if it's what you had in mind or not but let's get the ball rolling.

Awaiting feedback :-)

@sapegin sapegin closed this as completed in b0851ba Dec 3, 2017
@wachunga
Copy link
Contributor

@sapegin is that Renderer removal documented somewhere? I've found it very confusing trying to apply styles.

@sapegin
Copy link
Member Author

sapegin commented Feb 16, 2018

@craigkovatch
Copy link

@sapegin this appears to be broken in prod -- is it because it relies on component name matching, and those component names are removed when minified?

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