Skip to content

Commit

Permalink
changes to the layout
Browse files Browse the repository at this point in the history
  • Loading branch information
okbel committed Oct 13, 2020
1 parent 30a8677 commit 038d02a
Show file tree
Hide file tree
Showing 11 changed files with 131 additions and 90 deletions.
16 changes: 14 additions & 2 deletions assets/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,27 @@
:root {
--bg-primary: white;
--bg-secondary: black;
--bg-primary-accent: rgba(0, 0, 0, 0.075);

--text-primary: black;
--text-secondary: #252f3f;
--text-secondary: white;

--text-default: #252f3f;
}

[data-theme='dark'] {
--bg-primary: black;
--bg-secondary: white;
--bg-primary-accent: rgba(255, 255, 255, 0.075);

--text-primary: white;
--text-secondary: white;
--text-secondary: black;

--text-default: white;
}

.fit {
min-height: calc(100vh - 200px);
}

*,
Expand Down
9 changes: 4 additions & 5 deletions components/core/Footer/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ const Footer: FC<Props> = ({ className }) => {
)
return (
<div className="bg-black text-white">
<hr
className="hidden md:block mt-4 border-gray-700"
style={{ flexBasis: '100%', height: 0 }}
/>
<footer className={rootClassName}>
<Link href="/">
<a className="flex flex-initial items-center md:items-start font-bold md:mr-24">
Expand Down Expand Up @@ -54,11 +58,6 @@ const Footer: FC<Props> = ({ className }) => {
<small className="text-base">
&copy; 2020 ACME, Inc. All rights reserved.
</small>

<hr
className="hidden md:block mt-4 border-gray-700"
style={{ flexBasis: '100%', height: 0 }}
/>
</footer>
</div>
)
Expand Down
2 changes: 1 addition & 1 deletion components/core/Layout/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const CoreLayout: FC<Props> = ({ className, children }) => {
<Container>
<Navbar />
</Container>
<main className="h-screen">{children}</main>
<main className="fit">{children}</main>
<Footer />
<Sidebar show={displaySidebar} close={closeSidebar}>
<CartSidebarView />
Expand Down
8 changes: 4 additions & 4 deletions components/product/ProductView/ProductView.module.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.root {
@apply flex flex-row h-screen py-12 px-6;
}

.button {
min-width: 300px;
}

.squareBg {
@apply absolute inset-24 z-0 bg-violet;
}
124 changes: 62 additions & 62 deletions components/product/ProductView/ProductView.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import cn from 'classnames'
import { FC, useState } from 'react'
import s from './ProductView.module.css'
import { Button } from '@components/ui'
import { Button, Container } from '@components/ui'
import { Swatch } from '@components/product'
import { Colors } from '@components/ui/types'
import type { Product } from '@lib/bigcommerce/api/operations/get-product'
Expand Down Expand Up @@ -43,76 +43,76 @@ const ProductView: FC<Props> = ({ product, className }) => {
const activeColor = choices.color

return (
<div className={cn(s.root, className)}>
<div className="absolute">
<h1 className="px-6 py-2 bg-violet text-white font-bold text-3xl">
{product.name}
</h1>
<div className="px-6 py-2 pb-4 bg-violet text-white font-semibold inline-block">
{product.prices?.price.value}
{` `}
{product.prices?.price.currencyCode}
</div>
</div>
<div className="flex-1 h-48 p-24 relative min-h-screen overflow-hidden">
<div className="absolute z-10 inset-0 flex items-center justify-center">
<img
className="w-full object-cover"
src={product.images.edges?.[0]?.node.urlXL}
/>
<Container>
<div className="relative flex flex-row items-start overflow-hidden">
<div className="absolute top-0 left-0 z-50">
<h1 className="px-6 py-2 bg-violet text-white font-bold text-3xl">
{product.name}
</h1>
<div className="px-6 py-2 pb-4 bg-violet text-white font-bold inline-block traking">
{product.prices?.price.value}
{` `}
{product.prices?.price.currencyCode}
</div>
</div>
<div className=" absolute inset-24 z-0 bg-violet"></div>
</div>
<div className="flex-1 flex flex-col">
<section className="pb-4">
<h2 className="uppercase font-medium">Color</h2>
<div className="flex flex-row py-4">
{COLORS.map((color) => (
<Swatch
key={color}
color={color}
active={color === activeColor}
onClick={() =>
setChoices((choices) => {
return { ...choices, color }
})
}
/>
))}
<div className="flex-1 p-24 relative fit overflow-hidden box-border">
<div className="absolute z-10 inset-0 flex items-center justify-center">
<img
className="w-full object-cover"
src={product.images.edges?.[0]?.node.urlXL}
/>
</div>
</section>
<section className="pb-4">
<h2 className="uppercase font-medium">Size</h2>
<div className="flex flex-row py-4">
{SIZES.map((size) => {
return (
<div className={s.squareBg}></div>
</div>
<div className="flex-1 flex flex-col">
<section className="pt-24">
<h2 className="uppercase font-medium">Color</h2>
<div className="flex flex-row py-4">
{COLORS.map((color) => (
<Swatch
size={size.toUpperCase()}
key={`size-${size}`}
active={size === activeSize}
key={color}
color={color}
active={color === activeColor}
onClick={() =>
setChoices((choices) => {
return { ...choices, size }
return { ...choices, color }
})
}
/>
)
})}
</div>
</section>
<section className="pb-12">
<div
className="break-words"
dangerouslySetInnerHTML={{ __html: product.description }}
/>
</section>
<section className="pb-4">
<Button type="button" className={s.button} onClick={addToCart}>
Add to Cart
</Button>
</section>
))}
</div>
</section>
<section className="pb-4">
<h2 className="uppercase font-medium">Size</h2>
<div className="flex flex-row py-4">
{SIZES.map((size) => {
return (
<Swatch
size={size.toUpperCase()}
key={`size-${size}`}
active={size === activeSize}
onClick={() =>
setChoices((choices) => ({ ...choices, size }))
}
/>
)
})}
</div>
</section>
<section className="pb-12">
<div
className="break-words"
dangerouslySetInnerHTML={{ __html: product.description }}
/>
</section>
<section className="pb-4">
<Button type="button" className={s.button} onClick={addToCart}>
Add to Cart
</Button>
</section>
</div>
</div>
</div>
</Container>
)
}

Expand Down
14 changes: 7 additions & 7 deletions components/product/Swatch/Swatch.module.css
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
.root {
@apply h-12 w-12 bg-white text-primary rounded-full mr-3 inline-flex items-center justify-center cursor-pointer transition duration-75 ease-in-out p-0 shadow-none;
@apply h-12 w-12 bg-primary text-primary rounded-full mr-3 inline-flex
items-center justify-center cursor-pointer transition duration-75 ease-in-out
p-0 shadow-none border-gray-200 border;
}

.active.size {
@apply border-black;
@apply border-secondary border-2;
}

.root:hover {
@apply transform scale-110;
@apply transform scale-110 bg-primary-accent;
}

.colorViolet {
Expand All @@ -22,8 +24,6 @@
@apply bg-black !important;
}

.colorWhite,
.size {
@apply bg-white !important;
@apply border border-gray-200;
.colorWhite {
@apply bg-white text-black !important;
}
3 changes: 0 additions & 3 deletions components/product/Swatch/Swatch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ const Swatch: FC<Props> = ({ className, size, color, active, ...props }) => {
className
)

// TODO: technically this is a radio

return (
<Button className={rootClassName} {...props}>
{color && active && (
Expand All @@ -47,4 +45,3 @@ const Swatch: FC<Props> = ({ className, size, color, active, ...props }) => {
}

export default Swatch

4 changes: 3 additions & 1 deletion components/ui/Button/Button.module.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
.root {
@apply cursor-pointer inline-flex px-10 rounded-sm leading-6 text-white bg-black transition ease-in-out duration-150 shadow-sm font-semibold text-center justify-center uppercase py-4 uppercase text-center focus:outline-none;
@apply text-secondary cursor-pointer inline-flex px-10 rounded-sm leading-6
bg-secondary transition ease-in-out duration-150 shadow-sm font-semibold
text-center justify-center uppercase py-4 uppercase text-center focus:outline-none;
}

.root:hover {
Expand Down
4 changes: 2 additions & 2 deletions pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default function Home({
All Categories
</li>
{categories.map((cat) => (
<li key={cat.path} className="py-1 text-secondary">
<li key={cat.path} className="py-1 text-default">
<a href="#">{cat.name}</a>
</li>
))}
Expand All @@ -59,7 +59,7 @@ export default function Home({
All Designers
</li>
{brands.flatMap(({ node }) => (
<li key={node.path} className="py-1 text-secondary">
<li key={node.path} className="py-1 text-default">
<a href="#">{node.name}</a>
</li>
))}
Expand Down
33 changes: 30 additions & 3 deletions pages/wishlist.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,41 @@ export async function getStaticProps({ preview }: GetStaticPropsContext) {
}
}

export default function Home({}: InferGetStaticPropsType<
typeof getStaticProps
>) {
export default function Home({
categories,
brands,
}: InferGetStaticPropsType<typeof getStaticProps>) {
return (
<Container>
<h2 className="pt-1 pb-4 text-2xl leading-7 font-bold text-primary tracking-wide">
My Wishlist
</h2>
<div className="grid grid-cols-12 gap-8 mt-3 mb-20">
<div className="col-span-2">
<ul className="mb-10">
<li className="py-1 text-primary font-bold tracking-wide">
All Categories
</li>
{categories.map((cat) => (
<li key={cat.path} className="py-1 text-secondary">
<a href="#">{cat.name}</a>
</li>
))}
</ul>
</div>
<div className="col-span-8">Items.</div>
<div className="col-span-2">
<ul>
<li className="py-1 text-primary font-bold tracking-wide">
Relevance
</li>
<li className="py-1 text-secondary">Latest arrivals</li>
<li className="py-1 text-secondary">Trending</li>
<li className="py-1 text-secondary">Price: Low to high</li>
<li className="py-1 text-secondary">Price: High to low</li>
</ul>
</div>
</div>
</Container>
)
}
Expand Down
4 changes: 4 additions & 0 deletions tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ module.exports = {
],
theme: {
extend: {
backgroundOpacity: {
075: '0.75',
},
colors: {
'accent-1': '#FAFAFA',
'accent-2': '#F1F3F5',
Expand All @@ -22,6 +25,7 @@ module.exports = {
red: '#DA3C3C',
primary: 'var(--bg-primary)',
secondary: 'var(--bg-secondary)',
'primary-accent': 'var(--bg-primary-accent)',
},
textColor: {
base: 'var(--text-primary)',
Expand Down

0 comments on commit 038d02a

Please sign in to comment.