chore: 🧹 remove dupe code

This commit is contained in:
Mel Massadian
2024-11-20 22:42:32 +01:00
committed by Mel Massadian
parent 22f7c30373
commit e099d581a7
2 changed files with 1 additions and 35 deletions
-33
View File
@@ -631,39 +631,6 @@ export const loadScript = (
})
}
export function defineClass(className, classStyles) {
const styleSheets = document.styleSheets
// Helper function to check if the class exists in a style sheet
function classExistsInStyleSheet(styleSheet) {
const rules = styleSheet.rules || styleSheet.cssRules
for (const rule of rules) {
if (rule.selectorText === `.${className}`) {
return true
}
}
return false
}
// Check if the class is already defined in any of the style sheets
let classExists = false
for (const styleSheet of styleSheets) {
if (classExistsInStyleSheet(styleSheet)) {
classExists = true
break
}
}
// If the class doesn't exist, add the new class definition to the first style sheet
if (!classExists) {
if (styleSheets[0].insertRule) {
styleSheets[0].insertRule(`.${className} { ${classStyles} }`, 0)
} else if (styleSheets[0].addRule) {
styleSheets[0].addRule(`.${className}`, classStyles, 0)
}
}
}
// #endregion
// #region documentation widget
+1 -2
View File
@@ -140,8 +140,7 @@ export const ensureMTBStyles = () => {
/* progress */
.mtb_slider[type="range"]::-moz-range-progress,
.mtb_slider[type="range"]::-ms-fill-upper {
.mtb_slider[type="range"]::-moz-range-progress {
background-color: ${S.accent};
height:10px;
border-radius: 5px;