mirror of
https://github.com/kremalicious/portfolio.git
synced 2025-01-03 18:35:00 +01:00
simplify header
This commit is contained in:
parent
61553a094e
commit
5db9d18114
@ -1,4 +1,4 @@
|
|||||||
import React, { PureComponent } from 'react'
|
import React from 'react'
|
||||||
import { Link } from 'gatsby'
|
import { Link } from 'gatsby'
|
||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
import { FadeIn } from '../atoms/Animations'
|
import { FadeIn } from '../atoms/Animations'
|
||||||
@ -8,35 +8,12 @@ import ThemeSwitch from '../molecules/ThemeSwitch'
|
|||||||
import LogoUnit from '../atoms/LogoUnit'
|
import LogoUnit from '../atoms/LogoUnit'
|
||||||
import styles from './Header.module.scss'
|
import styles from './Header.module.scss'
|
||||||
|
|
||||||
class Header extends PureComponent {
|
const Header = ({ meta, isHomepage }) => (
|
||||||
constructor(props) {
|
<header
|
||||||
super(props)
|
className={
|
||||||
|
isHomepage ? `${styles.header}` : `${styles.header} ${styles.minimal}`
|
||||||
this.state = { classes: 'header' }
|
|
||||||
}
|
}
|
||||||
|
>
|
||||||
componentDidMount() {
|
|
||||||
this.toggleClasses()
|
|
||||||
}
|
|
||||||
|
|
||||||
componentDidUpdate() {
|
|
||||||
this.toggleClasses()
|
|
||||||
}
|
|
||||||
|
|
||||||
toggleClasses = () => {
|
|
||||||
if (this.props.isHomepage) {
|
|
||||||
this.setState({ classes: styles.header })
|
|
||||||
} else {
|
|
||||||
this.setState({ classes: `${styles.header} ${styles.minimal}` })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
|
||||||
const meta = this.props.meta
|
|
||||||
const isHomepage = this.props.isHomepage
|
|
||||||
|
|
||||||
return (
|
|
||||||
<header className={this.state.classes}>
|
|
||||||
<ThemeSwitch />
|
<ThemeSwitch />
|
||||||
<FadeIn>
|
<FadeIn>
|
||||||
<Link className={styles.header__link} to={'/'}>
|
<Link className={styles.header__link} to={'/'}>
|
||||||
@ -48,9 +25,7 @@ class Header extends PureComponent {
|
|||||||
|
|
||||||
<Availability hide={!isHomepage && !meta.availability.status} />
|
<Availability hide={!isHomepage && !meta.availability.status} />
|
||||||
</header>
|
</header>
|
||||||
)
|
)
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Header.propTypes = {
|
Header.propTypes = {
|
||||||
meta: PropTypes.object,
|
meta: PropTypes.object,
|
||||||
|
Loading…
Reference in New Issue
Block a user