Skip to content

Commit 70f209d

Browse files
committed
#226 edited regex to handle CSS selectors containing @ char
1 parent 50e0e0d commit 70f209d

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

scripts/build/cssToTs/classNames.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@ export const parseClassNames = memoize((rawCssCode: string): string[] => {
99

1010
objectKeys(rulesByBreakpoint).forEach(breakpoint => {
1111
const rules = rulesByBreakpoint[breakpoint];
12-
1312
rules.forEach(({ selectors }) => {
1413
selectors.forEach(selector => {
15-
const matchArr = selector.match(/\.fr-[a-zA-Z0-9_-]+/g);
16-
14+
const matchArr = selector.match(/\.fr-[a-zA-Z0-9_-]+(?:@[a-zA-Z0-9_-]+)?/g);
1715
if (matchArr === null) {
1816
return;
1917
}
@@ -24,7 +22,6 @@ export const parseClassNames = memoize((rawCssCode: string): string[] => {
2422
});
2523
});
2624
});
27-
2825
return Array.from(classNames);
2926
});
3027

test/runtime/scripts/classNames/parseClassNames.test.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint no-useless-escape: 0 */
12
import { it, expect } from "vitest";
23
import { parseClassNames } from "../../../../scripts/build/cssToTs/classNames";
34

@@ -24,6 +25,11 @@ it("Parsing of fr classnames", () => {
2425
color: #3a3a3a;
2526
}
2627
28+
.fr-tile--vertical\@md {
29+
display: flex;
30+
flex-direction: column;
31+
}
32+
2733
@supports (aspect-ratio: 16/9) {
2834
.fr-ratio-32x9 {
2935
aspect-ratio: 3.5555555556 !important;
@@ -34,7 +40,6 @@ it("Parsing of fr classnames", () => {
3440
}
3541
}
3642
37-
3843
@media (min-width: 36em) { }
3944
@media (min-width: 48em) { }
4045
@media (min-width: 62em) { }
@@ -50,6 +55,7 @@ it("Parsing of fr classnames", () => {
5055
"fr-col",
5156
"fr-header__navbar",
5257
"fr-btn--menu",
58+
"fr-tile--vertical@md",
5359
"fr-ratio-32x9",
5460
"fr-ratio-16x9"
5561
];

0 commit comments

Comments
 (0)