Skip to content

[WIP] Implement docs site #205

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
22 changes: 0 additions & 22 deletions docs/Cartesian.md

This file was deleted.

16 changes: 0 additions & 16 deletions docs/Catch.md

This file was deleted.

26 changes: 0 additions & 26 deletions docs/Colorable.md

This file was deleted.

20 changes: 0 additions & 20 deletions docs/Diff.md

This file was deleted.

17 changes: 0 additions & 17 deletions docs/Markdown.md

This file was deleted.

38 changes: 0 additions & 38 deletions docs/Matrix.md

This file was deleted.

61 changes: 61 additions & 0 deletions docs/_app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import React from 'react'
import RebassMDX from '@rebass/mdx'
import * as Rebass from 'rebass'
import { Flex, Box, Container } from 'rebass'
import sortBy from 'lodash.sortby'
import { Link } from 'react-router-dom'
import { SidebarLayout as Layout } from '@compositor/x0/components'
import { Kit as KitLogo } from '@compositor/logo'

import * as Kit from '../core/src'

const navOrder = [
'index',
'introduction',
'getting-started'
]

const pageNames = { index: 'Home' }

const sortRoutes = routes => [
...sortBy([...routes], a => {
const i = navOrder.indexOf(a.name)
return i < 0 ? Infinity : i
})
].map(route => {
if (!pageNames[route.name]) return route
return {
...route,
name: pageNames[route.name]
}
})

export default class App extends React.Component {
static defaultProps = {
title: 'Kit'
}

render () {
const {
routes,
route,
children,
} = this.props
const { layout } = (route && route.props) || {}
const disableLayout = layout === false

const nav = sortRoutes(routes)

return (
<RebassMDX components={{ ...Rebass, ...Kit }}>
{disableLayout ? children : (
<Layout
{...this.props}
logo={<KitLogo size={30} />}
routes={nav}
/>
)}
</RebassMDX>
)
}
}
21 changes: 21 additions & 0 deletions docs/components/Cartesian.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Cartesian

Display the Cartesian product of component props.

```.jsx
<Cartesian
component={Button}
m={4}
p={[3, 4]}
fontSize={[1, 3]}
bg={['blue', 'tomato', 'purple']}
children={'Beep'}
/>
```

## Props

name | type | description
---|---|---
`component` | React component | the component to render
`...props` | Props for Cartesian product | Only arrays are computed in the product
24 changes: 24 additions & 0 deletions docs/components/Catch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Catch

React `componentDidCatch` component that displays errors.
Wrap it around other components that might error like a LiveEditor or a fetch.

```jsx
import React from 'react'
import { Catch } from '@compositor/kit'
import Button from '../src/Button'

export default props => (
<Catch>
<Button>Hello</Button>
</Catch>
)
```

### Example

Here a ReferenceError is being caught.

```.jsx
<Catch>{imNotDefined}</Catch>
```
19 changes: 19 additions & 0 deletions docs/components/Colorable.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Colorable

Render prop component for the [colorable][colorable] library.

```.jsx
<Colorable
colors={['black', 'white', '#07c', 'tomato']}
children={combos => combos.map(combo =>
<div
key={combo.hex}
children={combo.combinations.map(c =>
<Button key={c.hex} bg={c.hex} color={combo.hex} m={3}>Beep</Button>
)}
/>
)}
/>
```

[colorable]: https://github.com/jxnblk/colorable
4 changes: 3 additions & 1 deletion docs/Debug.md → docs/components/Debug.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
The Debug component can be used to get a formatted JSON printout of an object.
It also provides a HOC for logging props when a component uses the implicit return.

![](images/debug.png)
```.jsx
<Debug>{{ some: 'object', to: 'debug' }}</Debug>
```

## Usage

Expand Down
12 changes: 12 additions & 0 deletions docs/components/Diff.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Diff

Shows a visual diff between two elements.

```.jsx
<Box mb={4}>
<Diff>
<Text fontSize={3}>Hi</Text>
<Text fontSize={4} color="red">Hey</Text>
</Diff>
</Box>
```
1 change: 0 additions & 1 deletion docs/Fetch.md → docs/components/Fetch.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# Fetch

Data fetcher, editor, and lifecycle toggle.
Expand Down
2 changes: 1 addition & 1 deletion docs/Font.md → docs/components/Font.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Font

Set font-family and other typographic styles
Set font-family and other typographic styles.

The `Font` components provides basic webfont utilities to wrap your app.
It also provides a convenient webfont loader using [Google Fonts](https://fonts.google.com/).
Expand Down
File renamed without changes.
44 changes: 22 additions & 22 deletions docs/Library.md → docs/components/Library.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,23 @@
The Library component manages a list of examples created with the Example component,
showing a grid view by default and a detailed view when a component is clicked.

![](images/library.png)

## Usage

```jsx
import React from 'react'
import { Library, Example } from '@compositor/kit'
import { Button, Heading } from '../src'

const App = props => (
<Library>
<Example name='Button'>
<Button>Beep</Button>
</Example>
<Example name='Heading'>
<Heading>Hello</Heading>
</Example>
</Library>
)
```.jsx
<Library basename="/components/Library">
<Example name='Button'>
<Button>Beep</Button>
</Example>
<Example name='Donut'>
<Donut />
</Example>
<Example name='Badge'>
<Badge bg='tomato'>Boop</Badge>
</Example>
<Example name='Heading'>
<Heading>Hello</Heading>
</Example>
</Library>
```

### Examples array
Expand Down Expand Up @@ -143,7 +141,7 @@ export default props =>
/>
```

## Library Component
### Library Component Props

Prop | Type | Description
---|---|---
Expand All @@ -152,12 +150,12 @@ title | string | Optional title to display in the side nav
renderSideNav | function | Optional render prop to customize side nav
renderCard | function | Optional render prop to customize card in the grid view

## Example Component
### Example Component

Use the Example component with the Library component to add examples.
Each Example component requires a unique `name` prop value.

### Usage
#### Usage

```jsx
import React from 'react'
Expand All @@ -175,15 +173,17 @@ const App = props => (
)
```

#### Example Component Props

Prop | Type | Description
---|---|---
name | string (required) | Unique identifier that will be used for navigation in the Library

## Detail Component
### Detail Component

Use the Detail component to add additional elements when viewing the example detail view. Elements in the Detail component will not show up in the grid view of the Library.

### Usage
#### Usage

```jsx
import React from 'react'
Expand Down
Loading