Skip to content

Commit

Permalink
Update files with prettier changes
Browse files Browse the repository at this point in the history
  • Loading branch information
rainboxx committed May 17, 2018
1 parent 561892d commit 771465d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 18 deletions.
29 changes: 15 additions & 14 deletions src/components/code-pane.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ import PropTypes from 'prop-types';
import { getStyles } from '../utils/base';
import styled from 'react-emotion';

import '../utils/prism-import';
import { Editor } from 'react-live';
import '../utils/prism-import';

const StyledWrapper = styled.div(props => props.styles);
const StyledEditor = styled(({ syntaxStyles: _, prismTheme: __, ...rest }) => <Editor {...rest} />)`
const StyledEditor = styled(({ syntaxStyles: _, prismTheme: __, ...rest }) => (
<Editor {...rest} />
))`
&& {
${props => props.syntaxStyles}
&.builtin-prism-theme {
${props => props.prismTheme}
${props => props.syntaxStyles} &.builtin-prism-theme {
${props => props.prismTheme};
}
}
`;
Expand All @@ -25,7 +25,9 @@ export default class CodePane extends Component {
render() {
const useDarkTheme = this.props.theme === 'dark';
const externalPrismTheme = this.props.theme === 'external';
const className = `language-${this.props.lang} ${externalPrismTheme ? '' : 'builtin-prism-theme'} ${this.props.className}`;
const className = `language-${this.props.lang} ${
externalPrismTheme ? '' : 'builtin-prism-theme'
} ${this.props.className}`;

const wrapperStyles = [
this.context.styles.components.codePane,
Expand All @@ -34,17 +36,16 @@ export default class CodePane extends Component {
];

return (
<StyledWrapper
className={this.props.className}
styles={wrapperStyles}
>
<StyledWrapper className={this.props.className} styles={wrapperStyles}>
<StyledEditor
className={className}
code={this.props.source}
language={this.props.lang}
contentEditable={this.props.contentEditable}
syntaxStyles={this.context.styles.components.syntax}
prismTheme={this.context.styles.prism[useDarkTheme ? 'dark' : 'light']}
prismTheme={
this.context.styles.prism[useDarkTheme ? 'dark' : 'light']
}
onKeyDown={this.handleEditorEvent}
onKeyUp={this.handleEditorEvent}
onClick={this.handleEditorEvent}
Expand All @@ -66,13 +67,13 @@ CodePane.propTypes = {
lang: PropTypes.string,
source: PropTypes.string,
style: PropTypes.object,
theme: PropTypes.oneOf(['dark', 'light', 'external']),
theme: PropTypes.oneOf(['dark', 'light', 'external'])
};

CodePane.defaultProps = {
className: '',
contentEditable: false,
lang: 'markup',
source: '',
theme: 'dark',
theme: 'dark'
};
10 changes: 6 additions & 4 deletions src/components/code-pane.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import CodePane from './code-pane';

describe('<CodePane />', () => {
test('should render correctly.', () => {
const context = { styles: {
components: { codePane: {}, syntax: {} },
prism: { light: 'light;', dark: 'dark;' }
} };
const context = {
styles: {
components: { codePane: {}, syntax: {} },
prism: { light: 'light;', dark: 'dark;' }
}
};
const source = `
const myButton = (
<CustomButton
Expand Down

0 comments on commit 771465d

Please sign in to comment.