footer / block / contacts refactoring

This commit is contained in:
tmshv committed 2020-02-18 15:36:20 +03:00
1 parent d0a11deae8
commit 48f7e971c9
8 files changed
+88 -69

No files matched your search

+5 -7
View File
@@ -9,13 +9,11 @@ const Page: NextPage = () => (
<Wrapper <Wrapper
header={null} header={null}
footer={( footer={(
<footer> <Block as={'footer'} direction={'horizontal'}>
<Block direction={'horizontal'}> <Spacer />
<Spacer /> <Copyright />
<Copyright /> <Spacer />
<Spacer /> </Block>
</Block>
</footer>
)} )}
> >
<NotFound /> <NotFound />
-20
View File
@@ -1,20 +0,0 @@
import { Footer } from '../Footer'
import { useContext } from 'react'
import { ConfigContext } from 'src/context/ConfigContext'
export type AppFooterProps = {
showAuthor: boolean
}
export const AppFooter: React.FC<AppFooterProps> = props => {
const config = useContext(ConfigContext)
return (
<Footer
showAuthor={props.showAuthor}
address={config.address}
telephone={config.telephone}
email={config.email}
/>
)
}
+2 -2
View File
@@ -6,7 +6,7 @@ import { Wrapper } from '../Wrapper'
import { Header } from './Header' import { Header } from './Header'
import { ConfigContext } from 'src/context/ConfigContext' import { ConfigContext } from 'src/context/ConfigContext'
import config from 'src/config' import config from 'src/config'
import { AppFooter } from './AppFooter' import { Footer } from '../Footer'
const Navigation = dynamic(() => import('../Navigation').then(mod => mod.Navigation), { const Navigation = dynamic(() => import('../Navigation').then(mod => mod.Navigation), {
ssr: false, ssr: false,
@@ -33,7 +33,7 @@ export const App: React.FC<IAppProps> = props => {
</Header> </Header>
)} )}
footer={( footer={(
<AppFooter <Footer
showAuthor={props.showAuthor} showAuthor={props.showAuthor}
/> />
)} )}
+19 -4
View File
@@ -1,11 +1,16 @@
import cx from 'classnames'
import { createElement } from 'react'
export type BlockProps = { export type BlockProps = {
as?: keyof HTMLElementTagNameMap
style?: React.CSSProperties style?: React.CSSProperties
direction: 'horizontal' | 'vertical' direction: 'horizontal' | 'vertical'
} }
export const Block: React.FC<BlockProps> = props => { export const Block: React.FC<BlockProps> = ({ as = 'div', style, direction, ...props }) => {
return ( const newProps = { className: cx(direction), style }
<div style={props.style}> const children = (
<>
<style jsx>{` <style jsx>{`
div { div {
display: flex; display: flex;
@@ -13,9 +18,19 @@ export const Block: React.FC<BlockProps> = props => {
align-items: baseline; align-items: baseline;
justify-content: flex-start; justify-content: flex-start;
} }
.horizontal {
flex-direction: row;
}
.vertical {
flex-direction: column;
}
`}</style> `}</style>
{props.children} {props.children}
</div> </>
) )
return createElement(as, newProps, children)
} }
+27
View File
@@ -0,0 +1,27 @@
import { useContext } from 'react'
import { ConfigContext } from 'src/context/ConfigContext'
export const Contacts: React.FC = props => {
const { contacts } = useContext(ConfigContext)
return (
<>
<style jsx>{`
h4 {
margin-bottom: var(--half-margin);
}
p {
margin-left: var(--single-margin);
margin-bottom: var(--half-margin);
}
`}</style>
<h4>Контактная информация</h4>
{contacts.map((x, i) => (
<p><a href={x.value}>{x.title}</a></p>
))}
</>
)
}
+7 -18
View File
@@ -2,32 +2,21 @@ import { Copyright } from '../Copyright'
import { Author } from './Author' import { Author } from './Author'
import { Block } from '../Block' import { Block } from '../Block'
import { Spacer } from '../Spacer' import { Spacer } from '../Spacer'
import { Contacts } from '../Contacts'
const mailto = email => `mailto:${email}`
export interface IFooterProps { export interface IFooterProps {
address: string
telephone: string
email: string
showAuthor: boolean showAuthor: boolean
} }
export const Footer: React.FC<IFooterProps> = props => ( export const Footer: React.FC<IFooterProps> = props => (
<footer> <footer>
<div className="contacts"> <Block direction={'vertical'} style={{
<div> marginBottom: 'var(--single-margin)',
<h4>Контактная информация</h4>
<p>Адрес: {props.address}</p>
<p>Телефон: {props.telephone}</p>
<p>Почта: <a href={mailto(props.email)}>{props.email}</a></p>
<p>Вконтакте: <a href="https://vk.com/shlisselburghudozka">shlisselburghudozka</a></p>
<p>Инстаграм: <a href="https://www.instagram.com/hudozka/">hudozka</a></p>
</div>
</div>
<Block direction={'horizontal'} style={{
padding: '1.5em 1em 0.25em',
}}> }}>
<Contacts />
</Block>
<Block direction={'horizontal'}>
<Copyright /> <Copyright />
{!props.showAuthor ? null : ( {!props.showAuthor ? null : (
+27 -3
View File
@@ -1,9 +1,33 @@
const currentYear = () => (new Date()).getFullYear() const currentYear = () => (new Date()).getFullYear()
export default { export default {
address: "г. Шлиссельбург ул. 18 января д. 3",
telephone: "+7 (81362) 76-312",
email: "hudozka@gmail.com",
yearStart: 2012, yearStart: 2012,
yearEnd: currentYear(), yearEnd: currentYear(),
contacts: [
{
type: 'link',
value: 'https://yandex.ru/maps/-/CKUkAXIb',
title: 'г. Шлиссельбург ул. 18 января д. 3',
},
{
type: 'tel',
value: 'tel:+78136276312',
title: '+7 (81362) 76-312',
},
{
type: 'email',
value: 'mailto:hudozka@gmail.com',
title: 'hudozka@gmail.com',
},
{
type: 'link',
value: 'https://vk.com/shlisselburghudozka',
title: 'Вконтакте'
},
{
type: 'link',
value: 'https://www.instagram.com/hudozka',
title: 'Инстаграм'
}
]
} }
+1 -15
View File
@@ -1,17 +1,3 @@
footer { footer {
padding: 0 var(--half-margin) var(--half-margin); padding: var(--single-margin);
position: relative;
.contacts {
margin: var(--double-margin) 0 var(--half-margin);
& > div {
padding: 0 var(--single-margin);
}
p {
margin: var(--half-margin) var(--single-margin);
}
}
} }