Skip to content

Commit 0a2d30a

Browse files
ramasilveyraarielger
authored andcommitted
Use highlight.js from npm and trim strings code blocks
1 parent ae85954 commit 0a2d30a

3 files changed

Lines changed: 9 additions & 7 deletions

File tree

packages/website/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"babel-polyfill": "^6.16.0",
2121
"codemirror": "^5.19.0",
2222
"component-playground": "^1.3.1",
23+
"highlight.js": "^9.7.0",
2324
"react": "^15.3.2",
2425
"react-copy-to-clipboard": "^4.2.3",
2526
"react-docgen": "^2.11.0",

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
1-
/* global hljs */
2-
import React, { PropTypes } from 'react';
1+
import React, { Component, PropTypes } from 'react';
32
import CopyToClipboard from 'react-copy-to-clipboard';
3+
import hljs from 'highlight.js'
44
import './index.styl';
55

6-
class Playground extends React.Component {
6+
class Playground extends Component {
77
componentDidMount() {
88
hljs.configure({ classPrefix: '' });
99
hljs.highlightBlock(this.codeBlock);
1010
}
11+
1112
componentDidUpdate() {
1213
hljs.configure({ classPrefix: '' });
1314
hljs.initHighlighting.called = false;
1415
hljs.highlightBlock(this.codeBlock);
1516
}
17+
1618
render() {
1719
const { component, code, title } = this.props;
1820
return (
@@ -25,12 +27,12 @@ class Playground extends React.Component {
2527
{component}
2628
</div>
2729
<div className="react-playground-code">
28-
<CopyToClipboard text={code}>
30+
<CopyToClipboard text={code.trim()}>
2931
<button className="copy-code-btn btn btn-sm btn-success">Copy code</button>
3032
</CopyToClipboard>
3133
<pre>
32-
<code className="javascript" ref={node => this.codeBlock = node}>
33-
{code}
34+
<code className="javascript" ref={node => { this.codeBlock = node; }}>
35+
{code.trim()}
3436
</code>
3537
</pre>
3638
</div>

packages/website/src/views/index.pug

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,5 @@ html
44
title= htmlWebpackPlugin.options.title
55
meta(name="viewport", content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no")
66
link(href="https://cdn.auth0.com/styleguide/4.7.7/index.min.css", rel="stylesheet")
7-
script(src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.7.0/highlight.min.js")
87
body
98
#app

0 commit comments

Comments
 (0)