mirror of
https://github.com/Steffo99/bluelib.git
synced 2024-12-22 19:44: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 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>
|
||||||
)
|
)
|
||||||
|
|
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