Skip to content
This repository has been archived by the owner on Jun 2, 2022. It is now read-only.

Commit

Permalink
add section to pages
Browse files Browse the repository at this point in the history
  • Loading branch information
tlgimenes committed Mar 3, 2022
1 parent 8287b0a commit a794445
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 35 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]

### Added
- Sections component with `content-visibility: auto`
- Webpack Bundle analyzer
- `GatsbyLink` to `Link` ui component.
- `Skeleton` loading components.
Expand Down
5 changes: 2 additions & 3 deletions src/components/sections/Section/Section.scss
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
.pages__section {
display: inline-block;
width: 100%;
width: 100vw;
content-visibility: auto;
contain-intrinsic-size: auto 500px;
contain-intrinsic-size: 2px 1024px;

.title-section {
margin-bottom: var(--space-3);
Expand Down
11 changes: 7 additions & 4 deletions src/pages/s.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import { parseSearchState, SearchProvider, useSession } from '@faststore/sdk'
import { graphql } from 'gatsby'
import { GatsbySeo } from 'gatsby-plugin-next-seo'
import React, { useMemo } from 'react'
import ProductGallery from 'src/components/sections/ProductGallery'
import Section from 'src/components/sections/Section'
import SROnly from 'src/components/ui/SROnly'
import { ITEMS_PER_PAGE } from 'src/constants'
import { applySearchState } from 'src/sdk/search/state'
import { mark } from 'src/sdk/tests/mark'
import type { PageProps } from 'gatsby'
import type {
SearchPageQueryQuery,
SearchPageQueryQueryVariables,
} from '@generated/graphql'
import { GatsbySeo } from 'gatsby-plugin-next-seo'
import SROnly from 'src/components/ui/SROnly'
import { mark } from 'src/sdk/tests/mark'

export type Props = PageProps<
SearchPageQueryQuery,
Expand Down Expand Up @@ -60,7 +61,9 @@ function Page(props: Props) {
*/}
<SROnly as="h1" text={title} />

<ProductGallery title="Search Results" />
<Section>
<ProductGallery title="Search Results" />
</Section>
</SearchProvider>
)
}
Expand Down
51 changes: 31 additions & 20 deletions src/pages/{StoreCollection.slug}.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ import { graphql } from 'gatsby'
import { BreadcrumbJsonLd, GatsbySeo } from 'gatsby-plugin-next-seo'
import { Headphones as HeadphonesIcon } from 'phosphor-react'
import React from 'react'
import Breadcrumb from 'src/components/sections/Breadcrumb'
import Hero from 'src/components/sections/Hero'
import ProductGallery from 'src/components/sections/ProductGallery'
import ProductShelf from 'src/components/sections/ProductShelf'
import Section from 'src/components/sections/Section'
import ScrollToTopButton from 'src/components/ui/ScrollToTopButton'
import { ITEMS_PER_PAGE } from 'src/constants'
import { useSearchParams } from 'src/hooks/useSearchParams'
import { applySearchState } from 'src/sdk/search/state'
import Breadcrumb from 'src/components/sections/Breadcrumb'
import { mark } from 'src/sdk/tests/mark'
import type { Props } from 'src/hooks/useSearchParams'

Expand Down Expand Up @@ -66,15 +67,17 @@ function Page(props: Props) {
Do not import or render components from any other folder in here.
*/}

<section className="product-listing__breadcrumb / grid-content">
<Breadcrumb
breadcrumbList={collection?.breadcrumbList.itemListElement}
name={title}
/>
</section>
<Section>
<div className="product-listing__breadcrumb / grid-content">
<Breadcrumb
breadcrumbList={collection?.breadcrumbList.itemListElement}
name={title}
/>
</div>
</Section>

<div className="product-listing__hero">
<section className="page__section">
<Section>
<div className="product-listing__hero">
<Hero
variant="small"
title={title}
Expand All @@ -83,23 +86,31 @@ function Page(props: Props) {
imageAlt="Quest 2 Controller on a table"
icon={<HeadphonesIcon size={48} weight="thin" />}
/>
</section>
</div>
</div>
</Section>

<ProductGallery title={title} />
<Section>
<ProductGallery title={title} />
</Section>

{youMightAlsoLikeProducts?.length > 0 && (
<section className="page__section page__section-shelf page__section-divisor / grid-section">
<h2 className="title-section / grid-content">You might also like</h2>
<div className="page__section-content">
<ProductShelf products={youMightAlsoLikeProducts.slice(0, 5)} />
<Section>
<div className="page__section-shelf page__section-divisor / grid-section">
<h2 className="title-section / grid-content">
You might also like
</h2>
<div className="page__section-content">
<ProductShelf products={youMightAlsoLikeProducts.slice(0, 5)} />
</div>
</div>
</section>
</Section>
)}

<div className="product-listing__scroll-top">
<ScrollToTopButton />
</div>
<Section>
<div className="product-listing__scroll-top">
<ScrollToTopButton />
</div>
</Section>
</SearchProvider>
)
}
Expand Down
23 changes: 15 additions & 8 deletions src/pages/{StoreProduct.slug}/p.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ import {
} from 'gatsby-plugin-next-seo'
import React from 'react'
import ProductDetails from 'src/components/sections/ProductDetails'
import ProductShelf from 'src/components/sections/ProductShelf'
import Section from 'src/components/sections/Section'
import { mark } from 'src/sdk/tests/mark'
import type { PageProps } from 'gatsby'
import type {
ProductPageQueryQuery,
ProductPageQueryQueryVariables,
} from '@generated/graphql'
import ProductShelf from 'src/components/sections/ProductShelf'
import { mark } from 'src/sdk/tests/mark'

export type Props = PageProps<
ProductPageQueryQuery,
Expand Down Expand Up @@ -94,15 +95,21 @@ function Page(props: Props) {
Do not import or render components from any other folder in here.
*/}

<ProductDetails product={product} />
<Section>
<ProductDetails product={product} />
</Section>

{youMightAlsoLikeProducts?.length > 0 && (
<section className="page__section page__section-shelf page__section-divisor / grid-section">
<h2 className="title-section / grid-content">You might also like</h2>
<div className="page__section-content">
<ProductShelf products={youMightAlsoLikeProducts.slice(0, 5)} />
<Section>
<div className="page__section-shelf page__section-divisor / grid-section">
<h2 className="title-section / grid-content">
You might also like
</h2>
<div className="page__section-content">
<ProductShelf products={youMightAlsoLikeProducts.slice(0, 5)} />
</div>
</div>
</section>
</Section>
)}
</>
)
Expand Down

0 comments on commit a794445

Please sign in to comment.