App component update; support reduced-motion

This commit is contained in:
tmshv committed 2019-10-17 14:33:28 +03:00
1 parent 96c1330d9b
commit 228e7824de
3 files changed
+53 -31

No files matched your search

+7 -7
View File
@@ -1,5 +1,6 @@
import React from 'react' import React from 'react'
import Head from 'next/head' import Head from 'next/head'
import { App } from '../src/components/App' import { App } from '../src/components/App'
import { Page } from '../src/components/Page' import { Page } from '../src/components/Page'
import menuModel from '../src/models/menu' import menuModel from '../src/models/menu'
@@ -13,19 +14,18 @@ const Index = (props) => (
menu={buildMenu(props.pageUrl, menuModel)} menu={buildMenu(props.pageUrl, menuModel)}
showAuthor={true} showAuthor={true}
menuPadding={true} menuPadding={true}
layout={'thin'}
> >
<Head> <Head>
<title>{props.title}</title> <title>{props.title}</title>
<Meta meta={props.meta} /> <Meta meta={props.meta} />
</Head> </Head>
<div className={'content content_thin'}> <Page
<Page showSocialShare={true}
showSocialShare={true} >
> {props.content}
{props.content} </Page>
</Page>
</div>
</App> </App>
) )
+42 -24
View File
@@ -1,7 +1,10 @@
import * as React from 'react' import * as React from 'react'
import dynamic from 'next/dynamic' import dynamic from 'next/dynamic'
import cx from 'classnames'
import { Footer } from '../Footer' import { Footer } from '../Footer'
import Comments from '../Comments' import Comments from '../Comments'
import { useReducedMotion } from '../../hooks/useReducedMotion'
const Header = dynamic(() => import('./Header'), { const Header = dynamic(() => import('./Header'), {
ssr: false, ssr: false,
@@ -9,31 +12,46 @@ const Header = dynamic(() => import('./Header'), {
import '../../style/style.scss' import '../../style/style.scss'
export const App = ({ children, menu, showAuthor, menuPadding }) => ( export interface IAppProps {
<div className="body-wrapper theme-default"> menu: any
<header> showAuthor: boolean
<div className="navigation"> menuPadding: boolean
<div className="navigation__body"> layout?: 'full' | 'wide' | 'thin'
<Header }
menuItems={menu.items}
/> export const App: React.FC<IAppProps> = props => {
const layout = props.layout ? props.layout : 'full'
const motionDisabled = useReducedMotion()
return (
<div className="body-wrapper theme-default">
<header>
<div className="navigation">
<div className="navigation__body">
<Header
menuItems={props.menu.items}
/>
</div>
</div> </div>
</div> </header>
</header>
<main className="body-wrapper__content"> <main className="body-wrapper__content">
<section className={`content content_full ${menuPadding ? 'content--padding-top--menu' : ''}`}> <section className={cx('content', `content_${layout}`, {
{children} 'content--padding-top--menu': props.menuPadding,
</section> 'reduced-motion': motionDisabled,
})}>
{props.children}
</section>
<Comments /> <Comments />
</main> </main>
<Footer <Footer
showAuthor={showAuthor} showAuthor={props.showAuthor}
address=" г. Шлиссельбург ул. 18 января д. 3" address=" г. Шлиссельбург ул. 18 января д. 3"
telephone="+7 (81362) 76-312" telephone="+7 (81362) 76-312"
email="hudozka@gmail.com" email="hudozka@gmail.com"
/> />
</div> </div>
) )
}
+4
View File
@@ -40,6 +40,10 @@
animation: smallSlideInFromTop 350ms ease-out; animation: smallSlideInFromTop 350ms ease-out;
} }
.content.reduced-motion {
animation: none;
}
@media screen and (max-width: var(--mobile-width)) { @media screen and (max-width: var(--mobile-width)) {
--content-mobile: 95%; --content-mobile: 95%;