refactor(site): proper dom styling logic
This commit is contained in:
parent
0e178fda79
commit
7cd863dc22
1 changed files with 20 additions and 2 deletions
|
@ -4,15 +4,33 @@ class CodeBlockComponent extends HTMLElement {
|
|||
const lang = this.getAttribute("language");
|
||||
|
||||
this.innerHTML = `
|
||||
<pre id="pre" style="padding:1em;background:#efefef;margin:1em 0;border-radius:5px;font-size:large;"><code id="code">${
|
||||
<pre id="pre"><code id="code">${
|
||||
this.trimmed
|
||||
}</code></pre>
|
||||
`;
|
||||
|
||||
if (lang) {
|
||||
/**
|
||||
* @type {HTMLPreElement}
|
||||
*/
|
||||
const pre = this.querySelector('#pre')
|
||||
|
||||
if (lang) {
|
||||
pre.className = `language-${lang}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* @type {Partial<CSSStyleDeclaration>}
|
||||
*/
|
||||
const style = {
|
||||
padding:'1em',
|
||||
background:'#efefef',
|
||||
margin: '1em 0',
|
||||
borderRadius: '5px',
|
||||
fontSize: 'large'
|
||||
}
|
||||
|
||||
Object.keys(style).forEach(rule => {
|
||||
pre.style[rule] = style[rule]
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue