Skip to content

Commit

Permalink
Refactor ProductHeroV2 layout (#4866)
Browse files Browse the repository at this point in the history
<!--
PR title: GRW-123 / Feature / Awesome new thing
-->

## Describe your changes
Colocate `ProductHero` specific styles
<!--
What changes are made?
If there are many changes, a list might be a good format.
If it makes sense, add screenshots and/or screen recordings here.
-->

## Justify why they are needed
Colocation 

## Checklist before requesting a review

- [ ] I have performed a self-review of my code
  • Loading branch information
gustaveen authored Oct 21, 2024
2 parents 0736c3e + f1a7ed6 commit 7e6faae
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,12 @@ export const pageGrid = style({
export const productHeroSection = style([
yStack({ justifyContent: 'center' }),
{
height: '13rem',
alignSelf: 'start',

...responsiveStyles({
lg: {
position: 'sticky',
top: 0,
gridColumn: '1 / span 7',
alignSelf: 'start',
minHeight: `calc(100vh - ${HEADER_HEIGHT_DESKTOP})`,
},
}),
Expand All @@ -54,19 +52,6 @@ export const priceCalculatorSection = style({
}),
})

export const productHero = style({
display: 'flex',
gap: tokens.space.xs,

...responsiveStyles({
lg: {
gap: tokens.space.md,
// Visually center Product Hero
marginTop: `calc(-1 * ${HEADER_HEIGHT_DESKTOP})`,
},
}),
})

export const purchaseSummaryWrapper = style([
yStack({ alignItems: 'center', justifyContent: 'center' }),
{ height: '100%' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { CartToast } from './CartToast/CartToast'
import {
pageGrid,
priceCalculatorSection,
productHero,
productHeroSection,
purchaseSummaryWrapper,
purchaseSummary,
Expand All @@ -26,7 +25,7 @@ export function PriceCalculatorCmsPageContent() {
<div className={pageGrid}>
{showProductHero && (
<section className={productHeroSection}>
<ProductHeroV2 className={productHero} />
<ProductHeroV2 />
</section>
)}
<section className={priceCalculatorSection}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
import { style } from '@vanilla-extract/css'
import { badgeFontColor } from 'ui/src/components/Badge/Badge.css'
import { responsiveStyles, tokens } from 'ui'
import { responsiveStyles, tokens, yStack } from 'ui'
import { HEADER_HEIGHT_DESKTOP } from '@/components/Header/Header.css'

export const productHeroWrapper = style([
yStack({ justifyContent: 'center', alignItems: 'center', gap: { _: 'xs', lg: 'md' } }),
{
height: '13rem',

...responsiveStyles({
lg: {
// Visually center Product Hero
marginTop: `calc(-1 * ${HEADER_HEIGHT_DESKTOP})`,
},
}),
},
])

export const pillowWrapper = style({
position: 'relative',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
'use client'
import { clsx } from 'clsx'
import type { Variants } from 'framer-motion'
import { AnimatePresence, motion } from 'framer-motion'
import { useRef } from 'react'
import { Badge, framerTransitions, Heading, sprinkles, Text, yStack } from 'ui'
import { Badge, framerTransitions, Heading, sprinkles, Text } from 'ui'
import { Pillow } from '@/components/Pillow/Pillow'
import { useProductData } from '@/components/ProductData/ProductDataProvider'
import { useSelectedOffer } from '@/components/ProductPage/PurchaseForm/useSelectedOffer'
Expand All @@ -13,6 +12,7 @@ import {
pillowWrapper,
priceLabel,
priceWrapper,
productHeroWrapper,
subTypeBadge,
subTypeLabel,
} from './ProductHeroV2.css'
Expand All @@ -26,7 +26,7 @@ const ANIMATION: Variants = {
}
const TRANSITION = { duration: 0.3, ...framerTransitions.easeInOutCubic }

export function ProductHeroV2({ className }: { className?: string }) {
export function ProductHeroV2() {
const ref = useRef(null)
const productData = useProductData()
const [selectedOffer] = useSelectedOffer()
Expand Down Expand Up @@ -74,7 +74,7 @@ export function ProductHeroV2({ className }: { className?: string }) {
}
</StickyProductHeader>

<div ref={ref} className={clsx(yStack({ alignItems: 'center' }), className)}>
<div ref={ref} className={productHeroWrapper}>
<div className={pillowWrapper}>
<Pillow
size={{ _: 'xlarge', lg: 'xxlarge' }}
Expand Down

0 comments on commit 7e6faae

Please sign in to comment.