Skip to content

Commit

Permalink
feat: Add MarkdownRender support css-in-js
Browse files Browse the repository at this point in the history
  • Loading branch information
myxvisual committed Aug 8, 2017
1 parent 8149025 commit 6335111
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions src/MarkdownRender/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,8 @@ export class MarkdownRender extends React.Component<MarkdownRenderProps> {
markdownStyleString = lightThemeCSSString || prismCoyCSS;
}

const className = `react-uwp-markdown-style-sheet`;
let styleSheet = document.querySelector(`.${className}`);
const cssString = getCSSString(theme, `react-uwp-markdown`) + "\n" + markdownStyleString;
if (!styleSheet) {
styleSheet = document.createElement("style");
styleSheet.className = className;
styleSheet.innerHTML = cssString;
document.head.appendChild(styleSheet);
} else {
styleSheet.innerHTML = cssString;
}
const CSSText = getCSSText(theme, `react-uwp-markdown`) + "\n" + markdownStyleString;
theme.styleManager.addCSSTextWithUpdate(CSSText);
}

render() {
Expand All @@ -111,7 +102,7 @@ export class MarkdownRender extends React.Component<MarkdownRenderProps> {

export default MarkdownRender;

function getCSSString(theme: ReactUWP.ThemeType, className: string) {
function getCSSText(theme: ReactUWP.ThemeType, className: string) {
return (
`.${className} {
/** background: ${theme.chromeMedium}; **/
Expand Down

0 comments on commit 6335111

Please sign in to comment.