From f4c8a29ba1e0c937194a38c9e77bb514962518f2 Mon Sep 17 00:00:00 2001 From: Davdeyang <1320501826@qq.com> Date: Thu, 23 Mar 2023 00:46:51 +0800 Subject: [PATCH 01/10] =?UTF-8?q?feat:=E6=B7=BB=E5=8A=A0dromDown=E7=BB=84?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/_test.tsx | 24 ++++++- src/components/dropDown/dropDown.module.css | 11 ++++ src/components/dropDown/dropDown.module.less | 13 ++++ src/components/dropDown/index.tsx | 68 ++++++++++++++++++++ 4 files changed, 115 insertions(+), 1 deletion(-) create mode 100644 src/components/dropDown/dropDown.module.css create mode 100644 src/components/dropDown/dropDown.module.less create mode 100644 src/components/dropDown/index.tsx diff --git a/src/_test.tsx b/src/_test.tsx index 4e3a04d..046615c 100644 --- a/src/_test.tsx +++ b/src/_test.tsx @@ -6,10 +6,13 @@ import Upload from './components/upload/upload'; import Tab from './components/tab/tab'; import * as GOJI from 'goji_ui' +import DropDown from './components/dropDown'; function App() { const [visible, setVisible] = useState(false) const [ev, setEv] = useState(false) + const [modalVisible,setModalVisible]= useState(false); + return
{/* 请选择文件 + + + { + setModalVisible(true) + }} + visible={modalVisible} + width={100} + disable={false} + style={{ + width:"100px", + height:"100px", + backgroundColor:"green" + }} + modelContent={
弹框内容
} + > + SHOW MODEL +
} -ReactDom.render(, document.getElementById("app")) \ No newline at end of file +ReactDom.render(, document.getElementById("app")) diff --git a/src/components/dropDown/dropDown.module.css b/src/components/dropDown/dropDown.module.css new file mode 100644 index 0000000..10ecfc7 --- /dev/null +++ b/src/components/dropDown/dropDown.module.css @@ -0,0 +1,11 @@ +.dropDownButton { + cursor: pointer; + position: relative; +} +.model { + height: auto; + border: 1px solid greenyellow; + position: absolute; + top: 20px; + left: 0; +} diff --git a/src/components/dropDown/dropDown.module.less b/src/components/dropDown/dropDown.module.less new file mode 100644 index 0000000..04efb2c --- /dev/null +++ b/src/components/dropDown/dropDown.module.less @@ -0,0 +1,13 @@ + .dropDownButton{ + cursor: pointer; + position: relative; + } + + .model{ + height: auto; + border: 1px solid greenyellow; + position: absolute; + top: 20px; + left: 0; + } + diff --git a/src/components/dropDown/index.tsx b/src/components/dropDown/index.tsx new file mode 100644 index 0000000..28a64d4 --- /dev/null +++ b/src/components/dropDown/index.tsx @@ -0,0 +1,68 @@ +import React, { ReactElement, ReactNode, useEffect, useMemo, useState } from "react"; +import { createPortal } from "react-dom"; +import styles from "./dropDown.module.less"; + +type trigger = "click" | "hover"; + +interface IDropDown { + // trigger?: ("click" | "hover")[]; + trigger: trigger; + style?: React.CSSProperties; + className?: string; + children?: ReactNode; + visible?: boolean; + disable?: boolean; + modelContent: ReactNode; + width: number; + onChangeVisible: () => void; +} + +const DropDown: React.FC = ({ + trigger, + style, + width, + className, + children, + visible, + disable, + modelContent, + onChangeVisible, +}) => { + const [show, setShow] = useState(visible); + const dropDownButton = document.getElementById('dropDownButton') as HTMLElement; + + return ( +
+ {trigger === "click" ? ( + + ) : ( + + )} + + {show === true && + createPortal( +
+ {modelContent} +
, + dropDownButton + )} +
+ ); +}; + +export default DropDown; From b3d15bc311a4fcfb93c93a08ee01dba6889a2fe6 Mon Sep 17 00:00:00 2001 From: Davdeyang <1320501826@qq.com> Date: Thu, 23 Mar 2023 16:47:46 +0800 Subject: [PATCH 02/10] =?UTF-8?q?feat:dropDown=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/_test.tsx | 8 ++++---- src/components/dropDown/dropDown.module.css | 13 ++++++------- src/components/dropDown/dropDown.module.less | 16 +++++++++------- src/components/dropDown/index.tsx | 12 +++++------- 4 files changed, 24 insertions(+), 25 deletions(-) diff --git a/src/_test.tsx b/src/_test.tsx index 046615c..2d1d02b 100644 --- a/src/_test.tsx +++ b/src/_test.tsx @@ -4,7 +4,6 @@ import ReactDom from 'react-dom' import Modal from './components/modal/modal'; import Upload from './components/upload/upload'; import Tab from './components/tab/tab'; - import * as GOJI from 'goji_ui' import DropDown from './components/dropDown'; @@ -103,11 +102,11 @@ function App() { { - setModalVisible(true) + setModalVisible(!modalVisible) }} - visible={modalVisible} width={100} disable={false} style={{ @@ -116,6 +115,7 @@ function App() { backgroundColor:"green" }} modelContent={
弹框内容
} + // className={"modless"} > SHOW MODEL
diff --git a/src/components/dropDown/dropDown.module.css b/src/components/dropDown/dropDown.module.css index 10ecfc7..d9fed29 100644 --- a/src/components/dropDown/dropDown.module.css +++ b/src/components/dropDown/dropDown.module.css @@ -1,11 +1,10 @@ -.dropDownButton { +.dropDown .dropDownButton { cursor: pointer; - position: relative; + display: block; } -.model { - height: auto; +.dropDown .model { border: 1px solid greenyellow; - position: absolute; - top: 20px; - left: 0; + display: inline-block; + height: auto; + box-shadow: 0 6px 16px 0 rgba(0, 0, 0, 0.08), 0 3px 6px -4px rgba(0, 0, 0, 0.12), 0 9px 28px 8px rgba(0, 0, 0, 0.05); } diff --git a/src/components/dropDown/dropDown.module.less b/src/components/dropDown/dropDown.module.less index 04efb2c..791e4d7 100644 --- a/src/components/dropDown/dropDown.module.less +++ b/src/components/dropDown/dropDown.module.less @@ -1,13 +1,15 @@ - .dropDownButton{ +.dropDown { + .dropDownButton { cursor: pointer; - position: relative; + display: block; } - .model{ + .model { height: auto; border: 1px solid greenyellow; - position: absolute; - top: 20px; - left: 0; + display: inline-block; + height: auto; + box-shadow: 0 6px 16px 0 rgba(0, 0, 0, 0.08), + 0 3px 6px -4px rgba(0, 0, 0, 0.12), 0 9px 28px 8px rgba(0, 0, 0, 0.05); } - +} diff --git a/src/components/dropDown/index.tsx b/src/components/dropDown/index.tsx index 28a64d4..d1f24b5 100644 --- a/src/components/dropDown/index.tsx +++ b/src/components/dropDown/index.tsx @@ -1,4 +1,4 @@ -import React, { ReactElement, ReactNode, useEffect, useMemo, useState } from "react"; +import React, { ReactNode, useEffect, useMemo, useState } from "react"; import { createPortal } from "react-dom"; import styles from "./dropDown.module.less"; @@ -29,16 +29,15 @@ const DropDown: React.FC = ({ onChangeVisible, }) => { const [show, setShow] = useState(visible); - const dropDownButton = document.getElementById('dropDownButton') as HTMLElement; + const dropDown = document.getElementById('dropDown') as HTMLElement; return ( -
+ ); From e515da27c14d2897d2f5acab028a5bc5d873559a Mon Sep 17 00:00:00 2001 From: Davdeyang <1320501826@qq.com> Date: Thu, 23 Mar 2023 18:01:51 +0800 Subject: [PATCH 03/10] =?UTF-8?q?feat:dropDown=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/_test.tsx | 235 ++++++++++-------- src/components/dropDown/dropDown.module.css | 29 ++- src/components/dropDown/dropDown.module.less | 30 ++- src/components/dropDown/index.tsx | 55 +++- .../\344\270\213\347\256\255\345\244\264.jpg" | Bin 0 -> 7759 bytes 5 files changed, 238 insertions(+), 111 deletions(-) create mode 100644 "static/\344\270\213\347\256\255\345\244\264.jpg" diff --git a/src/_test.tsx b/src/_test.tsx index 2d1d02b..0db12f2 100644 --- a/src/_test.tsx +++ b/src/_test.tsx @@ -1,19 +1,19 @@ - -import React, { useState } from 'react'; -import ReactDom from 'react-dom' -import Modal from './components/modal/modal'; -import Upload from './components/upload/upload'; -import Tab from './components/tab/tab'; -import * as GOJI from 'goji_ui' -import DropDown from './components/dropDown'; +import React, { useState } from "react"; +import ReactDom from "react-dom"; +import Modal from "./components/modal/modal"; +import Upload from "./components/upload/upload"; +import Tab from "./components/tab/tab"; +import * as GOJI from "goji_ui"; +import DropDown from "./components/dropDown"; function App() { - const [visible, setVisible] = useState(false) - const [ev, setEv] = useState(false) - const [modalVisible,setModalVisible]= useState(false); + const [visible, setVisible] = useState(false); + const [ev, setEv] = useState(false); + const [modalVisible, setModalVisible] = useState(false); - return
- {/* + {/* 这是扩展的内容
} items={[ @@ -30,96 +30,129 @@ function App() { ]} /> */} +

test

+ + { + setEv(true); + }} + hiddenStyle={{ + height: "0px", + overflow: "hidden", + }} + tabContentVisible={ev} + extSelector={'[aria-label="tab"]'} + extension={ +
{ + setEv(!ev); + }} + className="ext" + > + 这是扩展的内容 +
+ } + items={[ + { + title: "tab1", + key: "tab1", + children:
tab1
, + }, + { + title: "tab2", + key: "tab2", + children:
tab2
, + }, + ]} + /> -

