Skip to content

Commit

Permalink
Pase classes rules in @suports, adds .fr-ratio-... classes
Browse files Browse the repository at this point in the history
  • Loading branch information
garronej committed May 23, 2023
1 parent 75898a2 commit e39f31b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
6 changes: 6 additions & 0 deletions scripts/build/cssToTs/breakpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@ export const getRulesByBreakpoint = memoize((rawCssCode: string): RulesByBreakpo
({ type }) => type === "rule"
);

(parsedCss.stylesheet!.rules as any[])
.filter(({ type }) => type === "supports")
.forEach(({ rules }: any) =>
rulesByBreakpoint.root.push(...rules.filter(({ type }: any) => type === "rule"))
);

(parsedCss.stylesheet!.rules as any[])
.filter(({ type }) => type === "media")
.filter(({ media }) => Object.values(mediaQueryByBreakpoint).includes(media))
Expand Down
15 changes: 14 additions & 1 deletion test/runtime/scripts/classNames/parseClassNames.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@ it("Parsing of fr classnames", () => {
color: #3a3a3a;
}
@supports (aspect-ratio: 16/9) {
.fr-ratio-32x9 {
aspect-ratio: 3.5555555556 !important;
}
.fr-ratio-16x9 {
aspect-ratio: 1.7777777778 !important;
}
}
@media (min-width: 36em) { }
@media (min-width: 48em) { }
@media (min-width: 62em) { }
Expand All @@ -38,7 +49,9 @@ it("Parsing of fr classnames", () => {
"fr-grid-row--gutters",
"fr-col",
"fr-header__navbar",
"fr-btn--menu"
"fr-btn--menu",
"fr-ratio-32x9",
"fr-ratio-16x9"
];

const got = parseClassNames(input);
Expand Down

0 comments on commit e39f31b

Please sign in to comment.