Skip to content

Commit

Permalink
Action icons behavior
Browse files Browse the repository at this point in the history
Action icons are always visible on a selected row. Action icons stay visible after click as expected even on unselected rows.
  • Loading branch information
dan-rukas committed Oct 2, 2024
1 parent c2c25c7 commit a1acd73
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
21 changes: 13 additions & 8 deletions platform/ui-next/src/_prototypes/DataRow/DataRow.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import React from 'react';
// src/_prototypes/DataRow/DataRow.tsx

import React, { useState } from 'react';
import { Button } from '../../components/Button/Button';
import {
DropdownMenu,
Expand Down Expand Up @@ -33,9 +35,12 @@ const DataRow: React.FC<DataRowProps> = ({
isSelected = false,
onSelect,
}) => {
// State to track if the dropdown is open
const [isDropdownOpen, setIsDropdownOpen] = useState(false);

return (
<div className="flex flex-col">
{/* Row 1 */}
{/* Row 1 with 'group' class to enable group-hover */}
<div
className={`flex items-center ${
isSelected ? 'bg-popover' : 'bg-muted'
Expand Down Expand Up @@ -75,18 +80,18 @@ const DataRow: React.FC<DataRowProps> = ({
</span>
</div>

{/* Actions Button (Appears on Hover of the entire row) */}
{/* Actions Button (Appears on Hover or when Dropdown is Open or Selected) */}
<div className="relative mr-0.5 flex items-center">
{' '}
{/* Updated div */}
<DropdownMenu>
<DropdownMenu onOpenChange={open => setIsDropdownOpen(open)}>
<DropdownMenuTrigger asChild>
<Button
size="small"
variant="ghost"
className="h-6 w-6 opacity-0 transition-opacity group-hover:opacity-100"
className={`h-6 w-6 transition-opacity ${
isSelected || isDropdownOpen ? 'opacity-100' : 'opacity-0 group-hover:opacity-100'
}`}
aria-label="Actions"
onClick={e => e.stopPropagation()}
onClick={e => e.stopPropagation()} // Prevent row selection on button click
>
<Icons.More className="h-6 w-6" />
</Button>
Expand Down
2 changes: 1 addition & 1 deletion platform/ui-next/src/tailwind.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
--primary: 214 98% 60%;
--primary-foreground: 0 0% 98%;
--secondary: 214 66% 48%;
--secondary-foreground: 0 0% 85%;
--secondary-foreground: 200 50% 84%;
--muted: 234 64% 10%;
--muted-foreground: 200 46% 65%;
--accent: 217 79% 24%;
Expand Down

0 comments on commit a1acd73

Please sign in to comment.