Skip to content

Commit

Permalink
chore: add line numbers in the example
Browse files Browse the repository at this point in the history
  • Loading branch information
satya164 committed Jul 1, 2018
1 parent 6f05861 commit 809d5f0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
10 changes: 9 additions & 1 deletion example/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,15 @@ class App extends React.Component<{}, State> {
<Editor
value={this.state.code}
onValueChange={code => this.setState({ code })}
highlight={code => highlight(code, languages.jsx)}
highlight={code =>
highlight(code, languages.jsx)
.split('\n')
.map(
line =>
`<span class="container_editor_line_number">${line}</span>`
)
.join('\n')
}
padding={10}
className="container__editor"
/>
Expand Down
13 changes: 13 additions & 0 deletions example/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,26 @@ body {
max-height: 400px;
overflow: auto;
margin: 1.67em 0;
padding-left: 3em;
}

.container__editor {
font-size: 12px;
font-variant-ligatures: common-ligatures;
background-color: #fafafa;
border-radius: 3px;
counter-reset: line;
}

.container_editor_line_number:before {
position: absolute;
right: 100%;
margin-right: 10px;
text-align: right;
opacity: .3;
user-select: none;
counter-increment: line;
content: counter(line);
}

.container__editor textarea {
Expand Down

0 comments on commit 809d5f0

Please sign in to comment.