|
| 1 | +import * as React from 'react' |
| 2 | +import { NavLink } from 'react-router-dom' |
| 3 | +import { Header, Icon } from 'semantic-ui-react' |
| 4 | + |
| 5 | +import { Button } from '@stardust-ui/react' |
| 6 | + |
| 7 | +import CodeSnippet from '../components/CodeSnippet' |
| 8 | +import DocPage from '../components/DocPage' |
| 9 | + |
| 10 | +export default () => ( |
| 11 | + <DocPage title="Quick Start"> |
| 12 | + <Header as="h2">Install</Header> |
| 13 | + <p> |
| 14 | + Stardust UI should be installed as a <code>dependency</code> of your app. |
| 15 | + </p> |
| 16 | + <CodeSnippet mode="sh" value="yarn add @stardust-ui/react" /> |
| 17 | + <Header as="h2">Setup</Header> |
| 18 | + <p> |
| 19 | + Stardust components are styled using CSS in JS. This technique requires a style renderer to |
| 20 | + render JavaScript objects to CSS.{' '} |
| 21 | + <a href="https://reactjs.org/docs/context.html" target="_blank" rel="noopener nofollow"> |
| 22 | + React Context <Icon name="external" size="small" link fitted /> |
| 23 | + </a>{' '} |
| 24 | + is used to provide the style renderer and theme to components. |
| 25 | + </p> |
| 26 | + <p> |
| 27 | + Place a <code>{'<Provider />'}</code> at the root of your app and pass theme as props. |
| 28 | + </p> |
| 29 | + <CodeSnippet |
| 30 | + label="index.jsx" |
| 31 | + value={[ |
| 32 | + `import React from 'react'`, |
| 33 | + `import ReactDOM from 'react-dom'`, |
| 34 | + `import { Provider } from '@stardust-ui/react'`, |
| 35 | + `import { fontFaces, staticStyles, theme } from '@stardust-ui/react/themes/teams'`, |
| 36 | + ``, |
| 37 | + `import App from './App'`, |
| 38 | + ``, |
| 39 | + `ReactDOM.render(`, |
| 40 | + ` <Provider theme={theme} staticStyles={staticStyles} fontFaces={fontFaces}>`, |
| 41 | + ` <App />`, |
| 42 | + ` </Provider>,`, |
| 43 | + ` document.getElementById('root'),`, |
| 44 | + `)`, |
| 45 | + ].join('\n')} |
| 46 | + /> |
| 47 | + <Header as="h2">Usage</Header> |
| 48 | + <p>That's it. You can now use Stardust UI components in your app.</p> |
| 49 | + <CodeSnippet |
| 50 | + label="App.jsx" |
| 51 | + value={[ |
| 52 | + `import React from 'react'`, |
| 53 | + `import { Button } from '@stardust-ui/react'`, |
| 54 | + ``, |
| 55 | + `export default () => (`, |
| 56 | + ` <Button type="primary" content="Docs" icon="arrow right" iconPosition="after" />`, |
| 57 | + `)`, |
| 58 | + ].join('\n')} |
| 59 | + /> |
| 60 | + <br /> |
| 61 | + {/* Show a preview of the above snippet */} |
| 62 | + <Button |
| 63 | + as={NavLink} |
| 64 | + content="Docs" |
| 65 | + type="primary" |
| 66 | + icon="arrow right" |
| 67 | + iconPosition="after" |
| 68 | + to="components/button" |
| 69 | + /> |
| 70 | + </DocPage> |
| 71 | +) |
0 commit comments