Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cssVarName无法改掉format后缀 #3

Closed
zhihengGet opened this issue Nov 2, 2023 · 3 comments
Closed

cssVarName无法改掉format后缀 #3

zhihengGet opened this issue Nov 2, 2023 · 3 comments

Comments

@zhihengGet
Copy link

zhihengGet commented Nov 2, 2023

生成的css var 里 有 -hsl or -rgb, 能不能去掉, 现在无法通过caaVarName生成自己想要的... 多谢

比如 hsla(var(--un-palette-primary-color-hsl)

@zhihengGet zhihengGet changed the title 能不能吧- {hsl|rgb cssVarName无法改掉 - hsl Nov 2, 2023
@zhihengGet zhihengGet changed the title cssVarName无法改掉 - hsl cssVarName无法改掉format后缀 Nov 2, 2023
@zhihengGet zhihengGet reopened this Nov 6, 2023
@zhihengGet
Copy link
Author

zhihengGet commented Nov 6, 2023

const colors = Object.fromEntries(Object.keys(themeColors).map(e => {
const colorValue = ${colorFormat}(var(${getVarName(e)}-${colorFormat}));
return [e, colorValue];
})); 如果设置 colorFormat=“” , 会出现 bug

@chizukicn
Copy link
Member

带有rgb或者hsl的其实是private的,建议直接这样引用
5bac4b3696a41f37199e9d4c0c979cf9

5ded766a9ac648f66262b8f22ee15ad4

@chizukicn
Copy link
Member

这里将一个themeColor分成两个css变量是为了让unocss识别出它的颜色格式,从而可以直接使用unocss内的透明度设定,例如bg-primary bg-op-30

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants