Skip to content

Commit e5be4e9

Browse files
authored
Merge pull request #73 from tone-row/grid-area-and-where
fix(slang): area prop; :where()
2 parents 0b3743b + 894933d commit e5be4e9

File tree

4 files changed

+29
-6
lines changed

4 files changed

+29
-6
lines changed

docs/components/slang/slang.css

+19-1
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ body {
494494
--errorTopMultiplier: var(--error-top-multiplier-7);
495495
--errorBottomMultiplier: var(--error-bottom-multiplier-7); }
496496

497-
:root {
497+
:where(:root) {
498498
--base-font-family:Neue Montreal;
499499
--base-font-size-px:20px;
500500
--base-font-size:20;
@@ -752,6 +752,12 @@ border-radius: calc(var(--smallest-border-radius-px) * var(--rad));
752752
.slang-box.rad_hover:hover {
753753
border-radius: calc(var(--smallest-border-radius-px) * var(--rad_hover));
754754
}
755+
.slang-box.area {
756+
grid-area: var(--area);
757+
}
758+
.slang-box.area_hover:hover {
759+
grid-area: var(--area_hover);
760+
}
755761
@media(min-width: 768px) {
756762
.slang-box.flow-tablet {
757763
grid-auto-flow: var(--flow-tablet);
@@ -891,6 +897,12 @@ border-radius: calc(var(--smallest-border-radius-px) * var(--rad-tablet));
891897
.slang-box.rad-tablet_hover:hover {
892898
border-radius: calc(var(--smallest-border-radius-px) * var(--rad-tablet_hover));
893899
}
900+
.slang-box.area-tablet {
901+
grid-area: var(--area-tablet);
902+
}
903+
.slang-box.area-tablet_hover:hover {
904+
grid-area: var(--area-tablet_hover);
905+
}
894906
}
895907
@media(min-width: 1024px) {
896908
.slang-box.flow-desktop {
@@ -1031,6 +1043,12 @@ border-radius: calc(var(--smallest-border-radius-px) * var(--rad-desktop));
10311043
.slang-box.rad-desktop_hover:hover {
10321044
border-radius: calc(var(--smallest-border-radius-px) * var(--rad-desktop_hover));
10331045
}
1046+
.slang-box.area-desktop {
1047+
grid-area: var(--area-desktop);
1048+
}
1049+
.slang-box.area-desktop_hover:hover {
1050+
grid-area: var(--area-desktop_hover);
1051+
}
10341052
}
10351053
.slang-type.weight {
10361054
font-weight: var(--weight);

docs/pages/box.tsx

+4
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ export default function BoxPage() {
5555
</Type>
5656
</Section>
5757
<Box as="button">Test</Box>
58+
<Box template="none / repeat(4, 1fr)">
59+
<Box area="auto / span 3">long</Box>
60+
<Box>short</Box>
61+
</Box>
5862
</Page>
5963
);
6064
}

slang/src/Box/props.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ export const propKeys = [
8383
"pl",
8484
"template",
8585
"content",
86+
"area",
8687
"items",
8788
"self",
8889
"gap",
@@ -111,6 +112,10 @@ export const boxConfig: ComponentConfig<ResponsiveProps>[] = [
111112
},
112113
{ key: "items", cssFromVariable: (v) => `place-items: ${v};` },
113114
{ key: "self", cssFromVariable: (v) => `place-self: ${v};` },
115+
{
116+
key: "area",
117+
cssFromVariable: (v) => `grid-area: ${v};`,
118+
},
114119
{
115120
key: "p",
116121
defaultValue: "0",
@@ -246,8 +251,4 @@ export const boxConfig: ComponentConfig<ResponsiveProps>[] = [
246251
cssFromVariable: (v) =>
247252
`border-radius: calc(var(--smallest-border-radius-px) * ${v});`,
248253
},
249-
{
250-
key: "area",
251-
cssFromVariable: (v) => `grid-area: ${v};`,
252-
},
253254
];

slang/src/makeCSS.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export function makeCSS(config?: Partial<SlangConfig>) {
66
const derivedProperties = createDerivedProperties(config);
77
const colorProperties = createColorProperties(config);
88
const responsiveCss = createComponentCss(config);
9-
return [":root {"]
9+
return [":where(:root) {"]
1010
.concat(
1111
Object.entries({
1212
...cssProperties,

0 commit comments

Comments
 (0)