mirror of
https://github.com/vercel/commerce.git
synced 2025-07-22 20:26:49 +00:00
build changes
This commit is contained in:
@@ -5,15 +5,15 @@ import ProductCard from '@components/product/ProductCard'
|
||||
interface Props {
|
||||
className?: string
|
||||
children?: any
|
||||
products: [any]
|
||||
products: [any] | any
|
||||
}
|
||||
|
||||
const ProductView: FC<Props> = ({ products, className }) => {
|
||||
const rootClassName = cn(s.root, className)
|
||||
return (
|
||||
<div className={rootClassName}>
|
||||
{products.slice(0, 6).map(({ node }) => (
|
||||
<ProductCard productData={node} />
|
||||
{products.map((data: any) => (
|
||||
<ProductCard productData={data.node} />
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
|
@@ -3,7 +3,15 @@ import { FC } from 'react'
|
||||
import s from './ProductView.module.css'
|
||||
import { Button } from '@components/ui'
|
||||
import { Swatch } from '@components/product'
|
||||
|
||||
import { Colors } from '@components/ui/types'
|
||||
interface ProductData {
|
||||
name: string
|
||||
images: any
|
||||
prices: any
|
||||
description: string
|
||||
colors?: any[]
|
||||
sizes?: any[]
|
||||
}
|
||||
interface Props {
|
||||
className?: string
|
||||
children?: any
|
||||
@@ -12,15 +20,15 @@ interface Props {
|
||||
|
||||
const ProductView: FC<Props> = ({ productData, className }) => {
|
||||
const rootClassName = cn(s.root, className)
|
||||
console.log(productData)
|
||||
const colors: Colors[] = ['pink', 'black', 'white']
|
||||
return (
|
||||
<div className={rootClassName}>
|
||||
<div className="absolute">
|
||||
<h1 className="px-8 py-2 bg-violet text-white font-bold text-3xl">
|
||||
{productData.title}
|
||||
{productData.name}
|
||||
</h1>
|
||||
<div className="px-6 py-2 pb-4 bg-violet text-white font-semibold inline-block">
|
||||
{productData.price}
|
||||
{productData.prices}
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex-1 h-full p-24">
|
||||
@@ -30,7 +38,7 @@ const ProductView: FC<Props> = ({ productData, className }) => {
|
||||
<section className="pb-4">
|
||||
<h2 className="uppercase font-medium">Color</h2>
|
||||
<div className="flex flex-row py-4">
|
||||
{productData.colors.map((c) => (
|
||||
{colors.map((c) => (
|
||||
<Swatch color={c} />
|
||||
))}
|
||||
</div>
|
||||
|
@@ -1,10 +1 @@
|
||||
import { Colors } from '@components/ui/types'
|
||||
export { Product } from '@lib/bigcommerce'
|
||||
|
||||
// export type ProductData = {
|
||||
// title: string;
|
||||
// price: string;
|
||||
// description: string;
|
||||
// colors: [Colors];
|
||||
// sizes: [string];
|
||||
// };
|
||||
|
@@ -1,46 +0,0 @@
|
||||
import React, { FC, MutableRefObject, useEffect, useRef } from 'react'
|
||||
|
||||
import { Component } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
|
||||
export interface ClickOutsideProps {
|
||||
onClickOutside: (e?: MouseEvent) => void
|
||||
children: React.ReactNode | any
|
||||
render: () => void
|
||||
}
|
||||
|
||||
export default class ClickOutside extends Component<ClickOutsideProps> {
|
||||
public domNode: Element | null = null
|
||||
|
||||
handleRef = (element) => {
|
||||
this.domNode = element
|
||||
}
|
||||
|
||||
public componentDidMount() {
|
||||
document.addEventListener('click', this.handleClick, true)
|
||||
}
|
||||
|
||||
public componentWillUnmount() {
|
||||
document.removeEventListener('mousedown', this.handleClick, true)
|
||||
document.removeEventListener('touchstart', this.handleClick, true)
|
||||
}
|
||||
|
||||
public handleClick = (event) => {
|
||||
function hasParent(element, root) {
|
||||
return root && root.contains(element)
|
||||
}
|
||||
|
||||
if (!hasParent(event.target, this.domNode)) {
|
||||
if (typeof this.props.onClickOutside === 'function') {
|
||||
this.props.onClickOutside(event)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
return null
|
||||
// return this.props.render({
|
||||
// innerRef: this.handleRef,
|
||||
// });
|
||||
}
|
||||
}
|
@@ -1 +0,0 @@
|
||||
export { default } from './ClickOutside'
|
@@ -1,25 +1,29 @@
|
||||
import React, { FC } from 'react'
|
||||
|
||||
export interface UIState {
|
||||
export interface State {
|
||||
displaySidebar: boolean
|
||||
openSidebar: () => {}
|
||||
closeSidebar: () => {}
|
||||
}
|
||||
|
||||
const initialState = {
|
||||
displaySidebar: false,
|
||||
openSidebar: null,
|
||||
closeSidebar: null,
|
||||
}
|
||||
|
||||
export const UIContext = React.createContext(initialState)
|
||||
type Action =
|
||||
| {
|
||||
type: 'OPEN_SIDEBAR'
|
||||
}
|
||||
| {
|
||||
type: 'CLOSE_SIDEBAR'
|
||||
}
|
||||
|
||||
export const UIContext = React.createContext<State | any>(initialState)
|
||||
UIContext.displayName = 'UIContext'
|
||||
|
||||
export const UIProvider: FC = (props) => {
|
||||
const [state, dispatch] = React.useReducer(uiReducer, initialState)
|
||||
|
||||
const openSidebar = () => dispatch('OPEN_SIDEBAR')
|
||||
const closeSidebar = () => dispatch('CLOSE_SIDEBAR')
|
||||
const openSidebar = () => dispatch({ type: 'OPEN_SIDEBAR' })
|
||||
const closeSidebar = () => dispatch({ type: 'CLOSE_SIDEBAR' })
|
||||
|
||||
const value = {
|
||||
...state,
|
||||
@@ -38,8 +42,8 @@ export const useUI = () => {
|
||||
return context
|
||||
}
|
||||
|
||||
function uiReducer(state, action) {
|
||||
switch (action) {
|
||||
function uiReducer(state: State, action: Action) {
|
||||
switch (action.type) {
|
||||
case 'OPEN_SIDEBAR': {
|
||||
return {
|
||||
...state,
|
||||
|
Reference in New Issue
Block a user