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

Add global styling setup to README #79

Merged
merged 2 commits into from
Oct 4, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 34 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,44 @@ The Storybook design system codifies existing UI components into a central, well
npm install --save @storybook/design-system
```

## Usage
## Global Styles

```jsx
import React, { Component } from 'react';
Components within the design system assume that a set of global styles have been configured. Depending upon the needs of the application, this can be done several ways:

#### Option 1: Render the `GlobalStyle` component

Useful when you don't need any custom `body` styling in the application, typically this would be placed in a layout component that wraps all pages, or a top-level `App` component.

import MyComponent from '@storybook/design-system';
```javascript
import { global } from '@storybook/design-system';
const { GlobalStyle } = global;
```

```javascript
/* Render the global styles once per page */
<GlobalStyle />
```

class Example extends Component {
render() {
return <MyComponent />;
#### Option 2: Use the `bodyStyles` to apply styling

Useful when you want build upon the shared global styling.

```javascript
import { createGlobalStyle } from 'styled-components';
import { global } from '@storybook/design-system';
const { bodyStyles } = global;

const CustomGlobalStyle = createGlobalStyle`
body {
${bodyStyles}
// Custom body styling for the app
}
}
`;
```

```javascript
/* Render the global styles once per page */
<CustomGlobalStyle />
```

## Font Loading
Expand Down