优化组件/更新
This commit is contained in:
24
uni_modules/lime-style/token/shared.uts
Normal file
24
uni_modules/lime-style/token/shared.uts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { TinyColor, generate } from '@/uni_modules/lime-color';
|
||||
import { LGenerateOptions } from '@/uni_modules/lime-color/utssdk/interface';
|
||||
|
||||
export const getAlphaColor = (baseColor : string, alpha : number) : string =>
|
||||
new TinyColor(baseColor).setAlpha(alpha).toRgbString();
|
||||
|
||||
export const getSolidColor = (baseColor : string, brightness : number) : string => {
|
||||
const instance = new TinyColor(baseColor);
|
||||
return instance.lighten(brightness).toHexString();
|
||||
};
|
||||
|
||||
export function generateColorPalettes(baseColor : string | null, name : string, theme: string = 'default') : UTSJSONObject {
|
||||
if (baseColor == null) return {}
|
||||
const colors = generate(baseColor, { theme } as LGenerateOptions);
|
||||
const colorPalettes = colors.reduce((prev:UTSJSONObject, color:string, index:number) : UTSJSONObject => {
|
||||
prev[`${name}${index + 1}`] = color;
|
||||
return prev
|
||||
}, {})
|
||||
|
||||
// 默认为中间色
|
||||
colorPalettes[name] = colorPalettes[`${name}${6}`]
|
||||
return colorPalettes
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user