Add icon support to Button component and improve DirectoryList UI
- Add leftIcon prop to Button component for Tabler icons - Support custom icon sizes with iconSize prop (defaults to 16px) - Update button layout with flex, gap, and responsive padding - Add IconScan to Scan button in DirectoryList for better UX - Improve button spacing in DirectoryList with gap-2 and mt-2 - Maintain backward compatibility for existing buttons 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
31784d91b2
commit
2d81844c05
@ -1,9 +1,12 @@
|
|||||||
import { ButtonHTMLAttributes, ReactNode } from 'react'
|
import { ButtonHTMLAttributes, ReactNode } from 'react'
|
||||||
|
import { Icon } from '@tabler/icons-react'
|
||||||
|
|
||||||
interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
||||||
variant?: 'primary' | 'secondary'
|
variant?: 'primary' | 'secondary'
|
||||||
children: ReactNode
|
children: ReactNode
|
||||||
enabled?: boolean
|
enabled?: boolean
|
||||||
|
leftIcon?: Icon
|
||||||
|
iconSize?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function Button({
|
export default function Button({
|
||||||
@ -12,12 +15,14 @@ export default function Button({
|
|||||||
className = '',
|
className = '',
|
||||||
enabled = true,
|
enabled = true,
|
||||||
disabled,
|
disabled,
|
||||||
|
leftIcon: LeftIcon,
|
||||||
|
iconSize = 16,
|
||||||
...props
|
...props
|
||||||
}: ButtonProps) {
|
}: ButtonProps) {
|
||||||
// Determine if button should be disabled
|
// Determine if button should be disabled
|
||||||
const isDisabled = disabled || !enabled
|
const isDisabled = disabled || !enabled
|
||||||
|
|
||||||
const baseClasses = 'px-12 py-2 rounded font-medium transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 transform'
|
const baseClasses = `${LeftIcon ? 'px-3 py-2' : 'px-12 py-2'} rounded font-medium transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 transform flex items-center justify-center gap-2`
|
||||||
|
|
||||||
const variantClasses = {
|
const variantClasses = {
|
||||||
primary: isDisabled
|
primary: isDisabled
|
||||||
@ -36,6 +41,7 @@ export default function Button({
|
|||||||
disabled={isDisabled}
|
disabled={isDisabled}
|
||||||
{...props}
|
{...props}
|
||||||
>
|
>
|
||||||
|
{LeftIcon && <LeftIcon size={iconSize} />}
|
||||||
{children}
|
{children}
|
||||||
</button>
|
</button>
|
||||||
)
|
)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
'use client'
|
'use client'
|
||||||
|
|
||||||
import { useState, useEffect } from 'react'
|
import { useState, useEffect } from 'react'
|
||||||
import { IconFolder, IconClock, IconTrash } from '@tabler/icons-react'
|
import { IconFolder, IconClock, IconTrash, IconScan } from '@tabler/icons-react'
|
||||||
import { Directory } from '@/types/photo'
|
import { Directory } from '@/types/photo'
|
||||||
import Button from "@/components/Button";
|
import Button from "@/components/Button";
|
||||||
|
|
||||||
@ -134,8 +134,6 @@ export default function DirectoryList({ onDirectorySelect, selectedDirectory, re
|
|||||||
<div className="text-xs text-gray-500 dark:text-gray-400 truncate">
|
<div className="text-xs text-gray-500 dark:text-gray-400 truncate">
|
||||||
{directory.path}
|
{directory.path}
|
||||||
</div>
|
</div>
|
||||||
<Button enabled={false}>Scan</Button>
|
|
||||||
<Button enabled={false}>Remove</Button>
|
|
||||||
<div className="flex items-center space-x-3 mt-1">
|
<div className="flex items-center space-x-3 mt-1">
|
||||||
<div className="flex items-center space-x-1 text-xs text-gray-500 dark:text-gray-400">
|
<div className="flex items-center space-x-1 text-xs text-gray-500 dark:text-gray-400">
|
||||||
<IconClock className="h-3 w-3" />
|
<IconClock className="h-3 w-3" />
|
||||||
@ -151,10 +149,16 @@ export default function DirectoryList({ onDirectorySelect, selectedDirectory, re
|
|||||||
{formatFileSize(directory.total_size)}
|
{formatFileSize(directory.total_size)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div className="flex gap-2 mt-2">
|
||||||
|
<Button leftIcon={IconScan}>Scan</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<button
|
<button
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
|
Loading…
Reference in New Issue
Block a user