|
1 | 1 | /* @flow */
|
2 | 2 |
|
3 | 3 | import React from 'react';
|
| 4 | +import { insertGlobal } from 'glamor'; |
4 | 5 | import Router from './Router';
|
5 | 6 | import Page from './Page';
|
6 | 7 | import Home from './Home';
|
7 | 8 | import ComponentDocs from './ComponentDocs';
|
| 9 | +import Markdown from './Markdown'; |
8 | 10 |
|
9 |
| -export const buildRoutes = (pages: Array<*>) => |
10 |
| - pages.map(it => ({ |
| 11 | +insertGlobal(` |
| 12 | + html { |
| 13 | + box-sizing: border-box; |
| 14 | + } |
| 15 | + *, *:before, *:after { |
| 16 | + box-sizing: inherit; |
| 17 | + } |
| 18 | + html, body { |
| 19 | + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; |
| 20 | + margin: 0; |
| 21 | + padding: 0; |
| 22 | + color: #333; |
| 23 | + lineHeight: 1.5; |
| 24 | + } |
| 25 | + code { |
| 26 | + font-family: "Roboto Mono", "Operator Mono", "Fira Code", "Ubuntu Mono", "Droid Sans Mono", "Liberation Mono", "Source Code Pro", Menlo, Consolas, Courier, monospace; |
| 27 | + color: #000; |
| 28 | + line-height: 2; |
| 29 | + } |
| 30 | + a { |
| 31 | + color: #1976D2; |
| 32 | + text-decoration: none; |
| 33 | + } |
| 34 | + a:hover { |
| 35 | + color: #2196F3; |
| 36 | + } |
| 37 | +`); |
| 38 | + |
| 39 | +export const buildRoutes = (pages: Array<*>, components: Array<*>) => |
| 40 | + components.map(it => ({ |
11 | 41 | title: it.name,
|
12 | 42 | name: it.name.toLowerCase(),
|
13 | 43 | description: it.info.description,
|
14 | 44 | component: props => (
|
15 |
| - <Page {...props} pages={pages}> |
| 45 | + <Page {...props} pages={pages} components={components}> |
16 | 46 | <ComponentDocs {...it} />
|
17 | 47 | </Page>
|
18 | 48 | ),
|
19 |
| - })).concat({ |
| 49 | + })).concat(pages.map(it => ({ |
| 50 | + title: it.name, |
| 51 | + name: it.name.toLowerCase().replace(/\s+/g, '-'), |
| 52 | + description: '', |
| 53 | + component: props => ( |
| 54 | + <Page {...props} pages={pages} components={components}> |
| 55 | + <Markdown source={it.text} /> |
| 56 | + </Page> |
| 57 | + ), |
| 58 | + }))).concat({ |
20 | 59 | title: 'Home',
|
21 | 60 | name: 'index',
|
22 | 61 | description: '',
|
23 | 62 | component: props => (
|
24 |
| - <Page {...props} pages={pages}> |
| 63 | + <Page {...props} pages={pages} components={components}> |
25 | 64 | <Home />
|
26 | 65 | </Page>
|
27 | 66 | ),
|
28 | 67 | });
|
29 | 68 |
|
30 |
| -export default function App({ pages, name }: any) { |
31 |
| - const routes = buildRoutes(pages); |
| 69 | +export default function App({ pages, components, name }: any) { |
| 70 | + const routes = buildRoutes(pages, components); |
32 | 71 | return (
|
33 | 72 | <Router
|
34 | 73 | name={name}
|
|
0 commit comments