mirror of
https://gitee.com/element-plus/element-plus.git
synced 2024-12-02 11:17:46 +08:00
refactor(utils): refactor aria color (#3742)
This commit is contained in:
parent
18e6810ac4
commit
fd06ac17c1
@ -27,9 +27,9 @@ export const isVisible = (element: HTMLElement) => {
|
||||
export const obtainAllFocusableElements = (
|
||||
element: HTMLElement
|
||||
): HTMLElement[] => {
|
||||
return Array.from(element.querySelectorAll(FOCUSABLE_ELEMENT_SELECTORS))
|
||||
.filter(isFocusable)
|
||||
.filter(isVisible) as HTMLElement[]
|
||||
return Array.from(
|
||||
element.querySelectorAll<HTMLElement>(FOCUSABLE_ELEMENT_SELECTORS)
|
||||
).filter((item: HTMLElement) => isFocusable(item) && isVisible(item))
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,11 +1,8 @@
|
||||
export function calcColorChannels(c: string) {
|
||||
let rawColor = c.replace('#', '')
|
||||
if (/^[0-9a-fA-F]{3}$/.test(rawColor)) {
|
||||
const color = rawColor.split('')
|
||||
for (let i = 2; i >= 0; i--) {
|
||||
color.splice(i, 0, color[i])
|
||||
}
|
||||
rawColor = color.join('')
|
||||
rawColor =
|
||||
rawColor[0].repeat(2) + rawColor[1].repeat(2) + rawColor[2].repeat(2)
|
||||
}
|
||||
if (/^[0-9a-fA-F]{6}$/.test(rawColor)) {
|
||||
return {
|
||||
@ -13,12 +10,11 @@ export function calcColorChannels(c: string) {
|
||||
green: parseInt(rawColor.slice(2, 4), 16),
|
||||
blue: parseInt(rawColor.slice(4, 6), 16),
|
||||
}
|
||||
} else {
|
||||
return {
|
||||
red: 255,
|
||||
green: 255,
|
||||
blue: 255,
|
||||
}
|
||||
}
|
||||
return {
|
||||
red: 255,
|
||||
green: 255,
|
||||
blue: 255,
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user