0855892643
- components/ui/Button.tsx — компонент Button (primary/secondary/ghost/danger, sm/md/lg, loading/disabled) - components/ui/CodeCopy.tsx — компонент копирования кода (clipboard API) - components/ui/Toggle.tsx — тумблер (client component, bb-toggle-track/thumb) - globals.css — CSS-классы: bb-btn, bb-input/textarea/select, bb-checkbox/radio, bb-toggle, @keyframes bb-spin - app/components/buttons/page.tsx — страница «Кнопки» (варианты, размеры, состояния, code copy, LLM-блок) - app/components/forms/page.tsx — страница «Форм-контролы» (Input/Textarea/Select/Checkbox/Radio/Toggle, LLM-блок) - foundation/logo/page.tsx — добавлен LLM-блок v1.0 - Sidebar: убраны «скоро» с Кнопок и Форм-контролов, версия Sprint 3 · v0.3.0 - docs/LLM_CONTEXT.md → версия 3.0, добавлена секция 9a с компонентами Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
46 lines
1.2 KiB
TypeScript
46 lines
1.2 KiB
TypeScript
"use client";
|
|
|
|
import { ButtonHTMLAttributes, forwardRef } from "react";
|
|
|
|
export type ButtonVariant = "primary" | "secondary" | "ghost" | "danger";
|
|
export type ButtonSize = "sm" | "md" | "lg";
|
|
|
|
export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
variant?: ButtonVariant;
|
|
size?: ButtonSize;
|
|
loading?: boolean;
|
|
}
|
|
|
|
export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
|
|
function Button(
|
|
{ variant = "primary", size = "md", loading = false, disabled, children, className = "", ...props },
|
|
ref
|
|
) {
|
|
const isDisabled = disabled || loading;
|
|
return (
|
|
<button
|
|
ref={ref}
|
|
disabled={isDisabled}
|
|
className={`bb-btn bb-btn-${size} bb-btn-${variant} ${className}`.trim()}
|
|
{...props}
|
|
>
|
|
{loading && (
|
|
<span
|
|
style={{
|
|
width: 13,
|
|
height: 13,
|
|
border: "2px solid currentColor",
|
|
borderTopColor: "transparent",
|
|
borderRadius: "50%",
|
|
display: "inline-block",
|
|
animation: "bb-spin 0.65s linear infinite",
|
|
flexShrink: 0,
|
|
}}
|
|
/>
|
|
)}
|
|
{children}
|
|
</button>
|
|
);
|
|
}
|
|
);
|