Skip to content

Commit fb4e5eb

Browse files
committed
Add component editor component (wip).
1 parent 0a2d30a commit fb4e5eb

6 files changed

Lines changed: 56 additions & 9 deletions

File tree

packages/website/src/components/Playground/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { Component, PropTypes } from 'react';
2+
import { Link } from 'react-router';
23
import CopyToClipboard from 'react-copy-to-clipboard';
34
import hljs from 'highlight.js'
45
import './index.styl';
@@ -16,13 +17,13 @@ class Playground extends Component {
1617
}
1718

1819
render() {
19-
const { component, code, title } = this.props;
20+
const { component, url, code, title } = this.props;
2021
return (
2122
<div className="react-playground">
2223
{ title && <h3 className="react-playground-title">{title}</h3> }
2324
<div className="react-playground-component">
2425
<div className="component-links">
25-
<a href="#">Open in stage</a>
26+
<Link to={`${url}/stage`}>Open in stage</Link>
2627
</div>
2728
{component}
2829
</div>

packages/website/src/containers/App/index.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import { HashRouter, Match, Miss } from 'react-router';
3-
import { ComponentPage, Splash, NotFound } from 'containers';
3+
import { ComponentPage, ComponentEditor, Splash, NotFound } from 'containers';
44
import { Sidebar } from 'components';
55
import * as StyleguideComponents from 'auth0-styleguide-react-components';
66
import * as StyleguideComponentsExamples from 'auth0-styleguide-react-components/build/examples';
@@ -22,11 +22,16 @@ const App = () => (
2222
<div>
2323
<Match pattern="/" exactly component={Splash} />
2424
{componentsCollection.map((component, index) =>
25-
<Match
26-
pattern={component.url}
27-
render={() => (<ComponentPage {...component} />)}
28-
key={index}
29-
/>
25+
<div key={index}>
26+
<Match
27+
pattern={component.url}
28+
render={() => (<ComponentPage {...component} />)}
29+
/>
30+
<Match
31+
pattern={`${component.url}/stage`}
32+
render={() => (<ComponentEditor {...component} />)}
33+
/>
34+
</div>
3035
)}
3136
<Miss component={NotFound} />
3237
</div>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import React from 'react';
2+
import { Link } from 'react-router';
3+
import './index.styl';
4+
5+
const ComponentEditor = ({ url }) =>
6+
<div className="component-editor">
7+
<div className="component-editor-content">
8+
<Link to={`${url}`}>
9+
<i className="close-editor-btn icon-budicon-471" />
10+
</Link>
11+
<h2>Component editor</h2>
12+
</div>
13+
</div>;
14+
15+
export default ComponentEditor;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
.component-editor
2+
background-color rgba(black, 0.25)
3+
position fixed
4+
top 0
5+
right 0
6+
bottom 0
7+
left 0
8+
z-index 100
9+
10+
.component-editor-content
11+
position relative
12+
border-radius 3px
13+
background-color white
14+
margin 0 auto
15+
margin-top 40px
16+
width calc(100% - 80px)
17+
height calc(100% - 80px)
18+
19+
.close-editor-btn
20+
position absolute
21+
top 30px
22+
right 30px
23+
font-size 20px
24+
color rgba(black, 0.8)

packages/website/src/containers/ComponentPage/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { PropTypes } from 'react';
22
import { Playground, PropertiesTable } from 'components';
33
import './index.styl';
44

5-
const ComponentPage = ({ title, description, props, examples }) =>
5+
const ComponentPage = ({ title, description, props, url, examples }) =>
66
<section className="react-component-page">
77
<div className="component-information">
88
<h1 className="component-title">{title}</h1>
@@ -14,6 +14,7 @@ const ComponentPage = ({ title, description, props, examples }) =>
1414
component={example.component}
1515
code={example.code}
1616
title={example.title}
17+
url={url}
1718
/>
1819
)}
1920
{ props && <PropertiesTable props={props} />}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export App from 'containers/App';
22
export NotFound from 'containers/NotFound';
33
export ComponentPage from 'containers/ComponentPage';
4+
export ComponentEditor from 'containers/ComponentEditor';
45
export Splash from 'containers/Splash';

0 commit comments

Comments
 (0)