diff --git a/src/components/DragAndDrop.tsx b/src/components/DragAndDrop.tsx index 2d9ea79..5b8fdf6 100644 --- a/src/components/DragAndDrop.tsx +++ b/src/components/DragAndDrop.tsx @@ -15,10 +15,10 @@ export const DragAndDrop: React.FC = () => {
-
+
diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx index 49420af..73263a7 100644 --- a/src/components/Sidebar.tsx +++ b/src/components/Sidebar.tsx @@ -1,10 +1,11 @@ 'use client' -import React, { useRef } from 'react' +import React, { useRef, useState } from 'react' import { useDrag } from 'react-dnd' import { Button } from "@/components/ui/button" import { roboto } from '../app/fonts' import { useElements } from '../context/ElementsContext' +import { Input } from "@/components/ui/input" interface DraggableElementProps { type: string @@ -40,20 +41,41 @@ const DraggableElement: React.FC = ({ type, content }) => export const Sidebar: React.FC = () => { const { elements, getElementContent } = useElements() + const [searchQuery, setSearchQuery] = useState('') + + const filteredElements = Array.from(elements.values()).filter(element => + getElementContent(element.type).toLowerCase().includes(searchQuery.toLowerCase()) + ) return ( -
-

Elements

-
- {Array.from(elements.values()).map((element) => ( - - ))} +
+
+
+ {filteredElements.map((element) => ( + + ))} +
+
+
+ {/*
+ + +
*/} + setSearchQuery(e.target.value)} + />
) -} - +} \ No newline at end of file diff --git a/src/components/ui/input.tsx b/src/components/ui/input.tsx new file mode 100644 index 0000000..69b64fb --- /dev/null +++ b/src/components/ui/input.tsx @@ -0,0 +1,22 @@ +import * as React from "react" + +import { cn } from "@/lib/utils" + +const Input = React.forwardRef>( + ({ className, type, ...props }, ref) => { + return ( + + ) + } +) +Input.displayName = "Input" + +export { Input } diff --git a/src/context/ElementsContext.tsx b/src/context/ElementsContext.tsx index 67c9199..84080f8 100644 --- a/src/context/ElementsContext.tsx +++ b/src/context/ElementsContext.tsx @@ -20,8 +20,8 @@ export function ElementsProvider({ children }: { children: React.ReactNode }) { const [elements, setElements] = useState>(new Map([ ['water', { type: 'water', emoji: '💧', text: 'Water' }], ['fire', { type: 'fire', emoji: '🔥', text: 'Fire' }], - ['earth', { type: 'earth', emoji: '🌿', text: 'Earth' }], - ['air', { type: 'air', emoji: '💨', text: 'Air' }], + ['earth', { type: 'earth', emoji: '🌎', text: 'Earth' }], + ['wind', { type: 'wind', emoji: '💨', text: 'Wind' }], ])) const addElement = useCallback((type: string, emoji: string) => {