From ea5cb4fd8bec68f1b0aff97aedad757846258084 Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Fri, 8 Mar 2024 10:14:58 -0700 Subject: [PATCH] Rework mobile drawers to have a max height (#10330) --- .../components/filter/ReviewFilterGroup.tsx | 162 ++++++++++-------- web/src/pages/SubmitPlus.tsx | 126 ++++++++------ 2 files changed, 158 insertions(+), 130 deletions(-) diff --git a/web/src/components/filter/ReviewFilterGroup.tsx b/web/src/components/filter/ReviewFilterGroup.tsx index 1d862998c..b1d74ce23 100644 --- a/web/src/components/filter/ReviewFilterGroup.tsx +++ b/web/src/components/filter/ReviewFilterGroup.tsx @@ -155,56 +155,62 @@ function CamerasFilterButton({ Filter Cameras - { - if (isChecked) { - setCurrentCameras(undefined); - } - }} - /> - {groups.length > 0 && ( - <> - - {groups.map(([name, conf]) => { - return ( - { - setCurrentCameras([...conf.cameras]); - }} - /> - ); - })} - - )} - - {allCameras.map((item) => ( +
{ if (isChecked) { - const updatedCameras = currentCameras ? [...currentCameras] : []; - - updatedCameras.push(item); - setCurrentCameras(updatedCameras); - } else { - const updatedCameras = currentCameras ? [...currentCameras] : []; - - // can not deselect the last item - if (updatedCameras.length > 1) { - updatedCameras.splice(updatedCameras.indexOf(item), 1); - setCurrentCameras(updatedCameras); - } + setCurrentCameras(undefined); } }} /> - ))} + {groups.length > 0 && ( + <> + + {groups.map(([name, conf]) => { + return ( + { + setCurrentCameras([...conf.cameras]); + }} + /> + ); + })} + + )} + + {allCameras.map((item) => ( + { + if (isChecked) { + const updatedCameras = currentCameras + ? [...currentCameras] + : []; + + updatedCameras.push(item); + setCurrentCameras(updatedCameras); + } else { + const updatedCameras = currentCameras + ? [...currentCameras] + : []; + + // can not deselect the last item + if (updatedCameras.length > 1) { + updatedCameras.splice(updatedCameras.indexOf(item), 1); + setCurrentCameras(updatedCameras); + } + } + }} + /> + ))} +
Filter Labels - { - if (isChecked) { - setCurrentLabels(undefined); - } - }} - /> - - {allLabels.map((item) => ( +
{ if (isChecked) { - const updatedLabels = currentLabels ? [...currentLabels] : []; - - updatedLabels.push(item); - setCurrentLabels(updatedLabels); - } else { - const updatedLabels = currentLabels ? [...currentLabels] : []; - - // can not deselect the last item - if (updatedLabels.length > 1) { - updatedLabels.splice(updatedLabels.indexOf(item), 1); - setCurrentLabels(updatedLabels); - } + setCurrentLabels(undefined); } }} /> - ))} + + {allLabels.map((item) => ( + { + if (isChecked) { + const updatedLabels = currentLabels ? [...currentLabels] : []; + + updatedLabels.push(item); + setCurrentLabels(updatedLabels); + } else { + const updatedLabels = currentLabels ? [...currentLabels] : []; + + // can not deselect the last item + if (updatedLabels.length > 1) { + updatedLabels.splice(updatedLabels.indexOf(item), 1); + setCurrentLabels(updatedLabels); + } + } + }} + /> + ))} +
- - + + Filter Cameras @@ -229,33 +235,35 @@ function PlusFilterGroup({ }} /> - {allCameras.map((item) => ( - { - if (isChecked) { - const updatedCameras = currentCameras - ? [...currentCameras] - : []; +
+ {allCameras.map((item) => ( + { + if (isChecked) { + const updatedCameras = currentCameras + ? [...currentCameras] + : []; - updatedCameras.push(item); - setCurrentCameras(updatedCameras); - } else { - const updatedCameras = currentCameras - ? [...currentCameras] - : []; - - // can not deselect the last item - if (updatedCameras.length > 1) { - updatedCameras.splice(updatedCameras.indexOf(item), 1); + updatedCameras.push(item); setCurrentCameras(updatedCameras); + } else { + const updatedCameras = currentCameras + ? [...currentCameras] + : []; + + // can not deselect the last item + if (updatedCameras.length > 1) { + updatedCameras.splice(updatedCameras.indexOf(item), 1); + setCurrentCameras(updatedCameras); + } } - } - }} - /> - ))} + }} + /> + ))} +
-
- - + + { if (!open) { @@ -279,7 +287,7 @@ function PlusFilterGroup({ setOpen(open ? "label" : "none"); }} > - + - - + + Filter Labels @@ -304,29 +312,35 @@ function PlusFilterGroup({ }} /> - {allLabels.map((item) => ( - { - if (isChecked) { - const updatedLabels = currentLabels ? [...currentLabels] : []; +
+ {allLabels.map((item) => ( + { + if (isChecked) { + const updatedLabels = currentLabels + ? [...currentLabels] + : []; - updatedLabels.push(item); - setCurrentLabels(updatedLabels); - } else { - const updatedLabels = currentLabels ? [...currentLabels] : []; - - // can not deselect the last item - if (updatedLabels.length > 1) { - updatedLabels.splice(updatedLabels.indexOf(item), 1); + updatedLabels.push(item); setCurrentLabels(updatedLabels); + } else { + const updatedLabels = currentLabels + ? [...currentLabels] + : []; + + // can not deselect the last item + if (updatedLabels.length > 1) { + updatedLabels.splice(updatedLabels.indexOf(item), 1); + setCurrentLabels(updatedLabels); + } } - } - }} - /> - ))} + }} + /> + ))} +
-
- + +
); }