added optional breadcrumbs; page layout refactoring; other chages
This commit is contained in:
1 parent
1dbbe04d59
commit
db485056e0
12 files changed
+138
-61
No files matched your search
+11
-1
@@ -5,6 +5,8 @@ import { Page } from 'src/components/Page'
|
|||||||
import { Meta } from 'src/components/Meta'
|
import { Meta } from 'src/components/Meta'
|
||||||
import { meta } from 'src/lib/meta'
|
import { meta } from 'src/lib/meta'
|
||||||
import { createApiUrl, requestGet, wrapInitialProps, IResponseItems } from 'src/next-lib'
|
import { createApiUrl, requestGet, wrapInitialProps, IResponseItems } from 'src/next-lib'
|
||||||
|
import { NextPage } from 'next'
|
||||||
|
import { IBreadcumbsPart, IMeta } from 'src/types'
|
||||||
|
|
||||||
function array<T>(value: T | T[]) {
|
function array<T>(value: T | T[]) {
|
||||||
return Array.isArray(value)
|
return Array.isArray(value)
|
||||||
@@ -12,12 +14,20 @@ function array<T>(value: T | T[]) {
|
|||||||
: [value]
|
: [value]
|
||||||
}
|
}
|
||||||
|
|
||||||
const Index = props => (
|
type Props = {
|
||||||
|
title: string
|
||||||
|
content: string
|
||||||
|
breadcrumbs: IBreadcumbsPart[]
|
||||||
|
meta: IMeta
|
||||||
|
}
|
||||||
|
|
||||||
|
const Index: NextPage<Props> = props => (
|
||||||
<App
|
<App
|
||||||
showAuthor={true}
|
showAuthor={true}
|
||||||
contentStyle={{
|
contentStyle={{
|
||||||
marginTop: 'var(--size-l)'
|
marginTop: 'var(--size-l)'
|
||||||
}}
|
}}
|
||||||
|
breadcrumbs={props.breadcrumbs}
|
||||||
>
|
>
|
||||||
<Head>
|
<Head>
|
||||||
<title>{props.title}</title>
|
<title>{props.title}</title>
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
export const Header: React.FC = props => (
|
|
||||||
<header>
|
|
||||||
<style jsx>{`
|
|
||||||
.navigation {
|
|
||||||
width: 100%;
|
|
||||||
background-color: white;
|
|
||||||
}
|
|
||||||
|
|
||||||
.navigation__body {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
`}</style>
|
|
||||||
|
|
||||||
<div className="navigation">
|
|
||||||
<div className="navigation__body">
|
|
||||||
{props.children}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</header>
|
|
||||||
)
|
|
||||||
@@ -1,12 +1,13 @@
|
|||||||
import dynamic from 'next/dynamic'
|
import dynamic from 'next/dynamic'
|
||||||
import cx from 'classnames'
|
|
||||||
import Comments from '../Comments'
|
import Comments from '../Comments'
|
||||||
import { useReducedMotion } from 'src/hooks/useReducedMotion'
|
|
||||||
import { Wrapper } from '../Wrapper'
|
import { Wrapper } from '../Wrapper'
|
||||||
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 { Footer } from '../Footer'
|
import { Footer } from '../Footer'
|
||||||
|
import { Content } from '../Content'
|
||||||
|
import { Block } from '../Block'
|
||||||
|
import { Breadcrumbs } from '../Breadcrumbs'
|
||||||
|
import { IBreadcumbsPart } from 'src/types'
|
||||||
|
|
||||||
const Navigation = dynamic(() => import('../Navigation').then(mod => mod.Navigation), {
|
const Navigation = dynamic(() => import('../Navigation').then(mod => mod.Navigation), {
|
||||||
ssr: false,
|
ssr: false,
|
||||||
@@ -16,18 +17,31 @@ export interface IAppProps {
|
|||||||
showAuthor: boolean
|
showAuthor: boolean
|
||||||
wide?: boolean
|
wide?: boolean
|
||||||
contentStyle?: React.CSSProperties
|
contentStyle?: React.CSSProperties
|
||||||
|
breadcrumbs?: IBreadcumbsPart[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export const App: React.FC<IAppProps> = ({ wide = false, ...props }) => {
|
export const App: React.FC<IAppProps> = props => {
|
||||||
const motionDisabled = useReducedMotion()
|
const wide = props.wide ?? false
|
||||||
|
const blockStyle = {
|
||||||
|
alignItems: 'center'
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ConfigContext.Provider value={config}>
|
<ConfigContext.Provider value={config}>
|
||||||
<Wrapper
|
<Wrapper
|
||||||
header={(
|
header={(
|
||||||
<Header>
|
<header>
|
||||||
<Navigation />
|
<Navigation />
|
||||||
</Header>
|
{!props.breadcrumbs ? null : (
|
||||||
|
<Block direction={'vertical'} style={blockStyle}>
|
||||||
|
<Content wide={wide}>
|
||||||
|
<Breadcrumbs
|
||||||
|
path={props.breadcrumbs}
|
||||||
|
/>
|
||||||
|
</Content>
|
||||||
|
</Block>
|
||||||
|
)}
|
||||||
|
</header>
|
||||||
)}
|
)}
|
||||||
footer={(
|
footer={(
|
||||||
<Footer
|
<Footer
|
||||||
@@ -35,15 +49,11 @@ export const App: React.FC<IAppProps> = ({ wide = false, ...props }) => {
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<div
|
<Block direction={'vertical'} style={blockStyle}>
|
||||||
className={cx('content', {
|
<Content wide={wide} style={props.contentStyle}>
|
||||||
'reduced-motion': motionDisabled,
|
|
||||||
'content_wide': wide,
|
|
||||||
})}
|
|
||||||
style={props.contentStyle}
|
|
||||||
>
|
|
||||||
{props.children}
|
{props.children}
|
||||||
</div>
|
</Content>
|
||||||
|
</Block>
|
||||||
|
|
||||||
{/* <Comments /> */}
|
{/* <Comments /> */}
|
||||||
</Wrapper>
|
</Wrapper>
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
import './styles.css'
|
||||||
|
|
||||||
|
import { IBreadcumbsPart } from 'src/types'
|
||||||
|
import { Button } from '../Button'
|
||||||
|
|
||||||
|
export type BreadcrumbsProps = {
|
||||||
|
style?: React.CSSProperties
|
||||||
|
path: IBreadcumbsPart[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export const Breadcrumbs: React.FC<BreadcrumbsProps> = props => {
|
||||||
|
return (
|
||||||
|
<nav className={'breadcrumbs'} style={props.style}>
|
||||||
|
{props.path.map((x, i) => (
|
||||||
|
<li key={x.href}>
|
||||||
|
<Button
|
||||||
|
href={x.href}
|
||||||
|
theme={'ghost'}
|
||||||
|
size={'small'}
|
||||||
|
>
|
||||||
|
{x.name}
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
{!(i < props.path.length - 1) ? null : (
|
||||||
|
<span style={{ margin: '0 var(--size-xs)' }}>/</span>
|
||||||
|
)}
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</nav>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
.breadcrumbs {
|
||||||
|
display: flex;
|
||||||
|
list-style: none;
|
||||||
|
|
||||||
|
position: relative;
|
||||||
|
right: var(--size-s);
|
||||||
|
}
|
||||||
@@ -1,16 +1,20 @@
|
|||||||
import './styles.css'
|
import './styles.css'
|
||||||
|
|
||||||
import Link from 'next/link'
|
import Link from 'next/link'
|
||||||
|
import cx from 'classnames'
|
||||||
|
|
||||||
export type ButtonProps = {
|
export type ButtonProps = {
|
||||||
style?: React.CSSProperties
|
style?: React.CSSProperties
|
||||||
href?: string
|
href?: string
|
||||||
|
theme?: 'default' | 'ghost'
|
||||||
|
size?: 'default' | 'small'
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Button: React.FC<ButtonProps> = props => {
|
export const Button: React.FC<ButtonProps> = ({ size='default', theme = 'default', ...props }) => {
|
||||||
if (props.href) {
|
if (props.href) {
|
||||||
return (
|
return (
|
||||||
<Link href={props.href}>
|
<Link href={props.href}>
|
||||||
<a className={'button invisible'} style={props.style}>
|
<a className={cx('button', theme, size)} style={props.style}>
|
||||||
{props.children}
|
{props.children}
|
||||||
</a>
|
</a>
|
||||||
</Link>
|
</Link>
|
||||||
@@ -23,3 +27,4 @@ export const Button: React.FC<ButtonProps> = props => {
|
|||||||
</button>
|
</button>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,18 +1,14 @@
|
|||||||
.button {
|
.button {
|
||||||
border: none;
|
|
||||||
font-size: var(--font-size-default);
|
font-size: var(--font-size-default);
|
||||||
|
|
||||||
text-align: center;
|
text-align: center;
|
||||||
margin-top: var(--size-m);
|
margin-top: var(--size-m);
|
||||||
margin-bottom: var(--size-m);
|
margin-bottom: var(--size-m);
|
||||||
margin-left: 1px;
|
|
||||||
margin-right: 1px;
|
|
||||||
|
|
||||||
padding: var(--size-s) var(--size-m);
|
|
||||||
border-radius: 100px;
|
border-radius: 100px;
|
||||||
|
border: 1px solid var(--color-shadow);
|
||||||
|
|
||||||
background-color: var(--color-back);
|
background-color: var(--color-back);
|
||||||
box-shadow: 0 0 0 1px var(--color-shadow);
|
|
||||||
|
|
||||||
transition: box-shadow 150ms;
|
transition: box-shadow 150ms;
|
||||||
|
|
||||||
@@ -21,5 +17,27 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.button:hover {
|
.button:hover {
|
||||||
|
margin-left: 1px;
|
||||||
|
margin-right: 1px;
|
||||||
|
|
||||||
|
border: none;
|
||||||
box-shadow: var(--shadow-active);
|
box-shadow: var(--shadow-active);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* THEME */
|
||||||
|
|
||||||
|
.button.ghost {
|
||||||
|
border-color: rgba(0, 0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* SIZE */
|
||||||
|
|
||||||
|
.button.default {
|
||||||
|
padding: var(--size-s) var(--size-m);
|
||||||
|
}
|
||||||
|
|
||||||
|
.button.small {
|
||||||
|
padding: var(--size-xs) var(--size-s);
|
||||||
|
font-size: var(--font-size-second);
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
import cx from 'classnames'
|
||||||
|
import { useReducedMotion } from 'src/hooks/useReducedMotion'
|
||||||
|
|
||||||
|
export type ContentProps = {
|
||||||
|
style?: React.CSSProperties
|
||||||
|
wide: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
export const Content: React.FC<ContentProps> = props => {
|
||||||
|
const motionDisabled = useReducedMotion()
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={cx('content', {
|
||||||
|
'reduced-motion': motionDisabled,
|
||||||
|
'content_wide': props.wide,
|
||||||
|
})}
|
||||||
|
style={props.style}
|
||||||
|
>
|
||||||
|
{props.children}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
import * as React from 'react'
|
|
||||||
import { Share } from '../Share'
|
import { Share } from '../Share'
|
||||||
import { Html } from '../Html'
|
import { Html } from '../Html'
|
||||||
|
|
||||||
|
|||||||
@@ -3,10 +3,12 @@ import cx from 'classnames'
|
|||||||
export type WrapperProps = {
|
export type WrapperProps = {
|
||||||
header: React.ReactNode
|
header: React.ReactNode
|
||||||
footer: React.ReactNode
|
footer: React.ReactNode
|
||||||
|
style?: React.CSSProperties
|
||||||
|
mainStyle?: React.CSSProperties
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Wrapper: React.FC<WrapperProps> = props => (
|
export const Wrapper: React.FC<WrapperProps> = props => (
|
||||||
<div className={cx('wrapper', 'theme-default')}>
|
<div className={cx('wrapper', 'theme-default')} style={props.style}>
|
||||||
<style jsx>{`
|
<style jsx>{`
|
||||||
.wrapper {
|
.wrapper {
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -17,20 +19,11 @@ export const Wrapper: React.FC<WrapperProps> = props => (
|
|||||||
font-family: var(--text-font);
|
font-family: var(--text-font);
|
||||||
font-size: var(--font-size-default);
|
font-size: var(--font-size-default);
|
||||||
}
|
}
|
||||||
|
|
||||||
.content {
|
|
||||||
flex: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
main {
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
}
|
|
||||||
`}</style>
|
`}</style>
|
||||||
|
|
||||||
{props.header}
|
{props.header}
|
||||||
|
|
||||||
<main>
|
<main style={props.mainStyle}>
|
||||||
{props.children}
|
{props.children}
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -67,8 +67,8 @@
|
|||||||
--color-back-opposite: var(--darker-color);
|
--color-back-opposite: var(--darker-color);
|
||||||
|
|
||||||
/* SIZE */
|
/* SIZE */
|
||||||
--size-xs: 0.25em;
|
--size-xs: 0.35em;
|
||||||
--size-s: 0.5em;
|
--size-s: 0.75em;
|
||||||
--size-m: 1em;
|
--size-m: 1em;
|
||||||
--size-l: 2em;
|
--size-l: 2em;
|
||||||
--size-xl: 3em;
|
--size-xl: 3em;
|
||||||
|
|||||||
+5
-2
@@ -1,8 +1,11 @@
|
|||||||
export interface IMenu {
|
export interface IMenu {
|
||||||
name: string
|
name: string
|
||||||
href: string
|
href: string
|
||||||
active: boolean
|
}
|
||||||
items?: IMenu[]
|
|
||||||
|
export interface IBreadcumbsPart {
|
||||||
|
name: string
|
||||||
|
href: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IDocument {
|
export interface IDocument {
|
||||||
|
|||||||
Reference in new issue
Block a user