Skip to content
Merged
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
66 changes: 54 additions & 12 deletions src/documentation/DocsTile/DocsTile.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import React, { Component } from 'react';
import SyntaxHighlighter from 'react-syntax-highlighter';
import { googlecode } from 'react-syntax-highlighter/styles/hljs';
import { Button } from '../../Button/Button';

export const DocsTile = props => {
const docsTileStyle = {
Expand Down Expand Up @@ -29,22 +30,63 @@ export const DocsTile = props => {
);
};

export const DocsText = props => {
const docsTextStyle = {
export class DocsText extends Component {
constructor(props) {
super(props);
this.state = {
showCode: false
};
}
handleBtnClick = () => {
this.setState(prevState => ({
showCode: !prevState.showCode
}));
console.log(this.state.showCode);
}
docsTextStyle = {
padding: '15px',
fontSize: '13px',
border: '1px solid #ccc',
borderTop: 'none',
borderRadius: '0 0 4px 4px',
backgroundColor: '#fff !important',
margin: '0'
};
const { children } = props;
docsBtnStyle = {
padding: '5px',
fontSize: '13px',
border: '1px solid #ccc',
backgroundColor: '#fff !important',
margin: '0',
textAlign: 'center'
};
docsBtnStyleHiddenCode = {
padding: '5px',
fontSize: '13px',
border: '1px solid #ccc',
borderRadius: '0 0 4px 4px',
backgroundColor: '#fff !important',
margin: '0',
textAlign: 'center'
};
render() {
const { children } = this.props;
return (
<React.Fragment>
<div style={this.state.showCode ? (this.docsBtnStyle) : (this.docsBtnStyleHiddenCode)}>
<Button option='light' onclick={() => this.handleBtnClick()}>
{
this.state.showCode ? ('Hide Code') : ('Show Code')
}
</Button>
</div>
{this.state.showCode && <pre style={this.docsTextStyle}>
<SyntaxHighlighter language='html' style={googlecode}>
{children}
</SyntaxHighlighter>
</pre>}
</React.Fragment>
);
}
}

return (
<pre style={docsTextStyle}>
<SyntaxHighlighter language='html' style={googlecode}>
{children}
</SyntaxHighlighter>
</pre>
);
};