From c6f0abf7322a2c3ede08d0506eb036845aa3226e Mon Sep 17 00:00:00 2001 From: spacebares <57186372+spacebares@users.noreply.github.com> Date: Sat, 17 Dec 2022 15:54:54 -0800 Subject: [PATCH] Show All and Solo selection buttons for MultiSelect. (#4723) * Show All and Solo selection buttons for MultiSelect. Similar to previous behavior of viewing events for single camera with 1 click, or All. * Fix visual bug with MultiSelect when selecting similar named options. eg. options like frontdoor, frontside, backdoor, etc * fix key prop for lint * Change MultiSelect onSolo to onSelectSingle * cosmetic changes on MultiSelect * Different look for SelectSingle buttons * Show All button is aligned with the items below it, no matter the popup size * MultiSelect ShowAll unfocused by default --- web/src/components/MultiSelect.jsx | 43 ++++++++++++++++++++---------- web/src/routes/Events.jsx | 8 ++++++ 2 files changed, 37 insertions(+), 14 deletions(-) diff --git a/web/src/components/MultiSelect.jsx b/web/src/components/MultiSelect.jsx index 0e41a0503..99412e938 100644 --- a/web/src/components/MultiSelect.jsx +++ b/web/src/components/MultiSelect.jsx @@ -3,15 +3,19 @@ import { useRef, useState } from 'preact/hooks'; import Menu from './Menu'; import { ArrowDropdown } from '../icons/ArrowDropdown'; import Heading from './Heading'; +import Button from './Button'; +import CameraIcon from '../icons/Camera'; -export default function MultiSelect({ className, title, options, selection, onToggle }) { +export default function MultiSelect({ className, title, options, selection, onToggle, onShowAll, onSelectSingle }) { const popupRef = useRef(null); const [state, setState] = useState({ showMenu: false, }); - + + const isOptionSelected = (item) => { return selection == "all" || selection.split(',').indexOf(item) > -1; } + return (