mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-26 10:55:27 +00:00
fix(webui): use system colors for fields and improve search filter select options
This commit is contained in:
@@ -119,31 +119,35 @@ const DateField: React.FC<FieldProps<string>> = ({ value, config, onSave, readOn
|
||||
if (isEditing) {
|
||||
return (
|
||||
<div className="relative w-full" ref={containerRef}>
|
||||
<div className="w-full px-2 py-1 border border-blue-500 rounded bg-white text-sm shadow-sm min-h-[28px] flex items-center">
|
||||
{value ? getDisplayValue(value) : <span className="text-gray-400">Select date...</span>}
|
||||
<div className="w-full px-2 py-1 border border-ring rounded bg-background text-sm shadow-sm min-h-[28px] flex items-center">
|
||||
{value ? (
|
||||
getDisplayValue(value)
|
||||
) : (
|
||||
<span className="text-muted-foreground">Select date...</span>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="absolute z-50 top-full left-0 mt-1 bg-white border border-gray-200 rounded-lg shadow-xl flex flex-col md:flex-row overflow-hidden min-w-[280px]">
|
||||
<div className="absolute z-50 top-full left-0 mt-1 bg-popover border border-border rounded-lg shadow-xl flex flex-col md:flex-row overflow-hidden min-w-[280px]">
|
||||
{/* Date Picker */}
|
||||
<div className="p-4 w-64">
|
||||
<div className="flex justify-between items-center mb-4">
|
||||
{/* Replaced subMonths with addMonths(-1) */}
|
||||
<button
|
||||
onClick={() => setViewDate(addMonths(viewDate, -1))}
|
||||
className="p-1 hover:bg-gray-100 rounded"
|
||||
className="p-1 hover:bg-accent rounded"
|
||||
>
|
||||
<ChevronLeft className="w-4 h-4" />
|
||||
</button>
|
||||
<span className="font-semibold text-sm">{format(viewDate, 'MMMM yyyy')}</span>
|
||||
<button
|
||||
onClick={() => setViewDate(addMonths(viewDate, 1))}
|
||||
className="p-1 hover:bg-gray-100 rounded"
|
||||
className="p-1 hover:bg-accent rounded"
|
||||
>
|
||||
<ChevronRight className="w-4 h-4" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-7 gap-1 text-center text-xs mb-2 text-gray-500">
|
||||
<div className="grid grid-cols-7 gap-1 text-center text-xs mb-2 text-muted-foreground">
|
||||
{['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'].map((d) => (
|
||||
<div key={d}>{d}</div>
|
||||
))}
|
||||
@@ -166,8 +170,10 @@ const DateField: React.FC<FieldProps<string>> = ({ value, config, onSave, readOn
|
||||
<button
|
||||
key={date.toString()}
|
||||
onClick={() => handleDateClick(date)}
|
||||
className={`w-8 h-8 rounded-full flex items-center justify-center hover:bg-blue-50 transition-colors ${
|
||||
isSelected ? 'bg-blue-50 text-white hover:bg-blue-600' : 'text-gray-700'
|
||||
className={`w-8 h-8 rounded-full flex items-center justify-center hover:bg-accent transition-colors ${
|
||||
isSelected
|
||||
? 'bg-primary text-primary-foreground hover:bg-primary/90'
|
||||
: 'text-foreground'
|
||||
}`}
|
||||
>
|
||||
{getDate(date)}
|
||||
@@ -179,17 +185,17 @@ const DateField: React.FC<FieldProps<string>> = ({ value, config, onSave, readOn
|
||||
|
||||
{/* Time Picker */}
|
||||
{dateConfig?.includeTime && (
|
||||
<div className="border-l border-gray-200 bg-gray-50 w-32 flex flex-col">
|
||||
<div className="p-2 border-b border-gray-200 text-xs font-semibold text-gray-500 flex items-center justify-center gap-1">
|
||||
<div className="border-l border-border bg-muted w-32 flex flex-col">
|
||||
<div className="p-2 border-b border-border text-xs font-semibold text-muted-foreground flex items-center justify-center gap-1">
|
||||
<Clock className="w-3 h-3" /> Time
|
||||
</div>
|
||||
<div className="flex flex-1 h-64">
|
||||
<div className="flex-1 overflow-y-auto scrollbar-hide border-r border-gray-200">
|
||||
<div className="flex-1 overflow-y-auto scrollbar-hide border-r border-border">
|
||||
{hours.map((h) => (
|
||||
<div
|
||||
key={h}
|
||||
onClick={() => handleTimeChange('hour', h)}
|
||||
className={`px-2 py-1 text-center text-sm cursor-pointer hover:bg-gray-200 ${getHours(safeDate) === h ? 'bg-blue-100 font-medium text-blue-700' : ''}`}
|
||||
className={`px-2 py-1 text-center text-sm cursor-pointer hover:bg-accent ${getHours(safeDate) === h ? 'bg-primary/10 font-medium text-primary' : ''}`}
|
||||
>
|
||||
{h.toString().padStart(2, '0')}
|
||||
</div>
|
||||
@@ -200,7 +206,7 @@ const DateField: React.FC<FieldProps<string>> = ({ value, config, onSave, readOn
|
||||
<div
|
||||
key={m}
|
||||
onClick={() => handleTimeChange('minute', m)}
|
||||
className={`px-2 py-1 text-center text-sm cursor-pointer hover:bg-gray-200 ${getMinutes(safeDate) === m ? 'bg-blue-100 font-medium text-blue-700' : ''}`}
|
||||
className={`px-2 py-1 text-center text-sm cursor-pointer hover:bg-accent ${getMinutes(safeDate) === m ? 'bg-primary/10 font-medium text-primary' : ''}`}
|
||||
>
|
||||
{m.toString().padStart(2, '0')}
|
||||
</div>
|
||||
@@ -217,11 +223,11 @@ const DateField: React.FC<FieldProps<string>> = ({ value, config, onSave, readOn
|
||||
return (
|
||||
<div
|
||||
onClick={handleStartEdit}
|
||||
className={`w-full min-h-[28px] px-2 py-1 text-sm text-gray-800 rounded border border-transparent transition-colors ${
|
||||
!readOnly ? 'cursor-pointer hover:bg-gray-100 hover:border-gray-200' : ''
|
||||
className={`w-full min-h-[28px] px-2 py-1 text-sm text-foreground rounded border border-transparent transition-colors ${
|
||||
!readOnly ? 'cursor-pointer hover:bg-accent hover:border-border' : ''
|
||||
}`}
|
||||
>
|
||||
{value ? getDisplayValue(value) : <span className="text-gray-400 italic">Empty</span>}
|
||||
{value ? getDisplayValue(value) : <span className="text-muted-foreground italic">Empty</span>}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ const LongTextField: React.FC<FieldProps<string>> = ({ value, onSave, readOnly }
|
||||
value={localValue}
|
||||
onChange={(e) => setLocalValue(e.target.value)}
|
||||
onBlur={handleBlur}
|
||||
className="w-full min-h-[80px] p-2 border border-blue-500 rounded bg-white text-sm outline-none shadow-sm resize-none"
|
||||
className="w-full min-h-[80px] p-2 border border-ring rounded bg-background text-sm outline-none shadow-sm resize-none"
|
||||
/>
|
||||
)
|
||||
}
|
||||
@@ -73,23 +73,23 @@ const LongTextField: React.FC<FieldProps<string>> = ({ value, onSave, readOnly }
|
||||
{/* Placeholder */}
|
||||
<div
|
||||
onClick={handlePlaceholderClick}
|
||||
className={`w-full text-gray-800 rounded border border-transparent transition-all px-2 py-1 line-clamp-2 max-h-[3rem] overflow-hidden ${
|
||||
!readOnly ? 'cursor-pointer hover:bg-gray-100 hover:border-gray-200' : 'cursor-pointer'
|
||||
className={`w-full text-foreground rounded border border-transparent transition-all px-2 py-1 line-clamp-2 max-h-[3rem] overflow-hidden ${
|
||||
!readOnly ? 'cursor-pointer hover:bg-accent hover:border-border' : 'cursor-pointer'
|
||||
}`}
|
||||
title="Click to expand"
|
||||
>
|
||||
{value ? value : <span className="text-gray-400 italic">Empty</span>}
|
||||
{value ? value : <span className="text-muted-foreground italic">Empty</span>}
|
||||
</div>
|
||||
|
||||
{/* Expanded Overlay */}
|
||||
{expanded && (
|
||||
<div
|
||||
onClick={handleOverlayClick}
|
||||
className={`absolute top-0 left-0 w-full min-h-full h-auto z-50 bg-white border border-blue-500 rounded shadow-lg px-2 py-1 whitespace-pre-wrap ${
|
||||
className={`absolute top-0 left-0 w-full min-h-full h-auto z-50 bg-background border border-ring rounded shadow-lg px-2 py-1 whitespace-pre-wrap ${
|
||||
!readOnly ? 'cursor-text' : ''
|
||||
}`}
|
||||
>
|
||||
{value ? value : <span className="text-gray-400 italic">Empty</span>}
|
||||
{value ? value : <span className="text-muted-foreground italic">Empty</span>}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -62,7 +62,7 @@ const NumberField: React.FC<FieldProps<number | undefined>> = ({
|
||||
onBlur={handleBlur}
|
||||
onKeyDown={handleKeyDown}
|
||||
onDoubleClick={(e) => e.stopPropagation()}
|
||||
className="w-full px-2 py-1 border border-blue-500 rounded bg-white text-sm outline-none shadow-sm text-left font-mono"
|
||||
className="w-full px-2 py-1 border border-ring rounded bg-background text-sm outline-none shadow-sm text-left font-mono"
|
||||
/>
|
||||
)
|
||||
}
|
||||
@@ -71,14 +71,14 @@ const NumberField: React.FC<FieldProps<number | undefined>> = ({
|
||||
<div
|
||||
onClick={handleStartEdit}
|
||||
onDoubleClick={(e) => e.stopPropagation()}
|
||||
className={`w-full min-h-[28px] px-2 py-1 text-sm text-gray-800 rounded border border-transparent transition-colors text-left font-mono ${
|
||||
!readOnly ? 'cursor-pointer hover:bg-gray-100 hover:border-gray-200' : ''
|
||||
className={`w-full min-h-[28px] px-2 py-1 text-sm text-foreground rounded border border-transparent transition-colors text-left font-mono ${
|
||||
!readOnly ? 'cursor-pointer hover:bg-accent hover:border-border' : ''
|
||||
}`}
|
||||
>
|
||||
{value !== undefined && value !== null ? (
|
||||
formatNumber(value)
|
||||
) : (
|
||||
<span className="text-gray-400 italic font-sans text-left block">Empty</span>
|
||||
<span className="text-muted-foreground italic font-sans text-left block">Empty</span>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -43,7 +43,7 @@ const RatingField: React.FC<FieldProps<number>> = ({ value, config, onSave, read
|
||||
>
|
||||
<Star
|
||||
className={`w-5 h-5 transition-colors ${
|
||||
isFilled ? 'fill-yellow-400 text-yellow-400' : 'fill-gray-100 text-gray-300'
|
||||
isFilled ? 'fill-yellow-400 text-yellow-400' : 'fill-muted text-muted-foreground/30'
|
||||
}`}
|
||||
/>
|
||||
</button>
|
||||
|
||||
@@ -28,7 +28,7 @@ const SelectField: React.FC<FieldProps<string>> = ({ value, config, onSave, read
|
||||
}
|
||||
|
||||
const renderOptionBadge = (option: SelectOption | undefined) => {
|
||||
if (!option) return <span className="text-gray-400 italic">Select an option</span>
|
||||
if (!option) return <span className="text-muted-foreground italic">Select an option</span>
|
||||
return (
|
||||
<span
|
||||
className="inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium"
|
||||
@@ -46,23 +46,23 @@ const SelectField: React.FC<FieldProps<string>> = ({ value, config, onSave, read
|
||||
<div
|
||||
onClick={handleStartEdit}
|
||||
className={`flex items-center justify-between w-full min-h-[28px] px-2 py-1 rounded border border-transparent transition-colors ${
|
||||
!readOnly ? 'cursor-pointer hover:bg-gray-100 hover:border-gray-200 group' : ''
|
||||
!readOnly ? 'cursor-pointer hover:bg-accent hover:border-border group' : ''
|
||||
}`}
|
||||
>
|
||||
{renderOptionBadge(selectedOption)}
|
||||
{!readOnly && (
|
||||
<ChevronDown className="w-4 h-4 text-gray-400 opacity-0 group-hover:opacity-100" />
|
||||
<ChevronDown className="w-4 h-4 text-muted-foreground opacity-0 group-hover:opacity-100" />
|
||||
)}
|
||||
</div>
|
||||
</PopoverTrigger>
|
||||
|
||||
<PopoverContent
|
||||
className="p-1 w-[--radix-popover-trigger-width] min-w-[150px] max-h-60 overflow-auto bg-white border border-gray-200 rounded-lg shadow-lg"
|
||||
className="p-1 w-[--radix-popover-trigger-width] min-w-[150px] max-h-60 overflow-auto bg-popover border border-border rounded-lg shadow-lg"
|
||||
align="start"
|
||||
>
|
||||
<div
|
||||
onClick={() => handleSelect('')}
|
||||
className="px-3 py-2 text-sm text-gray-500 hover:bg-gray-50 cursor-pointer flex items-center gap-2"
|
||||
className="px-3 py-2 text-sm text-muted-foreground hover:bg-accent cursor-pointer flex items-center gap-2"
|
||||
>
|
||||
<X className="w-3 h-3" /> Clear
|
||||
</div>
|
||||
@@ -70,7 +70,7 @@ const SelectField: React.FC<FieldProps<string>> = ({ value, config, onSave, read
|
||||
<div
|
||||
key={option.id}
|
||||
onClick={() => handleSelect(option.id)}
|
||||
className="px-3 py-2 hover:bg-gray-50 cursor-pointer flex items-center"
|
||||
className="px-3 py-2 hover:bg-accent cursor-pointer flex items-center"
|
||||
>
|
||||
<span
|
||||
className="inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium"
|
||||
|
||||
@@ -120,12 +120,12 @@ const SelectMultiField: React.FC<FieldProps<string[]>> = ({
|
||||
onClick={handlePlaceholderClick}
|
||||
className={`w-full px-1 py-1 flex flex-wrap gap-1 rounded border border-transparent transition-all box-border h-[32px] overflow-hidden ${
|
||||
!readOnly || hiddenCount > 0
|
||||
? 'cursor-pointer hover:bg-gray-100 hover:border-gray-200'
|
||||
? 'cursor-pointer hover:bg-accent hover:border-border'
|
||||
: ''
|
||||
}`}
|
||||
>
|
||||
{selectedOptions.length === 0 && (
|
||||
<span className="text-gray-400 text-sm italic px-1 pt-0.5">Empty</span>
|
||||
<span className="text-muted-foreground text-sm italic px-1 pt-0.5">Empty</span>
|
||||
)}
|
||||
|
||||
{/* Render visible items */}
|
||||
@@ -140,7 +140,7 @@ const SelectMultiField: React.FC<FieldProps<string[]>> = ({
|
||||
))}
|
||||
|
||||
{hiddenCount > 0 && (
|
||||
<span className="inline-flex items-center px-1.5 py-0.5 rounded-full text-xs font-medium bg-gray-200 text-gray-600 h-[22px]">
|
||||
<span className="inline-flex items-center px-1.5 py-0.5 rounded-full text-xs font-medium bg-muted text-muted-foreground h-[22px]">
|
||||
+{hiddenCount}
|
||||
</span>
|
||||
)}
|
||||
@@ -148,10 +148,10 @@ const SelectMultiField: React.FC<FieldProps<string[]>> = ({
|
||||
</PopoverTrigger>
|
||||
|
||||
<PopoverContent
|
||||
className={`p-1 bg-white border rounded-lg shadow-xl max-h-60 overflow-auto ${
|
||||
className={`p-1 bg-popover border rounded-lg shadow-xl max-h-60 overflow-auto ${
|
||||
expanded && !isEditing
|
||||
? 'w-[--radix-popover-trigger-width] min-w-[200px] flex flex-wrap gap-1 border-blue-500 min-h-[32px] h-auto cursor-pointer'
|
||||
: 'w-64 border-gray-200'
|
||||
? 'w-[--radix-popover-trigger-width] min-w-[200px] flex flex-wrap gap-1 border-ring min-h-[32px] h-auto cursor-pointer'
|
||||
: 'w-64 border-border'
|
||||
}`}
|
||||
align="start"
|
||||
onClick={expanded && !isEditing ? handleOverlayClick : undefined}
|
||||
@@ -159,7 +159,7 @@ const SelectMultiField: React.FC<FieldProps<string[]>> = ({
|
||||
{expanded && !isEditing ? (
|
||||
<>
|
||||
{selectedOptions.length === 0 && (
|
||||
<span className="text-gray-400 text-sm italic px-1 pt-0.5">Empty</span>
|
||||
<span className="text-muted-foreground text-sm italic px-1 pt-0.5">Empty</span>
|
||||
)}
|
||||
{selectedOptions.map((option: SelectOption) => (
|
||||
<span
|
||||
@@ -178,7 +178,7 @@ const SelectMultiField: React.FC<FieldProps<string[]>> = ({
|
||||
<div
|
||||
key={option.id}
|
||||
onClick={() => toggleOption(option.id)}
|
||||
className="px-3 py-2 hover:bg-gray-50 cursor-pointer flex items-center justify-between"
|
||||
className="px-3 py-2 hover:bg-accent cursor-pointer flex items-center justify-between"
|
||||
>
|
||||
<span
|
||||
className="inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium"
|
||||
@@ -186,7 +186,7 @@ const SelectMultiField: React.FC<FieldProps<string[]>> = ({
|
||||
>
|
||||
{option.displayName}
|
||||
</span>
|
||||
{isSelected && <Check className="w-4 h-4 text-blue-500" />}
|
||||
{isSelected && <Check className="w-4 h-4 text-primary" />}
|
||||
</div>
|
||||
)
|
||||
})
|
||||
|
||||
@@ -43,7 +43,7 @@ const TextField: React.FC<FieldProps<string>> = ({ value, onSave, readOnly }) =>
|
||||
onChange={(e) => setLocalValue(e.target.value)}
|
||||
onBlur={handleBlur}
|
||||
onKeyDown={handleKeyDown}
|
||||
className="w-full px-2 py-1 border border-blue-500 rounded bg-white text-sm outline-none shadow-sm"
|
||||
className="w-full px-2 py-1 border border-ring rounded bg-background text-sm outline-none shadow-sm"
|
||||
/>
|
||||
)
|
||||
}
|
||||
@@ -51,11 +51,11 @@ const TextField: React.FC<FieldProps<string>> = ({ value, onSave, readOnly }) =>
|
||||
return (
|
||||
<div
|
||||
onClick={handleStartEdit}
|
||||
className={`w-full min-h-[28px] px-2 py-1 text-sm text-gray-800 rounded truncate border border-transparent transition-colors ${
|
||||
!readOnly ? 'cursor-pointer hover:bg-gray-100 hover:border-gray-200' : ''
|
||||
className={`w-full min-h-[28px] px-2 py-1 text-sm text-foreground rounded truncate border border-transparent transition-colors ${
|
||||
!readOnly ? 'cursor-pointer hover:bg-accent hover:border-border' : ''
|
||||
}`}
|
||||
>
|
||||
{value || <span className="text-gray-400 italic">Empty</span>}
|
||||
{value || <span className="text-muted-foreground italic">Empty</span>}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -24,12 +24,12 @@ const ToggleField: React.FC<FieldProps> = ({ value, onSave, readOnly }) => {
|
||||
className={`flex items-center h-[28px] w-full ${!readOnly ? 'cursor-pointer' : ''}`}
|
||||
>
|
||||
<div
|
||||
className={`relative inline-flex h-5 w-9 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 ${
|
||||
value ? 'bg-green-500' : 'bg-gray-300'
|
||||
className={`relative inline-flex h-5 w-9 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 ${
|
||||
value ? 'bg-primary' : 'bg-input'
|
||||
} ${readOnly ? 'opacity-70' : ''}`}
|
||||
>
|
||||
<span
|
||||
className={`inline-block h-3.5 w-3.5 transform rounded-full bg-white transition duration-200 ease-in-out ${
|
||||
className={`inline-block h-3.5 w-3.5 transform rounded-full bg-background transition duration-200 ease-in-out ${
|
||||
value ? 'translate-x-4.5' : 'translate-x-1'
|
||||
}`}
|
||||
style={{ transform: value ? 'translateX(18px)' : 'translateX(4px)' }}
|
||||
|
||||
Reference in New Issue
Block a user