mirror of
https://github.com/Steffo99/bluelib.git
synced 2024-12-22 11:34:21 +00:00
Add a default style context
This commit is contained in:
parent
d38c63da7e
commit
019baf06dd
2 changed files with 8 additions and 2 deletions
|
@ -1,14 +1,16 @@
|
|||
import SyntaxHighlighter from 'react-syntax-highlighter'
|
||||
import {monokai} from "react-syntax-highlighter/dist/cjs/styles/hljs";
|
||||
import stripTabs from "../../utils/stripTabs";
|
||||
import {useContext} from "preact/hooks";
|
||||
import CodeDefaultLanguage from "../../contexts/CodeDefaultLanguage";
|
||||
import CodeDefaultStyle from "../../contexts/CodeDefaultStyle";
|
||||
|
||||
export default function(props) {
|
||||
const language = useContext(CodeDefaultLanguage)
|
||||
const style = useContext(CodeDefaultStyle)
|
||||
|
||||
return (
|
||||
<SyntaxHighlighter language={props.language ? props.language : language} style={monokai}>
|
||||
<SyntaxHighlighter language={props.language ? props.language : language}
|
||||
style={props.style ? props.style : style}>
|
||||
{stripTabs(String(props.children))}
|
||||
</SyntaxHighlighter>
|
||||
)
|
||||
|
|
4
src/contexts/CodeDefaultStyle.js
Normal file
4
src/contexts/CodeDefaultStyle.js
Normal file
|
@ -0,0 +1,4 @@
|
|||
import {createContext} from "preact";
|
||||
import {tomorrowNightBlue} from "react-syntax-highlighter/dist/cjs/styles/hljs";
|
||||
|
||||
export default createContext(tomorrowNightBlue);
|
Loading…
Reference in a new issue