Copyright component extraction

This commit is contained in:
tmshv committed 2020-02-18 14:31:27 +03:00
1 parent c0dd5cf6ae
commit 5b19a6a359
4 files changed
+18 -11

No files matched your search

+2 -1
View File
@@ -1,6 +1,7 @@
import { NextPage } from 'next' import { NextPage } from 'next'
import { Wrapper } from 'src/components/Wrapper' import { Wrapper } from 'src/components/Wrapper'
import { NotFound } from 'src/components/NotFound' import { NotFound } from 'src/components/NotFound'
import { Copyright } from 'src/components/Copyright'
const Page: NextPage = () => ( const Page: NextPage = () => (
<Wrapper <Wrapper
@@ -8,7 +9,7 @@ const Page: NextPage = () => (
footer={( footer={(
<footer className="footer--centered"> <footer className="footer--centered">
<div className="copyright"> <div className="copyright">
<span>©&nbsp;2012—2019 Шлиссельбургская детская художественная школа</span> <Copyright />
</div> </div>
</footer> </footer>
)} )}
+10
View File
@@ -0,0 +1,10 @@
import { useContext } from 'react'
import { ConfigContext } from 'src/context/ConfigContext'
export const Copyright: React.FC = () => {
const { yearStart, yearEnd } = useContext(ConfigContext)
return (
<span>©&nbsp;{yearStart}—{yearEnd} Шлиссельбургская детская художественная школа</span>
)
}
+2 -10
View File
@@ -1,7 +1,6 @@
import * as React from 'react' import { Copyright } from '../Copyright'
const mailto = email => `mailto:${email}` const mailto = email => `mailto:${email}`
const currentYear = () => (new Date()).getFullYear()
export interface IFooterProps { export interface IFooterProps {
address: string address: string
@@ -24,10 +23,7 @@ export const Footer: React.FC<IFooterProps> = props => (
</div> </div>
<div className="copyright"> <div className="copyright">
<Copyright <Copyright />
yearStart={2012}
yearEnd={currentYear()}
/>
{!props.showAuthor ? null : ( {!props.showAuthor ? null : (
<Author /> <Author />
)} )}
@@ -43,7 +39,3 @@ const Author = () => (
</a> </a>
</span> </span>
) )
const Copyright = ({ yearStart, yearEnd }) => (
<span>©&nbsp;{yearStart}—{yearEnd} Шлиссельбургская детская художественная школа</span>
)
+4
View File
@@ -1,5 +1,9 @@
const currentYear = () => (new Date()).getFullYear()
export default { export default {
address: "г. Шлиссельбург ул. 18 января д. 3", address: "г. Шлиссельбург ул. 18 января д. 3",
telephone: "+7 (81362) 76-312", telephone: "+7 (81362) 76-312",
email: "hudozka@gmail.com", email: "hudozka@gmail.com",
yearStart: 2012,
yearEnd: currentYear(),
} }