mirror of
https://github.com/kremalicious/portfolio.git
synced 2024-12-22 17:23:22 +01:00
page animations
This commit is contained in:
parent
df60dcacf3
commit
026edb8504
@ -1,15 +1,13 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import CSSTransition from 'react-transition-group/CSSTransition'
|
import CSSTransition from 'react-transition-group/CSSTransition'
|
||||||
import './FadeIn.scss'
|
import './Animations.scss'
|
||||||
|
|
||||||
const FadeIn = props => (
|
export const FadeIn = props => (
|
||||||
<CSSTransition
|
<CSSTransition
|
||||||
{...props}
|
|
||||||
classNames="fadein"
|
classNames="fadein"
|
||||||
appear={true}
|
appear={true}
|
||||||
in={true}
|
in={true}
|
||||||
timeout={400}
|
timeout={{ enter: 300, exit: 200, appear: 300 }}
|
||||||
|
{...props}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
|
|
||||||
export default FadeIn
|
|
26
src/components/atoms/Animations.scss
Normal file
26
src/components/atoms/Animations.scss
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
.fadein-appear {
|
||||||
|
opacity: .01;
|
||||||
|
|
||||||
|
&.fadein-appear-active {
|
||||||
|
opacity: 1;
|
||||||
|
transition: 400ms ease-in;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.fadein-enter {
|
||||||
|
opacity: .01;
|
||||||
|
|
||||||
|
&.fadein-enter-active {
|
||||||
|
opacity: 1;
|
||||||
|
transition: 300ms ease-out;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.fadein-exit {
|
||||||
|
opacity: 1;
|
||||||
|
transition: 300ms ease-in;
|
||||||
|
|
||||||
|
&.fadein-exit-active {
|
||||||
|
opacity: .01;
|
||||||
|
}
|
||||||
|
}
|
@ -1,8 +0,0 @@
|
|||||||
.fadein-appear {
|
|
||||||
opacity: .01;
|
|
||||||
|
|
||||||
&.fadein-appear-active {
|
|
||||||
opacity: 1;
|
|
||||||
transition: opacity 400ms ease-in;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,6 +1,6 @@
|
|||||||
import React, { Fragment } from 'react'
|
import React, { Fragment } from 'react'
|
||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
import FadeIn from '../atoms/FadeIn'
|
import { FadeIn } from '../atoms/Animations'
|
||||||
import './Availability.scss'
|
import './Availability.scss'
|
||||||
|
|
||||||
const Availability = ({ meta, hide }) => {
|
const Availability = ({ meta, hide }) => {
|
||||||
|
@ -2,7 +2,7 @@ import React, { Fragment } from 'react'
|
|||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
import { OutboundLink } from 'gatsby-plugin-google-analytics'
|
import { OutboundLink } from 'gatsby-plugin-google-analytics'
|
||||||
import { Email, Blog, Twitter, GitHub, Dribbble } from '../atoms/Icons'
|
import { Email, Blog, Twitter, GitHub, Dribbble } from '../atoms/Icons'
|
||||||
import FadeIn from '../atoms/FadeIn'
|
import { FadeIn } from '../atoms/Animations'
|
||||||
import './Social.scss'
|
import './Social.scss'
|
||||||
|
|
||||||
const SocialIcon = ({ title }) => {
|
const SocialIcon = ({ title }) => {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import Link from 'gatsby-link'
|
import Link from 'gatsby-link'
|
||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
import FadeIn from '../atoms/FadeIn'
|
import { FadeIn } from '../atoms/Animations'
|
||||||
import { Logo } from '../atoms/Icons'
|
import { Logo } from '../atoms/Icons'
|
||||||
import Social from '../molecules/Social'
|
import Social from '../molecules/Social'
|
||||||
import Availability from '../molecules/Availability'
|
import Availability from '../molecules/Availability'
|
||||||
|
@ -1,11 +1,25 @@
|
|||||||
import React from 'react'
|
import React, { Component } from 'react'
|
||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
|
import withRouter from 'react-router-dom/withRouter'
|
||||||
import Typekit from 'react-typekit'
|
import Typekit from 'react-typekit'
|
||||||
|
import TransitionGroup from 'react-transition-group/TransitionGroup'
|
||||||
import Head from '../components/atoms/Head'
|
import Head from '../components/atoms/Head'
|
||||||
import Header from '../components/organisms/Header'
|
import Header from '../components/organisms/Header'
|
||||||
import Footer from '../components/organisms/Footer'
|
import Footer from '../components/organisms/Footer'
|
||||||
|
import { FadeIn } from '../components/atoms/Animations'
|
||||||
import './index.scss'
|
import './index.scss'
|
||||||
|
|
||||||
|
class TransitionHandler extends Component {
|
||||||
|
shouldComponentUpdate() {
|
||||||
|
return this.props.location.pathname === window.location.pathname
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const { children } = this.props
|
||||||
|
return <div className="transition-container">{children}</div>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const TemplateWrapper = ({ data, location, children }) => {
|
const TemplateWrapper = ({ data, location, children }) => {
|
||||||
const meta = data.dataJson
|
const meta = data.dataJson
|
||||||
const isHomepage = location.pathname === '/'
|
const isHomepage = location.pathname === '/'
|
||||||
@ -16,20 +30,33 @@ const TemplateWrapper = ({ data, location, children }) => {
|
|||||||
<Typekit kitId={meta.typekit} />
|
<Typekit kitId={meta.typekit} />
|
||||||
<Header meta={meta} isHomepage={isHomepage} />
|
<Header meta={meta} isHomepage={isHomepage} />
|
||||||
|
|
||||||
{children()}
|
<TransitionGroup appear={true}>
|
||||||
|
<FadeIn
|
||||||
|
key={location.pathname}
|
||||||
|
timeout={{ enter: 300, exit: 200, appear: 300 }}>
|
||||||
|
<TransitionHandler location={location}>
|
||||||
|
{children()}
|
||||||
|
</TransitionHandler>
|
||||||
|
</FadeIn>
|
||||||
|
</TransitionGroup>
|
||||||
|
|
||||||
<Footer meta={meta} />
|
<Footer meta={meta} />
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TransitionHandler.propTypes = {
|
||||||
|
children: PropTypes.any,
|
||||||
|
location: PropTypes.object.isRequired,
|
||||||
|
}
|
||||||
|
|
||||||
TemplateWrapper.propTypes = {
|
TemplateWrapper.propTypes = {
|
||||||
children: PropTypes.func,
|
children: PropTypes.func,
|
||||||
data: PropTypes.object.isRequired,
|
data: PropTypes.object.isRequired,
|
||||||
location: PropTypes.object.isRequired,
|
location: PropTypes.object.isRequired,
|
||||||
}
|
}
|
||||||
|
|
||||||
export default TemplateWrapper
|
export default withRouter(TemplateWrapper)
|
||||||
|
|
||||||
export const query = graphql`
|
export const query = graphql`
|
||||||
query metaQuery {
|
query metaQuery {
|
||||||
|
@ -112,3 +112,12 @@ svg {
|
|||||||
flex: 1;
|
flex: 1;
|
||||||
padding: $spacer;
|
padding: $spacer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.transition-group {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.transition-container {
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user