-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Wojciech Krysiak
authored and
Wojciech Krysiak
committed
Sep 20, 2020
1 parent
830a2ef
commit 81a2bee
Showing
8 changed files
with
279 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import React, { Fragment, useState } from 'react' | ||
|
||
import Editor from 'react-simple-code-editor' | ||
import Highlight, { defaultProps } from 'prism-react-renderer' | ||
import theme from 'prism-react-renderer/themes/nightOwlLight' | ||
|
||
const styles = { | ||
root: { | ||
boxSizing: 'border-box', | ||
fontFamily: '"Dank Mono", "Fira Code", monospace', | ||
...theme.plain, | ||
}, | ||
} | ||
|
||
const EditorExample = (props) => { | ||
const { value, onChange } = props | ||
|
||
const highlight = code => ( | ||
<Highlight {...defaultProps} theme={theme} code={code} language="jsx"> | ||
{({ className, style, tokens, getLineProps, getTokenProps }) => ( | ||
<Fragment> | ||
{tokens.map((line, i) => ( | ||
<div {...getLineProps({ line, key: i })}> | ||
{line.map((token, key) => <span {...getTokenProps({ token, key })} />)} | ||
</div> | ||
))} | ||
</Fragment> | ||
)} | ||
</Highlight> | ||
) | ||
|
||
return ( | ||
<Editor | ||
value={value} | ||
onValueChange={onChange} | ||
highlight={highlight} | ||
padding={10} | ||
style={styles.root} | ||
/> | ||
) | ||
} | ||
export default EditorExample |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
.editor-preview | ||
border: 1px solid $border; | ||
position: relative; | ||
margin: 30px 0; | ||
|
||
&::before | ||
content: "Edit code"; | ||
position: absolute; | ||
right: 0; | ||
top: -25px; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,17 @@ | ||
.tag | ||
text-transform: uppercase | ||
text-transform: uppercase | ||
|
||
body pre .tag | ||
text-transform: none | ||
align-items: normal | ||
background-color: inherit | ||
border-radius: 0 | ||
color: inherit | ||
display: inline | ||
font-size: 15px | ||
height: auto | ||
justify-content: normal | ||
line-height: 22.5px | ||
padding-left: 0 | ||
padding-right: 0 | ||
white-space: pre-wrap |
Oops, something went wrong.