ecr-product-card
Version:
Este es un paquete de pruebas de despliegue en NPM
64 lines (63 loc) • 1.69 kB
TypeScript
import { JSX } from "react";
export interface Product {
id: string;
title: string;
img?: string;
}
export interface ProductTitleProps {
title?: string;
className?: string;
style?: React.CSSProperties;
}
export interface ProductImageProps {
img?: string;
className?: string;
style?: React.CSSProperties;
}
export interface ProductButtonsProps {
className?: string;
style?: React.CSSProperties;
}
export interface ProductChangeProps {
product: Product;
count: number;
}
export interface ProductContextProps {
counter: number;
increaseBy: (value: number) => void;
product: Product;
maxCount?: number;
}
export interface ProductCardHOCProps {
(props: ProductCardProps): JSX.Element;
Title: (props: ProductTitleProps) => JSX.Element;
Image: (props: ProductImageProps) => JSX.Element;
Buttons: (props: ProductButtonsProps) => JSX.Element;
}
export interface ProductInCart extends Product {
count: number;
}
export interface ShoppingCartArgs {
[key: string]: ProductInCart;
}
export interface InitialValues {
count?: number;
maxCount?: number;
}
export interface ProductCardProps {
product: Product;
children: (args: ProductCardHandlers) => React.ReactNode;
className?: string;
style?: React.CSSProperties;
onChange?: (props: ProductChangeProps) => void;
value?: number;
initialValues?: InitialValues;
}
export interface ProductCardHandlers {
count: number;
isMaxCountReached: boolean;
maxCount?: number;
product: Product;
increaseBy: (value: number) => void;
reset: () => void;
}