mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 16:23:36 +00:00
Merge branch 'add-eye-password' into 'main'
feat: add eye to toggle visibility of passwords See merge request soapbox-pub/act2!15
This commit is contained in:
commit
1947402d9a
3 files changed
+56
-6
No files matched your search
@@ -10,6 +10,9 @@ stages:
|
||||
|
||||
test:
|
||||
stage: test
|
||||
variables:
|
||||
VITE_GITHUB_OAUTH_CLIENT_ID: "********************"
|
||||
VITE_GITHUB_OAUTH_CLIENT_SECRET: "****************************************"
|
||||
script:
|
||||
- npm run test
|
||||
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
import * as React from "react"
|
||||
import { Eye, EyeOff } from "lucide-react"
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
const PasswordInput = React.forwardRef<HTMLInputElement, React.InputHTMLAttributes<HTMLInputElement>>(
|
||||
({ className, ...props }, ref) => {
|
||||
const [showPassword, setShowPassword] = React.useState(false)
|
||||
const [isFocused, setIsFocused] = React.useState(false)
|
||||
|
||||
return (
|
||||
<div className="relative">
|
||||
<input
|
||||
type={showPassword ? "text" : "password"}
|
||||
className={cn(
|
||||
"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 pr-10 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
|
||||
isFocused && "ring-2 ring-ring ring-offset-2",
|
||||
className
|
||||
)}
|
||||
ref={ref}
|
||||
onFocus={(e) => {
|
||||
setIsFocused(true)
|
||||
props.onFocus?.(e)
|
||||
}}
|
||||
onBlur={(e) => {
|
||||
setIsFocused(false)
|
||||
props.onBlur?.(e)
|
||||
}}
|
||||
{...props}
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setShowPassword(!showPassword)}
|
||||
className="absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 rounded-sm disabled:cursor-not-allowed disabled:opacity-50"
|
||||
disabled={props.disabled}
|
||||
aria-label={showPassword ? "Hide password" : "Show password"}
|
||||
>
|
||||
{showPassword ? (
|
||||
<EyeOff className="h-4 w-4" />
|
||||
) : (
|
||||
<Eye className="h-4 w-4" />
|
||||
)}
|
||||
</button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
)
|
||||
PasswordInput.displayName = "PasswordInput"
|
||||
|
||||
export { PasswordInput }
|
||||
@@ -2,6 +2,7 @@ import { useState } from 'react';
|
||||
import { Check, Bot, ArrowLeft, Trash2 } from 'lucide-react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { PasswordInput } from '@/components/ui/password-input';
|
||||
import { Label } from '@/components/ui/label';
|
||||
import { Separator } from '@/components/ui/separator';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
@@ -245,9 +246,8 @@ export function AISettings() {
|
||||
{!provider?.nostr && (
|
||||
<div className="grid gap-2">
|
||||
<Label htmlFor={`${providerId}-apiKey`}>API Key</Label>
|
||||
<Input
|
||||
<PasswordInput
|
||||
id={`${providerId}-apiKey`}
|
||||
type="password"
|
||||
placeholder="Enter your API key"
|
||||
value={provider?.apiKey || ''}
|
||||
onChange={(e) => handleUpdateProvider(providerId, { apiKey: e.target.value })}
|
||||
@@ -286,9 +286,8 @@ export function AISettings() {
|
||||
</div>
|
||||
<div className="flex gap-2">
|
||||
{!preset.nostr && (
|
||||
<Input
|
||||
<PasswordInput
|
||||
placeholder={preset.id === "routstr" ? "Enter a Cashu token" : "Enter your API key"}
|
||||
type="password"
|
||||
className="flex-1"
|
||||
value={presetApiKeys[preset.id] || ''}
|
||||
onChange={(e) => setPresetApiKeys(prev => ({
|
||||
@@ -368,9 +367,8 @@ export function AISettings() {
|
||||
{customAuthMethod === 'api-key' && (
|
||||
<div className="grid gap-2">
|
||||
<Label htmlFor="custom-apikey">API Key</Label>
|
||||
<Input
|
||||
<PasswordInput
|
||||
id="custom-apikey"
|
||||
type="password"
|
||||
placeholder="Enter your API key (optional)"
|
||||
value={customApiKey}
|
||||
onChange={(e) => setCustomApiKey(e.target.value)}
|
||||
|
||||
Reference in new issue
Block a user