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

[docs] show line numbers in online jsx compiler #3294

Merged
merged 1 commit into from
Mar 5, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/_js/jsx-compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ var CompilerPlayground = React.createClass({
renderCode={true}
transformer={transformer.bind(null, this.state.harmony)}
showCompiledJSTab={false}
showLineNumbers={true}
/>
<label className="compiler-option">
<input
Expand Down
17 changes: 15 additions & 2 deletions docs/_js/live_editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,21 @@ var IS_MOBILE = (
);

var CodeMirrorEditor = React.createClass({
propTypes: {
lineNumbers: React.PropTypes.bool,
onChange: React.PropTypes.func
},
getDefaultProps: function() {
return {
lineNumbers: false
};
},
componentDidMount: function() {
if (IS_MOBILE) return;

this.editor = CodeMirror.fromTextArea(this.refs.editor.getDOMNode(), {
mode: 'javascript',
lineNumbers: false,
lineNumbers: this.props.lineNumbers,
lineWrapping: true,
smartIndent: false, // javascript mode does bad things with jsx indents
matchBrackets: true,
Expand Down Expand Up @@ -75,6 +84,7 @@ var ReactPlayground = React.createClass({
transformer: React.PropTypes.func,
renderCode: React.PropTypes.bool,
showCompiledJSTab: React.PropTypes.bool,
showLineNumbers: React.PropTypes.bool,
editorTabTitle: React.PropTypes.string
},

Expand All @@ -84,7 +94,8 @@ var ReactPlayground = React.createClass({
return JSXTransformer.transform(code).code;
},
editorTabTitle: 'Live JSX Editor',
showCompiledJSTab: true
showCompiledJSTab: true,
showLineNumbers: false
};
},

Expand Down Expand Up @@ -122,6 +133,7 @@ var ReactPlayground = React.createClass({
onChange={this.handleCodeChange}
codeText={compiledCode}
readOnly={true}
lineNumbers={this.props.showLineNumbers}
/>;

var JSXContent =
Expand All @@ -130,6 +142,7 @@ var ReactPlayground = React.createClass({
onChange={this.handleCodeChange}
className="playgroundStage"
codeText={this.state.code}
lineNumbers={this.props.showLineNumbers}
/>;

var JSXTabClassName =
Expand Down
4 changes: 2 additions & 2 deletions docs/css/react.scss
Original file line number Diff line number Diff line change
Expand Up @@ -608,8 +608,8 @@ div.CodeMirror pre, div.CodeMirror-linenumber, code {
@include code-typography;
}

div.CodeMirror-linenumber:after {
content: '.';
div.CodeMirror-linenumber {
text-align: right;
}

.CodeMirror, div.CodeMirror-gutters, div.highlight {
Expand Down