Skip to content

Commit 6b5d2a4

Browse files
fix: class sorting algorithm (#36)
fix class sorting static -> dynamic
1 parent 0ca6e73 commit 6b5d2a4

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/utils/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ export function sortClassNames(classNames: string, variantsMap: {[key:string]: n
8989
const head = variants.join(':') + ':';
9090
const utility = raw.replace(head, '');
9191
const key = utility.match(/\w+/);
92-
const offset = variants.map(i => variantsMap[i] * 100).reduce((p, c) => p + c, 0) + (important ? 500: 0);
92+
const hasDynamicValue = utility.match(/\d+/);
93+
const offset = variants.map(i => variantsMap[i] * 100).reduce((p, c) => p + c, 0) + (important ? 500: 0) + (hasDynamicValue ? 25 : 0);
9394
if (key === null) return { raw, weight: offset };
9495
return { raw, weight: (keyOrder[key[0]] ?? 300 ) + offset };
9596
}).sort((a, b) => a.weight - b.weight).map(i => i.raw).join(' ');

0 commit comments

Comments
 (0)