From 19ae1537d94c9c6cad7aedecbf45ff82d87b4cae Mon Sep 17 00:00:00 2001 From: Pavel Grinchenko Date: Wed, 1 Apr 2020 14:19:05 +0300 Subject: [PATCH 01/51] Move blog's components under Blog namespace --- .../{BlogFeed => Blog/Feed}/Item/index.tsx | 14 +++++------ .../Feed}/Item/placeholder.svg | 0 .../Feed}/Item/styles.module.css | 0 .../{BlogFeed => Blog/Feed}/index.tsx | 12 +++++----- .../{BlogFeed => Blog/Feed}/styles.module.css | 0 .../{BlogFeedMeta => Blog/FeedMeta}/index.tsx | 8 +++---- .../FeedMeta}/styles.module.css | 0 .../{BlogHome => Blog/Home}/index.tsx | 14 +++++------ .../{BlogLayout => Blog/Layout}/index.tsx | 8 +++---- .../Layout}/styles.module.css | 0 .../{BlogPost => Blog/Post}/HeroPic/index.tsx | 4 ++-- .../Post}/HeroPic/styles.module.css | 0 .../Post}/Markdown/index.tsx | 0 .../Post}/Markdown/styles.module.css | 0 .../Post}/Share/icons/facebook.svg | 0 .../Post}/Share/icons/subscribe.svg | 0 .../Post}/Share/icons/twitter.svg | 0 .../{BlogPost => Blog/Post}/Share/index.tsx | 2 +- .../Post}/Share/styles.module.css | 0 .../{BlogPost => Blog/Post}/Tooltip/index.tsx | 0 .../Post}/Tooltip/styles.module.css | 0 .../{BlogPost => Blog/Post}/index.tsx | 24 +++++++++---------- .../{BlogPost => Blog/Post}/styles.module.css | 0 .../{BlogTags => Blog/Tags}/index.tsx | 14 +++++------ src/components/Page/index.tsx | 4 ++-- src/templates/blog-home.tsx | 4 ++-- src/templates/blog-post.tsx | 4 ++-- src/templates/blog-tags.tsx | 4 ++-- 28 files changed, 58 insertions(+), 58 deletions(-) rename src/components/{BlogFeed => Blog/Feed}/Item/index.tsx (93%) rename src/components/{BlogFeed => Blog/Feed}/Item/placeholder.svg (100%) rename src/components/{BlogFeed => Blog/Feed}/Item/styles.module.css (100%) rename src/components/{BlogFeed => Blog/Feed}/index.tsx (83%) rename src/components/{BlogFeed => Blog/Feed}/styles.module.css (100%) rename src/components/{BlogFeedMeta => Blog/FeedMeta}/index.tsx (86%) rename src/components/{BlogFeedMeta => Blog/FeedMeta}/styles.module.css (100%) rename src/components/{BlogHome => Blog/Home}/index.tsx (67%) rename src/components/{BlogLayout => Blog/Layout}/index.tsx (80%) rename src/components/{BlogLayout => Blog/Layout}/styles.module.css (100%) rename src/components/{BlogPost => Blog/Post}/HeroPic/index.tsx (93%) rename src/components/{BlogPost => Blog/Post}/HeroPic/styles.module.css (100%) rename src/components/{BlogPost => Blog/Post}/Markdown/index.tsx (100%) rename src/components/{BlogPost => Blog/Post}/Markdown/styles.module.css (100%) rename src/components/{BlogPost => Blog/Post}/Share/icons/facebook.svg (100%) rename src/components/{BlogPost => Blog/Post}/Share/icons/subscribe.svg (100%) rename src/components/{BlogPost => Blog/Post}/Share/icons/twitter.svg (100%) rename src/components/{BlogPost => Blog/Post}/Share/index.tsx (98%) rename src/components/{BlogPost => Blog/Post}/Share/styles.module.css (100%) rename src/components/{BlogPost => Blog/Post}/Tooltip/index.tsx (100%) rename src/components/{BlogPost => Blog/Post}/Tooltip/styles.module.css (100%) rename src/components/{BlogPost => Blog/Post}/index.tsx (85%) rename src/components/{BlogPost => Blog/Post}/styles.module.css (100%) rename src/components/{BlogTags => Blog/Tags}/index.tsx (53%) diff --git a/src/components/BlogFeed/Item/index.tsx b/src/components/Blog/Feed/Item/index.tsx similarity index 93% rename from src/components/BlogFeed/Item/index.tsx rename to src/components/Blog/Feed/Item/index.tsx index acffe4e7cb..23a646cdf3 100644 --- a/src/components/BlogFeed/Item/index.tsx +++ b/src/components/Blog/Feed/Item/index.tsx @@ -1,17 +1,17 @@ import React, { useEffect, useRef } from 'react' import { useRafState, useWindowSize } from 'react-use' import { graphql } from 'gatsby' -import Link from '../../Link' +import Link from '../../../Link' import Image, { FixedObject, FluidObject } from 'gatsby-image' import cn from 'classnames' -import BlogFeedMeta from '../../BlogFeedMeta' +import FeedMeta from '../../FeedMeta' import styles from './styles.module.css' import { ReactComponent as Placeholder } from './placeholder.svg' -export interface IBlogFeedPostData { +export interface IBlogPostData { id: string timeToRead: string fields: { @@ -45,10 +45,10 @@ export interface IBlogFeedPostData { interface IBlogFeedItemProps { big?: boolean - feedPost: IBlogFeedPostData + feedPost: IBlogPostData } -const BlogFeedItem: React.SFC = ({ +const Item: React.SFC = ({ big, feedPost: { fields, frontmatter, timeToRead } }) => { @@ -97,7 +97,7 @@ const BlogFeedItem: React.SFC = ({
{description}
- } @@ -23,7 +23,7 @@ interface IBlogFeedProps { pageInfo: IPaginatorPageInfo } -const BlogFeed: React.SFC = ({ +const Feed: React.SFC = ({ feedPostList: { edges }, pageInfo, bigFirst = true, @@ -42,7 +42,7 @@ const BlogFeed: React.SFC = ({
{edges.map(({ node }, index) => ( - = ({ +const FeedMeta: React.SFC = ({ avatar, commentsUrl, commentsCount, @@ -47,4 +47,4 @@ const BlogFeedMeta: React.SFC = ({ ) } -export default BlogFeedMeta +export default FeedMeta diff --git a/src/components/BlogFeedMeta/styles.module.css b/src/components/Blog/FeedMeta/styles.module.css similarity index 100% rename from src/components/BlogFeedMeta/styles.module.css rename to src/components/Blog/FeedMeta/styles.module.css diff --git a/src/components/BlogHome/index.tsx b/src/components/Blog/Home/index.tsx similarity index 67% rename from src/components/BlogHome/index.tsx rename to src/components/Blog/Home/index.tsx index 551ddb620e..7cd1ed32c6 100644 --- a/src/components/BlogHome/index.tsx +++ b/src/components/Blog/Home/index.tsx @@ -1,20 +1,20 @@ import React from 'react' -import { IPaginatorPageInfo } from '../Paginator' -import PageContent from '../PageContent' -import BlogFeed, { IBlogFeedPostList } from '../BlogFeed' -import Subscribe from '../Subscribe' +import { IPaginatorPageInfo } from '../../Paginator' +import PageContent from '../../PageContent' +import Feed, { IBlogFeedPostList } from '../Feed' +import Subscribe from '../../Subscribe' interface IBlogHomeProps { posts: IBlogFeedPostList pageInfo: IPaginatorPageInfo } -const BlogHome: React.SFC = ({ posts, pageInfo }) => { +const Home: React.SFC = ({ posts, pageInfo }) => { return ( <> - = ({ posts, pageInfo }) => { ) } -export default BlogHome +export default Home diff --git a/src/components/BlogLayout/index.tsx b/src/components/Blog/Layout/index.tsx similarity index 80% rename from src/components/BlogLayout/index.tsx rename to src/components/Blog/Layout/index.tsx index bf1f5907ae..8371ea95b6 100644 --- a/src/components/BlogLayout/index.tsx +++ b/src/components/Blog/Layout/index.tsx @@ -1,6 +1,6 @@ import React from 'react' -import SEO from '../SEO' -import MainLayout, { LayoutComponent } from '../MainLayout' +import SEO from '../../SEO' +import MainLayout, { LayoutComponent } from '../../MainLayout' import styles from './styles.module.css' @@ -9,7 +9,7 @@ const keywords = const description = 'Data Version Control Blog. We write about machine learning workflow. From data versioning and processing to model productionization. We share our news, findings, interesting reads, community takeaways.' -const BlogLayout: LayoutComponent = ({ children, ...restProps }) => ( +const Layout: LayoutComponent = ({ children, ...restProps }) => ( ( ) -export default BlogLayout +export default Layout diff --git a/src/components/BlogLayout/styles.module.css b/src/components/Blog/Layout/styles.module.css similarity index 100% rename from src/components/BlogLayout/styles.module.css rename to src/components/Blog/Layout/styles.module.css diff --git a/src/components/BlogPost/HeroPic/index.tsx b/src/components/Blog/Post/HeroPic/index.tsx similarity index 93% rename from src/components/BlogPost/HeroPic/index.tsx rename to src/components/Blog/Post/HeroPic/index.tsx index 5be49f95e5..b296a4625d 100644 --- a/src/components/BlogPost/HeroPic/index.tsx +++ b/src/components/Blog/Post/HeroPic/index.tsx @@ -1,11 +1,11 @@ import Image from 'gatsby-image' import React from 'react' -import { BLOG } from '../../../consts' +import { BLOG } from '../../../../consts' import { IBlogPostHeroPic, IGatsbyImageProps -} from '../../../templates/blog-post' +} from '../../../../templates/blog-post' import styles from './styles.module.css' diff --git a/src/components/BlogPost/HeroPic/styles.module.css b/src/components/Blog/Post/HeroPic/styles.module.css similarity index 100% rename from src/components/BlogPost/HeroPic/styles.module.css rename to src/components/Blog/Post/HeroPic/styles.module.css diff --git a/src/components/BlogPost/Markdown/index.tsx b/src/components/Blog/Post/Markdown/index.tsx similarity index 100% rename from src/components/BlogPost/Markdown/index.tsx rename to src/components/Blog/Post/Markdown/index.tsx diff --git a/src/components/BlogPost/Markdown/styles.module.css b/src/components/Blog/Post/Markdown/styles.module.css similarity index 100% rename from src/components/BlogPost/Markdown/styles.module.css rename to src/components/Blog/Post/Markdown/styles.module.css diff --git a/src/components/BlogPost/Share/icons/facebook.svg b/src/components/Blog/Post/Share/icons/facebook.svg similarity index 100% rename from src/components/BlogPost/Share/icons/facebook.svg rename to src/components/Blog/Post/Share/icons/facebook.svg diff --git a/src/components/BlogPost/Share/icons/subscribe.svg b/src/components/Blog/Post/Share/icons/subscribe.svg similarity index 100% rename from src/components/BlogPost/Share/icons/subscribe.svg rename to src/components/Blog/Post/Share/icons/subscribe.svg diff --git a/src/components/BlogPost/Share/icons/twitter.svg b/src/components/Blog/Post/Share/icons/twitter.svg similarity index 100% rename from src/components/BlogPost/Share/icons/twitter.svg rename to src/components/Blog/Post/Share/icons/twitter.svg diff --git a/src/components/BlogPost/Share/index.tsx b/src/components/Blog/Post/Share/index.tsx similarity index 98% rename from src/components/BlogPost/Share/index.tsx rename to src/components/Blog/Post/Share/index.tsx index 4503bafa95..f6b8a75efd 100644 --- a/src/components/BlogPost/Share/index.tsx +++ b/src/components/Blog/Post/Share/index.tsx @@ -1,7 +1,7 @@ import { graphql, useStaticQuery } from 'gatsby' import React, { useCallback } from 'react' -import Link from '../../Link' +import Link from '../../../Link' import Tooltip from '../Tooltip' import { ReactComponent as Facebook } from './icons/facebook.svg' diff --git a/src/components/BlogPost/Share/styles.module.css b/src/components/Blog/Post/Share/styles.module.css similarity index 100% rename from src/components/BlogPost/Share/styles.module.css rename to src/components/Blog/Post/Share/styles.module.css diff --git a/src/components/BlogPost/Tooltip/index.tsx b/src/components/Blog/Post/Tooltip/index.tsx similarity index 100% rename from src/components/BlogPost/Tooltip/index.tsx rename to src/components/Blog/Post/Tooltip/index.tsx diff --git a/src/components/BlogPost/Tooltip/styles.module.css b/src/components/Blog/Post/Tooltip/styles.module.css similarity index 100% rename from src/components/BlogPost/Tooltip/styles.module.css rename to src/components/Blog/Post/Tooltip/styles.module.css diff --git a/src/components/BlogPost/index.tsx b/src/components/Blog/Post/index.tsx similarity index 85% rename from src/components/BlogPost/index.tsx rename to src/components/Blog/Post/index.tsx index 369f0149b2..9eb7686ae3 100644 --- a/src/components/BlogPost/index.tsx +++ b/src/components/Blog/Post/index.tsx @@ -3,24 +3,24 @@ import cn from 'classnames' import React, { useMemo, useRef } from 'react' import { useWindowScroll, useWindowSize } from 'react-use' -import { IBlogPostData } from '../../templates/blog-post' +import { IBlogPostData } from '../../../templates/blog-post' -import { useCommentsCount } from '../../utils/api' -import { pluralizeComments } from '../../utils/i18n' -import tagToSlug from '../../utils/tagToSlug' +import { useCommentsCount } from '../../../utils/api' +import { pluralizeComments } from '../../../utils/i18n' +import tagToSlug from '../../../utils/tagToSlug' import Markdown from './Markdown' -import BlogFeedMeta from '../BlogFeedMeta' -import Link from '../Link' -import PseudoButton from '../PseudoButton' +import FeedMeta from '../FeedMeta' +import Link from '../../Link' +import PseudoButton from '../../PseudoButton' import HeroPic from './HeroPic' import Share from './Share' -import PageContent from '../PageContent' -import Subscribe from '../Subscribe' +import PageContent from '../../PageContent' +import Subscribe from '../../Subscribe' import styles from './styles.module.css' -const BlogPost: React.SFC = ({ +const Post: React.SFC = ({ html, timeToRead, frontmatter, @@ -80,7 +80,7 @@ const BlogPost: React.SFC = ({ ) : (
{description}
)} - = ({ ) } -export default BlogPost +export default Post diff --git a/src/components/BlogPost/styles.module.css b/src/components/Blog/Post/styles.module.css similarity index 100% rename from src/components/BlogPost/styles.module.css rename to src/components/Blog/Post/styles.module.css diff --git a/src/components/BlogTags/index.tsx b/src/components/Blog/Tags/index.tsx similarity index 53% rename from src/components/BlogTags/index.tsx rename to src/components/Blog/Tags/index.tsx index bd1f411f73..3039c3125f 100644 --- a/src/components/BlogTags/index.tsx +++ b/src/components/Blog/Tags/index.tsx @@ -1,9 +1,9 @@ import React from 'react' -import { IPaginatorPageInfo } from '../Paginator' -import PageContent from '../PageContent' -import BlogFeed, { IBlogFeedPostList } from '../BlogFeed' -import Subscribe from '../Subscribe' +import { IPaginatorPageInfo } from '../../Paginator' +import PageContent from '../../PageContent' +import Feed, { IBlogFeedPostList } from '../Feed' +import Subscribe from '../../Subscribe' interface IBlogTagsProps { posts: IBlogFeedPostList @@ -11,11 +11,11 @@ interface IBlogTagsProps { header: string } -const BlogTags: React.SFC = ({ posts, pageInfo, header }) => { +const Tags: React.SFC = ({ posts, pageInfo, header }) => { return ( <> - = ({ posts, pageInfo, header }) => { ) } -export default BlogTags +export default Tags diff --git a/src/components/Page/index.tsx b/src/components/Page/index.tsx index 33df66a96b..f5c6150950 100644 --- a/src/components/Page/index.tsx +++ b/src/components/Page/index.tsx @@ -4,7 +4,7 @@ import { GlobalStyle } from '../../styles' import MainLayout, { LayoutComponent } from '../MainLayout' import DefaultSEO from './DefaultSEO' import DocumentationLayout from '../Documentation/Layout' -import BlogLayout from '../BlogLayout' +import Layout from '../Blog/Layout' import { useRedirects, useAnchorNavigation, useSmoothScroll } from './utils' @@ -40,7 +40,7 @@ const Page: React.SFC = props => { if (props.pageContext.isDocs) { LayoutComponent = DocumentationLayout as LayoutComponent } else if (props.pageContext.isBlog) { - LayoutComponent = BlogLayout + LayoutComponent = Layout } } diff --git a/src/templates/blog-home.tsx b/src/templates/blog-home.tsx index e87863d23a..2dd5fe7556 100644 --- a/src/templates/blog-home.tsx +++ b/src/templates/blog-home.tsx @@ -5,9 +5,9 @@ import { IPaginatorLocationContextValue, PaginatorLocationContext } from '../components/Paginator/LocationContext' -import BlogHome from '../components/BlogHome' +import BlogHome from '../components/Blog/Home' import { IPaginatorPageInfo } from '../components/Paginator' -import { IBlogFeedPostList } from '../components/BlogFeed' +import { IBlogFeedPostList } from '../components/Blog/Feed' interface IBlogHomePageProps { data: { posts: IBlogFeedPostList } diff --git a/src/templates/blog-post.tsx b/src/templates/blog-post.tsx index 6fb930c868..86fa915818 100644 --- a/src/templates/blog-post.tsx +++ b/src/templates/blog-post.tsx @@ -4,7 +4,7 @@ import { graphql } from 'gatsby' import React from 'react' import SEO from '../components/SEO' -import BlogPost from '../components/BlogPost' +import Post from '../components/Blog/Post' interface IFluidObject extends FluidObject { presentationWidth?: number @@ -86,7 +86,7 @@ const BlogPostPage: React.SFC = ({ data }) => { post.frontmatter.picture.childImageSharp.fluid.src } /> - + ) } diff --git a/src/templates/blog-tags.tsx b/src/templates/blog-tags.tsx index 21b5620c65..f8aae1db7b 100644 --- a/src/templates/blog-tags.tsx +++ b/src/templates/blog-tags.tsx @@ -8,8 +8,8 @@ import { } from '../components/Paginator/LocationContext' import SEO from '../components/SEO' import { IPaginatorPageInfo } from '../components/Paginator' -import BlogTags from '../components/BlogTags' -import { IBlogFeedPostList } from '../components/BlogFeed' +import BlogTags from '../components/Blog/Tags' +import { IBlogFeedPostList } from '../components/Blog/Feed' interface IBlogTagsPageData { data: { posts: IBlogFeedPostList } From 5edd0de26733522b955ed6935dff03b257bc862c Mon Sep 17 00:00:00 2001 From: Pavel Grinchenko Date: Wed, 1 Apr 2020 14:35:55 +0300 Subject: [PATCH 02/51] Restructure components --- src/components/Blog/Home/index.tsx | 4 +- src/components/Blog/Post/index.tsx | 4 +- src/components/Blog/Tags/index.tsx | 4 +- src/components/Community/index.js | 4 +- .../Layout}/SearchForm/index.js | 2 +- .../Layout}/SearchForm/styles.js | 2 +- src/components/Documentation/Layout/index.js | 6 +- .../{ => Features}/FeaturesHero/index.js | 0 .../{ => Features}/FeaturesHero/styles.js | 0 src/components/Features/index.js | 8 +- .../{Hamburger => HamburgerIcon}/index.tsx | 2 +- .../styles.module.css | 0 src/components/HamburgerMenu/index.tsx | 4 +- src/components/{Hero => HeroSection}/index.js | 4 +- .../{Hero => HeroSection}/styles.js | 0 src/components/{ => Home}/Diagram/index.js | 4 +- src/components/{ => Home}/Diagram/styles.js | 2 +- .../LandingHero}/GithubLine/index.js | 2 +- .../LandingHero}/GithubLine/styles.js | 0 .../{ => Home}/LandingHero/index.js | 8 +- .../{ => Home}/LandingHero/styles.js | 2 +- src/components/{ => Home}/LearnMore/index.js | 2 +- src/components/{ => Home}/LearnMore/styles.js | 2 +- .../{ => Home}/PromoSection/index.js | 4 +- .../{ => Home}/PromoSection/styles.js | 2 +- .../{ => Home/UseCases}/TextCollapse/index.js | 0 .../UseCases}/TextCollapse/styles.js | 0 .../{ => Home/UseCases}/Video/index.js | 2 +- .../{ => Home/UseCases}/Video/styles.js | 0 src/components/{ => Home}/UseCases/index.js | 6 +- src/components/{ => Home}/UseCases/styles.js | 2 +- src/components/Home/index.js | 20 +-- .../{ => LayoutHeader}/Nav/index.tsx | 8 +- .../{ => LayoutHeader}/Nav/styles.module.css | 0 src/components/LayoutHeader/index.tsx | 2 +- .../form => SubscribeSection/Form}/index.tsx | 0 .../Form}/styles.module.css | 0 .../glyph-1.svg | 0 .../glyph-2.svg | 0 .../{Subscribe => SubscribeSection}/index.tsx | 4 +- .../styles.module.css | 0 src/components/{ => Support}/Popover/index.js | 0 .../{ => Support}/Popover/styles.js | 0 src/components/Support/index.js | 8 +- src/components/TextRotate/index.js | 132 ------------------ src/components/TextRotate/styles.js | 7 - .../{ => Tooltip/MobileView}/Modal/index.js | 0 src/components/Tooltip/MobileView/index.js | 2 +- 48 files changed, 63 insertions(+), 202 deletions(-) rename src/components/{ => Documentation/Layout}/SearchForm/index.js (95%) rename src/components/{ => Documentation/Layout}/SearchForm/styles.js (95%) rename src/components/{ => Features}/FeaturesHero/index.js (100%) rename src/components/{ => Features}/FeaturesHero/styles.js (100%) rename src/components/{Hamburger => HamburgerIcon}/index.tsx (85%) rename src/components/{Hamburger => HamburgerIcon}/styles.module.css (100%) rename src/components/{Hero => HeroSection}/index.js (75%) rename src/components/{Hero => HeroSection}/styles.js (100%) rename src/components/{ => Home}/Diagram/index.js (98%) rename src/components/{ => Home}/Diagram/styles.js (97%) rename src/components/{ => Home/LandingHero}/GithubLine/index.js (95%) rename src/components/{ => Home/LandingHero}/GithubLine/styles.js (100%) rename src/components/{ => Home}/LandingHero/index.js (93%) rename src/components/{ => Home}/LandingHero/styles.js (98%) rename src/components/{ => Home}/LearnMore/index.js (92%) rename src/components/{ => Home}/LearnMore/styles.js (96%) rename src/components/{ => Home}/PromoSection/index.js (92%) rename src/components/{ => Home}/PromoSection/styles.js (98%) rename src/components/{ => Home/UseCases}/TextCollapse/index.js (100%) rename src/components/{ => Home/UseCases}/TextCollapse/styles.js (100%) rename src/components/{ => Home/UseCases}/Video/index.js (97%) rename src/components/{ => Home/UseCases}/Video/styles.js (100%) rename src/components/{ => Home}/UseCases/index.js (95%) rename src/components/{ => Home}/UseCases/styles.js (96%) rename src/components/{ => LayoutHeader}/Nav/index.tsx (94%) rename src/components/{ => LayoutHeader}/Nav/styles.module.css (100%) rename src/components/{Subscribe/form => SubscribeSection/Form}/index.tsx (100%) rename src/components/{Subscribe/form => SubscribeSection/Form}/styles.module.css (100%) rename src/components/{Subscribe => SubscribeSection}/glyph-1.svg (100%) rename src/components/{Subscribe => SubscribeSection}/glyph-2.svg (100%) rename src/components/{Subscribe => SubscribeSection}/index.tsx (90%) rename src/components/{Subscribe => SubscribeSection}/styles.module.css (100%) rename src/components/{ => Support}/Popover/index.js (100%) rename src/components/{ => Support}/Popover/styles.js (100%) delete mode 100644 src/components/TextRotate/index.js delete mode 100644 src/components/TextRotate/styles.js rename src/components/{ => Tooltip/MobileView}/Modal/index.js (100%) diff --git a/src/components/Blog/Home/index.tsx b/src/components/Blog/Home/index.tsx index 7cd1ed32c6..5d3c2d9610 100644 --- a/src/components/Blog/Home/index.tsx +++ b/src/components/Blog/Home/index.tsx @@ -3,7 +3,7 @@ import React from 'react' import { IPaginatorPageInfo } from '../../Paginator' import PageContent from '../../PageContent' import Feed, { IBlogFeedPostList } from '../Feed' -import Subscribe from '../../Subscribe' +import SubscribeSection from '../../SubscribeSection' interface IBlogHomeProps { posts: IBlogFeedPostList @@ -27,7 +27,7 @@ const Home: React.SFC = ({ posts, pageInfo }) => { } /> - + ) } diff --git a/src/components/Blog/Post/index.tsx b/src/components/Blog/Post/index.tsx index 9eb7686ae3..5bcb8cc72c 100644 --- a/src/components/Blog/Post/index.tsx +++ b/src/components/Blog/Post/index.tsx @@ -16,7 +16,7 @@ import PseudoButton from '../../PseudoButton' import HeroPic from './HeroPic' import Share from './Share' import PageContent from '../../PageContent' -import Subscribe from '../../Subscribe' +import SubscribeSection from '../../SubscribeSection' import styles from './styles.module.css' @@ -123,7 +123,7 @@ const Post: React.SFC = ({ )}
- + ) } diff --git a/src/components/Blog/Tags/index.tsx b/src/components/Blog/Tags/index.tsx index 3039c3125f..1ceacb7374 100644 --- a/src/components/Blog/Tags/index.tsx +++ b/src/components/Blog/Tags/index.tsx @@ -3,7 +3,7 @@ import React from 'react' import { IPaginatorPageInfo } from '../../Paginator' import PageContent from '../../PageContent' import Feed, { IBlogFeedPostList } from '../Feed' -import Subscribe from '../../Subscribe' +import SubscribeSection from '../../SubscribeSection' interface IBlogTagsProps { posts: IBlogFeedPostList @@ -22,7 +22,7 @@ const Tags: React.SFC = ({ posts, pageInfo, header }) => { header={header} /> - + ) } diff --git a/src/components/Community/index.js b/src/components/Community/index.js index e711d01f63..9d59fde4f9 100644 --- a/src/components/Community/index.js +++ b/src/components/Community/index.js @@ -1,6 +1,6 @@ import React from 'react' -import Subscribe from '../Subscribe' +import SubscribeSection from '../SubscribeSection' import CommunityContribute from './Contribute' import CommunityEvents from './Events' @@ -25,7 +25,7 @@ export default function Community() { - + ) diff --git a/src/components/SearchForm/index.js b/src/components/Documentation/Layout/SearchForm/index.js similarity index 95% rename from src/components/SearchForm/index.js rename to src/components/Documentation/Layout/SearchForm/index.js index a97911c835..265d7581ff 100644 --- a/src/components/SearchForm/index.js +++ b/src/components/Documentation/Layout/SearchForm/index.js @@ -1,6 +1,6 @@ import React, { useEffect, useState } from 'react' import Promise from 'promise-polyfill' -import { loadResource } from '../../utils/resources' +import { loadResource } from '../../../../utils/resources' import { SearchArea, Input, Wrapper } from './styles' diff --git a/src/components/SearchForm/styles.js b/src/components/Documentation/Layout/SearchForm/styles.js similarity index 95% rename from src/components/SearchForm/styles.js rename to src/components/Documentation/Layout/SearchForm/styles.js index bc74136b77..9852258104 100644 --- a/src/components/SearchForm/styles.js +++ b/src/components/Documentation/Layout/SearchForm/styles.js @@ -1,6 +1,6 @@ import styled from 'styled-components' -import { media } from '../../styles' +import { media } from '../../../../styles' export const SearchArea = styled.div` box-sizing: border-box; diff --git a/src/components/Documentation/Layout/index.js b/src/components/Documentation/Layout/index.js index abd03e5f2d..a55a87a3e0 100644 --- a/src/components/Documentation/Layout/index.js +++ b/src/components/Documentation/Layout/index.js @@ -1,8 +1,8 @@ import React, { useCallback, useState } from 'react' import PropTypes from 'prop-types' import MainLayout, { LayoutModifiers } from '../../MainLayout' -import Hamburger from '../../Hamburger' -import SearchForm from '../../SearchForm' +import HamburgerIcon from '../../HamburgerIcon' +import SearchForm from './SearchForm' import SidebarMenu from './SidebarMenu' import { Container, Backdrop, Side, SideToggle } from './styles' @@ -25,7 +25,7 @@ function Layout({ children, ...restProps }) { - + diff --git a/src/components/FeaturesHero/index.js b/src/components/Features/FeaturesHero/index.js similarity index 100% rename from src/components/FeaturesHero/index.js rename to src/components/Features/FeaturesHero/index.js diff --git a/src/components/FeaturesHero/styles.js b/src/components/Features/FeaturesHero/styles.js similarity index 100% rename from src/components/FeaturesHero/styles.js rename to src/components/Features/FeaturesHero/styles.js diff --git a/src/components/Features/index.js b/src/components/Features/index.js index b762bbebca..a45b7d0577 100644 --- a/src/components/Features/index.js +++ b/src/components/Features/index.js @@ -1,7 +1,7 @@ import React from 'react' -import Hero from '../Hero' -import FeaturesHero from '../FeaturesHero' +import HeroSection from '../HeroSection' +import FeaturesHero from './FeaturesHero' import TrySection from '../TrySection' import { Container, Description, Feature, Features, Icon, Name } from './styles' @@ -9,9 +9,9 @@ import { Container, Description, Feature, Features, Icon, Name } from './styles' export default function FeaturesPage() { return ( <> - + - + diff --git a/src/components/Hamburger/index.tsx b/src/components/HamburgerIcon/index.tsx similarity index 85% rename from src/components/Hamburger/index.tsx rename to src/components/HamburgerIcon/index.tsx index edb16148f3..3c282963d0 100644 --- a/src/components/Hamburger/index.tsx +++ b/src/components/HamburgerIcon/index.tsx @@ -7,7 +7,7 @@ interface IHamburgetProps { opened: boolean } -export default function Hamburger({ opened }: IHamburgetProps) { +export default function HamburgerIcon({ opened }: IHamburgetProps) { return (
diff --git a/src/components/Hamburger/styles.module.css b/src/components/HamburgerIcon/styles.module.css similarity index 100% rename from src/components/Hamburger/styles.module.css rename to src/components/HamburgerIcon/styles.module.css diff --git a/src/components/HamburgerMenu/index.tsx b/src/components/HamburgerMenu/index.tsx index 1cf412660c..c87a231273 100644 --- a/src/components/HamburgerMenu/index.tsx +++ b/src/components/HamburgerMenu/index.tsx @@ -1,7 +1,7 @@ import cn from 'classnames' import React, { useCallback, useState, useEffect } from 'react' -import Hamburger from '../Hamburger' +import HamburgerIcon from '../HamburgerIcon' import Link from '../Link' import { logEvent } from '../../utils/ga' @@ -44,7 +44,7 @@ function HamburgerMenu() { onClick={toggleMobileMenu} onKeyDown={openOnEnterKey} > - +
diff --git a/src/components/Hero/index.js b/src/components/HeroSection/index.js similarity index 75% rename from src/components/Hero/index.js rename to src/components/HeroSection/index.js index ba7ab7d285..aed299dca0 100644 --- a/src/components/Hero/index.js +++ b/src/components/HeroSection/index.js @@ -3,7 +3,7 @@ import PropTypes from 'prop-types' import { Container, Wrapper } from './styles' -export default function Hero({ children }) { +export default function HeroSection({ children }) { return ( {children} @@ -11,6 +11,6 @@ export default function Hero({ children }) { ) } -Hero.propTypes = { +HeroSection.propTypes = { children: PropTypes.node.isRequired } diff --git a/src/components/Hero/styles.js b/src/components/HeroSection/styles.js similarity index 100% rename from src/components/Hero/styles.js rename to src/components/HeroSection/styles.js diff --git a/src/components/Diagram/index.js b/src/components/Home/Diagram/index.js similarity index 98% rename from src/components/Diagram/index.js rename to src/components/Home/Diagram/index.js index a59448f958..c260b5253f 100644 --- a/src/components/Diagram/index.js +++ b/src/components/Home/Diagram/index.js @@ -8,9 +8,9 @@ import Slider from 'react-slick' import 'slick-carousel/slick/slick.css' import 'slick-carousel/slick/slick-theme.css' -import Link from '../Link' +import Link from '../../Link' -import { OnlyDesktop, OnlyMobile } from '../../styles' +import { OnlyDesktop, OnlyMobile } from '../../../styles' import { Abstract, diff --git a/src/components/Diagram/styles.js b/src/components/Home/Diagram/styles.js similarity index 97% rename from src/components/Diagram/styles.js rename to src/components/Home/Diagram/styles.js index 34ab734608..6eff3415f3 100644 --- a/src/components/Diagram/styles.js +++ b/src/components/Home/Diagram/styles.js @@ -1,6 +1,6 @@ import styled from 'styled-components' -import { column, columns, container, media } from '../../styles' +import { column, columns, container, media } from '../../../styles' export const Diagram = styled.section` padding-top: 80px; diff --git a/src/components/GithubLine/index.js b/src/components/Home/LandingHero/GithubLine/index.js similarity index 95% rename from src/components/GithubLine/index.js rename to src/components/Home/LandingHero/GithubLine/index.js index f9ca7dddaa..9c57b74562 100644 --- a/src/components/GithubLine/index.js +++ b/src/components/Home/LandingHero/GithubLine/index.js @@ -1,5 +1,5 @@ import React, { useEffect, useState } from 'react' -import Link from '../Link' +import Link from '../../../Link' import { Count, Github, Link as LinkSC, Star, Wrapper } from './styles' diff --git a/src/components/GithubLine/styles.js b/src/components/Home/LandingHero/GithubLine/styles.js similarity index 100% rename from src/components/GithubLine/styles.js rename to src/components/Home/LandingHero/GithubLine/styles.js diff --git a/src/components/LandingHero/index.js b/src/components/Home/LandingHero/index.js similarity index 93% rename from src/components/LandingHero/index.js rename to src/components/Home/LandingHero/index.js index e71c64ef32..4fa9710ad6 100644 --- a/src/components/LandingHero/index.js +++ b/src/components/Home/LandingHero/index.js @@ -1,12 +1,12 @@ import React, { Component } from 'react' import { scroller } from 'react-scroll' -import DownloadButton from '../DownloadButton' -import GithubLine from '../GithubLine' +import DownloadButton from '../../DownloadButton' +import GithubLine from './GithubLine' -import { logEvent } from '../../utils/ga' +import { logEvent } from '../../../utils/ga' -import { OnlyDesktop, OnlyMobile } from '../../styles' +import { OnlyDesktop, OnlyMobile } from '../../../styles' import { Wrapper, About, diff --git a/src/components/LandingHero/styles.js b/src/components/Home/LandingHero/styles.js similarity index 98% rename from src/components/LandingHero/styles.js rename to src/components/Home/LandingHero/styles.js index 4f86fb770d..4bebd09ad1 100644 --- a/src/components/LandingHero/styles.js +++ b/src/components/Home/LandingHero/styles.js @@ -1,6 +1,6 @@ import styled, { css } from 'styled-components' -import { media } from '../../styles' +import { media } from '../../../styles' export const Wrapper = styled.div` padding-top: 136px; diff --git a/src/components/LearnMore/index.js b/src/components/Home/LearnMore/index.js similarity index 92% rename from src/components/LearnMore/index.js rename to src/components/Home/LearnMore/index.js index 60f6084c55..efbb200165 100644 --- a/src/components/LearnMore/index.js +++ b/src/components/Home/LearnMore/index.js @@ -1,7 +1,7 @@ import React from 'react' import { scroller } from 'react-scroll' -import { logEvent } from '../../utils/ga' +import { logEvent } from '../../../utils/ga' import { Wrapper, Icon, Caption } from './styles' diff --git a/src/components/LearnMore/styles.js b/src/components/Home/LearnMore/styles.js similarity index 96% rename from src/components/LearnMore/styles.js rename to src/components/Home/LearnMore/styles.js index 73bb565cd2..ea7fd8a65a 100644 --- a/src/components/LearnMore/styles.js +++ b/src/components/Home/LearnMore/styles.js @@ -1,6 +1,6 @@ import styled, { keyframes } from 'styled-components' -import { media } from '../../styles' +import { media } from '../../../styles' export const Wrapper = styled.a` display: flex; diff --git a/src/components/PromoSection/index.js b/src/components/Home/PromoSection/index.js similarity index 92% rename from src/components/PromoSection/index.js rename to src/components/Home/PromoSection/index.js index 74ed013ddd..d882a27872 100644 --- a/src/components/PromoSection/index.js +++ b/src/components/Home/PromoSection/index.js @@ -1,7 +1,7 @@ import React from 'react' -import Link from '../Link' +import Link from '../../Link' -import { logEvent } from '../../utils/ga' +import { logEvent } from '../../../utils/ga' import { Button, Buttons, Container, Glyph, Title, Wrapper } from './styles' diff --git a/src/components/PromoSection/styles.js b/src/components/Home/PromoSection/styles.js similarity index 98% rename from src/components/PromoSection/styles.js rename to src/components/Home/PromoSection/styles.js index 9191df8453..176b05c876 100644 --- a/src/components/PromoSection/styles.js +++ b/src/components/Home/PromoSection/styles.js @@ -1,6 +1,6 @@ import styled from 'styled-components' -import { media } from '../../styles' +import { media } from '../../../styles' export const Wrapper = styled.section` position: relative; diff --git a/src/components/TextCollapse/index.js b/src/components/Home/UseCases/TextCollapse/index.js similarity index 100% rename from src/components/TextCollapse/index.js rename to src/components/Home/UseCases/TextCollapse/index.js diff --git a/src/components/TextCollapse/styles.js b/src/components/Home/UseCases/TextCollapse/styles.js similarity index 100% rename from src/components/TextCollapse/styles.js rename to src/components/Home/UseCases/TextCollapse/styles.js diff --git a/src/components/Video/index.js b/src/components/Home/UseCases/Video/index.js similarity index 97% rename from src/components/Video/index.js rename to src/components/Home/UseCases/Video/index.js index 63df5d1016..9810369ef4 100644 --- a/src/components/Video/index.js +++ b/src/components/Home/UseCases/Video/index.js @@ -1,7 +1,7 @@ import React, { Component } from 'react' import PropTypes from 'prop-types' -import { logEvent } from '../../utils/ga' +import { logEvent } from '../../../../utils/ga' import { Button, diff --git a/src/components/Video/styles.js b/src/components/Home/UseCases/Video/styles.js similarity index 100% rename from src/components/Video/styles.js rename to src/components/Home/UseCases/Video/styles.js diff --git a/src/components/UseCases/index.js b/src/components/Home/UseCases/index.js similarity index 95% rename from src/components/UseCases/index.js rename to src/components/Home/UseCases/index.js index fe173cbc9b..00a8e810c2 100644 --- a/src/components/UseCases/index.js +++ b/src/components/Home/UseCases/index.js @@ -1,10 +1,10 @@ import React from 'react' import { Element } from 'react-scroll' -import { default as YoutubeVideo } from '../Video' -import TextCollapse from '../TextCollapse' +import { default as YoutubeVideo } from './Video' +import TextCollapse from './TextCollapse' -import { OnlyDesktop, OnlyMobile } from '../../styles' +import { OnlyDesktop, OnlyMobile } from '../../../styles' import { Case, diff --git a/src/components/UseCases/styles.js b/src/components/Home/UseCases/styles.js similarity index 96% rename from src/components/UseCases/styles.js rename to src/components/Home/UseCases/styles.js index e57b256827..d82e0bc923 100644 --- a/src/components/UseCases/styles.js +++ b/src/components/Home/UseCases/styles.js @@ -1,6 +1,6 @@ import styled from 'styled-components' -import { container, media } from '../../styles' +import { container, media } from '../../../styles' export const Wrapper = styled.section` padding-top: 80px; diff --git a/src/components/Home/index.js b/src/components/Home/index.js index 331a2affc5..1d60fd4c68 100644 --- a/src/components/Home/index.js +++ b/src/components/Home/index.js @@ -1,29 +1,29 @@ import React from 'react' -import LearnMore from '../LearnMore' -import Hero from '../Hero' -import LandingHero from '../LandingHero' -import Diagram from '../Diagram' -import PromoSection from '../PromoSection' -import UseCases from '../UseCases' -import Subscribe from '../Subscribe' +import LearnMore from './LearnMore' +import HeroSection from '../HeroSection' +import LandingHero from './LandingHero' +import Diagram from './Diagram' +import PromoSection from './PromoSection' +import UseCases from './UseCases' +import SubscribeSection from '../SubscribeSection' import { LearnMoreSection } from './styles' export default function HomePage() { return ( <> - + - + - + ) } diff --git a/src/components/Nav/index.tsx b/src/components/LayoutHeader/Nav/index.tsx similarity index 94% rename from src/components/Nav/index.tsx rename to src/components/LayoutHeader/Nav/index.tsx index 664d1b922f..feb8eca2e7 100644 --- a/src/components/Nav/index.tsx +++ b/src/components/LayoutHeader/Nav/index.tsx @@ -1,11 +1,11 @@ import React from 'react' import cn from 'classnames' -import Link from '../Link' -import PseudoButton from '../PseudoButton' +import Link from '../../Link' +import PseudoButton from '../../PseudoButton' -import { logEvent } from '../../utils/ga' -import { getFirstPage } from '../../utils/sidebar' +import { logEvent } from '../../../utils/ga' +import { getFirstPage } from '../../../utils/sidebar' const docsPage = getFirstPage() diff --git a/src/components/Nav/styles.module.css b/src/components/LayoutHeader/Nav/styles.module.css similarity index 100% rename from src/components/Nav/styles.module.css rename to src/components/LayoutHeader/Nav/styles.module.css diff --git a/src/components/LayoutHeader/index.tsx b/src/components/LayoutHeader/index.tsx index 4d4b4e6656..470a73dc93 100644 --- a/src/components/LayoutHeader/index.tsx +++ b/src/components/LayoutHeader/index.tsx @@ -5,7 +5,7 @@ import { useWindowScroll } from 'react-use' import { LayoutModifiers, ILayoutModifiable } from '../MainLayout' import LayoutWidthContainer from '../LayoutWidthContainer' import Link from '../Link' -import Nav from '../Nav' +import Nav from './Nav' import { ReactComponent as LogoSVG } from '../../../static/img/logo.svg' import styles from './styles.module.css' diff --git a/src/components/Subscribe/form/index.tsx b/src/components/SubscribeSection/Form/index.tsx similarity index 100% rename from src/components/Subscribe/form/index.tsx rename to src/components/SubscribeSection/Form/index.tsx diff --git a/src/components/Subscribe/form/styles.module.css b/src/components/SubscribeSection/Form/styles.module.css similarity index 100% rename from src/components/Subscribe/form/styles.module.css rename to src/components/SubscribeSection/Form/styles.module.css diff --git a/src/components/Subscribe/glyph-1.svg b/src/components/SubscribeSection/glyph-1.svg similarity index 100% rename from src/components/Subscribe/glyph-1.svg rename to src/components/SubscribeSection/glyph-1.svg diff --git a/src/components/Subscribe/glyph-2.svg b/src/components/SubscribeSection/glyph-2.svg similarity index 100% rename from src/components/Subscribe/glyph-2.svg rename to src/components/SubscribeSection/glyph-2.svg diff --git a/src/components/Subscribe/index.tsx b/src/components/SubscribeSection/index.tsx similarity index 90% rename from src/components/Subscribe/index.tsx rename to src/components/SubscribeSection/index.tsx index 9efdae5f16..52bb7b11c5 100644 --- a/src/components/Subscribe/index.tsx +++ b/src/components/SubscribeSection/index.tsx @@ -6,9 +6,9 @@ import styles from './styles.module.css' import { default as Glyph1Src } from './glyph-1.svg' import { default as Glyph2Src } from './glyph-2.svg' -import SubscribeForm from './form' +import SubscribeForm from './Form' -export default function Subscribe() { +export default function SubscribeSection() { return (
- + Questions, feedback, or just need to get in touch? - + diff --git a/src/components/TextRotate/index.js b/src/components/TextRotate/index.js deleted file mode 100644 index a4c4f1a50b..0000000000 --- a/src/components/TextRotate/index.js +++ /dev/null @@ -1,132 +0,0 @@ -import React, { Component } from 'react' -import PropTypes from 'prop-types' - -import { Cursor, Wrapper } from './styles' - -export default class TextRotate extends Component { - static defaultProps = { - words: [], - delay: 80, - wordDelay: 1000, - textBefore: ``, - textAfter: `` - } - - state = { - ready: false, - currentWordIndex: 0, - pos: 1, - length: 0, - grow: true, - timer: null - } - - componentDidMount() { - this.initTimer() - this.setState({ - grow: true, - ready: true - }) - } - - componentWillUnmount() { - this.deinitTimer() - } - - initTimer() { - const word = this.props.words[this.state.currentWordIndex] - - this.setState({ - pos: word.length, - grow: false - }) - - setTimeout(() => { - const timer = setInterval(this.animate, this.props.delay) - this.setState({ - timer - }) - }, this.props.wordDelay) - } - - deinitTimer() { - clearTimeout(this.state.timer) - } - - animate = () => { - if ( - this.state.pos === this.props.words[this.state.currentWordIndex].length - ) { - this.setState( - prevState => ({ - grow: !prevState.grow - }), - () => { - if (!this.state.grow) { - clearInterval(this.state.timer) - this.initTimer() - } - } - ) - } - - if (!this.state.grow && this.state.pos === 0) { - return this.nextWord() - } - - if (this.state.grow) { - this.setState(prevState => ({ - pos: prevState.pos + 1 - })) - } else { - this.setState(prevState => ({ - pos: prevState.pos - 1 - })) - } - } - - nextWord = () => { - let nextWordIndex = this.state.currentWordIndex + 1 - if (nextWordIndex > this.props.words.length - 1) { - nextWordIndex = 0 - } - - this.setState(() => ({ - currentWordIndex: nextWordIndex, - pos: 0, - grow: true - })) - } - - getCurrentWord() { - const currentWord = this.props.words[this.state.currentWordIndex] - - if (!this.state.ready) return currentWord - - return currentWord.slice(0, this.state.pos + 1) - } - - render() { - const { textBefore, textAfter } = this.props - const word = this.getCurrentWord() - - return ( - -

{textBefore}

{' '} -

- {word} - |{' '} -

-

{textAfter}

-
- ) - } -} - -TextRotate.propTypes = { - textBefore: PropTypes.string.isRequired, - textAfter: PropTypes.string.isRequired, - delay: PropTypes.number.isRequired, - words: PropTypes.arrayOf(PropTypes.string).isRequired, - wordDelay: PropTypes.number.isRequired -} diff --git a/src/components/TextRotate/styles.js b/src/components/TextRotate/styles.js deleted file mode 100644 index a2f9d74350..0000000000 --- a/src/components/TextRotate/styles.js +++ /dev/null @@ -1,7 +0,0 @@ -import styled from 'styled-components' - -export const Wrapper = styled.span`` - -export const Cursor = styled.span` - vertical-align: 4px; -` diff --git a/src/components/Modal/index.js b/src/components/Tooltip/MobileView/Modal/index.js similarity index 100% rename from src/components/Modal/index.js rename to src/components/Tooltip/MobileView/Modal/index.js diff --git a/src/components/Tooltip/MobileView/index.js b/src/components/Tooltip/MobileView/index.js index 37f106b407..b12d8ef243 100644 --- a/src/components/Tooltip/MobileView/index.js +++ b/src/components/Tooltip/MobileView/index.js @@ -2,7 +2,7 @@ import React, { Component } from 'react' import ReactMarkdown from 'react-markdown' import PropTypes from 'prop-types' -import Modal from '../../Modal' +import Modal from './Modal' import { CloseContainer, From 421dae74f643658b85db79fae8c148e4e7164dbd Mon Sep 17 00:00:00 2001 From: Pavel Grinchenko Date: Wed, 1 Apr 2020 17:25:24 +0300 Subject: [PATCH 03/51] Allow to scroll smoothly in the scrollIntoLayout util function --- package.json | 2 ++ src/typings.ts | 24 ++++++++++++++++++++++++ src/utils/scroll.ts | 25 +++++++++++++++++++++++-- yarn.lock | 10 ++++++++++ 4 files changed, 59 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 316479f009..f00e56aae4 100644 --- a/package.json +++ b/package.json @@ -44,6 +44,7 @@ "compression": "^1.7.4", "date-fns": "^2.8.1", "docsearch.js": "^2.6.3", + "ease-component": "^1.0.0", "express": "^4.17.1", "fs-extra": "^9.0.0", "gatsby": "^2.20.2", @@ -79,6 +80,7 @@ "rehype-react": "^4.0.1", "request": "^2.88.0", "s3-client": "^4.4.2", + "scroll": "^3.0.1", "serve-handler": "^6.1.2", "slick-carousel": "^1.8.1", "styled-components": "^4.4.1", diff --git a/src/typings.ts b/src/typings.ts index 4ca841c123..ad8acd1c1d 100644 --- a/src/typings.ts +++ b/src/typings.ts @@ -21,3 +21,27 @@ declare module '*.svg' { const svg: IReactSVGR export = svg } + +declare module 'scroll' { + type ScrollTo = ( + node: HTMLElement, + position: number, + options: {}, + cb?: (err: Error | null, position: number) => void + ) => () => void + type ScrollModule = { + left: ScrollTo + top: ScrollTo + } + const scroll: ScrollModule + export = scroll +} + +declare module 'ease-component' { + type EaseFunction = (value: number) => number + type EaseModule = { + [key: string]: EaseFunction + } + const ease: EaseModule + export = ease +} diff --git a/src/utils/scroll.ts b/src/utils/scroll.ts index 5c296c6760..bc4bf6af3d 100644 --- a/src/utils/scroll.ts +++ b/src/utils/scroll.ts @@ -1,4 +1,15 @@ -export const scrollIntoLayout = (node: Element | null) => { +import scroll from 'scroll' +export { default as ease } from 'ease-component' + +export const scrollIntoLayout = ( + node: Element | null, + opts?: { + smooth: true + offset?: number + duration?: number + ease?: (value: number) => number + } +) => { if (!node) { return } @@ -6,6 +17,16 @@ export const scrollIntoLayout = (node: Element | null) => { const htmlNode = document.documentElement const headerHeight = document.getElementById('header')?.clientHeight || 0 const nodeOffset = node.getBoundingClientRect() + const position = + htmlNode.scrollTop + nodeOffset.top - headerHeight + (opts?.offset || 0) + + if (!opts?.smooth) { + htmlNode.scrollTop = position + return + } - htmlNode.scrollTop = htmlNode.scrollTop + nodeOffset.top - headerHeight + scroll.top(htmlNode, position, { + duration: opts?.duration, + ease: opts?.ease + }) } diff --git a/yarn.lock b/yarn.lock index e1d492e8a9..dbd632e57f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5319,6 +5319,11 @@ duplexify@^3.4.2, duplexify@^3.6.0: readable-stream "^2.0.0" stream-shift "^1.0.0" +ease-component@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/ease-component/-/ease-component-1.0.0.tgz#b375726db0b5b04595b77440396fec7daa5d77c9" + integrity sha1-s3VybbC1sEWVt3RAOW/sfapdd8k= + ecc-jsbn@~0.1.1: version "0.1.2" resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz#3a83a904e54353287874c564b7549386849a98c9" @@ -14359,6 +14364,11 @@ scroll-behavior@^0.9.12: dom-helpers "^3.4.0" invariant "^2.2.4" +scroll@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/scroll/-/scroll-3.0.1.tgz#d5afb59fb3592ee3df31c89743e78b39e4cd8a26" + integrity sha512-pz7y517OVls1maEzlirKO5nPYle9AXsFzTMNJrRGmT951mzpIBy7sNHOg5o/0MQd/NqliCiWnAi0kZneMPFLcg== + section-matter@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/section-matter/-/section-matter-1.0.0.tgz#e9041953506780ec01d59f292a19c7b850b84167" From 06ad93a4ae8e18590b0290ff2dc66ab72ae5a8eb Mon Sep 17 00:00:00 2001 From: Pavel Grinchenko Date: Wed, 1 Apr 2020 17:27:45 +0300 Subject: [PATCH 04/51] Replace styled-reset to reset-css. Merge global styles. Use local classNames instead of global in few components --- package.json | 2 +- src/components/HamburgerMenu/index.tsx | 2 +- .../HamburgerMenu/styles.module.css | 4 ++ src/components/Page/base.css | 30 +++++++----- src/components/Page/index.tsx | 3 +- src/components/Page/styles.module.css | 5 ++ src/components/Page/utils.ts | 4 +- src/styles.js | 48 +------------------ yarn.lock | 10 ++-- 9 files changed, 38 insertions(+), 70 deletions(-) diff --git a/package.json b/package.json index f00e56aae4..234e13518a 100644 --- a/package.json +++ b/package.json @@ -80,11 +80,11 @@ "rehype-react": "^4.0.1", "request": "^2.88.0", "s3-client": "^4.4.2", + "reset-css": "^5.0.1", "scroll": "^3.0.1", "serve-handler": "^6.1.2", "slick-carousel": "^1.8.1", "styled-components": "^4.4.1", - "styled-reset": "^4.0.8", "unist-util-visit": "2.0.2" }, "devDependencies": { diff --git a/src/components/HamburgerMenu/index.tsx b/src/components/HamburgerMenu/index.tsx index c87a231273..99fa1edf4b 100644 --- a/src/components/HamburgerMenu/index.tsx +++ b/src/components/HamburgerMenu/index.tsx @@ -34,7 +34,7 @@ function HamburgerMenu() { useEffect(() => { const method = isOpened ? 'add' : 'remove' - document.body.classList[method]('noScroll') + document.body.classList[method](styles.hiddenScrollbar) }, [isOpened]) return ( diff --git a/src/components/HamburgerMenu/styles.module.css b/src/components/HamburgerMenu/styles.module.css index 705e6c6c54..91ebfa6f54 100644 --- a/src/components/HamburgerMenu/styles.module.css +++ b/src/components/HamburgerMenu/styles.module.css @@ -1,3 +1,7 @@ +.hiddenScrollbar { + overflow-y: hidden; +} + .wrapper { display: block; padding: 25px 15px 15px; diff --git a/src/components/Page/base.css b/src/components/Page/base.css index a7fe1e81c0..31e16e5015 100644 --- a/src/components/Page/base.css +++ b/src/components/Page/base.css @@ -21,26 +21,16 @@ --layout-header-height-scrolled: calc(var(--layout-header-height) - 20px); } -:global { - .bodySmoothScrolling { - scroll-behavior: smooth; - will-change: scroll-position; - } - - .noScroll { - overflow-y: hidden; - } -} - html { - text-rendering: optimizeLegibility; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; + text-rendering: optimizelegibility; } body { - margin: 0; font-family: var(--font-brandon); + font-weight: 400; + line-height: 1.5; color: var(--color-black); } @@ -48,4 +38,18 @@ body { * { -webkit-text-size-adjust: none; text-size-adjust: none; + + &:focus { + outline: 0; + } +} + +/* TODO: check it later */ +img + em, +.gatsby-highlight + p > em:only-child { + color: #6a737d; + font-size: 0.9em; + display: block; + margin-top: -6px; + text-align: center; } diff --git a/src/components/Page/index.tsx b/src/components/Page/index.tsx index f5c6150950..b178f5d5c5 100644 --- a/src/components/Page/index.tsx +++ b/src/components/Page/index.tsx @@ -1,5 +1,4 @@ import React from 'react' -import { GlobalStyle } from '../../styles' import MainLayout, { LayoutComponent } from '../MainLayout' import DefaultSEO from './DefaultSEO' @@ -8,6 +7,7 @@ import Layout from '../Blog/Layout' import { useRedirects, useAnchorNavigation, useSmoothScroll } from './utils' +import 'reset-css' import './base.css' import './fonts/fonts.css' import styles from './styles.module.css' @@ -46,7 +46,6 @@ const Page: React.SFC = props => { return ( <> -