Skip to content

Commit

Permalink
fix: support kebab-case class name (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
FlandreDaisuki committed Oct 5, 2023
1 parent 33958f6 commit a06984c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/index.ts
Expand Up @@ -139,7 +139,7 @@ export function presetTheme<T extends Record<string, any>>(options: PresetThemeO
return {
matcher,
selector(input) {
const themeName = input.match(/\:(\w+)\\\:\d+/)![1]
const themeName = input.match(/\:([\w-]+)\\\:\d+/)![1]
return selectors[themeName] || `.${themeName}`
},
}
Expand Down
8 changes: 4 additions & 4 deletions tests/index.test.ts
Expand Up @@ -29,7 +29,7 @@ describe('theme', () => {
presetUno(options.unoOptions),
presetTheme<Theme>(mergeDeep({
theme: {
dark: {
'dark': {
colors: {
main: {
100: '#fffff1',
Expand All @@ -43,13 +43,13 @@ describe('theme', () => {
},
},
},
compact: {
'compact': {
fontSize: {
xs: ['1.75rem', '2rem'],
sm: ['1.875rem', '2.25rem'],
},
},
star: {
'starry-night': {
colors: {
main: {
100: '#1ffff1',
Expand Down Expand Up @@ -87,7 +87,7 @@ describe('theme', () => {
:root{--un-preset-theme-colors-main-100:0, 0, 1;--un-preset-theme-colors-main-500:0, 0, 4;--un-preset-theme-colors-main-200:0, 0, 2;--un-preset-theme-fontSize-sm-0:0.875rem;--un-preset-theme-fontSize-sm-1:0.875rem;--un-preset-theme-fontSize-xs-0:0.75rem;--un-preset-theme-fontSize-xs-1:0.75rem;}
.compact{--un-preset-theme-fontSize-sm-0:1.875rem;--un-preset-theme-fontSize-sm-1:2.25rem;--un-preset-theme-fontSize-xs-0:1.75rem;--un-preset-theme-fontSize-xs-1:2rem;}
.dark{--un-preset-theme-colors-main-100:255, 255, 241;--un-preset-theme-colors-main-500:255, 255, 244;--un-preset-theme-colors-main-200:255, 255, 242;}
.star{--un-preset-theme-colors-main-100:31, 255, 241;--un-preset-theme-colors-main-500:31, 255, 244;--un-preset-theme-colors-main-200:31, 255, 242;}
.starry-night{--un-preset-theme-colors-main-100:31, 255, 241;--un-preset-theme-colors-main-500:31, 255, 244;--un-preset-theme-colors-main-200:31, 255, 242;}
/* layer: default */
.border-main-500{--un-border-opacity:1;border-color:rgba(var(--un-preset-theme-colors-main-500),var(--un-border-opacity));}
.bg-main-200{--un-bg-opacity:1;background-color:rgba(var(--un-preset-theme-colors-main-200),var(--un-bg-opacity));}
Expand Down

0 comments on commit a06984c

Please sign in to comment.