Skip to content

Commit

Permalink
Latest Release (vercel#187)
Browse files Browse the repository at this point in the history
* Remove duplicated css rules. (vercel#185)

* Fix typo in the Marquee component (vercel#176)

Co-authored-by: Hugo Lopes <[email protected]>

* Remove duplicated css rules.
Fix invalid JSX props.

Co-authored-by: Hugo Lopes <[email protected]>

* Fix the body scroll when the sidebar is open (vercel#184)

* Fix typo in the Marquee component (vercel#176)

Co-authored-by: Hugo Lopes <[email protected]>

* Fix the body scroll when the sidebar is open

Co-authored-by: Hugo Lopes <[email protected]>

* Remove duplicate class in the I18nWidget comp (vercel#183)

* Fix typo in the Marquee component (vercel#176)

Co-authored-by: Hugo Lopes <[email protected]>

* Remove duplicate class name in the I18nWidget comp

This PR removes a duplicate class name in the I18nWidget component.

Co-authored-by: Hugo Lopes <[email protected]>
Co-authored-by: Hugo Lopes <[email protected]>

* add horizontal margin to pages when mobile screen (vercel#180)

* Add cart item options like color and size (vercel#177)

Co-authored-by: hlopes <[email protected]>

* Changes

Co-authored-by: Hugo Lopes <[email protected]>
Co-authored-by: Hugo Lopes <[email protected]>
Co-authored-by: Jamie Isaksen <[email protected]>
Co-authored-by: Vinicius Zucatti <[email protected]>
  • Loading branch information
5 people authored Jan 29, 2021
1 parent 08a6b2e commit 3a7d5e2
Show file tree
Hide file tree
Showing 15 changed files with 51 additions and 32 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ yarn-debug.log*
yarn-error.log*

# local env files
.env
.env.local
.env.development.local
.env.test.local
Expand Down
2 changes: 0 additions & 2 deletions assets/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ a {
}

.animated {
-webkit-animation-duration: 1s;
animation-duration: 1s;
-webkit-animation-duration: 1s;
animation-duration: 1s;
-webkit-animation-fill-mode: both;
Expand Down
21 changes: 18 additions & 3 deletions components/cart/CartItem/CartItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ import useUpdateItem from '@framework/cart/use-update-item'
import useRemoveItem from '@framework/cart/use-remove-item'
import s from './CartItem.module.css'

type ItemOption = {
name: string,
nameId: number,
value: string,
valueId: number
}

const CartItem = ({
item,
currencyCode,
Expand Down Expand Up @@ -88,12 +95,20 @@ const CartItem = ({
<div className="flex-1 flex flex-col text-base">
{/** TODO: Replace this. No `path` found at Cart */}
<Link href={`/product/${item.url.split('/')[3]}`}>
<span className="font-bold mb-5 text-lg cursor-pointer">
<span className="font-bold text-lg cursor-pointer leading-6">
{item.name}
</span>
</Link>

<div className="flex items-center">
{item.options && item.options.length > 0 ? (
<div className="">
{item.options.map((option:ItemOption, i: number) =>
<span key={`${item.id}-${option.name}`} className="text-sm font-semibold text-accents-7">
{option.value}{ i === item.options.length -1 ? "" : ", " }
</span>
)}
</div>
) : null}
<div className="flex items-center mt-3">
<button type="button" onClick={() => increaseQuantity(-1)}>
<Minus width={18} height={18} />
</button>
Expand Down
2 changes: 1 addition & 1 deletion components/common/I18nWidget/I18nWidget.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
}

.item {
@apply flex cursor-pointer px-6 py-3 flex transition ease-in-out duration-150 text-primary leading-6 font-medium items-center;
@apply flex cursor-pointer px-6 py-3 transition ease-in-out duration-150 text-primary leading-6 font-medium items-center;
text-transform: capitalize;
}

Expand Down
8 changes: 4 additions & 4 deletions components/common/Layout/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,16 @@ const Layout: FC<Props> = ({ children, pageProps }) => {
<main className="fit">{children}</main>
<Footer pages={pageProps.pages} />

<Sidebar open={displaySidebar} onClose={closeSidebar}>
<CartSidebarView />
</Sidebar>

<Modal open={displayModal} onClose={closeModal}>
{modalView === 'LOGIN_VIEW' && <LoginView />}
{modalView === 'SIGNUP_VIEW' && <SignUpView />}
{modalView === 'FORGOT_VIEW' && <ForgotPassword />}
</Modal>

<Sidebar open={displaySidebar} onClose={closeSidebar}>
<CartSidebarView />
</Sidebar>

<FeatureBar
title="This site uses cookies to improve your experience. By clicking, you agree to our Privacy Policy."
hide={acceptedCookies}
Expand Down
7 changes: 3 additions & 4 deletions components/product/ProductView/ProductView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,14 @@ const ProductView: FC<Props> = ({ product }) => {
size: null,
color: null,
})
const variant =
getCurrentVariant(product, choices) || product.variants.edges?.[0]
const variant = getCurrentVariant(product, choices)

const addToCart = async () => {
setLoading(true)
try {
await addItem({
productId: product.entityId,
variantId: product.variants.edges?.[0]?.node.entityId!,
variantId: variant?.node.entityId!,
})
openSidebar()
setLoading(false)
Expand Down Expand Up @@ -156,7 +155,7 @@ const ProductView: FC<Props> = ({ product }) => {
<WishlistButton
className={s.wishlistButton}
productId={product.entityId}
variant={product.variants.edges?.[0]!}
variant={variant!}
/>
</div>
</Container>
Expand Down
13 changes: 9 additions & 4 deletions components/product/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ export function getProductOptions(product: ProductNode) {
export function getCurrentVariant(product: ProductNode, opts: SelectedOptions) {
const variant = product.variants.edges?.find((edge) => {
const { node } = edge ?? {}
const numberOfDefinedOpts = Object.values(opts).filter(value => value !== null).length;
const numberOfEdges = node?.productOptions?.edges?.length;

return Object.entries(opts).every(([key, value]) =>
const isEdgeEqualToOption = ([key, value]:[string, string | null]) =>
node?.productOptions.edges?.find((edge) => {
if (
edge?.node.__typename === 'MultipleChoiceOption' &&
Expand All @@ -43,9 +45,12 @@ export function getCurrentVariant(product: ProductNode, opts: SelectedOptions) {
(valueEdge) => valueEdge?.node.label === value
)
}
})
)
});

return numberOfDefinedOpts === numberOfEdges ?
Object.entries(opts).every(isEdgeEqualToOption)
: Object.entries(opts).some(isEdgeEqualToOption)
})

return variant
return variant ?? product.variants.edges?.[0]
}
4 changes: 2 additions & 2 deletions components/ui/Marquee/Marquee.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface Props {
variant?: 'primary' | 'secondary'
}

const Maquee: FC<Props> = ({
const Marquee: FC<Props> = ({
className = '',
children,
variant = 'primary',
Expand All @@ -32,4 +32,4 @@ const Maquee: FC<Props> = ({
)
}

export default Maquee
export default Marquee
1 change: 1 addition & 0 deletions components/ui/context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ function uiReducer(state: State, action: Action) {
return {
...state,
displayModal: true,
displaySidebar: false,
}
}
case 'CLOSE_MODAL': {
Expand Down
4 changes: 2 additions & 2 deletions framework/bigcommerce/api/cart/handlers/add-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ const addItem: CartHandlers['addItem'] = async ({
}),
}
const { data } = cartId
? await config.storeApiFetch(`/v3/carts/${cartId}/items`, options)
: await config.storeApiFetch('/v3/carts', options)
? await config.storeApiFetch(`/v3/carts/${cartId}/items?include=line_items.physical_items.options`, options)
: await config.storeApiFetch('/v3/carts?include=line_items.physical_items.options', options)

// Create or update the cart cookie
res.setHeader(
Expand Down
2 changes: 1 addition & 1 deletion framework/bigcommerce/api/cart/handlers/get-cart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const getCart: CartHandlers['getCart'] = async ({

if (cartId) {
try {
result = await config.storeApiFetch(`/v3/carts/${cartId}`)
result = await config.storeApiFetch(`/v3/carts/${cartId}?include=line_items.physical_items.options`)
} catch (error) {
if (error instanceof BigcommerceApiError && error.status === 404) {
// Remove the cookie if it exists but the cart wasn't found
Expand Down
2 changes: 1 addition & 1 deletion framework/bigcommerce/api/cart/handlers/remove-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const removeItem: CartHandlers['removeItem'] = async ({
}

const result = await config.storeApiFetch<{ data: any } | null>(
`/v3/carts/${cartId}/items/${itemId}`,
`/v3/carts/${cartId}/items/${itemId}?include=line_items.physical_items.options`,
{ method: 'DELETE' }
)
const data = result?.data ?? null
Expand Down
2 changes: 1 addition & 1 deletion framework/bigcommerce/api/cart/handlers/update-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const updateItem: CartHandlers['updateItem'] = async ({
}

const { data } = await config.storeApiFetch(
`/v3/carts/${cartId}/items/${itemId}`,
`/v3/carts/${cartId}/items/${itemId}?include=line_items.physical_items.options`,
{
method: 'PUT',
body: JSON.stringify({
Expand Down
2 changes: 1 addition & 1 deletion pages/[...pages].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default function Pages({
page,
}: InferGetStaticPropsType<typeof getStaticProps>) {
return (
<div className="max-w-2xl mx-auto py-20">
<div className="max-w-2xl mx-8 sm:mx-auto py-20">
{page?.body && <Text html={page.body} />}
</div>
)
Expand Down
12 changes: 6 additions & 6 deletions pages/search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ export default function Search({
fill="currentColor"
>
<path
fill-rule="evenodd"
fillRule="evenodd"
d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z"
clip-rule="evenodd"
clipRule="evenodd"
/>
</svg>
</button>
Expand Down Expand Up @@ -205,9 +205,9 @@ export default function Search({
fill="currentColor"
>
<path
fill-rule="evenodd"
fillRule="evenodd"
d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z"
clip-rule="evenodd"
clipRule="evenodd"
/>
</svg>
</button>
Expand Down Expand Up @@ -378,9 +378,9 @@ export default function Search({
fill="currentColor"
>
<path
fill-rule="evenodd"
fillRule="evenodd"
d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z"
clip-rule="evenodd"
clipRule="evenodd"
/>
</svg>
</button>
Expand Down

0 comments on commit 3a7d5e2

Please sign in to comment.