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
+89 -70

No files matched your search

-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 { ConfigContext } from 'src/context/ConfigContext'
import config from 'src/config'
import { AppFooter } from './AppFooter'
import { Footer } from '../Footer'
const Navigation = dynamic(() => import('../Navigation').then(mod => mod.Navigation), {
ssr: false,
@@ -33,7 +33,7 @@ export const App: React.FC<IAppProps> = props => {
</Header>
)}
footer={(
<AppFooter
<Footer
showAuthor={props.showAuthor}
/>
)}
+19 -4
View File
@@ -1,11 +1,16 @@
import cx from 'classnames'
import { createElement } from 'react'
export type BlockProps = {
as?: keyof HTMLElementTagNameMap
style?: React.CSSProperties
direction: 'horizontal' | 'vertical'
}
export const Block: React.FC<BlockProps> = props => {
return (
<div style={props.style}>
export const Block: React.FC<BlockProps> = ({ as = 'div', style, direction, ...props }) => {
const newProps = { className: cx(direction), style }
const children = (
<>
<style jsx>{`
div {
display: flex;
@@ -13,9 +18,19 @@ export const Block: React.FC<BlockProps> = props => {
align-items: baseline;
justify-content: flex-start;
}
.horizontal {
flex-direction: row;
}
.vertical {
flex-direction: column;
}
`}</style>
{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 { Block } from '../Block'
import { Spacer } from '../Spacer'
const mailto = email => `mailto:${email}`
import { Contacts } from '../Contacts'
export interface IFooterProps {
address: string
telephone: string
email: string
showAuthor: boolean
}
export const Footer: React.FC<IFooterProps> = props => (
<footer>
<div className="contacts">
<div>
<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',
<Block direction={'vertical'} style={{
marginBottom: 'var(--single-margin)',
}}>
<Contacts />
</Block>
<Block direction={'horizontal'}>
<Copyright />
{!props.showAuthor ? null : (