General source code refactoring
This commit is contained in:
74
src/content/icons.js
Normal file
74
src/content/icons.js
Normal file
@@ -0,0 +1,74 @@
|
||||
function createContentIcons({
|
||||
appendPath,
|
||||
environment
|
||||
}) {
|
||||
const { document } = environment;
|
||||
function createThemeIcon(iconName) {
|
||||
const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
||||
const path = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
||||
|
||||
svg.setAttribute("viewBox", "0 0 24 24");
|
||||
svg.setAttribute("aria-hidden", "true");
|
||||
svg.setAttribute("focusable", "false");
|
||||
|
||||
if (iconName === "sun") {
|
||||
path.setAttribute("d", "M12 3V1m0 22v-2m9-9h2M1 12h2m15.36 6.36 1.42 1.42M4.22 4.22l1.42 1.42m12.72 0 1.42-1.42M4.22 19.78l1.42-1.42M16.5 12a4.5 4.5 0 1 1-9 0 4.5 4.5 0 0 1 9 0Z");
|
||||
} else {
|
||||
path.setAttribute("d", "M20.5 14.2A8.5 8.5 0 0 1 9.8 3.5a8.5 8.5 0 1 0 10.7 10.7Z");
|
||||
}
|
||||
|
||||
path.setAttribute("fill", "none");
|
||||
path.setAttribute("stroke", "currentColor");
|
||||
path.setAttribute("stroke-linecap", "round");
|
||||
path.setAttribute("stroke-linejoin", "round");
|
||||
path.setAttribute("stroke-width", "1.8");
|
||||
svg.append(path);
|
||||
return svg;
|
||||
}
|
||||
|
||||
function createSettingsIcon() {
|
||||
const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
||||
const upperControl = document.createElementNS("http://www.w3.org/2000/svg", "circle");
|
||||
const lowerControl = document.createElementNS("http://www.w3.org/2000/svg", "circle");
|
||||
|
||||
svg.setAttribute("viewBox", "0 0 24 24");
|
||||
svg.setAttribute("class", "opportunities-extension-settings-icon");
|
||||
svg.setAttribute("aria-hidden", "true");
|
||||
svg.setAttribute("focusable", "false");
|
||||
appendPath(svg, "", "M4 7h16M4 17h16");
|
||||
|
||||
[upperControl, lowerControl].forEach((control, index) => {
|
||||
control.setAttribute("cx", index === 0 ? "9" : "15");
|
||||
control.setAttribute("cy", index === 0 ? "7" : "17");
|
||||
control.setAttribute("r", "2.5");
|
||||
control.setAttribute("fill", "currentColor");
|
||||
control.setAttribute("stroke", "currentColor");
|
||||
control.setAttribute("stroke-width", "1.8");
|
||||
});
|
||||
|
||||
svg.querySelector("path").setAttribute("fill", "none");
|
||||
svg.querySelector("path").setAttribute("stroke", "currentColor");
|
||||
svg.querySelector("path").setAttribute("stroke-linecap", "round");
|
||||
svg.querySelector("path").setAttribute("stroke-width", "1.8");
|
||||
svg.append(upperControl, lowerControl);
|
||||
return svg;
|
||||
}
|
||||
|
||||
function createCloseIcon() {
|
||||
const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
||||
const path = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
||||
|
||||
svg.setAttribute("viewBox", "0 0 24 24");
|
||||
svg.setAttribute("aria-hidden", "true");
|
||||
svg.setAttribute("focusable", "false");
|
||||
path.setAttribute("d", "m6 6 12 12M18 6 6 18");
|
||||
path.setAttribute("fill", "none");
|
||||
path.setAttribute("stroke", "currentColor");
|
||||
path.setAttribute("stroke-linecap", "round");
|
||||
path.setAttribute("stroke-width", "1.8");
|
||||
svg.append(path);
|
||||
return svg;
|
||||
}
|
||||
|
||||
return { createThemeIcon, createSettingsIcon, createCloseIcon };
|
||||
}
|
||||
Reference in New Issue
Block a user