Skip to content

Commit

Permalink
Merge pull request #73 from tone-row/grid-area-and-where
Browse files Browse the repository at this point in the history
fix(slang): area prop; :where()
  • Loading branch information
rob-gordon committed May 24, 2021
2 parents 0b3743b + 894933d commit e5be4e9
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 6 deletions.
20 changes: 19 additions & 1 deletion docs/components/slang/slang.css
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ body {
--errorTopMultiplier: var(--error-top-multiplier-7);
--errorBottomMultiplier: var(--error-bottom-multiplier-7); }

:root {
:where(:root) {
--base-font-family:Neue Montreal;
--base-font-size-px:20px;
--base-font-size:20;
Expand Down Expand Up @@ -752,6 +752,12 @@ border-radius: calc(var(--smallest-border-radius-px) * var(--rad));
.slang-box.rad_hover:hover {
border-radius: calc(var(--smallest-border-radius-px) * var(--rad_hover));
}
.slang-box.area {
grid-area: var(--area);
}
.slang-box.area_hover:hover {
grid-area: var(--area_hover);
}
@media(min-width: 768px) {
.slang-box.flow-tablet {
grid-auto-flow: var(--flow-tablet);
Expand Down Expand Up @@ -891,6 +897,12 @@ border-radius: calc(var(--smallest-border-radius-px) * var(--rad-tablet));
.slang-box.rad-tablet_hover:hover {
border-radius: calc(var(--smallest-border-radius-px) * var(--rad-tablet_hover));
}
.slang-box.area-tablet {
grid-area: var(--area-tablet);
}
.slang-box.area-tablet_hover:hover {
grid-area: var(--area-tablet_hover);
}
}
@media(min-width: 1024px) {
.slang-box.flow-desktop {
Expand Down Expand Up @@ -1031,6 +1043,12 @@ border-radius: calc(var(--smallest-border-radius-px) * var(--rad-desktop));
.slang-box.rad-desktop_hover:hover {
border-radius: calc(var(--smallest-border-radius-px) * var(--rad-desktop_hover));
}
.slang-box.area-desktop {
grid-area: var(--area-desktop);
}
.slang-box.area-desktop_hover:hover {
grid-area: var(--area-desktop_hover);
}
}
.slang-type.weight {
font-weight: var(--weight);
Expand Down
4 changes: 4 additions & 0 deletions docs/pages/box.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ export default function BoxPage() {
</Type>
</Section>
<Box as="button">Test</Box>
<Box template="none / repeat(4, 1fr)">
<Box area="auto / span 3">long</Box>
<Box>short</Box>
</Box>
</Page>
);
}
9 changes: 5 additions & 4 deletions slang/src/Box/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export const propKeys = [
"pl",
"template",
"content",
"area",
"items",
"self",
"gap",
Expand Down Expand Up @@ -111,6 +112,10 @@ export const boxConfig: ComponentConfig<ResponsiveProps>[] = [
},
{ key: "items", cssFromVariable: (v) => `place-items: ${v};` },
{ key: "self", cssFromVariable: (v) => `place-self: ${v};` },
{
key: "area",
cssFromVariable: (v) => `grid-area: ${v};`,
},
{
key: "p",
defaultValue: "0",
Expand Down Expand Up @@ -246,8 +251,4 @@ export const boxConfig: ComponentConfig<ResponsiveProps>[] = [
cssFromVariable: (v) =>
`border-radius: calc(var(--smallest-border-radius-px) * ${v});`,
},
{
key: "area",
cssFromVariable: (v) => `grid-area: ${v};`,
},
];
2 changes: 1 addition & 1 deletion slang/src/makeCSS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export function makeCSS(config?: Partial<SlangConfig>) {
const derivedProperties = createDerivedProperties(config);
const colorProperties = createColorProperties(config);
const responsiveCss = createComponentCss(config);
return [":root {"]
return [":where(:root) {"]
.concat(
Object.entries({
...cssProperties,
Expand Down

1 comment on commit e5be4e9

@vercel
Copy link

@vercel vercel bot commented on e5be4e9 May 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.