diff --git a/assets/global.css b/assets/global.less similarity index 58% rename from assets/global.css rename to assets/global.less index ddfefb2..e58d036 100644 --- a/assets/global.css +++ b/assets/global.less @@ -53,3 +53,33 @@ form button { textarea { resize: vertical; } + +.input-group { + display: flex; + + input { + flex: 1 1 auto; + } + + input:not(:last-child) { + border-right: none; + border-top-right-radius: 0; + border-bottom-right-radius: 0; + } + + button:not(:first-child) { + border-left: none; + border-top-left-radius: 0; + border-bottom-left-radius: 0; + } + + button { + flex: 1; + padding: 0 .75em; + + svg { + width: 1.5em; + height: 1.5em; + } + } +} diff --git a/assets/icons.tsx b/assets/icons.tsx index cae10b6..2f50bbc 100644 --- a/assets/icons.tsx +++ b/assets/icons.tsx @@ -33,3 +33,15 @@ export function IconSad() { ); } + +export function IconEye() { + return ( + + ); +} + +export function IconEyeClose() { + return ( + + ); +} diff --git a/components/ui/inputHidden/index.tsx b/components/ui/inputHidden/index.tsx new file mode 100644 index 0000000..28dfb9f --- /dev/null +++ b/components/ui/inputHidden/index.tsx @@ -0,0 +1,29 @@ +import { useState } from "react"; +import type { InputHTMLAttributes, MouseEvent, ReactElement } from "react"; +import { IconEye, IconEyeClose } from "~assets/icons"; + +type InputHiddenProps = Partial> & { + suffix?: ReactElement +} + +function InputHidden(props: InputHiddenProps) { + const [type, setType] = useState<"text" | "password">("password"); + + const onSwitchType = (ev: MouseEvent) => { + ev.preventDefault(); + + setType(type === "text" ? "password" : "text"); + } + + return ( +
+ + {props.suffix && props.suffix} + +
+ ); +} + +export default InputHidden; diff --git a/options/index.tsx b/options/index.tsx index 039c743..6f92e06 100644 --- a/options/index.tsx +++ b/options/index.tsx @@ -3,7 +3,8 @@ import Form from "~components/ui/form"; import { IconPaul } from "~assets/icons"; import Message from "~components/ui/message"; import { add } from "~components/ui/message/utils"; -import "~assets/global.css"; +import InputHidden from "~components/ui/inputHidden"; +import "~assets/global.less"; import styles from "./options.module.less"; function Options() { @@ -51,7 +52,7 @@ function Options() {
- +
diff --git a/popup/index.tsx b/popup/index.tsx index fcb94ed..af3e198 100644 --- a/popup/index.tsx +++ b/popup/index.tsx @@ -4,7 +4,7 @@ import Read from "./read"; import Toy from "./bili"; import Message from "~components/ui/message"; import { clsn } from "~utils"; -import "assets/global.css"; +import "assets/global.less"; import styles from "./popup.module.less"; function IndexPopup() {