main
|
Last change
on this file since 73b69b2 was b62cefc, checked in by kikisrbinoska <srbinoskakristina07@…>, 4 months ago |
|
Added frontend and imporoved AI Suggestions service
|
-
Property mode
set to
100644
|
|
File size:
2.1 KB
|
| Line | |
|---|
| 1 | import React from 'react'
|
|---|
| 2 |
|
|---|
| 3 | interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|---|
| 4 | variant?: 'primary' | 'secondary' | 'danger' | 'ghost'
|
|---|
| 5 | size?: 'sm' | 'md' | 'lg'
|
|---|
| 6 | loading?: boolean
|
|---|
| 7 | children: React.ReactNode
|
|---|
| 8 | }
|
|---|
| 9 |
|
|---|
| 10 | export const Button: React.FC<ButtonProps> = ({
|
|---|
| 11 | variant = 'primary',
|
|---|
| 12 | size = 'md',
|
|---|
| 13 | loading = false,
|
|---|
| 14 | children,
|
|---|
| 15 | className = '',
|
|---|
| 16 | disabled,
|
|---|
| 17 | ...props
|
|---|
| 18 | }) => {
|
|---|
| 19 | const base =
|
|---|
| 20 | 'inline-flex items-center justify-center font-medium rounded-xl transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-slate-900 disabled:opacity-50 disabled:cursor-not-allowed'
|
|---|
| 21 |
|
|---|
| 22 | const variants = {
|
|---|
| 23 | primary:
|
|---|
| 24 | 'bg-gradient-to-r from-indigo-600 to-violet-600 text-white hover:from-indigo-500 hover:to-violet-500 focus:ring-indigo-500 shadow-lg glow-indigo hover:scale-105 active:scale-95',
|
|---|
| 25 | secondary:
|
|---|
| 26 | 'bg-slate-700 text-slate-100 hover:bg-slate-600 focus:ring-slate-500 border border-slate-600',
|
|---|
| 27 | danger:
|
|---|
| 28 | 'bg-gradient-to-r from-rose-600 to-rose-500 text-white hover:from-rose-500 hover:to-rose-400 focus:ring-rose-500 shadow-lg',
|
|---|
| 29 | ghost:
|
|---|
| 30 | 'bg-transparent text-slate-300 hover:bg-slate-800 hover:text-white focus:ring-slate-500 border border-transparent hover:border-slate-600',
|
|---|
| 31 | }
|
|---|
| 32 |
|
|---|
| 33 | const sizes = {
|
|---|
| 34 | sm: 'px-3 py-1.5 text-sm gap-1.5',
|
|---|
| 35 | md: 'px-4 py-2 text-sm gap-2',
|
|---|
| 36 | lg: 'px-6 py-3 text-base gap-2',
|
|---|
| 37 | }
|
|---|
| 38 |
|
|---|
| 39 | return (
|
|---|
| 40 | <button
|
|---|
| 41 | className={`${base} ${variants[variant]} ${sizes[size]} ${className}`}
|
|---|
| 42 | disabled={disabled || loading}
|
|---|
| 43 | {...props}
|
|---|
| 44 | >
|
|---|
| 45 | {loading && (
|
|---|
| 46 | <svg
|
|---|
| 47 | className="animate-spin h-4 w-4"
|
|---|
| 48 | xmlns="http://www.w3.org/2000/svg"
|
|---|
| 49 | fill="none"
|
|---|
| 50 | viewBox="0 0 24 24"
|
|---|
| 51 | >
|
|---|
| 52 | <circle
|
|---|
| 53 | className="opacity-25"
|
|---|
| 54 | cx="12"
|
|---|
| 55 | cy="12"
|
|---|
| 56 | r="10"
|
|---|
| 57 | stroke="currentColor"
|
|---|
| 58 | strokeWidth="4"
|
|---|
| 59 | />
|
|---|
| 60 | <path
|
|---|
| 61 | className="opacity-75"
|
|---|
| 62 | fill="currentColor"
|
|---|
| 63 | d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"
|
|---|
| 64 | />
|
|---|
| 65 | </svg>
|
|---|
| 66 | )}
|
|---|
| 67 | {children}
|
|---|
| 68 | </button>
|
|---|
| 69 | )
|
|---|
| 70 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.