1
Fork 0
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:
Steffo 2020-10-14 02:39:06 +02:00
parent d38c63da7e
commit 019baf06dd
2 changed files with 8 additions and 2 deletions

View file

@ -1,14 +1,16 @@
import SyntaxHighlighter from 'react-syntax-highlighter' import SyntaxHighlighter from 'react-syntax-highlighter'
import {monokai} from "react-syntax-highlighter/dist/cjs/styles/hljs";
import stripTabs from "../../utils/stripTabs"; import stripTabs from "../../utils/stripTabs";
import {useContext} from "preact/hooks"; import {useContext} from "preact/hooks";
import CodeDefaultLanguage from "../../contexts/CodeDefaultLanguage"; import CodeDefaultLanguage from "../../contexts/CodeDefaultLanguage";
import CodeDefaultStyle from "../../contexts/CodeDefaultStyle";
export default function(props) { export default function(props) {
const language = useContext(CodeDefaultLanguage) const language = useContext(CodeDefaultLanguage)
const style = useContext(CodeDefaultStyle)
return ( 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))} {stripTabs(String(props.children))}
</SyntaxHighlighter> </SyntaxHighlighter>
) )

View file

@ -0,0 +1,4 @@
import {createContext} from "preact";
import {tomorrowNightBlue} from "react-syntax-highlighter/dist/cjs/styles/hljs";
export default createContext(tomorrowNightBlue);