prop types

This commit is contained in:
Sergey Yarkov 2020-07-02 09:09:35 +03:00
parent 1e31dbdf3b
commit 0d4e98c7c8
9 changed files with 62 additions and 21 deletions

View File

@ -1,4 +1,5 @@
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'
import { Link } from 'gatsby' import { Link } from 'gatsby'
import './About.scss' import './About.scss'
@ -39,3 +40,15 @@ const About = ({ title, pageTitle, email }) => {
} }
export default About export default About
About.propTypes = {
title: PropTypes.string,
pageTitle: PropTypes.string,
email: PropTypes.string
}
About.defaultProps = {
title: null,
pageTitle: null,
email: null
}

View File

@ -2,7 +2,7 @@ import React from 'react';
import ArticleCard from './ArticleCard/ArticleCard' import ArticleCard from './ArticleCard/ArticleCard'
import './Articles.scss' import './Articles.scss'
export default () => { const Articles = () => {
return ( return (
<div className="articles"> <div className="articles">
<div className="articles-content"> <div className="articles-content">
@ -11,3 +11,5 @@ export default () => {
</div> </div>
) )
} }
export default Articles

View File

@ -1,7 +1,9 @@
import React from 'react'; import React from 'react';
import './Description.scss' import './Description.scss'
export default () => { import HelloIcon from '../../images/hello-icon.svg'
const Description = () => {
return ( return (
<section className="description"> <section className="description">
<div className="container-fluid"> <div className="container-fluid">
@ -16,15 +18,7 @@ export default () => {
<p> <p>
сборник статей и руководств по тематике веб-разработки и IT для того чтобы помочь вам сборник статей и руководств по тематике веб-разработки и IT для того чтобы помочь вам
</p> </p>
<svg xmlns="http://www.w3.org/2000/svg" xmlnsXlink="http://www.w3.org/1999/xlink" aria-hidden="true" focusable="false" width="21px" height="21px" style={{msTransform: 'rotate(360deg)', WebkitTransform: 'rotate(360deg)', transform: 'rotate(360deg)'}} preserveAspectRatio="xMidYMid meet" viewBox="0 0 36 36"> <HelloIcon />
<path fill="#EF9645" d="M4.861 9.147c.94-.657 2.357-.531 3.201.166l-.968-1.407c-.779-1.111-.5-2.313.612-3.093c1.112-.777 4.263 1.312 4.263 1.312c-.786-1.122-.639-2.544.483-3.331a2.483 2.483 0 0 1 3.456.611l10.42 14.72L25 31l-11.083-4.042L4.25 12.625a2.495 2.495 0 0 1 .611-3.478z" />
<path fill="#FFDC5D" d="M2.695 17.336s-1.132-1.65.519-2.781c1.649-1.131 2.78.518 2.78.518l5.251 7.658c.181-.302.379-.6.6-.894L4.557 11.21s-1.131-1.649.519-2.78c1.649-1.131 2.78.518 2.78.518l6.855 9.997c.255-.208.516-.417.785-.622L7.549 6.732s-1.131-1.649.519-2.78c1.649-1.131 2.78.518 2.78.518l7.947 11.589c.292-.179.581-.334.871-.498L12.238 4.729s-1.131-1.649.518-2.78c1.649-1.131 2.78.518 2.78.518l7.854 11.454l1.194 1.742c-4.948 3.394-5.419 9.779-2.592 13.902c.565.825 1.39.26 1.39.26c-3.393-4.949-2.357-10.51 2.592-13.903L24.515 8.62s-.545-1.924 1.378-2.47c1.924-.545 2.47 1.379 2.47 1.379l1.685 5.004c.668 1.984 1.379 3.961 2.32 5.831c2.657 5.28 1.07 11.842-3.94 15.279c-5.465 3.747-12.936 2.354-16.684-3.11L2.695 17.336z" />
<g fill="#5DADEC">
<path d="M12 32.042C8 32.042 3.958 28 3.958 24c0-.553-.405-1-.958-1s-1.042.447-1.042 1C1.958 30 6 34.042 12 34.042c.553 0 1-.489 1-1.042s-.447-.958-1-.958z" />
<path d="M7 34c-3 0-5-2-5-5a1 1 0 1 0-2 0c0 4 3 7 7 7a1 1 0 1 0 0-2zM24 2a1 1 0 0 0 0 2c4 0 8 3.589 8 8a1 1 0 0 0 2 0c0-5.514-4-10-10-10z" />
<path d="M29 .042c-.552 0-1 .406-1 .958s.448 1.042 1 1.042c3 0 4.958 2.225 4.958 4.958c0 .552.489 1 1.042 1s.958-.448.958-1C35.958 3.163 33 .042 29 .042z" />
</g>
</svg>
</div> </div>
</div> </div>
</div> </div>
@ -33,3 +27,5 @@ export default () => {
</section> </section>
) )
} }
export default Description

View File

@ -1,4 +1,5 @@
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'
import './Footer.scss' import './Footer.scss'
const Footer = ({ title }) => { const Footer = ({ title }) => {
@ -61,3 +62,11 @@ const Footer = ({ title }) => {
} }
export default Footer export default Footer
Footer.propTypes = {
title: PropTypes.string
}
Footer.defaultProps = {
title: null
}

View File

@ -1,4 +1,5 @@
import React from 'react' import React from 'react'
import PropTypes from 'prop-types'
import { Link } from 'gatsby' import { Link } from 'gatsby'
import ThemeContext from '../../context/ThemeContext' import ThemeContext from '../../context/ThemeContext'
import './Header.scss' import './Header.scss'
@ -88,3 +89,18 @@ const Header = ({ title, menuLinks }) => {
} }
export default Header export default Header
Header.propTypes = {
title: PropTypes.string,
menuLinks: PropTypes.arrayOf(
PropTypes.shape({
link: PropTypes.string,
name: PropTypes.string
})
)
}
Header.defaultProps = {
title: null,
menuLinks: null
}

View File

@ -1,7 +1,7 @@
import React from 'react'; import React from 'react';
import './Newsletter.scss' import './Newsletter.scss'
export default () => { const Newsletter = () => {
return ( return (
<div className="newsletter"> <div className="newsletter">
<div className="newsletter-heading"> <div className="newsletter-heading">
@ -23,3 +23,5 @@ export default () => {
</div> </div>
) )
} }
export default Newsletter

View File

@ -6,7 +6,7 @@ import ViewsIcon from '../../images/views-icon.svg'
import TagIcon from '../../images/tag-icon.svg' import TagIcon from '../../images/tag-icon.svg'
import BooksIcon from '../../images/books-icon.svg' import BooksIcon from '../../images/books-icon.svg'
export default () => { const Offers = () => {
return ( return (
<div className="offers"> <div className="offers">
<div className="offers-popular offer-box"> <div className="offers-popular offer-box">
@ -97,3 +97,5 @@ export default () => {
</div> </div>
) )
} }
export default Offers

View File

@ -18,7 +18,7 @@ const ThemeProvider = ({ children }) => {
} }
React.useEffect(() => { React.useEffect(() => {
if (localStorage.getItem('dark')) { if (localStorage.getItem('dark') || (new Date().getHours() >= 22 || new Date().getHours() <= 6)) {
toggleDarkTheme() toggleDarkTheme()
} }
}, [setIsDark]) }, [setIsDark])

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" focusable="false" width="21px" height="21px" preserveAspectRatio="xMidYMid meet" viewBox="0 0 36 36" style="transform: rotate(360deg);"><path fill="#EF9645" d="M4.861 9.147c.94-.657 2.357-.531 3.201.166l-.968-1.407c-.779-1.111-.5-2.313.612-3.093c1.112-.777 4.263 1.312 4.263 1.312c-.786-1.122-.639-2.544.483-3.331a2.483 2.483 0 0 1 3.456.611l10.42 14.72L25 31l-11.083-4.042L4.25 12.625a2.495 2.495 0 0 1 .611-3.478z"></path><path fill="#FFDC5D" d="M2.695 17.336s-1.132-1.65.519-2.781c1.649-1.131 2.78.518 2.78.518l5.251 7.658c.181-.302.379-.6.6-.894L4.557 11.21s-1.131-1.649.519-2.78c1.649-1.131 2.78.518 2.78.518l6.855 9.997c.255-.208.516-.417.785-.622L7.549 6.732s-1.131-1.649.519-2.78c1.649-1.131 2.78.518 2.78.518l7.947 11.589c.292-.179.581-.334.871-.498L12.238 4.729s-1.131-1.649.518-2.78c1.649-1.131 2.78.518 2.78.518l7.854 11.454l1.194 1.742c-4.948 3.394-5.419 9.779-2.592 13.902c.565.825 1.39.26 1.39.26c-3.393-4.949-2.357-10.51 2.592-13.903L24.515 8.62s-.545-1.924 1.378-2.47c1.924-.545 2.47 1.379 2.47 1.379l1.685 5.004c.668 1.984 1.379 3.961 2.32 5.831c2.657 5.28 1.07 11.842-3.94 15.279c-5.465 3.747-12.936 2.354-16.684-3.11L2.695 17.336z"></path><g fill="#5DADEC"><path d="M12 32.042C8 32.042 3.958 28 3.958 24c0-.553-.405-1-.958-1s-1.042.447-1.042 1C1.958 30 6 34.042 12 34.042c.553 0 1-.489 1-1.042s-.447-.958-1-.958z"></path><path d="M7 34c-3 0-5-2-5-5a1 1 0 1 0-2 0c0 4 3 7 7 7a1 1 0 1 0 0-2zM24 2a1 1 0 0 0 0 2c4 0 8 3.589 8 8a1 1 0 0 0 2 0c0-5.514-4-10-10-10z"></path><path d="M29 .042c-.552 0-1 .406-1 .958s.448 1.042 1 1.042c3 0 4.958 2.225 4.958 4.958c0 .552.489 1 1.042 1s.958-.448.958-1C35.958 3.163 33 .042 29 .042z"></path></g></svg>

After

Width:  |  Height:  |  Size: 1.7 KiB