-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #238 from iCHEF/feature/storybook_docs
Install storybook docs
- Loading branch information
Showing
7 changed files
with
2,921 additions
and
855 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = [ | ||
'@storybook/addon-docs/react/preset', | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { Meta, Story, Preview } from '@storybook/addon-docs/blocks'; | ||
|
||
<Meta title="0 | Introduction" /> | ||
|
||
# Introduction | ||
|
||
`gypcrete` is an in-house components library from iCHEF. | ||
It's currently split into 3 packages: | ||
|
||
- `@ichef/gypcrete` - core components and styles | ||
- `@ichef/gypcrete-form` - components built for form purposes | ||
- `@ichef/gypcrete-imageeditor` - a component that allows you to scale, rotate and crop images | ||
|
||
Here's a quick example of how you might use components from gypcrete: | ||
|
||
```jsx | ||
import React from 'react'; | ||
import { Button } from '@ichef/gypcrete'; | ||
|
||
const CustomComponent = () => ( | ||
<Button basic="Hello World!" /> | ||
); | ||
|
||
export default CustomComponent; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { extractProps } from '@storybook/addon-docs/dist/frameworks/react/extractProps'; | ||
|
||
function formatValue(value) { | ||
switch (typeof value) { | ||
case 'string': | ||
return `'${value}'`; | ||
case 'boolean': | ||
return `${value}`; | ||
case 'function': | ||
return '[function]'; | ||
default: | ||
return value; | ||
} | ||
} | ||
|
||
export default function getComponentProps(component) { | ||
const extractedProps = extractProps(component).rows; | ||
|
||
if (!extractedProps.length) { | ||
const inferredProps = Object.keys(component.propTypes || {}) | ||
.map((propName) => { | ||
const required = !(typeof component.propTypes[propName].isRequired === 'function'); | ||
const defaultValue = formatValue((component.defaultProps || {})[propName]); | ||
|
||
return { | ||
name: propName, | ||
required, | ||
defaultValue: defaultValue && ({ summary: defaultValue }), | ||
}; | ||
}); | ||
|
||
return inferredProps; | ||
} | ||
|
||
return extractedProps; | ||
} |
Oops, something went wrong.