refactor(footer): use team data

This commit is contained in:
2021-02-07 22:59:11 +00:00
parent 0861995936
commit e6a5b57f4c

View File

@@ -1,4 +1,5 @@
import React from "react"; import React from "react";
import { graphql, StaticQuery } from "gatsby";
import styled from "@emotion/styled"; import styled from "@emotion/styled";
import { css } from "@emotion/react"; import { css } from "@emotion/react";
import { Grid, IconWithContent, Icon, Link, Text } from "."; import { Grid, IconWithContent, Icon, Link, Text } from ".";
@@ -36,11 +37,27 @@ const Item = styled.div`
export default function Footer() { export default function Footer() {
const year = new Date().getFullYear(); const year = new Date().getFullYear();
return (
<StaticQuery
query={graphql`
query {
allPerson(filter: { name: { eq: "Nicholas Day" } }) {
nodes {
phone
altPhone
email
}
}
}
`}
render={data => {
const { phone, altPhone, email } = data.allPerson.nodes[0];
return ( return (
<Container> <Container>
<Content> <Content>
<Grid columns={[1, 2]} breakpoints={["45em"]}> <Grid columns={[1, 2]} breakpoints={["45em"]}>
<Cell> <Cell>
{phone && (
<Item> <Item>
<IconWithContent> <IconWithContent>
<Icon color="dark" size="lg"> <Icon color="dark" size="lg">
@@ -50,13 +67,17 @@ export default function Footer() {
weight="bold" weight="bold"
color="dark" color="dark"
size="lg" size="lg"
to="tel:+447539051512" to={`tel:${phone
.replace(/ /, "")
.replace(/^0/, "+44")}`}
noDecoration noDecoration
> >
07539 051512 {phone}
</Link> </Link>
</IconWithContent> </IconWithContent>
</Item> </Item>
)}
{altPhone && (
<Item> <Item>
<IconWithContent> <IconWithContent>
<Icon color="dark" size="lg"> <Icon color="dark" size="lg">
@@ -66,15 +87,19 @@ export default function Footer() {
weight="bold" weight="bold"
color="dark" color="dark"
size="lg" size="lg"
to="tel:+447378839358" to={`tel:${altPhone
.replace(/ /, "")
.replace(/^0/, "+44")}`}
noDecoration noDecoration
> >
07378 839358 {altPhone}
</Link> </Link>
</IconWithContent> </IconWithContent>
</Item> </Item>
)}
</Cell> </Cell>
<Cell flexEnd={"45em"}> <Cell flexEnd={"45em"}>
{email && (
<Item> <Item>
<IconWithContent> <IconWithContent>
<Icon color="dark" size="lg"> <Icon color="dark" size="lg">
@@ -84,17 +109,21 @@ export default function Footer() {
weight="bold" weight="bold"
color="dark" color="dark"
size="md" size="md"
to="mailto:quotations@abcprojectdesign.com" to={`mailto:${email}`}
noDecoration noDecoration
> >
quotations@abcprojectdesign.com {email}
</Link> </Link>
</IconWithContent> </IconWithContent>
</Item> </Item>
)}
</Cell> </Cell>
</Grid> </Grid>
<Text size="xs">&copy; {year} Abc Project Ltd</Text> <Text size="xs">&copy; {year} Abc Project Ltd</Text>
</Content> </Content>
</Container> </Container>
); );
}}
/>
);
} }