feat(grid): init component
This commit is contained in:
34
src/components/grid.js
Normal file
34
src/components/grid.js
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
import React from "react";
|
||||||
|
import styled from "@emotion/styled";
|
||||||
|
import { css } from "@emotion/react";
|
||||||
|
|
||||||
|
const Container = styled.div`
|
||||||
|
display: grid;
|
||||||
|
gap: var(--spacing-x-sm) var(--spacing-y-sm);
|
||||||
|
${props =>
|
||||||
|
props.columns &&
|
||||||
|
props.columns.map((column, i) =>
|
||||||
|
i === 0 && column > 1
|
||||||
|
? css`
|
||||||
|
grid-template-columns: repeat(${column}, minmax(10px, 1fr));
|
||||||
|
`
|
||||||
|
: css`
|
||||||
|
@media (min-width: ${props.breakpoints[i - 1]}) {
|
||||||
|
grid-template-columns: repeat(${column}, minmax(10px, 1fr));
|
||||||
|
${
|
||||||
|
i === 1 &&
|
||||||
|
css`
|
||||||
|
gap: var(--spacing-x-md) var(--spacing-y-md);
|
||||||
|
`
|
||||||
|
}
|
||||||
|
`
|
||||||
|
)}
|
||||||
|
`;
|
||||||
|
|
||||||
|
export default function Grid({ columns, breakpoints = ["30em"], children }) {
|
||||||
|
return (
|
||||||
|
<Container columns={columns} breakpoints={breakpoints}>
|
||||||
|
{children}
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ export { default as Card } from "./card";
|
|||||||
export { default as Content } from "./content";
|
export { default as Content } from "./content";
|
||||||
export { default as CustomSlick } from "./custom-slick";
|
export { default as CustomSlick } from "./custom-slick";
|
||||||
export { default as Footer } from "./footer";
|
export { default as Footer } from "./footer";
|
||||||
|
export { default as Grid } from "./grid";
|
||||||
export { default as HeaderLogo } from "./header-logo";
|
export { default as HeaderLogo } from "./header-logo";
|
||||||
export { default as Header } from "./header";
|
export { default as Header } from "./header";
|
||||||
export { default as Heading } from "./heading";
|
export { default as Heading } from "./heading";
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import styled from "@emotion/styled";
|
import styled from "@emotion/styled";
|
||||||
import { css } from "@emotion/react";
|
|
||||||
import { Heading } from ".";
|
import { Heading } from ".";
|
||||||
|
|
||||||
const Container = styled.div`
|
const Container = styled.div`
|
||||||
@@ -23,27 +22,11 @@ const Head = styled.div`
|
|||||||
text-align: center;
|
text-align: center;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const Body = styled.div`
|
|
||||||
${props =>
|
|
||||||
props.grid > 0 &&
|
|
||||||
css`
|
|
||||||
display: grid;
|
|
||||||
gap: var(--spacing-x-sm) 0;
|
|
||||||
|
|
||||||
@media (min-width: ${props.breakpoint}) {
|
|
||||||
grid-template-columns: repeat(${props.grid}, 1fr);
|
|
||||||
gap: var(--spacing-x-md);
|
|
||||||
}
|
|
||||||
`}
|
|
||||||
`;
|
|
||||||
|
|
||||||
export default function Section({
|
export default function Section({
|
||||||
heading,
|
heading,
|
||||||
headingElement = "h2",
|
headingElement = "h2",
|
||||||
children,
|
children,
|
||||||
variant,
|
variant
|
||||||
grid,
|
|
||||||
breakpoint = "30em"
|
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<Container variant={variant}>
|
<Container variant={variant}>
|
||||||
@@ -53,9 +36,7 @@ export default function Section({
|
|||||||
<Heading el={headingElement}>{heading}</Heading>
|
<Heading el={headingElement}>{heading}</Heading>
|
||||||
</Head>
|
</Head>
|
||||||
)}
|
)}
|
||||||
<Body grid={grid} breakpoint={breakpoint}>
|
|
||||||
{children}
|
{children}
|
||||||
</Body>
|
|
||||||
</Content>
|
</Content>
|
||||||
</Container>
|
</Container>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { Marker } from "google-maps-react";
|
|||||||
import Layout from "../layout";
|
import Layout from "../layout";
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
|
Grid,
|
||||||
Header,
|
Header,
|
||||||
Icon,
|
Icon,
|
||||||
IconWithContent,
|
IconWithContent,
|
||||||
@@ -56,7 +57,8 @@ export default function Index({ data }) {
|
|||||||
>
|
>
|
||||||
<h1>Get in touch</h1>
|
<h1>Get in touch</h1>
|
||||||
</Header>
|
</Header>
|
||||||
<Section grid={2} breakpoint="40em">
|
<Section>
|
||||||
|
<Grid columns={[1, 2]} breakpoints={["40rem"]}>
|
||||||
<div>
|
<div>
|
||||||
<Text>Get in touch with us</Text>
|
<Text>Get in touch with us</Text>
|
||||||
<Text textStyle="italic">More info here</Text>
|
<Text textStyle="italic">More info here</Text>
|
||||||
@@ -133,6 +135,7 @@ export default function Index({ data }) {
|
|||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
</Grid>
|
||||||
</Section>
|
</Section>
|
||||||
<Map
|
<Map
|
||||||
initialCenter={{
|
initialCenter={{
|
||||||
|
|||||||
Reference in New Issue
Block a user