feat(Layout): Add classic layout

This commit is contained in:
陈凯龙
2022-01-18 16:22:47 +08:00
parent 958edefe7b
commit 839b6015b8
26 changed files with 632 additions and 147 deletions

View File

@@ -30,7 +30,7 @@ export const rgbToHex = (r: number, g: number, b: number) => {
* @param {string} hex The color to transform
* @returns The RGB representation of the passed color
*/
export const hexToRGB = (hex: string) => {
export const hexToRGB = (hex: string, opacity?: number) => {
let sHex = hex.toLowerCase()
if (isHexColor(hex)) {
if (sHex.length === 4) {
@@ -44,7 +44,9 @@ export const hexToRGB = (hex: string) => {
for (let i = 1; i < 7; i += 2) {
sColorChange.push(parseInt('0x' + sHex.slice(i, i + 2)))
}
return 'RGB(' + sColorChange.join(',') + ')'
return opacity
? 'RGBA(' + sColorChange.join(',') + ',' + opacity + ')'
: 'RGB(' + sColorChange.join(',') + ')'
}
return sHex
}

View File

@@ -59,3 +59,7 @@ export const findIndex = <T = Recordable>(ary: Array<T>, fn: Fn): number => {
})
return index
}
export const trim = (str: string) => {
return str.replace(/(^\s*)|(\s*$)/g, '')
}