oa-login-password-recovery-ux 改进登录找回密码体验
这个提交包含在:
@@ -0,0 +1,41 @@
|
||||
import { Eye, EyeOff } from "lucide-react";
|
||||
import * as React from "react";
|
||||
import { cn } from "../../lib/utils";
|
||||
import { Button } from "./button";
|
||||
import { Input, type InputProps } from "./input";
|
||||
|
||||
export type PasswordInputProps = Omit<InputProps, "type"> & {
|
||||
revealLabel?: string;
|
||||
hideLabel?: string;
|
||||
};
|
||||
|
||||
export const PasswordInput = React.forwardRef<HTMLInputElement, PasswordInputProps>(
|
||||
({ className, revealLabel = "显示密码", hideLabel = "隐藏密码", ...props }, ref) => {
|
||||
const [visible, setVisible] = React.useState(false);
|
||||
const Icon = visible ? EyeOff : Eye;
|
||||
const label = visible ? hideLabel : revealLabel;
|
||||
|
||||
return (
|
||||
<div className="relative">
|
||||
<Input
|
||||
{...props}
|
||||
ref={ref}
|
||||
type={visible ? "text" : "password"}
|
||||
className={cn("pr-11", className)}
|
||||
/>
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
aria-label={label}
|
||||
className="absolute right-1 top-1/2 h-8 w-8 -translate-y-1/2 text-slate-500 hover:text-primary"
|
||||
onClick={() => setVisible((current) => !current)}
|
||||
>
|
||||
<Icon aria-hidden="true" className="h-4 w-4" />
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
PasswordInput.displayName = "PasswordInput";
|
||||
在新工单中引用
屏蔽一个用户