+
- )
-}
+ );
+};
diff --git a/src/popup/components/ui/Button.tsx b/src/popup/components/ui/Button.tsx
index 2ed857cb..bc21e6fd 100644
--- a/src/popup/components/ui/Button.tsx
+++ b/src/popup/components/ui/Button.tsx
@@ -1,14 +1,14 @@
-import { type VariantProps, cva } from 'class-variance-authority'
-import React, { forwardRef } from 'react'
+import { type VariantProps, cva } from 'class-variance-authority';
+import React, { forwardRef } from 'react';
-import { LoadingSpinner } from '@/popup/components/LoadingSpinner'
-import { cn } from '@/shared/helpers'
+import { LoadingSpinner } from '@/popup/components/LoadingSpinner';
+import { cn } from '@/shared/helpers';
const buttonVariants = cva(
[
'relative inline-flex items-center justify-center whitespace-nowrap rounded-xl font-semibold',
'focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500',
- 'disabled:pointer-events-none disabled:select-none disabled:opacity-50'
+ 'disabled:pointer-events-none disabled:select-none disabled:opacity-50',
],
{
@@ -16,32 +16,32 @@ const buttonVariants = cva(
variant: {
default: 'bg-button-base text-white hover:bg-button-base-hover',
destructive: 'bg-error text-error hover:bg-error-hover',
- ghost: ''
+ ghost: '',
},
size: {
default: 'px-6 py-4 font-medium',
- icon: 'h-6 w-6'
+ icon: 'h-6 w-6',
},
fullWidth: {
- true: 'w-full'
+ true: 'w-full',
},
loading: {
- true: 'text-transparent'
- }
+ true: 'text-transparent',
+ },
},
defaultVariants: {
variant: 'default',
- size: 'default'
- }
- }
-)
+ size: 'default',
+ },
+ },
+);
export interface ButtonProps
extends VariantProps
,
React.ButtonHTMLAttributes {
- loading?: boolean
+ loading?: boolean;
/** Optional only when children are passed */
- ['aria-label']?: string
+ ['aria-label']?: string;
}
export const Button = forwardRef(
@@ -56,7 +56,7 @@ export const Button = forwardRef(
children,
...props
},
- ref
+ ref,
) {
return (
- )
- }
-)
+ );
+ },
+);
diff --git a/src/popup/components/ui/Code.tsx b/src/popup/components/ui/Code.tsx
index 931e0b39..71998828 100644
--- a/src/popup/components/ui/Code.tsx
+++ b/src/popup/components/ui/Code.tsx
@@ -1,10 +1,10 @@
-import React from 'react'
-import { Button } from './Button'
-import { CheckIcon, ClipboardIcon } from '../Icons'
-import { cn } from '@/shared/helpers'
+import React from 'react';
+import { Button } from './Button';
+import { CheckIcon, ClipboardIcon } from '../Icons';
+import { cn } from '@/shared/helpers';
interface CodeProps extends React.HTMLAttributes {
- value: string
+ value: string;
}
export const Code = ({ value, className, ...props }: CodeProps) => {
@@ -12,7 +12,7 @@ export const Code = ({ value, className, ...props }: CodeProps) => {
@@ -21,23 +21,23 @@ export const Code = ({ value, className, ...props }: CodeProps) => {
- )
-}
+ );
+};
interface CopyButtonProps extends React.HTMLAttributes {
- value: string
+ value: string;
}
const CopyButton = ({ value, ...props }: CopyButtonProps) => {
- const [hasCopied, setHasCopied] = React.useState(false)
+ const [hasCopied, setHasCopied] = React.useState(false);
React.useEffect(() => {
if (hasCopied === true) {
setTimeout(() => {
- setHasCopied(false)
- }, 2000)
+ setHasCopied(false);
+ }, 2000);
}
- }, [hasCopied])
+ }, [hasCopied]);
return (
- )
-}
+ );
+};
diff --git a/src/popup/components/ui/Input.tsx b/src/popup/components/ui/Input.tsx
index 6d9cf837..ebbe9786 100644
--- a/src/popup/components/ui/Input.tsx
+++ b/src/popup/components/ui/Input.tsx
@@ -1,61 +1,75 @@
-import { type VariantProps, cva } from 'class-variance-authority'
-import React, { forwardRef } from 'react'
-import { cn } from '@/shared/helpers'
-import { Label } from '@/popup/components/ui/Label'
+import { type VariantProps, cva } from 'class-variance-authority';
+import React, { forwardRef } from 'react';
+import { cn } from '@/shared/helpers';
+import { Label } from '@/popup/components/ui/Label';
const inputVariants = cva(
[
'h-14 w-full rounded-xl border border-2 px-4 text-base text-medium',
'focus:border-focus focus:outline-none',
- 'placeholder-disabled'
+ 'placeholder:text-disabled',
],
{
variants: {
variant: {
- default: 'border-base'
+ default: 'border-base',
},
disabled: {
- true: 'border-transparent bg-disabled'
- }
+ true: 'border-transparent bg-disabled',
+ },
+ readOnly: {
+ true: 'border-transparent bg-disabled',
+ },
},
defaultVariants: {
- variant: 'default'
- }
- }
-)
+ variant: 'default',
+ },
+ },
+);
export interface InputProps
extends VariantProps,
React.InputHTMLAttributes {
- errorMessage?: string
- disabled?: boolean
- addOn?: React.ReactNode
- label?: React.ReactNode
- description?: React.ReactNode
+ errorMessage?: string;
+ disabled?: boolean;
+ readOnly?: boolean;
+ addOn?: React.ReactNode;
+ addOnPosition?: 'left' | 'right';
+ label?: React.ReactNode;
+ description?: React.ReactNode;
}
export const Input = forwardRef(function Input(
{
type = 'text',
addOn,
+ addOnPosition = 'left',
label,
description,
errorMessage,
disabled,
className,
+ id,
...props
},
- ref
+ ref,
) {
- const id = React.useId()
+ const randomId = React.useId();
+ id ||= randomId; // cannot call useId conditionally, but use randomId only if default not provided
+
return (
{label ?
: null}
{description ?
{description}
: null}