@@ -70,16 +70,18 @@ type TableRowProps = {
70
70
className ?: string ;
71
71
children : ReactNode ;
72
72
disabled ?: boolean ;
73
+ isSelected ?: boolean ;
73
74
} ;
74
75
75
76
export const TableRow = forwardRef < HTMLTableRowElement , TableRowProps > (
76
- ( { className, disabled, children } , ref ) => {
77
+ ( { className, disabled, isSelected , children } , ref ) => {
77
78
return (
78
79
< tr
79
80
ref = { ref }
80
81
className = { cn (
81
- disabled && "opacity-50" ,
82
82
"group/table-row relative w-full after:absolute after:bottom-0 after:left-3 after:right-0 after:h-px after:bg-grid-dimmed" ,
83
+ disabled && "opacity-50" ,
84
+ isSelected && isSelectedStyle ,
83
85
className
84
86
) }
85
87
>
@@ -146,6 +148,7 @@ type TableCellProps = TableCellBasicProps & {
146
148
isSticky ?: boolean ;
147
149
actionClassName ?: string ;
148
150
rowHoverStyle ?: keyof typeof rowHoverStyles ;
151
+ isSelected ?: boolean ;
149
152
} ;
150
153
151
154
const rowHoverStyles = {
@@ -160,6 +163,8 @@ const rowHoverStyles = {
160
163
const stickyStyles =
161
164
"sticky right-0 bg-background-dimmed group-hover/table-row:bg-charcoal-750 w-[--sticky-width] [&:has(.group-hover\\/table-row\\:block)]:w-auto" ;
162
165
166
+ const isSelectedStyle = "bg-charcoal-750 group-hover:bg-charcoal-750" ;
167
+
163
168
export const TableCell = forwardRef < HTMLTableCellElement , TableCellProps > (
164
169
(
165
170
{
@@ -173,6 +178,7 @@ export const TableCell = forwardRef<HTMLTableCellElement, TableCellProps>(
173
178
hasAction = false ,
174
179
isSticky = false ,
175
180
rowHoverStyle = "default" ,
181
+ isSelected,
176
182
} ,
177
183
ref
178
184
) => {
@@ -203,7 +209,8 @@ export const TableCell = forwardRef<HTMLTableCellElement, TableCellProps>(
203
209
to || onClick || hasAction ? "cursor-pointer" : "px-3 py-3 align-middle" ,
204
210
! to && ! onClick && alignmentClassName ,
205
211
isSticky && stickyStyles ,
206
- rowHoverStyles [ rowHoverStyle ] ,
212
+ isSelected && isSelectedStyle ,
213
+ ! isSelected && rowHoverStyles [ rowHoverStyle ] ,
207
214
className
208
215
) }
209
216
colSpan = { colSpan }
@@ -259,10 +266,20 @@ export const TableCellMenu = forwardRef<
259
266
hiddenButtons ?: ReactNode ;
260
267
popoverContent ?: ReactNode ;
261
268
children ?: ReactNode ;
269
+ isSelected ?: boolean ;
262
270
}
263
271
> (
264
272
(
265
- { className, isSticky, onClick, visibleButtons, hiddenButtons, popoverContent, children } ,
273
+ {
274
+ className,
275
+ isSticky,
276
+ onClick,
277
+ visibleButtons,
278
+ hiddenButtons,
279
+ popoverContent,
280
+ children,
281
+ isSelected,
282
+ } ,
266
283
ref
267
284
) => {
268
285
const [ isOpen , setIsOpen ] = useState ( false ) ;
@@ -275,9 +292,17 @@ export const TableCellMenu = forwardRef<
275
292
ref = { ref }
276
293
alignment = "right"
277
294
hasAction = { true }
295
+ isSelected = { isSelected }
278
296
>
279
- < div className = "relative p-1" >
280
- < div className = "absolute right-0 top-1/2 mr-1 flex -translate-y-1/2 items-center justify-end gap-0.5 bg-background-dimmed p-0.5 group-hover/table-row:rounded-[0.25rem] group-hover/table-row:bg-background-bright group-hover/table-row:ring-1 group-hover/table-row:ring-grid-bright" >
297
+ < div className = "relative h-full p-1" >
298
+ < div
299
+ className = { cn (
300
+ "absolute right-0 top-1/2 mr-1 flex -translate-y-1/2 items-center justify-end gap-0.5 rounded-[0.25rem] bg-background-dimmed p-0.5 group-hover/table-row:bg-background-bright group-hover/table-row:ring-1 group-hover/table-row:ring-grid-bright" ,
301
+ isSelected && isSelectedStyle ,
302
+ isSelected &&
303
+ "group-hover/table-row:bg-charcoal-750 group-hover/table-row:ring-charcoal-600/50"
304
+ ) }
305
+ >
281
306
{ /* Hidden buttons that show on hover */ }
282
307
{ hiddenButtons && (
283
308
< div className = "hidden pr-0.5 group-hover/table-row:block group-hover/table-row:border-r group-hover/table-row:border-grid-dimmed" >
0 commit comments