mdui-ext
Version:
a extension for mdui !(not completed)
34 lines (30 loc) • 1.11 kB
text/typescript
class ClassUtil {
static changeTextColor(textColor: string, element: HTMLElement) {
ClassUtil.removeClassNameStartsWith("mdui-text-color", element)
element.classList.add("mdui-text-color-" + textColor)
}
static changeColor(color: string, element: HTMLElement) {
ClassUtil.removeClassNameStartsWith("mdui-color-", element)
element.classList.add("mdui-color-" + color)
}
static removeClassNameStartsWith(startsWith: string, element: HTMLElement) {
const classList = element.classList
classList.forEach((clazz: string) => {
if (clazz.startsWith(startsWith)) {
classList.remove(clazz)
}
})
}
static containsClassNameStartWith(startWith: string, element: HTMLElement): boolean {
const classList = element.classList
let ret = false
classList.forEach((clazz) => {
if(clazz.startsWith(startWith)){
ret = true
return
}
})
return ret
}
}
export {ClassUtil}