From 466dcdef7b3caa98ec1d97caa72045bc21740ecf Mon Sep 17 00:00:00 2001
From: 0xPierre <43297207+PierreCrb@users.noreply.github.com>
Date: Thu, 8 Sep 2022 17:53:59 +0200
Subject: [PATCH] feat: make input search sticky in sidebar
---
src/components/sidebar/Sidebar.tsx | 144 +++++++++++++++--------------
1 file changed, 74 insertions(+), 70 deletions(-)
diff --git a/src/components/sidebar/Sidebar.tsx b/src/components/sidebar/Sidebar.tsx
index 7ff5f7974c..8bb8933944 100644
--- a/src/components/sidebar/Sidebar.tsx
+++ b/src/components/sidebar/Sidebar.tsx
@@ -6,6 +6,7 @@ import {
InputRightElement,
DarkMode,
IconButton,
+ Flex,
} from '@chakra-ui/react'
import { CloseIcon, SearchIcon } from '@chakra-ui/icons'
import DragItem from './DragItem'
@@ -22,90 +23,93 @@ const Menu = () => {
overflowX="visible"
boxShadow="xl"
flex="0 0 14rem"
- p={5}
m={0}
+ p={0}
as="menu"
backgroundColor="#2e3748"
width="15rem"
>
-
- ) =>
- setSearchTerm(event.target.value)
- }
- borderColor="rgba(255, 255, 255, 0.04)"
- bg="rgba(255, 255, 255, 0.06)"
- _hover={{
- borderColor: 'rgba(255, 255, 255, 0.08)',
- }}
- zIndex={0}
- />
-
- {searchTerm ? (
- }
- size="xs"
- onClick={() => setSearchTerm('')}
- />
- ) : (
-
- )}
-
-
+
+
+ ) =>
+ setSearchTerm(event.target.value)
+ }
+ borderColor="rgba(255, 255, 255, 0.04)"
+ bg="rgba(255, 255, 255, 0.06)"
+ _hover={{
+ borderColor: 'rgba(255, 255, 255, 0.08)',
+ }}
+ zIndex={0}
+ />
+
+ {searchTerm ? (
+ }
+ size="xs"
+ onClick={() => setSearchTerm('')}
+ />
+ ) : (
+
+ )}
+
+
+
+
+ {(Object.keys(menuItems) as ComponentType[])
+ .filter(c => c.toLowerCase().includes(searchTerm.toLowerCase()))
+ .map(name => {
+ const { children, soon } = menuItems[name] as MenuItem
- {(Object.keys(menuItems) as ComponentType[])
- .filter(c => c.toLowerCase().includes(searchTerm.toLowerCase()))
- .map(name => {
- const { children, soon } = menuItems[name] as MenuItem
+ if (children) {
+ const elements = Object.keys(children).map(childName => (
+
+ {childName}
+
+ ))
- if (children) {
- const elements = Object.keys(children).map(childName => (
-
- {childName}
-
- ))
+ return [
+
+ {name}
+ ,
+ ...elements,
+ ]
+ }
- return [
+ return (
{name}
- ,
- ...elements,
- ]
- }
-
- return (
-
- {name}
-
- )
- })}
+
+ )
+ })}
+
)