test

- - { - setEv(true) - }} - hiddenStyle={{ - height:'0px', - overflow:'hidden' - }} - tabContentVisible={ev} - extSelector={'[aria-label="tab"]'} - extension={
{ setEv(!ev) }} className="ext">这是扩展的内容
} - items={[ - { - title: "tab1", - key: "tab1", - children:
tab1
- }, - { - title: "tab2", - key: "tab2", - children:
tab2
- } - ]} - /> - - { - setVisible(false) - }} - visible={visible} - > -
- how to set default value for typescript interface field - -
-
- - { - for (var i = 0; i < f.length; i++) { - console.log(f[i].name) - } - return new Promise((r, j) => { - setTimeout(() => { - r(f) - }, 1000); - }) - }} - - valueFilter={({ response }) => { - return (response as Record).url - }} - onComplete={(res: any[]) => { - console.log(res) - }} - > - 请选择文件 - + { + setVisible(false); + }} + visible={visible} + > +
+ how to set default value for typescript interface field + +
+
+ { + for (var i = 0; i < f.length; i++) { + console.log(f[i].name); + } + return new Promise((r, j) => { + setTimeout(() => { + r(f); + }, 1000); + }); + }} + valueFilter={({ response }) => { + return (response as Record).url; + }} + onComplete={(res: any[]) => { + console.log(res); + }} + > + 请选择文件 + - { - setModalVisible(!modalVisible) - }} - width={100} - disable={false} - style={{ - width:"100px", - height:"100px", - backgroundColor:"green" - }} - modelContent={
弹框内容
} - // className={"modless"} - > - SHOW MODEL -
-
+ { + setModalVisible(!modalVisible); + }} + // width={100} + disable={false} + style={{ + width: "100px", + height: "100px", + backgroundColor: "green", + }} + modelContent={[ + { + id: "1", + label: ( + + 1st menu item + + ), + }, + { + id: "2", + label: ( + + 2nd menu item + + ), + }, + ] + } + // className={"modless"} + > + SHOW MODEL + + + ); } -ReactDom.render(, document.getElementById("app")) +ReactDom.render(, document.getElementById("app")); diff --git a/src/components/dropDown/dropDown.module.css b/src/components/dropDown/dropDown.module.css index d9fed29..a6316a4 100644 --- a/src/components/dropDown/dropDown.module.css +++ b/src/components/dropDown/dropDown.module.css @@ -1,10 +1,35 @@ +.dropDown { + position: relative; +} .dropDown .dropDownButton { cursor: pointer; - display: block; + position: absolute; + top: 0; + left: 0; } .dropDown .model { - border: 1px solid greenyellow; + position: absolute; + top: 25px; + cursor: pointer; + padding: 5px; display: inline-block; height: auto; + border-radius: 5px; box-shadow: 0 6px 16px 0 rgba(0, 0, 0, 0.08), 0 3px 6px -4px rgba(0, 0, 0, 0.12), 0 9px 28px 8px rgba(0, 0, 0, 0.05); } +.dropDown .model .modelList { + margin: 0; + padding: 0; +} +.dropDown .model .modelList .modalListItem { + list-style: none; + padding: 5px; +} +.dropDown .model .modelList .modalListItem a { + text-decoration: none; + color: #414141; +} +.dropDown .model .modelList .modalListItem:hover { + transition: all 0.2s; + background-color: aliceblue; +} diff --git a/src/components/dropDown/dropDown.module.less b/src/components/dropDown/dropDown.module.less index 791e4d7..9d2c224 100644 --- a/src/components/dropDown/dropDown.module.less +++ b/src/components/dropDown/dropDown.module.less @@ -1,15 +1,41 @@ .dropDown { + position: relative; .dropDownButton { cursor: pointer; - display: block; + position: absolute; + top: 0; + left: 0; } .model { + position: absolute; + top: 25px; + cursor: pointer; height: auto; - border: 1px solid greenyellow; + padding: 5px; display: inline-block; height: auto; + border-radius: 5px; box-shadow: 0 6px 16px 0 rgba(0, 0, 0, 0.08), 0 3px 6px -4px rgba(0, 0, 0, 0.12), 0 9px 28px 8px rgba(0, 0, 0, 0.05); + + .modelList{ + margin: 0; + padding: 0; + .modalListItem { + list-style: none; + padding: 5px; + a{ + text-decoration: none; + color: rgb(65, 65, 65); + } + } + + .modalListItem:hover{ + transition: all .2s; + background-color: aliceblue; + } + } + } } diff --git a/src/components/dropDown/index.tsx b/src/components/dropDown/index.tsx index d1f24b5..bbb076c 100644 --- a/src/components/dropDown/index.tsx +++ b/src/components/dropDown/index.tsx @@ -3,7 +3,7 @@ import { createPortal } from "react-dom"; import styles from "./dropDown.module.less"; type trigger = "click" | "hover"; - +type position = "left" | "right" | "top" | "bottom"; interface IDropDown { // trigger?: ("click" | "hover")[]; trigger: trigger; @@ -12,8 +12,9 @@ interface IDropDown { children?: ReactNode; visible?: boolean; disable?: boolean; - modelContent: ReactNode; - width: number; + modelContent: object[]; + width?: number; + position?: position; onChangeVisible: () => void; } @@ -26,10 +27,38 @@ const DropDown: React.FC = ({ visible, disable, modelContent, + position, onChangeVisible, }) => { const [show, setShow] = useState(visible); - const dropDown = document.getElementById('dropDown') as HTMLElement; + const dropDown = document.getElementById("dropDown") as HTMLElement; + + const fixedPositon = () => { + switch (position) { + case "left": + return { + bottom: 0, + left: 0, + }; + case "right": + return { + right: 0, + top: 0, + }; + case "top": + return { + bottom: 0, + left: 0, + }; + case "bottom": + return { + bottom: 0, + left: 0, + }; + default: + break; + } + }; return ( ); } diff --git a/src/common/style/index.css b/src/common/style/index.css new file mode 100644 index 0000000..98383e1 --- /dev/null +++ b/src/common/style/index.css @@ -0,0 +1,8 @@ +:root { + --background: #ebedff; + --blueDark: #5c6dff; + --fadedGary: #818181; + --white: #ffffff; + --black: #000000; + --white-shadow: 0px 0px 13px 5px rgba(173, 182, 255, 0.25); +} diff --git a/src/common/style/index.less b/src/common/style/index.less new file mode 100644 index 0000000..97b05a3 --- /dev/null +++ b/src/common/style/index.less @@ -0,0 +1,9 @@ +// :root 伪类选择器 匹配文档树的根节点 +:root { + --background: #ebedff; + --blueDark: #5c6dff; + --fadedGary: #818181; + --white: #ffffff; + --black: #000000; + --white-shadow: 0px 0px 13px 5px rgba(173, 182, 255, 0.25); +} diff --git a/src/components/button/button.tsx b/src/components/button/button.tsx new file mode 100644 index 0000000..9b2b09d --- /dev/null +++ b/src/components/button/button.tsx @@ -0,0 +1,79 @@ +import React from "react"; +import "./index.less"; +import classnames from "classnames"; + +type type = "primary" | "link" | "dashed" | "text" | "disable"; +type shape = "round" | "circle"; +type iconPos = "left" | "right"; + +interface IButton { + type?: type | undefined; + style?: React.CSSProperties | undefined; + className?: string | undefined; + children?: React.ReactNode | undefined; + disable?: boolean | undefined; + shape?: shape | undefined; + icon?: React.ReactNode | undefined; + iconPos?: iconPos | undefined; + herf?: string | undefined; + onBtnClick?: () => void; +} + +const Button: React.FC = ({ + type, + style, + className, + children, + disable, + shape, + icon, + iconPos, + onBtnClick, +}) => { + const getBtnClass = () => { + switch (type) { + case "primary": + return "primaryButton gojiButton"; + case "dashed": + return "dashedButton gojiButton"; + case "link": + return "linkButton gojiButton"; + case "text": + return "textButton gojiButton"; + case "disable": + return "disable gojiButton"; + default: + return "gojiButton"; + } + }; + + const shapes = () => { + switch (shape) { + case "circle": + return "circle"; + case "round": + return "round"; + default: + break; + } + }; + + + return ( + + ); +}; + +export default Button; diff --git a/src/components/button/index.css b/src/components/button/index.css new file mode 100644 index 0000000..36a67cf --- /dev/null +++ b/src/components/button/index.css @@ -0,0 +1,61 @@ +.gojiButton { + display: inline-block; + font-size: 14px; + padding: 4px 15px; + border-radius: 6px; + cursor: pointer; + background-color: #fff; + color: #000; + text-align: center; + border: 1px solid; + margin: 6px; + line-height: 30px; +} +.gojiButton:hover { + color: red; +} +.primaryButton { + font-size: 14px; + padding: 4px 15px; + border-radius: 6px; + cursor: pointer; + background-color: #fff; + list-style: none; + color: rgba(0, 0, 0, 0.88); + text-align: center; + border: 1px solid; +} +.primaryButton:hover { + background-color: green !important; + color: #fff !important; +} +.linkButton { + border: none; + color: green; +} +.linkButton:hover { + color: #1f77db !important; +} +.textButton { + border: none; +} +.textButton:hover { + background-color: #b3b4b4; + color: #000; +} +.round { + border-radius: 40px; +} +.circle { + border-radius: 50%; +} +.dashedButton { + border: 1px dashed; +} +.disableButton { + cursor: not-allowed !important; + border-color: #d9d9d9; + color: rgba(0, 0, 0, 0.25); + background-color: rgba(0, 0, 0, 0.04); + box-shadow: none; +} diff --git a/src/components/button/index.less b/src/components/button/index.less new file mode 100644 index 0000000..3cde6cc --- /dev/null +++ b/src/components/button/index.less @@ -0,0 +1,72 @@ +.gojiButton { + display: inline-block; + font-size: 14px; + padding: 4px 15px; + border-radius: 6px; + cursor: pointer; + background-color: #fff; + color: #000; + text-align: center; + border: 1px solid; + margin: 6px; + line-height: 30px; +} + +.gojiButton:hover { + color: red; +} + +.primaryButton { + font-size: 14px; + padding: 4px 15px; + border-radius: 6px; + cursor: pointer; + background-color: #fff; + list-style: none; + color: rgba(0, 0, 0, 0.88); + text-align: center; + border: 1px solid; +} + +.primaryButton:hover { + background-color: green !important; + color: #fff !important; +} + +.linkButton { + border: none; + color: green; +} + +.linkButton:hover { + color: rgb(31, 119, 219) !important; +} + +.textButton { + border: none; +} + +.textButton:hover { + background-color: rgb(179, 180, 180); + color: #000; +} + +.round { + border-radius: 40px; +} + +.circle { + border-radius: 50%; +} + +.dashedButton { + border: 1px dashed; +} + +.disableButton { + cursor: not-allowed !important; + border-color: #d9d9d9; + color: rgba(0, 0, 0, 0.25); + background-color: rgba(0, 0, 0, 0.04); + box-shadow: none; +} diff --git a/src/components/dropDown/dropDown.css b/src/components/dropDown/dropDown.css new file mode 100644 index 0000000..ae20d94 --- /dev/null +++ b/src/components/dropDown/dropDown.css @@ -0,0 +1,156 @@ +.dropDown { + display: flex; + justify-content: space-between; + align-items: center; + box-shadow: var(--white-shadow); + padding: 12px 24px; + cursor: pointer; + position: relative; + border-radius: 5px; +} +.dropDown .dropDownOption { + background: var(--white); + width: 100%; + box-shadow: var(--white-shadow); + padding: 2px; +} +.dropDown .dropDownOption .dropDownOptionItem { + padding: 12px; + color: var(--black); +} +.dropDown .dropDownOption .dropDownOptionItem:hover { + background: var(--background); + color: var(--fadedGary); +} +.dropDown .PositionTop { + position: absolute; + top: -12px; + left: 0; + transform: translateY(-100%); + background: var(--white); + width: 100%; + box-shadow: var(--white-shadow); +} +.dropDown .PositionTop::after { + width: 0; + height: 0; + content: ""; + border-width: 8px; + border-color: #ffffff transparent transparent transparent; + border-style: dashed dashed solid dashed; + position: absolute; + top: 91px; + right: 45%; + z-index: 99; +} +.dropDown .PositionTop::before { + width: 0; + height: 0; + content: ""; + border-width: 8px; + border-color: #ffffff transparent transparent transparent; + border-style: dashed dashed solid dashed; + position: absolute; + top: 91px; + right: 45%; + z-index: 99; +} +.dropDown .PositionTopRight { + position: absolute; + top: -12px; + left: 0; + transform: translateY(-100%); + background: var(--white); + width: 100%; + box-shadow: var(--white-shadow); +} +.dropDown .PositionTopRight::after { + width: 0; + height: 0; + content: ""; + border-width: 8px; + border-color: #ffffff transparent transparent transparent; + border-style: dashed dashed solid dashed; + position: absolute; + top: 91px; + right: 9px; + z-index: 99; +} +.dropDown .PositionTopRight::before { + width: 0; + height: 0; + content: ""; + border-width: 8px; + border-color: #ffffff transparent transparent transparent; + border-style: dashed dashed solid dashed; + position: absolute; + top: 91px; + right: 9px; + z-index: 99; +} +.dropDown .PositionBottom { + position: absolute; + left: 0; + bottom: -10px; + transform: translateY(100%); + background: var(--white); + width: 100%; + box-shadow: var(--white-shadow); +} +.dropDown .PositionBottom::after { + width: 0; + height: 0; + content: ""; + border-width: 8px; + border-color: transparent transparent #ffffff transparent; + border-style: dashed dashed solid dashed; + position: absolute; + top: -14px; + right: 45%; + z-index: 99; +} +.dropDown .PositionBottom::before { + width: 0; + height: 0; + content: ""; + border-width: 8px; + border-color: transparent transparent #ffffff transparent; + border-style: dashed dashed solid dashed; + position: absolute; + top: -14px; + right: 45%; + z-index: 99; +} +.dropDown .PositionBottomRight { + position: absolute; + left: 0; + bottom: -10px; + transform: translateY(100%); + background: var(--white); + width: 100%; + box-shadow: var(--white-shadow); +} +.dropDown .PositionBottomRight::after { + width: 0; + height: 0; + content: ""; + border-width: 6px; + border-color: transparent transparent #a07676 transparent; + border-style: dashed dashed solid dashed; + position: absolute; + top: -11px; + right: 9px; + z-index: 99; +} +.dropDown .PositionBottomRight::before { + width: 0; + height: 0; + content: ""; + border-width: 6px; + border-color: transparent transparent #884b4b transparent; + border-style: dashed dashed solid dashed; + position: absolute; + top: -11px; + right: 9px; + z-index: 99; +} diff --git a/src/components/dropDown/dropDown.less b/src/components/dropDown/dropDown.less new file mode 100644 index 0000000..d2fc826 --- /dev/null +++ b/src/components/dropDown/dropDown.less @@ -0,0 +1,170 @@ +.dropDown { + display: flex; + justify-content: space-between; + align-items: center; + box-shadow: var(--white-shadow); + padding: 12px 24px; + cursor: pointer; + position: relative; + border-radius: 5px; + + .dropDownOption { + background: var(--white); + width: 100%; + box-shadow: var(--white-shadow); + padding: 2px; + .dropDownOptionItem { + padding: 12px; + color: var(--black); + } + + .dropDownOptionItem:hover { + background: var(--background); + color: var(--fadedGary); + } + } + + .PositionTop { + position: absolute; + top: -12px; + left: 0; + transform: translateY(-100%); + background: var(--white); + width: 100%; + box-shadow: var(--white-shadow); + } + + .PositionTop::after { + width: 0; + height: 0; + content: ""; + border-width: 8px; + border-color: #ffffff transparent transparent transparent; + border-style: dashed dashed solid dashed; + position: absolute; + top: 91px; + right: 45%; + z-index: 99; + } + + .PositionTop::before { + width: 0; + height: 0; + content: ""; + border-width: 8px; + border-color: #ffffff transparent transparent transparent; + border-style: dashed dashed solid dashed; + position: absolute; + top: 91px; + right: 45%; + z-index: 99; + } + + .PositionTopRight { + position: absolute; + top: -12px; + left: 0; + transform: translateY(-100%); + background: var(--white); + width: 100%; + box-shadow: var(--white-shadow); + } + + .PositionTopRight::after { + width: 0; + height: 0; + content: ""; + border-width: 8px; + border-color: #ffffff transparent transparent transparent; + border-style: dashed dashed solid dashed; + position: absolute; + top: 91px; + right: 9px; + z-index: 99; + } + + .PositionTopRight::before { + width: 0; + height: 0; + content: ""; + border-width: 8px; + border-color: #ffffff transparent transparent transparent; + border-style: dashed dashed solid dashed; + position: absolute; + top: 91px; + right: 9px; + z-index: 99; + } + + .PositionBottom { + position: absolute; + left: 0; + bottom: -10px; + transform: translateY(100%); + background: var(--white); + width: 100%; + box-shadow: var(--white-shadow); + } + + .PositionBottom::after { + width: 0; + height: 0; + content: ""; + border-width: 8px; + border-color: transparent transparent #ffffff transparent; + border-style: dashed dashed solid dashed; + position: absolute; + top: -14px; + right: 45%; + z-index: 99; + } + + .PositionBottom::before { + width: 0; + height: 0; + content: ""; + border-width: 8px; + border-color: transparent transparent #ffffff transparent; + border-style: dashed dashed solid dashed; + position: absolute; + top: -14px; + right: 45%; + z-index: 99; + } + + .PositionBottomRight { + position: absolute; + left: 0; + bottom: -10px; + transform: translateY(100%); + background: var(--white); + width: 100%; + box-shadow: var(--white-shadow); + } + + .PositionBottomRight::after { + width: 0; + height: 0; + content: ""; + border-width: 6px; + border-color: transparent transparent #a07676 transparent; + border-style: dashed dashed solid dashed; + position: absolute; + top: -11px; + right: 9px; + z-index: 99; + } + + .PositionBottomRight::before { + width: 0; + height: 0; + content: ""; + border-width: 6px; + border-color: transparent transparent #884b4b transparent; + border-style: dashed dashed solid dashed; + position: absolute; + top: -11px; + right: 9px; + z-index: 99; + } +} diff --git a/src/components/dropDown/dropDown.module.css b/src/components/dropDown/dropDown.module.css deleted file mode 100644 index 79bf71a..0000000 --- a/src/components/dropDown/dropDown.module.css +++ /dev/null @@ -1,205 +0,0 @@ -.dropDown { - margin-top: 100px; - position: relative; -} -.dropDown .dropDownButton { - cursor: pointer; - display: flex; - justify-content: space-between; - align-items: center; -} -.dropDown .modelLeft { - position: absolute; - cursor: pointer; - padding: 5px; - display: inline-block; - height: auto; - border-radius: 5px; - box-shadow: 0 6px 16px 0 rgba(0, 0, 0, 0.08), 0 3px 6px -4px rgba(0, 0, 0, 0.12), 0 9px 28px 8px rgba(0, 0, 0, 0.05); -} -.dropDown .modelLeft .modelList { - margin: 0; - padding: 0; -} -.dropDown .modelLeft .modelList .modalListItem { - list-style: none; - padding: 5px; -} -.dropDown .modelLeft .modelList .modalListItem a { - text-decoration: none; - color: #414141; -} -.dropDown .modelLeft .modelList .modalListItem:hover { - transition: all 0.2s; - background-color: aliceblue; -} -.dropDown .modelLeft::after { - width: 0; - height: 0; - content: ""; - border-width: 6px; - border-color: transparent transparent #a07676 transparent; - border-style: dashed dashed solid dashed; - position: absolute; - top: -11px; - right: 9px; - z-index: 99; -} -.dropDown .modelLeft::before { - width: 0; - height: 0; - content: ""; - border-width: 6px; - border-color: transparent transparent #884b4b transparent; - border-style: dashed dashed solid dashed; - position: absolute; - top: -11px; - right: 9px; - z-index: 99; -} -.dropDown .modelCenter { - cursor: pointer; - padding: 5px; - display: inline-block; - height: auto; - border-radius: 5px; - box-shadow: 0 6px 16px 0 rgba(0, 0, 0, 0.08), 0 3px 6px -4px rgba(0, 0, 0, 0.12), 0 9px 28px 8px rgba(0, 0, 0, 0.05); -} -.dropDown .modelCenter .modelList { - margin: 0; - padding: 0; -} -.dropDown .modelCenter .modelList .modalListItem { - list-style: none; - padding: 5px; -} -.dropDown .modelCenter .modelList .modalListItem a { - text-decoration: none; - color: #414141; -} -.dropDown .modelCenter .modelList .modalListItem:hover { - transition: all 0.2s; - background-color: aliceblue; -} -.dropDown .modelCenter::before { - width: 0; - height: 0; - content: ""; - border-width: 6px; - border-color: transparent transparent #ffffff transparent; - border-style: dashed dashed solid dashed; - position: absolute; - top: -11px; - right: 45%; - z-index: 99; -} -.dropDown .modelCenter::after { - width: 0; - height: 0; - content: ""; - border-width: 6px; - border-color: transparent transparent #ffffff transparent; - border-style: dashed dashed solid dashed; - position: absolute; - top: -11px; - right: 45%; - z-index: 99; -} -.dropDown .modelTopRight { - position: absolute; - cursor: pointer; - padding: 5px; - display: inline-block; - height: auto; - border-radius: 5px; - box-shadow: 0 6px 16px 0 rgba(0, 0, 0, 0.08), 0 3px 6px -4px rgba(0, 0, 0, 0.12), 0 9px 28px 8px rgba(0, 0, 0, 0.05); -} -.dropDown .modelTopRight .modelList { - margin: 0; - padding: 0; -} -.dropDown .modelTopRight .modelList .modalListItem { - list-style: none; - padding: 5px; -} -.dropDown .modelTopRight .modelList .modalListItem a { - text-decoration: none; - color: #414141; -} -.dropDown .modelTopRight .modelList .modalListItem:hover { - transition: all 0.2s; - background-color: aliceblue; -} -.dropDown .modelTopRight::before { - width: 0; - height: 0; - content: ""; - border-width: 6px; - border-color: #ffffff transparent transparent transparent; - border-style: dashed dashed solid dashed; - position: absolute; - top: -11px; - right: 9px; - z-index: 99; -} -.dropDown .modelTopRight::after { - width: 0; - height: 0; - content: ""; - border-width: 6px; - border-color: #ffffff transparent transparent transparent; - border-style: dashed dashed solid dashed; - position: absolute; - top: -11px; - right: 9px; - z-index: 99; -} -.dropDown .modelTopCenter { - position: absolute; - cursor: pointer; - padding: 5px; - display: inline-block; - height: auto; - border-radius: 5px; - box-shadow: 0 6px 16px 0 rgba(0, 0, 0, 0.08), 0 3px 6px -4px rgba(0, 0, 0, 0.12), 0 9px 28px 8px rgba(0, 0, 0, 0.05); -} -.dropDown .modelTopCenter .modelList { - margin: 0; - padding: 0; -} -.dropDown .modelTopCenter .modelList .modalListItem { - list-style: none; - padding: 5px; -} -.dropDown .modelTopCenter .modelList .modalListItem a { - text-decoration: none; - color: #414141; -} -.dropDown .modelTopCenter .modelList .modalListItem:hover { - transition: all 0.2s; - background-color: aliceblue; -} -.dropDown .modelTopCenter::before { - width: 0; - height: 0; - content: ""; - border-width: 6px; - border-color: #ffffff transparent transparent transparent; - border-style: dashed dashed solid dashed; - position: absolute; - top: -11px; - right: 45%; - z-index: 99; -} -.dropDown .modelTopCenter::after { - width: 0; - height: 0; - content: ""; - border-width: 6px; - border-color: #ffffff transparent transparent transparent; - border-style: dashed dashed solid dashed; - position: absolute; - top: -11px; - right: 45%; - z-index: 99; -} diff --git a/src/components/dropDown/dropDown.module.less b/src/components/dropDown/dropDown.module.less deleted file mode 100644 index c0c9ce7..0000000 --- a/src/components/dropDown/dropDown.module.less +++ /dev/null @@ -1,239 +0,0 @@ -.dropDown { - margin-top: 100px; - position: relative; - // overflow: hidden; - .dropDownButton { - cursor: pointer; - // position: absolute; - // top: 0; - // left: 0; - display: flex; - justify-content: space-between; - align-items: center; - } - - .modelLeft{ - position: absolute; - cursor: pointer; - height: auto; - padding: 5px; - display: inline-block; - height: auto; - border-radius: 5px; - box-shadow: 0 6px 16px 0 rgba(0, 0, 0, 0.08), - 0 3px 6px -4px rgba(0, 0, 0, 0.12), 0 9px 28px 8px rgba(0, 0, 0, 0.05); - - .modelList{ - margin: 0; - padding: 0; - .modalListItem { - list-style: none; - padding: 5px; - a{ - text-decoration: none; - color: rgb(65, 65, 65); - } - } - - .modalListItem:hover{ - transition: all .2s; - background-color: aliceblue; - } - } - } - - .modelLeft::after{ - width: 0; - height: 0; - content: ""; - border-width: 6px; - border-color: transparent transparent #a07676 transparent; - border-style: dashed dashed solid dashed; - position: absolute; - top: -11px; - right: 9px; - z-index: 99; - } - - .modelLeft::before{ - width: 0; - height: 0; - content: ""; - border-width: 6px; - border-color: transparent transparent #884b4b transparent; - border-style: dashed dashed solid dashed; - position: absolute; - top: -11px; - right: 9px; - z-index: 99; - } - - .modelCenter{ - // position: absolute; - cursor: pointer; - height: auto; - padding: 5px; - display: inline-block; - height: auto; - border-radius: 5px; - box-shadow: 0 6px 16px 0 rgba(0, 0, 0, 0.08), - 0 3px 6px -4px rgba(0, 0, 0, 0.12), 0 9px 28px 8px rgba(0, 0, 0, 0.05); - - .modelList{ - margin: 0; - padding: 0; - .modalListItem { - list-style: none; - padding: 5px; - a{ - text-decoration: none; - color: rgb(65, 65, 65); - } - } - - .modalListItem:hover{ - transition: all .2s; - background-color: aliceblue; - } - } - } - - .modelCenter::before{ - width: 0; - height: 0; - content: ""; - border-width: 6px; - border-color: transparent transparent #ffffff transparent; - border-style: dashed dashed solid dashed; - position: absolute; - top: -11px; - right: 45%; - z-index: 99; - } - - .modelCenter::after{ - width: 0; - height: 0; - content: ""; - border-width: 6px; - border-color: transparent transparent #ffffff transparent; - border-style: dashed dashed solid dashed; - position: absolute; - top: -11px; - right: 45%; - z-index: 99; - } - - - .modelTopRight{ - position: absolute; - cursor: pointer; - height: auto; - padding: 5px; - display: inline-block; - height: auto; - border-radius: 5px; - box-shadow: 0 6px 16px 0 rgba(0, 0, 0, 0.08), - 0 3px 6px -4px rgba(0, 0, 0, 0.12), 0 9px 28px 8px rgba(0, 0, 0, 0.05); - - .modelList{ - margin: 0; - padding: 0; - .modalListItem { - list-style: none; - padding: 5px; - a{ - text-decoration: none; - color: rgb(65, 65, 65); - } - } - - .modalListItem:hover{ - transition: all .2s; - background-color: aliceblue; - } - } - } - - .modelTopRight::before{ - width: 0; - height: 0; - content: ""; - border-width: 6px; - border-color: #ffffff transparent transparent transparent; - border-style: dashed dashed solid dashed; - position: absolute; - top: -11px; - right: 9px; - z-index: 99; - } - - .modelTopRight::after{ - width: 0; - height: 0; - content: ""; - border-width: 6px; - border-color: #ffffff transparent transparent transparent; - border-style: dashed dashed solid dashed; - position: absolute; - top: -11px; - right: 9px; - z-index: 99; - } - - .modelTopCenter{ - position: absolute; - cursor: pointer; - height: auto; - padding: 5px; - display: inline-block; - height: auto; - border-radius: 5px; - box-shadow: 0 6px 16px 0 rgba(0, 0, 0, 0.08), - 0 3px 6px -4px rgba(0, 0, 0, 0.12), 0 9px 28px 8px rgba(0, 0, 0, 0.05); - - .modelList{ - margin: 0; - padding: 0; - .modalListItem { - list-style: none; - padding: 5px; - a{ - text-decoration: none; - color: rgb(65, 65, 65); - } - } - - .modalListItem:hover{ - transition: all .2s; - background-color: aliceblue; - } - } - } - - .modelTopCenter::before{ - width: 0; - height: 0; - content: ""; - border-width: 6px; - border-color: #ffffff transparent transparent transparent; - border-style: dashed dashed solid dashed; - position: absolute; - top: -11px; - right: 45%; - z-index: 99; - } - - .modelTopCenter::after{ - width: 0; - height: 0; - content: ""; - border-width: 6px; - border-color: #ffffff transparent transparent transparent; - border-style: dashed dashed solid dashed; - position: absolute; - top: -11px; - right: 45%; - z-index: 99; - } -} diff --git a/src/components/dropDown/index.tsx b/src/components/dropDown/index.tsx index 2de8bca..c1c5dfa 100644 --- a/src/components/dropDown/index.tsx +++ b/src/components/dropDown/index.tsx @@ -1,23 +1,22 @@ import React, { ReactNode, useState } from "react"; import { createPortal } from "react-dom"; -import styles from "./dropDown.module.less"; -import Model from "./model"; - +import "./dropDown.less"; +import { v4 as uuidv4 } from "uuid"; type trigger = "click" | "hover"; type position = "bottomRight" | "bottom" | "top" | "topRight"; interface IDropDown { - // trigger?: ("click" | "hover")[]; trigger: trigger; style?: React.CSSProperties; className?: string; children?: ReactNode; visible?: boolean; - disable?: boolean; - modelContent: object[]; + setVisible?: any; + modelContent?: object[] | undefined; width?: number; position?: position; onChangeVisible: () => void; + icons: ReactNode[]; } const DropDown: React.FC = ({ @@ -27,94 +26,88 @@ const DropDown: React.FC = ({ className, children, visible, - disable, modelContent, position, + icons, + setVisible, onChangeVisible, }) => { - const [show, setShow] = useState(visible); - const dropDown = document.getElementById("dropDown") as HTMLElement; + // const dropDown = document.getElementById("dropDown") as HTMLElement; + + const [optionValue, setOptionValue] = useState(children); - const fixedPosition = { - bottomRight: { - top: "30px", - }, - bottom: { - top: "30px", - }, - top: { - bottom: "30px", - }, - topRight: { - bottom: "30px", - }, + const fixedPosition = (position: position) => { + switch (position) { + case "bottom": + return "PositionBottom"; + case "bottomRight": + return "PositionBottomRight"; + case "top": + return "PositionTop"; + case "topRight": + return "PositionTopRight"; + default: + break; + } }; - const modelClassName = { - bottom: "modelCenter", - bottomLeft: "modelLeft", - top: "modelTopCenter", - topRight: "modelTopRight", + const handleSelected = (option: unknown) => { + setOptionValue(option?.label); + setVisible(false); }; return ( <> - {trigger === "hover" ? ( + {trigger === "click" ? ( ) : ( - From be05dda6db5a286feae65a4d1b3e71c4154b3e87 Mon Sep 17 00:00:00 2001 From: Davdeyang <1320501826@qq.com> Date: Fri, 7 Apr 2023 02:37:16 +0800 Subject: [PATCH 08/10] =?UTF-8?q?fix:=E6=B7=BB=E5=8A=A0input=E7=BB=84?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 62 +++++++++++++++++++++++++++--- package.json | 1 + src/_test.tsx | 56 +++++++++++++++++---------- src/components/dropDown/index.tsx | 50 ++---------------------- src/components/input/index.css | 36 +++++++++++++++++ src/components/input/index.less | 39 +++++++++++++++++++ src/components/input/input.tsx | 64 +++++++++++++++++++++++++++++++ 7 files changed, 235 insertions(+), 73 deletions(-) create mode 100644 src/components/input/index.css create mode 100644 src/components/input/index.less create mode 100644 src/components/input/input.tsx diff --git a/package-lock.json b/package-lock.json index 5c3c76b..da3ed28 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,6 +10,7 @@ "license": "ISC", "dependencies": { "@types/uuid": "^9.0.1", + "@uiw/react-color-alpha": "^1.1.3", "classnames": "^2.3.2", "framer-motion": "^8.5.5", "uuid": "^9.0.0" @@ -1788,7 +1789,6 @@ "version": "7.21.0", "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.21.0.tgz", "integrity": "sha512-xwII0//EObnq89Ji5AKYQaRYiW/nZ3llSv29d49IuxPhKbtJoLP+9QUUZ4nVragQVtaVGeZrpB+ZtG/Pdy/POw==", - "dev": true, "dependencies": { "regenerator-runtime": "^0.13.11" }, @@ -3494,6 +3494,38 @@ "integrity": "sha512-iO9ZQHkZxHn4mSakYV0vFHAVDyEOIJQrV2uZ06HxEPcx+mt8swXoZHIbaaJ2crJYFfErySgktuTZ3BeLz+XmFA==", "dev": true }, + "node_modules/@uiw/color-convert": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/@uiw/color-convert/-/color-convert-1.1.3.tgz", + "integrity": "sha512-/ZtvW4YWfM9vzrbZOmlSY3DQ0mll8D6uY87yITJnDmOh50qOpiZPC2/l3ReoUxbyS6xLcn4/ba1DzH5BEx6dCg==", + "peerDependencies": { + "@babel/runtime": ">=7.19.0" + } + }, + "node_modules/@uiw/react-color-alpha": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/@uiw/react-color-alpha/-/react-color-alpha-1.1.3.tgz", + "integrity": "sha512-JenSKVRuDbScq0FUeIVVkIuP3x3SMdyqlwh6ik00wyvHQiaq7W1srihGtlRKlJKrignzELNprIppulI2euwvCA==", + "dependencies": { + "@uiw/color-convert": "1.1.3", + "@uiw/react-drag-event-interactive": "1.1.3" + }, + "peerDependencies": { + "@babel/runtime": ">=7.19.0", + "react": ">=16.9.0", + "react-dom": ">=16.9.0" + } + }, + "node_modules/@uiw/react-drag-event-interactive": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/@uiw/react-drag-event-interactive/-/react-drag-event-interactive-1.1.3.tgz", + "integrity": "sha512-PHbXPQELjh3TaU8m/wFblbQyiKujb/hHfs94PKfB69YnS7uZPKCMsasbxm08AmMVYSZ92MG1Ip/vIKVoAxEEaQ==", + "peerDependencies": { + "@babel/runtime": ">=7.19.0", + "react": ">=16.9.0", + "react-dom": ">=16.9.0" + } + }, "node_modules/@vue/compiler-core": { "version": "3.2.47", "resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.2.47.tgz", @@ -11771,8 +11803,7 @@ "node_modules/regenerator-runtime": { "version": "0.13.11", "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz", - "integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==", - "dev": true + "integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==" }, "node_modules/regenerator-transform": { "version": "0.15.1", @@ -15495,7 +15526,6 @@ "version": "7.21.0", "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.21.0.tgz", "integrity": "sha512-xwII0//EObnq89Ji5AKYQaRYiW/nZ3llSv29d49IuxPhKbtJoLP+9QUUZ4nVragQVtaVGeZrpB+ZtG/Pdy/POw==", - "dev": true, "requires": { "regenerator-runtime": "^0.13.11" } @@ -16863,6 +16893,27 @@ "integrity": "sha512-iO9ZQHkZxHn4mSakYV0vFHAVDyEOIJQrV2uZ06HxEPcx+mt8swXoZHIbaaJ2crJYFfErySgktuTZ3BeLz+XmFA==", "dev": true }, + "@uiw/color-convert": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/@uiw/color-convert/-/color-convert-1.1.3.tgz", + "integrity": "sha512-/ZtvW4YWfM9vzrbZOmlSY3DQ0mll8D6uY87yITJnDmOh50qOpiZPC2/l3ReoUxbyS6xLcn4/ba1DzH5BEx6dCg==", + "requires": {} + }, + "@uiw/react-color-alpha": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/@uiw/react-color-alpha/-/react-color-alpha-1.1.3.tgz", + "integrity": "sha512-JenSKVRuDbScq0FUeIVVkIuP3x3SMdyqlwh6ik00wyvHQiaq7W1srihGtlRKlJKrignzELNprIppulI2euwvCA==", + "requires": { + "@uiw/color-convert": "1.1.3", + "@uiw/react-drag-event-interactive": "1.1.3" + } + }, + "@uiw/react-drag-event-interactive": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/@uiw/react-drag-event-interactive/-/react-drag-event-interactive-1.1.3.tgz", + "integrity": "sha512-PHbXPQELjh3TaU8m/wFblbQyiKujb/hHfs94PKfB69YnS7uZPKCMsasbxm08AmMVYSZ92MG1Ip/vIKVoAxEEaQ==", + "requires": {} + }, "@vue/compiler-core": { "version": "3.2.47", "resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.2.47.tgz", @@ -23095,8 +23146,7 @@ "regenerator-runtime": { "version": "0.13.11", "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz", - "integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==", - "dev": true + "integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==" }, "regenerator-transform": { "version": "0.15.1", diff --git a/package.json b/package.json index 199c9e5..6054c29 100644 --- a/package.json +++ b/package.json @@ -76,6 +76,7 @@ }, "dependencies": { "@types/uuid": "^9.0.1", + "@uiw/react-color-alpha": "^1.1.3", "classnames": "^2.3.2", "framer-motion": "^8.5.5", "uuid": "^9.0.0" diff --git a/src/_test.tsx b/src/_test.tsx index baac6e7..b50b95b 100644 --- a/src/_test.tsx +++ b/src/_test.tsx @@ -7,14 +7,29 @@ import * as GOJI from "goji_ui"; import DropDown from "./components/dropDown"; import Button from "./components/button/button"; import "./_test.less"; +import Alpha from "@uiw/react-color-alpha"; +import Input from "./components/input/input"; function App() { const [visible, setVisible] = useState(false); const [ev, setEv] = useState(false); const [modalVisible, setModalVisible] = useState(false); + const [hsva, setHsva] = useState({ h: 0, s: 0, v: 20, a: 1 }); + + const [value, setValue] = useState(); + + const handleClick = (e: unknown) => { + setValue(e?.target.value); + }; return (
+ {/* 这是扩展的内容
} @@ -31,7 +46,6 @@ function App() { } ]} /> */} -

