@frontity/twentytwenty-theme
Version:
The WordPress Twenty Twenty starter theme for Frontity
98 lines (83 loc) • 2.09 kB
JavaScript
import { styled, connect } from "frontity";
import Link from "./link";
import SectionContainer from "./styles/section-container";
// Component that provides scroll to top functionality
const BackToTop = () => {
// scroll to top function
const scrollToTop = (event) => {
// prevent the default behaviors
event.preventDefault();
// scroll to the top smoothly
scrollTo({ top: 0, left: 0, behavior: "smooth" });
};
return (
<a href="#site-header" onClick={scrollToTop} style={{ cursor: "pointer" }}>
<span style={{ marginRight: 8 }}>To the top</span>
<span className="arrow" aria-hidden="true">
↑
</span>
</a>
);
};
const Footer = ({ state }) => {
const currentYear = new Date().getFullYear();
const { footerBg } = state.theme.colors;
return (
<SiteFooter bg={footerBg} role="contentinfo">
<SiteFooterInner>
<Credits>
<Copyright>
© {currentYear}{" "}
<Link link={state.frontity.url}>{state.frontity.title}</Link>
</Copyright>
<PoweredBy>Powered by Frontity</PoweredBy>
</Credits>
<BackToTop />
</SiteFooterInner>
</SiteFooter>
);
};
export default connect(Footer);
const SiteFooterInner = styled(SectionContainer)`
align-items: baseline;
display: flex;
justify-content: space-between;
`;
const SiteFooter = styled.footer`
margin-top: 5rem;
border-color: #dcd7ca;
border-style: solid;
border-width: 0;
padding: 3rem 0;
background-color: ${(props) => props.bg};
color: #000000;
@media (min-width: 700px) {
margin-top: 8rem;
font-size: 1.8rem;
padding: 4.3rem 0;
}
a {
color: inherit;
text-decoration: none;
}
`;
const Credits = styled.div`
@media (min-width: 700px) {
display: flex;
}
`;
const Copyright = styled.p`
font-weight: 600;
margin: 0;
@media (min-width: 700px) {
font-weight: 700;
}
`;
const PoweredBy = styled.p`
color: #6d6d6d;
display: none;
margin: 0 0 0 2.4rem;
@media (min-width: 700px) {
display: block;
}
`;