diff --git a/pages/index.tsx b/pages/index.tsx index 0005eacd0..65340eb7a 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -2,10 +2,32 @@ import { ButtonCommon, Layout } from 'src/components/common' import { IconBuy } from 'src/components/icons' import { ButonType, ButtonSize } from 'src/utils/constanst.utils' +import {CarouselCommon, LabelCommon, QuanittyInput } from 'src/components/common' +const dataTest = [{ + text:1 +},{ + text:2 +},{ + text:3 +},{ + text:4 +},{ + text:5 +},{ + text:6 +}] +const test = (props:{text:string})=>
{props.text}
export default function Home() { return ( <> -
This is home page
+ + + + SEEFOOT + -15% + Waitting + Delivering + Delivered Button default {ButonType.light} - Button light {ButonType.light} - Button light @@ -13,9 +35,6 @@ export default function Home() { }>{ButtonSize.large} - Button default large } disabled isIconSuffix={true}>Button with icon disabled } type={ButonType.light}>Button with icon -

Go to pages/index.tsx to get your hand dirty!

-

Go to src/components to make your awesome component!

-

Go to src/styles to find global styles!

) } diff --git a/src/components/common/CarouselCommon/CaroucelCommon.module.scss b/src/components/common/CarouselCommon/CaroucelCommon.module.scss new file mode 100644 index 000000000..b1cc3e01e --- /dev/null +++ b/src/components/common/CarouselCommon/CaroucelCommon.module.scss @@ -0,0 +1,5 @@ +.navigation_wrapper{ + @apply relative; + min-height: theme("caroucel.arrow-height") ; + +} \ No newline at end of file diff --git a/src/components/common/CarouselCommon/CarouselCommon.tsx b/src/components/common/CarouselCommon/CarouselCommon.tsx new file mode 100644 index 000000000..074295533 --- /dev/null +++ b/src/components/common/CarouselCommon/CarouselCommon.tsx @@ -0,0 +1,57 @@ +import { useKeenSlider } from 'keen-slider/react' +import React from 'react' +import 'keen-slider/keen-slider.min.css' +import { CustomCarouselArrow } from './CustomArrow/CustomCarouselArrow'; +import s from "./CaroucelCommon.module.scss" +interface CarouselCommonProps { + children?: React.ReactNode + data?: any[] + Component: React.ComponentType + isArrow?:Boolean + itemKey:String +} + +const CarouselCommon = ({ data, Component,itemKey }: CarouselCommonProps) => { + const [currentSlide, setCurrentSlide] = React.useState(0) + const [sliderRef, slider] = useKeenSlider({ + slidesPerView: 1, + initial: 0, + slideChanged(s) { + setCurrentSlide(s.details().relativeSlide) + }, + }) + const handleRightArrowClick = () => { + slider.next() + } + + const handleLeftArrowClick = () => { + slider.prev() + } + return ( +
+
+ {data?.map((props,index) => ( +
+ +
+ ))} +
+ {slider && ( + <> + + + + )} +
+ ) +} + +export default CarouselCommon diff --git a/src/components/common/CarouselCommon/CustomArrow/CustomCarouselArrow.module.scss b/src/components/common/CarouselCommon/CustomArrow/CustomCarouselArrow.module.scss new file mode 100644 index 000000000..ec1bf0d88 --- /dev/null +++ b/src/components/common/CarouselCommon/CustomArrow/CustomCarouselArrow.module.scss @@ -0,0 +1,17 @@ +.custom_arrow{ + width: 64px; + height: 64px; + &:focus{ + outline: none; + } + @apply absolute top-1/2 bg-background-arrow transform -translate-y-1/2 flex justify-center items-center transition duration-100; + &.left{ + @apply left-0; + } + &.right{ + @apply right-0; + } + &.isDisabled{ + @apply hidden ; + } +} diff --git a/src/components/common/CarouselCommon/CustomArrow/CustomCarouselArrow.tsx b/src/components/common/CarouselCommon/CustomArrow/CustomCarouselArrow.tsx new file mode 100644 index 000000000..779591671 --- /dev/null +++ b/src/components/common/CarouselCommon/CustomArrow/CustomCarouselArrow.tsx @@ -0,0 +1,24 @@ +import classNames from 'classnames' +import React from 'react' +import ArrowLeft from 'src/components/icons/ArrowLeft' +import ArrowRight from 'src/components/icons/ArrowRight' +import s from "./CustomCarouselArrow.module.scss" +interface CustomCarouselArrowProps + extends React.ButtonHTMLAttributes { + side: 'left' | 'right' + isDisabled:Boolean +} + +export const CustomCarouselArrow = ({ + side,isDisabled, + ...props +}: CustomCarouselArrowProps) => { + return ( + + ) +} diff --git a/src/components/common/LabelCommon/LabelCommon.module.scss b/src/components/common/LabelCommon/LabelCommon.module.scss new file mode 100644 index 000000000..20dcb1294 --- /dev/null +++ b/src/components/common/LabelCommon/LabelCommon.module.scss @@ -0,0 +1,43 @@ +.labelCommonWarper{ + display: inline-flex; + align-items: flex-start; + font-weight: bold; + letter-spacing: 0.01em; + @apply text-white text-right; + &.defaultSize{ + min-height: 2rem; + line-height: 2rem; + font-size: 1.2rem; + padding: 0 0.8rem; + } + &.largeSize{ + max-height: 2.4rem; + line-height: 2.4rem; + font-size: 1.6rem; + padding: 0 1.8rem; + } + &.defaultType{ + @apply bg-positive-dark; + } + &.discountType{ + @apply bg-negative; + } + &.waitingType{ + @apply bg-warning; + } + &.deliveringType{ + @apply bg-info; + } + &.deliveredType{ + @apply bg-positive; + } + &.defaultShape{ + border-radius: 0.4rem; + } + &.halfShape{ + border-radius: 0px 1.4rem 1.4rem 0px; + } + &.roundShape{ + border-radius: 1.4rem; + } +} \ No newline at end of file diff --git a/src/components/common/LabelCommon/LabelCommon.tsx b/src/components/common/LabelCommon/LabelCommon.tsx new file mode 100644 index 000000000..fcb9b7eae --- /dev/null +++ b/src/components/common/LabelCommon/LabelCommon.tsx @@ -0,0 +1,30 @@ +import classNames from 'classnames' +import React from 'react' +import s from './LabelCommon.module.scss' +interface LabelCommonProps extends React.HTMLAttributes { + size?: 'default' | 'large' + shape?: 'half' | 'round' | 'default' + type?: 'default' | 'discount' | 'waiting' | 'delivering' | 'delivered' + color?: string +} + +const LabelCommon = ({ + size = 'default', + type = 'default', + shape = "default", + children, +}: LabelCommonProps) => { + return ( +
+ {children} +
+ ) +} + +export default LabelCommon diff --git a/src/components/common/QuanittyInput/QuanittyInput.module.scss b/src/components/common/QuanittyInput/QuanittyInput.module.scss new file mode 100644 index 000000000..d8a0e5fc1 --- /dev/null +++ b/src/components/common/QuanittyInput/QuanittyInput.module.scss @@ -0,0 +1,39 @@ +@import '../../../styles/utilities'; +.quanittyInputWarper{ + border-color: theme("textColor.active"); + @apply border border-solid inline-flex justify-between items-center custom-border-radius; + .plusIcon, .minusIcon{ + &:hover{ + cursor: pointer; + } + } + &.default{ + max-width: 18.4rem; + min-height: 4rem; + .plusIcon, .minusIcon{ + margin: 0.8rem; + width: 2.4rem; + height: 2.4rem; + } + } + &.small{ + max-width: 10rem; + min-height: 2.8rem; + .plusIcon, .minusIcon{ + margin: 0 0.6rem; + // width: 1rem; + // height: 1rem; + } + } + .quanittyInput{ + @apply bg-background outline-none w-1/2 text-center h-full font-bold; + font-size: 20px; + line-height: 28px; + color: theme("textColor.active"); + &::-webkit-inner-spin-button, &::-webkit-inner-spin-button{ + -webkit-appearance: none; + margin: 0; + } + } + +} \ No newline at end of file diff --git a/src/components/common/QuanittyInput/QuanittyInput.tsx b/src/components/common/QuanittyInput/QuanittyInput.tsx new file mode 100644 index 000000000..a01f16fe7 --- /dev/null +++ b/src/components/common/QuanittyInput/QuanittyInput.tsx @@ -0,0 +1,83 @@ +import React, { ChangeEvent, useEffect, useState } from 'react' +import s from './QuanittyInput.module.scss' +import classNames from 'classnames' +import { Minus, Plus } from '@components/icons' +interface QuanittyInputProps + extends Omit< + React.InputHTMLAttributes, + 'onChange' | 'min' | 'max' | 'step' | "type" | "size" + > { + size?: 'default' | 'small' + onChange?: (value: number) => void + initValue?: number + min?: number + max?: number + step?: number +} + +const QuanittyInput = ({ + size = 'default', + onChange, + initValue = 0, + min, + max, + step = 1, + ...props +}: QuanittyInputProps) => { + const [value, setValue] = useState(0) + + useEffect(() => { + onChange && onChange(value) + }, [value]) + + useEffect(() => { + initValue && setValue(initValue) + }, [initValue]) + + const onPlusClick = () => { + if (max && value + step > max) { + setValue(max) + } else { + setValue(value + step) + } + } + + const onMinusClick = () => { + if (min && value - step < min) { + setValue(min) + } else { + setValue(value - step) + } + } + + const onValueChange = (e: ChangeEvent) => { + let value = Number(e.target.value) || 0 + if (min && value < min) { + setValue(min) + } else if (max && value > max) { + setValue(max) + } else { + setValue(value) + } + } + + return ( +
+
+ +
+ +
+ +
+
+ ) +} + +export default QuanittyInput diff --git a/src/components/common/index.ts b/src/components/common/index.ts index 8144b0de0..6cc7b42d9 100644 --- a/src/components/common/index.ts +++ b/src/components/common/index.ts @@ -1,5 +1,8 @@ export { default as ButtonCommon } from './ButtonCommon/ButtonCommon' export { default as Layout } from './Layout/Layout' +export { default as CarouselCommon } from './CarouselCommon/CarouselCommon' +export { default as QuanittyInput } from './QuanittyInput/QuanittyInput' +export { default as LabelCommon } from './LabelCommon/LabelCommon' export { default as Head } from './Head/Head' export { default as ViewAllItem} from './ViewAllItem/ViewAllItem' export { default as ItemWishList} from './ItemWishList/ItemWishList' diff --git a/src/components/icons/ArrowLeft.tsx b/src/components/icons/ArrowLeft.tsx new file mode 100644 index 000000000..cc85d36dd --- /dev/null +++ b/src/components/icons/ArrowLeft.tsx @@ -0,0 +1,18 @@ +const ArrowLeft = ({ ...props }) => { + return ( + + + + ) +} + +export default ArrowLeft diff --git a/src/components/icons/ArrowRight.tsx b/src/components/icons/ArrowRight.tsx new file mode 100644 index 000000000..0b57e663a --- /dev/null +++ b/src/components/icons/ArrowRight.tsx @@ -0,0 +1,18 @@ +const ArrowRight = ({ ...props }) => { + return ( + + + + ) +} + +export default ArrowRight diff --git a/src/components/icons/Minus.tsx b/src/components/icons/Minus.tsx new file mode 100644 index 000000000..7c3b97d30 --- /dev/null +++ b/src/components/icons/Minus.tsx @@ -0,0 +1,18 @@ +const ArrowRight = ({ ...props }) => { + return ( + + + + ) +} + +export default ArrowRight diff --git a/src/components/icons/Plus.tsx b/src/components/icons/Plus.tsx new file mode 100644 index 000000000..c8b2fcca3 --- /dev/null +++ b/src/components/icons/Plus.tsx @@ -0,0 +1,18 @@ +const ArrowLeft = ({ ...props }) => { + return ( + + + + ) +} + +export default ArrowLeft diff --git a/src/styles/_base.scss b/src/styles/_base.scss index affd4207b..abffa0914 100644 --- a/src/styles/_base.scss +++ b/src/styles/_base.scss @@ -34,9 +34,12 @@ --border-line: #ebebeb; --background: #f8f8f8; --white: #fbfbfb; + --background-arrow:rgba(20, 20, 20, 0.05); + --font-size: 1.6rem; + --line-height: 2.4rem; - --font-size: 16px; - --line-height: 24px; + // --font-size: 16px; + // --line-height: 24px; --font-sans: "Nunito", cursive, -apple-system, system-ui, BlinkMacSystemFont, "Helvetica Neue", "Helvetica", sans-serif; diff --git a/tailwind.config.js b/tailwind.config.js index 393960c51..d2fe7ee70 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -48,6 +48,9 @@ module.exports = { 'line': 'var(--border-line)', 'background': 'var(--background)', 'white': 'var(--white)', + + 'background-arrow':'var(--background-arrow)', + 'disabled': 'var(--text-disabled)', // @deprecated (NOT use these variables) @@ -113,7 +116,10 @@ module.exports = { '2xl': '1536px', // => @media (min-width: 1536px) { ... } - } + }, + caroucel:{ + "arrow-height":"64px" + }, }, }, plugins: [require('postcss-import'), require('tailwindcss'), require('autoprefixer')]