test

+ + <> + { + setHsva({ ...hsva, ...newAlpha }); + }} + background={`linear-gradient(to right,rgb(218,44,2) 0%, rgb(253,253,32)20%, rgb(255,255,255) 35%, rgb(255,255,255) 60% ,#D0F5FB 65%, rgb(98,165,218) 100%)`} + /> + {/*
+ {JSON.stringify(hsva)} +
*/} + ); } diff --git a/src/components/dropDown/index.tsx b/src/components/dropDown/index.tsx index 44801dc..4fdb2ab 100644 --- a/src/components/dropDown/index.tsx +++ b/src/components/dropDown/index.tsx @@ -12,7 +12,7 @@ type IDropDown = { children?: ReactNode; visible?: boolean; setVisible?: any; - modelContent?: ReactNode | React.ReactNode[]; + modelContent?: ReactNode; width?: number; position?: position; onChangeVisible: () => void; @@ -52,11 +52,7 @@ const DropDown: React.FC = ({ }; const handleSelected = (option: ReactNode) => { - if (typeof option === "object") { - setOptionValue(option?.label); - } else { - setOptionValue(option); - } + setOptionValue(option); setVisible(false); }; @@ -72,26 +68,7 @@ const DropDown: React.FC = ({ {visible ? icons[0] : icons[1]} {visible && (
- {Array.isArray(modelContent) ? ( - modelContent?.map((option: unknown) => { - return ( -
handleSelected(option)} - > - {option?.label} -
- ); - }) - ) : ( -
handleSelected(modelContent)} - > - {modelContent} -
- )} + {modelContent}
)} @@ -106,26 +83,7 @@ const DropDown: React.FC = ({ {visible ? icons[0] : icons[1]} {visible && (
- {Array.isArray(modelContent) ? ( - modelContent?.map((option: unknown) => { - return ( -
handleSelected(option)} - > - {option?.label} -
- ); - }) - ) : ( -
handleSelected(modelContent)} - > - {modelContent} -
- )} + {modelContent}
)} diff --git a/src/components/input/index.css b/src/components/input/index.css new file mode 100644 index 0000000..0accd21 --- /dev/null +++ b/src/components/input/index.css @@ -0,0 +1,36 @@ +.inputBox { + border: 1px solid #036df7; + display: inline; + padding: 4px; + border-radius: 5px; + margin: 10px; +} +.inputBox input { + outline: none; + border: none; + height: 19px; +} +.inputBox .numberLimit { + font-size: 14px; +} +.action { + border: 1px solid red; + display: inline; + padding: 4px; + border-radius: 5px; + margin: 10px; +} +.action input { + outline: none; + border: none; + height: 19px; +} +.action .numberLimit { + font-size: 14px; +} +.message { + margin: 0; + padding: 0; + color: red; + font-size: 12px; +} diff --git a/src/components/input/index.less b/src/components/input/index.less new file mode 100644 index 0000000..bd420c7 --- /dev/null +++ b/src/components/input/index.less @@ -0,0 +1,39 @@ +.inputBox { + border: 1px solid rgb(3, 109, 247); + display: inline; + padding: 4px; + border-radius: 5px; + margin: 10px; + input { + outline: none; + border: none; + height: 19px; + } + + .numberLimit { + font-size: 14px; + } +} + +.action { + border: 1px solid red; + display: inline; + padding: 4px; + border-radius: 5px; + margin: 10px; + input { + outline: none; + border: none; + height: 19px; + } + .numberLimit { + font-size: 14px; + } +} + +.message { + margin: 0; + padding: 0; + color: red; + font-size: 12px; +} diff --git a/src/components/input/input.tsx b/src/components/input/input.tsx new file mode 100644 index 0000000..e2e6752 --- /dev/null +++ b/src/components/input/input.tsx @@ -0,0 +1,64 @@ +import React, { useEffect, useState } from "react"; +import "./index.less"; + +type IProps = { + value?: string | number | undefined; + defaultValue?: string | number | undefined; + maxLength?: number | undefined; + onChange: (e: Event) => void; +}; + +const Input: React.FC = ({ + value, + defaultValue, + maxLength, + onChange, +}) => { + const [inputLength, setInputLength] = useState(0); + + useEffect(() => { + if (value) { + let inputValues = value.split("").length; + setInputLength(inputValues); + } else { + setInputLength(0); + } + }, [value]); + + useEffect(() => { + if (defaultValue) { + if (typeof defaultValue === "number") { + let defaultValueArrayLength = defaultValue + ?.toString() + ?.split("")?.length; + setInputLength(defaultValueArrayLength); + } else if (typeof defaultValue === "string") { + let defaultValues = defaultValue.split("").length; + setInputLength(defaultValues); + } else { + setInputLength(0); + } + } + }, [defaultValue]); + + return ( + <> +
+ onChange(e)} + /> + {`${inputLength}/${ + maxLength && maxLength + }`} +
+ {inputLength > 10 && ( + 内容超过10,请重新输入 + )} + + ); +}; + +export default Input; From b9414ec7a840c870397ae41ed8843571554d8db2 Mon Sep 17 00:00:00 2001 From: Davdeyang <1320501826@qq.com> Date: Fri, 7 Apr 2023 03:33:23 +0800 Subject: [PATCH 09/10] =?UTF-8?q?button=E6=8C=89=E9=92=AE=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E9=BC=A0=E6=A0=87=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/_test.tsx | 3 +++ src/components/button/button.tsx | 40 ++++++++++++++++++++++++++++++++ src/components/button/index.css | 4 ++-- src/components/button/index.less | 4 ++-- src/components/input/input.tsx | 6 ++--- 5 files changed, 50 insertions(+), 7 deletions(-) diff --git a/src/_test.tsx b/src/_test.tsx index b50b95b..88919f0 100644 --- a/src/_test.tsx +++ b/src/_test.tsx @@ -208,6 +208,7 @@ function App() { + + + <> void; + onDoubleClick?: () => void; + onMouseDown?: () => void; + onMouseEnter?: () => void; + onMouseLeave?: () => void; + onMouseMove?: () => void; + onMouseOut?: () => void; + onMouseOutCapture?: () => void; + onMouseOver?: () => void; + onMouseUp?: () => void; + onMouseUpCapture?: () => void; }; const Button: React.FC = ({ @@ -28,7 +43,20 @@ const Button: React.FC = ({ shape, icon, iconPos, + form, + value, + name, onBtnClick, + onDoubleClick, + onMouseDown, + onMouseEnter, + onMouseLeave, + onMouseMove, + onMouseOut, + onMouseOutCapture, + onMouseOver, + onMouseUp, + onMouseUpCapture, }) => { const getBtnClass = () => { switch (type) { @@ -66,8 +94,20 @@ const Button: React.FC = ({ onClick={ onBtnClick ? onBtnClick : () => console.log("Nothing is happing") } + onDoubleClick={ + onDoubleClick ? onDoubleClick : () => console.log("Nothing is happing") + } + onMouseDown={ + onMouseDown ? onMouseDown : () => console.log("Nothing is happing") + } + onMouseEnter={ + onMouseEnter ? onMouseEnter : () => console.log("Nothing is ...") + } disabled={disable} style={style} + form={form} + value={value} + name={name} > {icon && iconPos === "left"} {children ? children : "BUTTON"} {icon && iconPos === "right"} diff --git a/src/components/button/index.css b/src/components/button/index.css index 36a67cf..2779de2 100644 --- a/src/components/button/index.css +++ b/src/components/button/index.css @@ -1,7 +1,7 @@ .gojiButton { display: inline-block; font-size: 14px; - padding: 4px 15px; + padding: 0px 15px; border-radius: 6px; cursor: pointer; background-color: #fff; @@ -16,7 +16,7 @@ } .primaryButton { font-size: 14px; - padding: 4px 15px; + padding: 0px 15px; border-radius: 6px; cursor: pointer; background-color: #fff; diff --git a/src/components/button/index.less b/src/components/button/index.less index 3cde6cc..5cd6cdc 100644 --- a/src/components/button/index.less +++ b/src/components/button/index.less @@ -1,7 +1,7 @@ .gojiButton { display: inline-block; font-size: 14px; - padding: 4px 15px; + padding: 0px 15px; border-radius: 6px; cursor: pointer; background-color: #fff; @@ -18,7 +18,7 @@ .primaryButton { font-size: 14px; - padding: 4px 15px; + padding: 0px 15px; border-radius: 6px; cursor: pointer; background-color: #fff; diff --git a/src/components/input/input.tsx b/src/components/input/input.tsx index e2e6752..2ccc0a7 100644 --- a/src/components/input/input.tsx +++ b/src/components/input/input.tsx @@ -2,7 +2,7 @@ import React, { useEffect, useState } from "react"; import "./index.less"; type IProps = { - value?: string | number | undefined; + value?: string | undefined; defaultValue?: string | number | undefined; maxLength?: number | undefined; onChange: (e: Event) => void; @@ -18,7 +18,7 @@ const Input: React.FC = ({ useEffect(() => { if (value) { - let inputValues = value.split("").length; + let inputValues = value?.split("").length; setInputLength(inputValues); } else { setInputLength(0); @@ -43,7 +43,7 @@ const Input: React.FC = ({ return ( <> -
+
Date: Mon, 10 Apr 2023 19:49:21 +0800 Subject: [PATCH 10/10] =?UTF-8?q?fix:input=20=E6=B7=BB=E5=8A=A0=E5=89=A9?= =?UTF-8?q?=E4=BD=99=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 16 ++++++ package.json | 1 + src/_test.tsx | 41 +++++++++++---- src/components/button/button.tsx | 81 +++++++----------------------- src/components/countdown/index.tsx | 27 ++++++++++ src/components/dropDown/index.tsx | 5 -- src/components/input/input.tsx | 35 ++++++------- 7 files changed, 106 insertions(+), 100 deletions(-) create mode 100644 src/components/countdown/index.tsx diff --git a/package-lock.json b/package-lock.json index da3ed28..ea2de7a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -41,6 +41,7 @@ "jest": "^29.5.0", "jest-environment-jsdom": "^29.5.0", "less-loader": "^11.1.0", + "moment": "^2.29.4", "postcss": "^8.4.21", "react": "^18.2.0", "rollup": "^3.19.1", @@ -10328,6 +10329,15 @@ "node": ">=10" } }, + "node_modules/moment": { + "version": "2.29.4", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz", + "integrity": "sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==", + "dev": true, + "engines": { + "node": "*" + } + }, "node_modules/ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", @@ -22122,6 +22132,12 @@ "brace-expansion": "^2.0.1" } }, + "moment": { + "version": "2.29.4", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz", + "integrity": "sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==", + "dev": true + }, "ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", diff --git a/package.json b/package.json index 6054c29..b216125 100644 --- a/package.json +++ b/package.json @@ -55,6 +55,7 @@ "jest": "^29.5.0", "jest-environment-jsdom": "^29.5.0", "less-loader": "^11.1.0", + "moment": "^2.29.4", "postcss": "^8.4.21", "react": "^18.2.0", "rollup": "^3.19.1", diff --git a/src/_test.tsx b/src/_test.tsx index 88919f0..16141ba 100644 --- a/src/_test.tsx +++ b/src/_test.tsx @@ -1,4 +1,4 @@ -import React, { useState } from "react"; +import React, { useEffect, useRef, useState } from "react"; import ReactDom from "react-dom"; import Modal from "./components/modal/modal"; import Upload from "./components/upload/upload"; @@ -9,26 +9,35 @@ import Button from "./components/button/button"; import "./_test.less"; import Alpha from "@uiw/react-color-alpha"; import Input from "./components/input/input"; +import useCountdown from "./components/countdown"; function App() { const [visible, setVisible] = useState(false); const [ev, setEv] = useState(false); const [modalVisible, setModalVisible] = useState(false); const [hsva, setHsva] = useState({ h: 0, s: 0, v: 20, a: 1 }); - - const [value, setValue] = useState(); + const [value, setValue] = useState(10); + const { date } = useCountdown(3); const handleClick = (e: unknown) => { setValue(e?.target.value); + console.log("e", e?.target.value); }; return (
+
{date}
{ + console.log("kdsk"); + }} + onFocus={() => { + console.log("sssss"); + }} /> {/* - - + + - - + + + + <> { + types?: type | undefined; style?: React.CSSProperties | undefined; className?: string | undefined; children?: React.ReactNode | undefined; - disable?: boolean | undefined; shape?: shape | undefined; icon?: React.ReactNode | undefined; iconPos?: iconPos | undefined; herf?: string | undefined; - form?: string | undefined; - value?: string | undefined; - name?: string | string; - onBtnClick?: () => void; - onDoubleClick?: () => void; - onMouseDown?: () => void; - onMouseEnter?: () => void; - onMouseLeave?: () => void; - onMouseMove?: () => void; - onMouseOut?: () => void; - onMouseOutCapture?: () => void; - onMouseOver?: () => void; - onMouseUp?: () => void; - onMouseUpCapture?: () => void; -}; + disabled?: boolean | undefined; +} + +const Button = (props: IButton) => { + const { types, style, className, children, shape, icon, iconPos, disabled } = + props; -const Button: React.FC = ({ - type, - style, - className, - children, - disable, - shape, - icon, - iconPos, - form, - value, - name, - onBtnClick, - onDoubleClick, - onMouseDown, - onMouseEnter, - onMouseLeave, - onMouseMove, - onMouseOut, - onMouseOutCapture, - onMouseOver, - onMouseUp, - onMouseUpCapture, -}) => { const getBtnClass = () => { - switch (type) { + switch (types) { case "primary": return "primaryButton gojiButton"; case "dashed": @@ -88,26 +54,13 @@ const Button: React.FC = ({ return (