From 6fea2ecc355d53497541656e3295aebe61783f00 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 23 Aug 2021 18:30:37 +0700 Subject: [PATCH] init: label common --- pages/index.tsx | 11 ++++-- .../LabelCommon/LabelCommon.module.scss | 38 +++++++++++++++++++ .../common/LabelCommon/LabelCommon.tsx | 30 +++++++++++++++ .../common/QuanittyInput/QuanittyInput.tsx | 8 ++-- src/components/common/index.ts | 1 + 5 files changed, 81 insertions(+), 7 deletions(-) create mode 100644 src/components/common/LabelCommon/LabelCommon.module.scss create mode 100644 src/components/common/LabelCommon/LabelCommon.tsx diff --git a/pages/index.tsx b/pages/index.tsx index 938809fb6..a73f90cb2 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -1,6 +1,6 @@ import { useState } from 'react' -import {CarouselCommon, Layout, QuanittyInput } from 'src/components/common' +import {CarouselCommon, LabelCommon, Layout, QuanittyInput } from 'src/components/common' const dataTest = [{ text:1 },{ @@ -19,8 +19,13 @@ export default function Home() { return ( <> - - + + + SEEFOOT + -15% + Waitting + delivering + delivered ) } diff --git a/src/components/common/LabelCommon/LabelCommon.module.scss b/src/components/common/LabelCommon/LabelCommon.module.scss new file mode 100644 index 000000000..94b683c20 --- /dev/null +++ b/src/components/common/LabelCommon/LabelCommon.module.scss @@ -0,0 +1,38 @@ +.labelCommonWarper{ + display: inline-flex; + font-weight: bold; + &.defaultSize{ + max-height: 2rem; + line-height: 2rem; + font-size: 1.2rem; + } + &.largeSize{ + max-height: 2.4rem; + line-height: 2.4rem; + font-size: 1.6rem; + } + &.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.tsx b/src/components/common/QuanittyInput/QuanittyInput.tsx index 21629548d..a01f16fe7 100644 --- a/src/components/common/QuanittyInput/QuanittyInput.tsx +++ b/src/components/common/QuanittyInput/QuanittyInput.tsx @@ -5,9 +5,9 @@ import { Minus, Plus } from '@components/icons' interface QuanittyInputProps extends Omit< React.InputHTMLAttributes, - 'onChange' | 'min' | 'max' | 'step' + 'onChange' | 'min' | 'max' | 'step' | "type" | "size" > { - type?: 'default' | 'small' + size?: 'default' | 'small' onChange?: (value: number) => void initValue?: number min?: number @@ -16,7 +16,7 @@ interface QuanittyInputProps } const QuanittyInput = ({ - type = 'default', + size = 'default', onChange, initValue = 0, min, @@ -62,7 +62,7 @@ const QuanittyInput = ({ } return ( -
+
diff --git a/src/components/common/index.ts b/src/components/common/index.ts index 5a5df21c9..16401b049 100644 --- a/src/components/common/index.ts +++ b/src/components/common/index.ts @@ -2,5 +2,6 @@ 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'