Skip to content

Commit

Permalink
Merge pull request #1 from shilman/925-monorepo-doc-update
Browse files Browse the repository at this point in the history
Monorepo/storybooks.js.org doc update
  • Loading branch information
thani-sh authored Apr 18, 2017
2 parents 2b25359 + 83294fe commit 5dee115
Show file tree
Hide file tree
Showing 128 changed files with 4,248 additions and 1 deletion.
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
node_modules
*.log
.idea
npm-shrinkwrap.json
dist
.tern-port
*.DS_Store
*.lerna_backup
build
packages/examples/automated-*
yarn.lock
3 changes: 3 additions & 0 deletions .storybook/addons.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { register } from './notes_addon';
register();
require('@kadira/storybook/addons');
9 changes: 9 additions & 0 deletions .storybook/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { configure } from '@kadira/storybook';
import 'bootstrap/dist/css/bootstrap.css';
import '../src/index.css';

function loadStories() {
require('../src/stories');
}

configure(loadStories, module);
78 changes: 78 additions & 0 deletions .storybook/notes_addon.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import React from 'react';
import addons from '@kadira/storybook-addons';

const styles = {
notesPanel: {
margin: 10,
fontFamily: '-apple-system, ".SFNSText-Regular", "San Francisco", Roboto, "Segoe UI", "Helvetica Neue", "Lucida Grande", sans-serif',
fontSize: 14,
color: '#444',
width: '100%',
overflow: 'auto',
}
};

export class WithNote extends React.Component {
render() {
const { children, note } = this.props;
// This is to make sure, we'll always call this at the end of the eventloop.
// So we know that, panel will get cleared, before we render the note.
setTimeout(() => {
addons.getChannel().emit('kadira/notes/add_note', note);
}, 0);
return children;
}
}

class Notes extends React.Component {
constructor(...args) {
super(...args);
this.state = {text: ''};
this.onAddNote = this.onAddNote.bind(this);
}

onAddNote(text) {
this.setState({text});
}

componentDidMount() {
const { channel, api } = this.props;
channel.on('kadira/notes/add_note', this.onAddNote);

this.stopListeningOnStory = api.onStory(() => {
this.setState({text: ''});
});
}

componentWillUnmount() {
if(this.stopListeningOnStory) {
this.stopListeningOnStory();
}

this.unmounted = true;
const { channel, api } = this.props;
channel.removeListener('kadira/notes/add_note', this.onAddNote);
}

render() {
const { text } = this.state;
const textAfterFormatted = text? text.trim().replace(/\n/g, '<br />') : "";

return (
<div style={styles.notesPanel}>
<div dangerouslySetInnerHTML={{__html: textAfterFormatted}} />
</div>
);
}
}

export function register() {
addons.register('kadira/notes', (api) => {
addons.addPanel('kadira/notes/panel', {
title: 'Notes',
render: () => (
<Notes channel={addons.getChannel()} api={api}/>
),
})
})
}
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,19 @@
# storybooks.github.io
# Website for [storybooks.js.org](https://storybooks.js.org)

This is the source for [storybooks.js.org](https://storybooks.js.org). This is a [Create React App](https://github.com/facebookincubator/create-react-app) based site.

This site has also has the documentation for Storybook.

### Usage

```
npm i
npm start
```

### Edit Documentation

This website carries the documentation for Storybook.<br/>
Documentation is located at: [`src/docs`](/src/docs) directory.

It's written in Markdown and ES6. So, it supports goodies of both worlds.
20 changes: 20 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "storybooks.js.org",
"scripts": {
},
"env": {
},
"formation": {
"web": {
"quantity": 1
}
},
"addons": [

],
"buildpacks": [
{
"url": "https://github.com/mars/create-react-app-buildpack.git"
}
]
}
31 changes: 31 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "storybooks.js.org",
"version": "0.0.1",
"private": true,
"devDependencies": {
"@kadira/storybook": "^2.35.3",
"react-scripts": "^0.9.5"
},
"dependencies": {
"@kadira/storybook-addons": "^1.3.1",
"airbnb-js-shims": "^1.0.1",
"bootstrap": "^3.3.7",
"common-tags": "^1.3.1",
"highlight.js": "^9.6.0",
"marked": "^0.3.6",
"prop-types": "^15.5.7",
"react": "^15.5.4",
"react-dom": "^15.5.4",
"react-helmet": "^3.1.0",
"react-router": "^2.6.1",
"react-router-scroll": "^0.3.2",
"reflexbox": "^2.1.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"eject": "react-scripts eject",
"storybook": "start-storybook -p 9009",
"build-storybook": "build-storybook"
}
}
Binary file added public/favicon.ico
Binary file not shown.
46 changes: 46 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1" >
<meta name="description" content="React Storybook is a UI development environment for your React components. With it, you can visualize different states of your UI components and develop them interactively." >

