1- import React from "react" ;
21import type { FilterConfig , FilterGroup } from "../types/filters" ;
32import SearchableSelect from "./SearchableSelect" ;
43import FilterInput from "./FilterInput" ;
4+ import Button from "./Button" ;
55import { getFieldType , getOperatorsForField } from "../util/filter-utils" ;
66
77interface FilterSelectorProps {
@@ -62,25 +62,27 @@ const FilterSelector = ({
6262 } ;
6363
6464 return (
65- < div className = "mb-4" >
66- < div className = "flex items-center justify-between mb-3" >
67- < h3 className = "text-sm font-medium text-gray-700" > { title } </ h3 >
68- < button
69- onClick = { addFilterGroup }
70- className = "text-xs text-blue-600 hover:text-blue-800 px-2 py-1"
71- >
72- + Add Filter Group
73- </ button >
65+ < div className = "mb-3" >
66+ < div className = "flex items-center justify-between mb-2" >
67+ < h3 className = "text-xs font-semibold text-gray-700" > { title } </ h3 >
68+ { filters . length > 0 && (
69+ < Button onClick = { addFilterGroup } size = "sm" variant = "secondary" >
70+ + Add Filter Group
71+ </ Button >
72+ ) }
7473 </ div >
75- < div className = "space-y-4" >
74+
75+ < div className = "space-y-2" >
7676 { filters . map ( ( group , groupIndex ) => (
7777 < div
7878 key = { groupIndex }
79- className = "border border-gray-200 rounded-lg p-4 bg-gray-50"
79+ className = { `pt-2 ${
80+ groupIndex > 0 ? "border-t border-gray-200 mt-2" : ""
81+ } `}
8082 >
81- < div className = "flex items-center justify-between mb-3 " >
82- < div className = "flex items-center space-x -2" >
83- < span className = "text-xs font-medium text-gray-700 bg-white px-2 py-1 rounded border border-gray-200 " >
83+ < div className = "flex items-center justify-between mb-2 " >
84+ < div className = "flex items-center gap -2" >
85+ < span className = "text-xs font-medium text-gray-600 " >
8486 Group { groupIndex + 1 }
8587 </ span >
8688 < SearchableSelect
@@ -93,27 +95,25 @@ const FilterSelector = ({
9395 { value : "OR" , label : "OR (any filter can match)" } ,
9496 ] }
9597 size = "sm"
96- className = "min-w-48 "
98+ className = "min-w-40 "
9799 />
98100 </ div >
99- < button
101+ < Button
100102 onClick = { ( ) => removeFilterGroup ( groupIndex ) }
101- className = "text-xs text-red-600 hover:text-red-800 px-2 py-1 hover:bg-red-50 rounded"
103+ size = "sm"
104+ variant = "secondary"
102105 >
103106 Remove Group
104- </ button >
107+ </ Button >
105108 </ div >
106109
107- < div className = "space-y-3 ml-4 pl-4 border-l-2 border-gray-200 " >
110+ < div className = "space-y-2 " >
108111 { group . filters . map ( ( filter , filterIndex ) => {
109112 const fieldType = filter . type || getFieldType ( filter . field ) ;
110113 const operators = getOperatorsForField ( fieldType ) ;
111114
112115 return (
113- < div
114- key = { filterIndex }
115- className = "flex items-center space-x-2 p-2 bg-white rounded border border-gray-200"
116- >
116+ < div key = { filterIndex } className = "flex items-center gap-2" >
117117 < SearchableSelect
118118 value = { filter . field }
119119 onChange = { ( value ) => {
@@ -130,7 +130,7 @@ const FilterSelector = ({
130130 } ) ) }
131131 placeholder = "Select field..."
132132 size = "sm"
133- className = "min-w-32 "
133+ className = "min-w-40 "
134134 />
135135 < SearchableSelect
136136 value = { filter . operator }
@@ -141,48 +141,47 @@ const FilterSelector = ({
141141 }
142142 options = { operators }
143143 size = "sm"
144- className = "min-w-32 "
144+ className = "min-w-36 "
145145 />
146146 < FilterInput
147147 filter = { filter }
148148 onUpdate = { ( updates ) =>
149149 updateFilterInGroup ( groupIndex , filterIndex , updates )
150150 }
151151 />
152- < button
152+ < Button
153153 onClick = { ( ) =>
154154 removeFilterFromGroup ( groupIndex , filterIndex )
155155 }
156- className = "text-xs text-red-600 hover:text-red-800 px-2 py-1 hover:bg-red-50 rounded"
156+ size = "sm"
157+ variant = "secondary"
157158 >
158159 Remove
159- </ button >
160+ </ Button >
160161 </ div >
161162 ) ;
162163 } ) }
163164
164- < button
165- onClick = { ( ) => addFilterToGroup ( groupIndex ) }
166- className = "text-xs text-blue-600 hover:text-blue-800 px-2 py-1 hover:bg-blue-50 rounded border border-dashed border-blue-300 w-full"
167- >
168- + Add Filter to Group
169- </ button >
165+ < div >
166+ < Button
167+ onClick = { ( ) => addFilterToGroup ( groupIndex ) }
168+ size = "sm"
169+ variant = "secondary"
170+ >
171+ + Add Filter to Group
172+ </ Button >
173+ </ div >
170174 </ div >
171175 </ div >
172176 ) ) }
173177
174178 { filters . length === 0 && (
175- < div className = "text-xs text-gray-500 text-center py-4 px-3 bg-gray-50 border border-dashed border-gray-300 rounded-lg" >
176- No filters configured. Click "Add Filter Group" to start filtering.
179+ < div className = "flex justify-center py-4" >
180+ < Button onClick = { addFilterGroup } size = "sm" variant = "primary" >
181+ + Add Filter Group
182+ </ Button >
177183 </ div >
178184 ) }
179-
180- < button
181- onClick = { addFilterGroup }
182- className = "text-xs text-blue-600 hover:text-blue-800 px-3 py-2 hover:bg-blue-50 rounded border border-dashed border-blue-300 w-full transition-colors"
183- >
184- + Add Filter Group
185- </ button >
186185 </ div >
187186 </ div >
188187 ) ;
0 commit comments