refactor: ♻️ Still use extraSVGAttrs with new method

This commit is contained in:
ThatOneCalculator 2022-04-04 00:40:19 -07:00
parent bbccfc4314
commit be7617476f
1 changed files with 11 additions and 18 deletions

View File

@ -29,13 +29,14 @@ const singleViewButton = <HTMLButtonElement>(
document.getElementById("single-view-button") document.getElementById("single-view-button")
) )
const extraSVGAttrs = {
width: "1em",
height: "1em",
fill: "currentColor",
}
function renderIcon(elem: HTMLButtonElement, icon: IconDefinition) { function renderIcon(elem: HTMLButtonElement, icon: IconDefinition) {
elem.innerHTML += renderIconDefinitionToSVGElement(icon, { elem.innerHTML += renderIconDefinitionToSVGElement(icon, {
extraSVGAttrs: { extraSVGAttrs: extraSVGAttrs,
width: "1em",
height: "1em",
fill: "currentColor",
},
}) })
} }
@ -91,11 +92,11 @@ tippy("#copy-button", {
tippy("#github-button", { tippy("#github-button", {
content: `GitHub<br><span class='keybind'> content: `GitHub<br><span class='keybind'>
${renderIconDefinitionToSVGElement(StarOutlined, { ${renderIconDefinitionToSVGElement(StarOutlined, {
extraSVGAttrs: { fill: "currentColor" }, extraSVGAttrs: extraSVGAttrs,
})} ${renderIconDefinitionToSVGElement(ForkOutlined, { })} ${renderIconDefinitionToSVGElement(ForkOutlined, {
extraSVGAttrs: { fill: "currentColor" }, extraSVGAttrs: extraSVGAttrs,
})} ${renderIconDefinitionToSVGElement(HeartOutlined, { })} ${renderIconDefinitionToSVGElement(HeartOutlined, {
extraSVGAttrs: { fill: "currentColor" }, extraSVGAttrs: extraSVGAttrs,
})}</span>`, })}</span>`,
placement: "bottom", placement: "bottom",
animation: "scale", animation: "scale",
@ -137,20 +138,12 @@ export function toggleHiddenIcon(hidden: boolean) {
hideButton.innerHTML = renderIconDefinitionToSVGElement( hideButton.innerHTML = renderIconDefinitionToSVGElement(
EyeInvisibleOutlined, EyeInvisibleOutlined,
{ {
extraSVGAttrs: { extraSVGAttrs: extraSVGAttrs,
width: "1em",
height: "1em",
fill: "currentColor",
},
} }
) )
} else { } else {
hideButton.innerHTML = renderIconDefinitionToSVGElement(EyeOutlined, { hideButton.innerHTML = renderIconDefinitionToSVGElement(EyeOutlined, {
extraSVGAttrs: { extraSVGAttrs: extraSVGAttrs,
width: "1em",
height: "1em",
fill: "currentColor",
},
}) })
} }
} }