From 1e520f7392323a8afee3bc12ab04000ae1d5dc16 Mon Sep 17 00:00:00 2001 From: Connor Yoh Date: Thu, 2 Oct 2025 12:52:29 +0100 Subject: [PATCH] Added colours to theme and used mantine button for automation selection --- .../tools/automate/AutomationEntry.tsx | 220 +++++++++--------- frontend/src/styles/theme.css | 2 + 2 files changed, 113 insertions(+), 109 deletions(-) diff --git a/frontend/src/components/tools/automate/AutomationEntry.tsx b/frontend/src/components/tools/automate/AutomationEntry.tsx index 1a0d2b5bb..8f739bcbf 100644 --- a/frontend/src/components/tools/automate/AutomationEntry.tsx +++ b/frontend/src/components/tools/automate/AutomationEntry.tsx @@ -1,6 +1,6 @@ import React, { useState } from 'react'; import { useTranslation } from 'react-i18next'; -import { Group, Text, ActionIcon, Menu, Box } from '@mantine/core'; +import { Group, Text, ActionIcon, Menu, Button, Box } from '@mantine/core'; import MoreVertIcon from '@mui/icons-material/MoreVert'; import EditIcon from '@mui/icons-material/Edit'; import DeleteIcon from '@mui/icons-material/Delete'; @@ -51,8 +51,7 @@ export default function AutomationEntry({ const [isHovered, setIsHovered] = useState(false); const [isMenuOpen, setIsMenuOpen] = useState(false); - // Keep item in hovered state if menu is open - const shouldShowHovered = isHovered || isMenuOpen; + const shouldShowMenu = isHovered || isMenuOpen; // Helper function to resolve tool display names const getToolDisplayName = (operation: string): string => { @@ -109,132 +108,135 @@ export default function AutomationEntry({ ); }; - const renderContent = () => { - if (title) { - // Custom automation with title - return ( - - {BadgeIcon && ( - } - {...(keepIconColor && { color: 'var(--mantine-primary-color-filled)' })} - /> - )} - + const buttonContent = ( + <> + {BadgeIcon && ( + } + {...(keepIconColor && { color: 'var(--mantine-primary-color-filled)' })} + /> + )} +
+ {title ? ( + // Custom automation with title + {title} - - ); - } else { - // Suggested automation showing tool chain - return ( - - {BadgeIcon && ( - } - {...(keepIconColor && { color: 'var(--mantine-primary-color-filled)' })} - /> - )} + ) : ( + // Suggested automation showing tool chain {operations.map((op, index) => ( - + {getToolDisplayName(op)} - {index < operations.length - 1 && ( - + )} ))} - - ); - } - }; + )} +
+ + ); - const boxContent = ( + const wrapperContent = ( setIsHovered(true)} onMouseLeave={() => setIsHovered(false)} > - -
- {renderContent()} -
+ + {showMenu && ( + setIsMenuOpen(true)} + onClose={() => setIsMenuOpen(false)} + > + + e.stopPropagation()} + style={{ + position: 'absolute', + right: '0.5rem', + top: '50%', + transform: 'translateY(-50%)', + zIndex: 1, + opacity: shouldShowMenu ? 1 : 0, + transition: 'opacity 0.2s ease', + pointerEvents: shouldShowMenu ? 'auto' : 'none' + }} + > + + + - {showMenu && ( - setIsMenuOpen(true)} - onClose={() => setIsMenuOpen(false)} - > - - e.stopPropagation()} - style={{ - opacity: shouldShowHovered ? 1 : 0, - transform: shouldShowHovered ? 'scale(1)' : 'scale(0.8)', - transition: 'opacity 0.3s ease, transform 0.3s ease', - pointerEvents: shouldShowHovered ? 'auto' : 'none' + + {onCopy && ( + } + onClick={(e) => { + e.stopPropagation(); + onCopy(); }} > - - - - - - {onCopy && ( - } - onClick={(e) => { - e.stopPropagation(); - onCopy(); - }} - > - {t('automate.copyToSaved', 'Copy to Saved')} - - )} - {onEdit && ( - } - onClick={(e) => { - e.stopPropagation(); - onEdit(); - }} - > - {t('edit', 'Edit')} - - )} - {onDelete && ( - } - onClick={(e) => { - e.stopPropagation(); - onDelete(); - }} - > - {t('delete', 'Delete')} - - )} - - - )} - + {t('automate.copyToSaved', 'Copy to Saved')} + + )} + {onEdit && ( + } + onClick={(e) => { + e.stopPropagation(); + onEdit(); + }} + > + {t('edit', 'Edit')} + + )} + {onDelete && ( + } + onClick={(e) => { + e.stopPropagation(); + onDelete(); + }} + > + {t('delete', 'Delete')} + + )} + + + )}
); @@ -248,9 +250,9 @@ export default function AutomationEntry({ arrow={true} delay={500} > - {boxContent} + {wrapperContent} ) : ( - boxContent + wrapperContent ); } diff --git a/frontend/src/styles/theme.css b/frontend/src/styles/theme.css index 6100e951d..3b0ac694b 100644 --- a/frontend/src/styles/theme.css +++ b/frontend/src/styles/theme.css @@ -120,6 +120,7 @@ --border-strong: #9ca3af; --hover-bg: #f9fafb; --active-bg: #f3f4f6; + --automation-entry-hover-bg: var(--color-gray-100); /* Icon colors for light mode */ --icon-user-bg: #9CA3AF; @@ -317,6 +318,7 @@ --border-strong: #4b5563; --hover-bg: #374151; --active-bg: #4b5563; + --automation-entry-hover-bg: var(--color-gray-200); /* Icon colors for dark mode */ --icon-user-bg: #2A2F36;