<meta name="twitter:card" content="summary_large_image" >
<meta name="twitter:site" content="@kadirahq" >
<meta name="twitter:url" content="https://storybooks.js.org" >
<meta name="twitter:title" content="Storybook - UI dev environment you'll love to use." >
<meta name="twitter:description" content="React Storybook is a UI development environment for your React components. With it, you can visualize different states of your UI components and develop them interactively." >
<meta name="twitter:image" content="https://cldup.com/xgMg-L_Com.png" >

<meta name="og:type" content="website" >
<meta name="og:site_name" content="Storybook" >
<meta name="og:url" content="https://storybooks.js.org" >
<meta name="og:title" content="Storybook - UI dev environment you'll love to use." >
<meta name="og:description" content="React Storybook is a UI development environment for your React components. With it, you can visualize different states of your UI components and develop them interactively." >
<meta name="og:image" content="https://cldup.com/xgMg-L_Com.png" >

<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-48364339-10', 'auto');
ga('send', 'pageview');
</script>
</head>
<body>
<a href="https://github.com/storybooks/react-storybook" class="github-corner" aria-label="View source on Github"><svg width="80" height="80" viewBox="0 0 250 250" style="fill:#E91E63; color:#fff; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a><style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}</style>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` in this folder.
To create a production bundle, use `npm run build`.
-->
</body>
</html>
93 changes: 93 additions & 0 deletions src/components/Docs/Container/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import PropTypes from 'prop-types';
import React from 'react';
import Nav from '../Nav';
import NavDropdown from '../Nav/dropdown';
import Content from '../Content';
import './style.css';

class Container extends React.Component {
renderTopNav(cat) {
const { selectedCatId } = this.props;
const path = `/docs/${cat.id}`;

if (selectedCatId === cat.id) {
return <li className="selected" key={cat.id}>{cat.title}</li>;
}

return <a key={cat.id} href={path}><li>{cat.title}</li></a>;
}

render() {
const {
categories,
selectedCatId,
sections,
selectedItem,
selectedSectionId,
selectedItemId,
} = this.props;

const gitHubRepoUrl = 'https://github.com/storybooks/storybooks.github.io';
const docPath = `${selectedCatId}/${selectedSectionId}/${selectedItemId}`;
const gitHubRepoDocUrl = `${gitHubRepoUrl}/tree/master/src/docs/${docPath}.js`;

return (
<div id="docs-container" className="row">
<div className="row">
<div className="col-xs-12">
<ul className="top-nav">
{categories.map(this.renderTopNav.bind(this))}
</ul>
</div>
</div>

<div className="nav col-sm-3 col-md-3 hidden-xs">
<Nav
selectedCatId={selectedCatId}
sections={sections}
selectedSection={selectedItem.section}
selectedItem={selectedItem.id}
selectedSectionId={selectedSectionId}
selectedItemId={selectedItemId}
/>
</div>
<div className="content col-xs-12 col-sm-9 col-md-9 col-lg-9">
<div className="nav-dropdown">
<NavDropdown
selectedCatId={selectedCatId}
sections={sections}
selectedSection={selectedItem.section}
selectedItem={selectedItem.id}
/>
</div>

<Content
title={selectedItem.title}
content={selectedItem.content}
editUrl={gitHubRepoDocUrl}
/>

<div className="nav-dropdown">
<NavDropdown
selectedCatId={selectedCatId}
sections={sections}
selectedSection={selectedItem.section}
selectedItem={selectedItem.id}
/>
</div>
</div>
</div>
);
}
}

Container.propTypes = {
categories: PropTypes.array,
selectedCatId: PropTypes.string,
sections: PropTypes.array,
selectedItem: PropTypes.object,
selectedSectionId: PropTypes.string,
selectedItemId: PropTypes.string,
};

export default Container;
59 changes: 59 additions & 0 deletions src/components/Docs/Container/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#docs-container {
border-top: 1px solid #F4F4F4;
border-bottom: 1px solid #F4F4F4;
margin: 10px 0;
padding: 0;
}

#docs-container ul.top-nav {
margin: 20px 0 0;
padding: 0;
list-style: none;
font-size: 13px;
}

#docs-container ul.top-nav li {
display: inline-block;
background-color: #eee;
margin-right: 10px;
padding: 6px 20px;
cursor: pointer;
border-bottom: 1px solid #ccc;
}

#docs-container ul.top-nav li.selected {
background-color: #eb5d88;
color: #FFF;
}

#docs-container ul.top-nav li a {
font-size: 13px;
}

#docs-container .nav-dropdown {
display: none;
}

#docs-container .nav-dropdown select {
width: 100%;
}

#docs-container .nav-dropdown div {
margin: 0 0 5px;
}

@media only screen and (max-width: 998px) {
#docs-container .nav {
display: none;
}

#docs-container .content {
border-left: none;
margin: 15px 0;
padding: 0;
}

#docs-container .nav-dropdown {
display: block;
}
}
Loading

0 comments on commit 5dee115

Please sign in to comment.