Skip to content

Commit

Permalink
Add icons to dropdown menu items
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanielrindlaub committed Jan 4, 2025
1 parent d837583 commit 076e3a0
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/components/Dropdown.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,19 @@ const itemStyles = {
fontSize: '$3',
fontWeight: '$2',
lineHeight: 1,
color: '$hiContrast',
color: '$textDark',
borderRadius: 3,
display: 'flex',
alignItems: 'center',
height: 27,
padding: '0 5px',
position: 'relative',
paddingLeft: '$2',
paddingLeft: 28,
userSelect: 'none',

'&[data-disabled]': {
color: mauve.mauve8,
// pointerEvents: 'none',
pointerEvents: 'none',
},

'&[data-state="checked"]': {
Expand Down
18 changes: 17 additions & 1 deletion src/features/cameras/CameraList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
DropdownMenuTrigger,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuItemIconLeft,
DropdownMenuArrow,
} from '../../components/Dropdown.jsx';
import {
Expand Down Expand Up @@ -35,7 +36,7 @@ import {
ChevronDownIcon,
} from '@radix-ui/react-icons';
import { StandAloneInput as Input } from '../../components/Form';
import { Camera, MapPin } from 'lucide-react';
import { Camera, MapPin, IdCard, Trash2, Unlink, Link } from 'lucide-react';
import { indigo } from '@radix-ui/colors';

import {
Expand Down Expand Up @@ -241,6 +242,9 @@ const CameraList = ({ cameras, handleSaveDepClick, handleDeleteDepClick }) => {
<DropdownMenuItem
onSelect={() => handleSaveDepClick({ cameraId: cam._id })}
>
<DropdownMenuItemIconLeft>
<MapPin size={15} />
</DropdownMenuItemIconLeft>
Add Deployment
</DropdownMenuItem>
)}
Expand All @@ -253,6 +257,9 @@ const CameraList = ({ cameras, handleSaveDepClick, handleDeleteDepClick }) => {
onMouseLeave={() => setEditSnTooltipOpen(false)}
disabled={cam.isWireless}
>
<DropdownMenuItemIconLeft>
<IdCard size={15} />
</DropdownMenuItemIconLeft>
Edit camera serial number
</DropdownMenuItem>
</TooltipTrigger>
Expand Down Expand Up @@ -280,6 +287,9 @@ const CameraList = ({ cameras, handleSaveDepClick, handleDeleteDepClick }) => {
});
}}
>
<DropdownMenuItemIconLeft>
<Unlink size={15} />
</DropdownMenuItemIconLeft>
Release camera
</DropdownMenuItem>
</TooltipTrigger>
Expand All @@ -301,6 +311,9 @@ const CameraList = ({ cameras, handleSaveDepClick, handleDeleteDepClick }) => {
});
}}
>
<DropdownMenuItemIconLeft>
<Link size={15} />
</DropdownMenuItemIconLeft>
Re-register camera
</DropdownMenuItem>
)}
Expand All @@ -322,6 +335,9 @@ const CameraList = ({ cameras, handleSaveDepClick, handleDeleteDepClick }) => {
});
}}
>
<DropdownMenuItemIconLeft>
<Trash2 size={15} />
</DropdownMenuItemIconLeft>
Delete camera
</DropdownMenuItem>
</TooltipTrigger>
Expand Down
2 changes: 1 addition & 1 deletion src/features/cameras/DeleteCameraAlert.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ const DeleteCameraAlert = () => {
<p>
Are you sure you&apos;d like to delete Camera <BoldText>{selectedCamera}</BoldText>?{' '}
{imageCount === 0 && 'This will remove the Camera and the Deployments '}
{imageCount > 0 && (
{!imageCountLoading && imageCount > 0 && (
<>
This will remove the Camera, its Deployments, and{' '}
{imageCount > 1 ? 'all' : 'the'}{' '}
Expand Down
8 changes: 8 additions & 0 deletions src/features/filters/FiltersPanelFooterDropdown.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ import {
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuArrow,
DropdownMenuItemIconLeft,
} from '../../components/Dropdown.jsx';
import { selectUserCurrentRoles } from '../auth/authSlice.js';
import { hasRole, DELETE_IMAGES_ROLES, EXPORT_DATA_ROLES } from '../auth/roles.js';
import { DotsHorizontalIcon } from '@radix-ui/react-icons';
import { Download, Trash2 } from 'lucide-react';
import { setDeleteImagesAlertStatus } from '../images/imagesSlice';

const StyledDropdownMenuTrigger = styled(DropdownMenuTrigger, {
Expand Down Expand Up @@ -40,11 +42,17 @@ const FiltersPanelFooterDropdown = (props) => {
<DropdownMenuContent sideOffset={5}>
{hasRole(userRoles, EXPORT_DATA_ROLES) && (
<DropdownMenuItem onSelect={() => props.handleModalToggle('export-modal')}>
<DropdownMenuItemIconLeft>
<Download size={15} />
</DropdownMenuItemIconLeft>
Export currently filtered data
</DropdownMenuItem>
)}
{hasRole(userRoles, DELETE_IMAGES_ROLES) && (
<DropdownMenuItem onSelect={handleDeleteImageItemClick}>
<DropdownMenuItemIconLeft>
<Trash2 size={15} />
</DropdownMenuItemIconLeft>
Delete all currently filtered images
</DropdownMenuItem>
)}
Expand Down
12 changes: 11 additions & 1 deletion src/features/loupe/Comment.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
DropdownMenuTrigger,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuItemIconLeft,
DropdownMenuArrow,
} from '../../components/Dropdown.jsx';
import Button from '../../components/Button.jsx';
Expand All @@ -17,6 +18,7 @@ import { selectUserUsername } from '../auth/authSlice.js';
import { DateTime } from 'luxon';
import { editComment } from '../review/reviewSlice.js';
import { indigo } from '@radix-ui/colors';
import { Trash2, Pencil } from 'lucide-react';

const StyledFieldRow = styled(FieldRow, {
display: 'block',
Expand Down Expand Up @@ -197,9 +199,17 @@ export const Comment = ({ comment, imageId, onChangeOpen, scrollRef }) => {
</StyledDropdownMenuTrigger>
<StyledDropdownMenuContent sideOffset={5}>
<DropdownMenuItem onSelect={() => setIsDeleteConfirm(true)}>
<DropdownMenuItemIconLeft>
<Trash2 size={15} />
</DropdownMenuItemIconLeft>
Delete
</DropdownMenuItem>
<DropdownMenuItem onSelect={() => setIsEdit(true)}>Edit</DropdownMenuItem>
<DropdownMenuItem onSelect={() => setIsEdit(true)}>
<DropdownMenuItemIconLeft>
<Pencil size={15} />
</DropdownMenuItemIconLeft>
Edit
</DropdownMenuItem>
<DropdownMenuArrow offset={12} />
</StyledDropdownMenuContent>
</DropdownMenu>
Expand Down
9 changes: 8 additions & 1 deletion src/features/loupe/LoupeDropdown.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ import {
DropdownMenuTrigger,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuItemIconLeft,
DropdownMenuArrow,
} from '../../components/Dropdown.jsx';
import IconButton from '../../components/IconButton.jsx';
import { DotsHorizontalIcon } from '@radix-ui/react-icons';
import DeleteImagesAlert from '../images/DeleteImagesAlert.jsx';
import { setDeleteImagesAlertStatus } from '../images/imagesSlice';
import { selectFocusIndex, setSelectedImageIndices } from '../review/reviewSlice.js';
import { Trash2 } from 'lucide-react';

const StyledDropdownMenuTrigger = styled(DropdownMenuTrigger, {
position: 'absolute',
Expand All @@ -37,7 +39,12 @@ const LoupeDropdown = ({ image }) => {
</IconButton>
</StyledDropdownMenuTrigger>
<DropdownMenuContent sideOffset={5}>
<DropdownMenuItem onSelect={handleDeleteImageItemClick}>Delete Image</DropdownMenuItem>
<DropdownMenuItem onSelect={handleDeleteImageItemClick}>
<DropdownMenuItemIconLeft>
<Trash2 size={15} />
</DropdownMenuItemIconLeft>
Delete Image
</DropdownMenuItem>
<DropdownMenuArrow offset={12} />
</DropdownMenuContent>

Expand Down

0 comments on commit 076e3a0

Please sign in to comment.