feat没问题

This commit is contained in:
许永平
2025-07-09 17:44:16 +08:00
parent 4367d5a5f3
commit 37dabcfdf6
3 changed files with 164 additions and 4 deletions

View File

@@ -8,6 +8,7 @@ interface ButtonProps {
onClick?: (e?: React.MouseEvent) => void;
disabled?: boolean;
type?: 'button' | 'submit' | 'reset';
loading?: boolean;
}
export function Button({
@@ -17,7 +18,8 @@ export function Button({
className = '',
onClick,
disabled = false,
type = 'button'
type = 'button',
loading = false
}: ButtonProps) {
const baseClasses = 'inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:opacity-50 disabled:pointer-events-none';
@@ -43,9 +45,15 @@ export function Button({
<button
className={classes}
onClick={onClick}
disabled={disabled}
disabled={disabled || loading}
type={type}
>
{loading && (
<svg className="animate-spin -ml-1 mr-2 h-4 w-4 text-white" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
<circle className="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="4"></circle>
<path className="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
</svg>
)}
{children}
</button>
);

View File

@@ -8,6 +8,12 @@ interface InputProps {
className?: string;
readOnly?: boolean;
id?: string;
name?: string;
type?: string;
required?: boolean;
min?: number;
max?: number;
step?: number;
}
export function Input({
@@ -17,17 +23,28 @@ export function Input({
placeholder,
className = '',
readOnly = false,
id
id,
name,
type = 'text',
required = false,
min,
max,
step,
}: InputProps) {
return (
<input
id={id}
type="text"
name={name}
type={type}
value={value}
onChange={onChange}
onKeyDown={onKeyDown}
placeholder={placeholder}
readOnly={readOnly}
required={required}
min={min}
max={max}
step={step}
className={`flex h-10 w-full rounded-md border border-gray-300 bg-white px-3 py-2 text-sm ring-offset-white file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-gray-500 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 ${className}`}
/>
);