Skip to content
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

[Doc] Improve codgen #2438

Merged
merged 1 commit into from
Dec 10, 2015
Merged
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
8 changes: 4 additions & 4 deletions docs/src/app/app-routes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import InlineStyles from './components/pages/customization/inline-styles';
import Components from './components/pages/components';
import AppBar from './components/pages/components/app-bar';
import AutoComplete from './components/pages/components/auto-complete';
import Avatars from './components/pages/components/avatars';
import Avatar from './components/pages/components/avatar';
import Badge from './components/pages/components/badge';
import Buttons from './components/pages/components/buttons';
import Cards from './components/pages/components/cards';
Expand Down Expand Up @@ -77,11 +77,11 @@ const AppRoutes = (
<Route path="inline-styles" component={InlineStyles} />
</Route>

<Redirect from="components" to="/components/appbar" />
<Redirect from="components" to="/components/app-bar" />
<Route path="components" component={Components}>
<Route path="appbar" component={AppBar} />
<Route path="app-bar" component={AppBar} />
<Route path="auto-complete" component={AutoComplete} />
<Route path="avatars" component={Avatars} />
<Route path="avatar" component={Avatar} />
<Route path="badge" component={Badge} />
<Route path="buttons" component={Buttons} />
<Route path="cards" component={Cards} />
Expand Down
2 changes: 1 addition & 1 deletion docs/src/app/components/AppBar/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## AppBar
## App Bar

App bars are a collection of components placed as a static header for an application.
It is used for navigation, search branding, and actions.
Expand Down
5 changes: 4 additions & 1 deletion docs/src/app/components/MarkdownElement.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import marked from 'marked';
import PureRenderMixin from 'react-addons-pure-render-mixin';
import StylePropable from 'material-ui/lib/mixins/style-propable';

require('./mui-github-markdown.css');

Expand All @@ -14,6 +15,7 @@ const styles = {

const MarkdownElement = React.createClass({
propTypes: {
style: React.PropTypes.object,
text: React.PropTypes.string,
},
mixins: [
Expand Down Expand Up @@ -42,13 +44,14 @@ const MarkdownElement = React.createClass({

render() {
const {
style,
text,
} = this.props;

/* eslint-disable */
return (
<div
style={styles.root}
style={StylePropable.mergeStyles(styles.root, style)}
className="markdown-body"
dangerouslySetInnerHTML={{__html: marked(text)}}
/>
Expand Down
67 changes: 65 additions & 2 deletions docs/src/app/components/code-example/code-block.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,30 @@
import React from 'react';
import MarkdownElement from '../MarkdownElement';
import PureRenderMixin from 'react-addons-pure-render-mixin';
import StylePropable from 'material-ui/lib/mixins/style-propable';
import FlatButton from 'material-ui/lib/flat-button';
import Transitions from 'material-ui/lib/styles/transitions';

const LINE_MAX = 17;

const styles = {
root: {
background: '#f8f8f8',
borderTop: 'solid 1px #e0e0e0',
},
markdown: {
overflow: 'auto',
maxHeight: 2000,
transition: Transitions.easeOut('1s', 'max-height'),
},
markdownRetracted: {
maxHeight: LINE_MAX * 18,
},
expand: {
padding: 10,
textAlign: 'center',
},
};

const CodeBlock = React.createClass({
propTypes: {
Expand All @@ -9,14 +33,53 @@ const CodeBlock = React.createClass({
mixins: [
PureRenderMixin,
],
getInitialState: function() {
return {
expand: false,
};
},
handleTouchTap() {
this.setState({
expand: !this.state.expand,
});
},
render() {
const text = `\`\`\`js
${this.props.children}
\`\`\``;

const lineNumber = (text.match(/\n/g) || []).length;

let expand;
let style = styles.markdown;

if (lineNumber > LINE_MAX) {
let label;

if (this.state.expand) {
label = 'Retract the example';
} else {
style = StylePropable.mergeStyles(styles.markdown, styles.markdownRetracted);
label = 'Expand the example';
}

expand = (
<div
style={styles.expand}
onTouchTap={this.handleTouchTap}
>
<FlatButton label={label} />
</div>
);
}

return (
<div className="CodeMirror">
<MarkdownElement text={text} />
<div style={styles.root}>
<MarkdownElement
style={style}
text={text}
/>
{expand}
</div>
);
},
Expand Down
1 change: 0 additions & 1 deletion docs/src/app/components/code-example/code-example.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ const CodeExample = React.createClass({
root: {
backgroundColor: canvasColor,
marginBottom: 32,
overflow: 'hidden',
},
exampleLabel: {
color: borderColor,
Expand Down
4 changes: 2 additions & 2 deletions docs/src/app/components/pages/components.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ export default class Components extends React.Component {

render() {
let menuItems = [
{route: '/components/appbar', text: 'AppBar'},
{route: '/components/app-bar', text: 'App Bar'},
{route: '/components/auto-complete', text: 'Auto Complete'},
{route: '/components/avatars', text: 'Avatars'},
{route: '/components/avatar', text: 'Avatar'},
{route: '/components/badge', text: 'Badge'},
{route: '/components/buttons', text: 'Buttons'},
{route: '/components/cards', text: 'Cards'},
Expand Down
2 changes: 1 addition & 1 deletion docs/src/app/components/pages/components/app-bar.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import appBarCode from '!raw!material-ui/app-bar';
import appBarCode from '!raw!material-ui/lib/app-bar';
import CodeExample from '../../code-example/code-example';
import PropTypeDescription from '../../PropTypeDescription';
import AppBarExampleIcon from '../../AppBar/ExampleIcon';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import avatarCode from '!raw!material-ui/avatar';
import avatarCode from '!raw!material-ui/lib/avatar';
import CodeExample from '../../code-example/code-example';
import PropTypeDescription from '../../PropTypeDescription';
import AvatarExampleSimple from '../../Avatar/ExampleSimple';
Expand All @@ -8,11 +8,6 @@ import MarkdownElement from '../../MarkdownElement';
import avatarReadmeText from '../../Avatar/README';

export default class AvatarsPage extends React.Component {

constructor(props) {
super(props);
}

render() {
return (
<div>
Expand Down
7 changes: 0 additions & 7 deletions docs/src/www/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@
/* hightlight.js for syntax highlighting */
@import "github.css";

.CodeMirror{
overflow: hidden;
background: #f8f8f8;
border-top: solid 1px #e0e0e0;
padding-top: 10px;
}

a {
color: #ff4081;
text-decoration: none;
Expand Down