From f86c618b1d84b7c7786fef5da8cecd12b0053c17 Mon Sep 17 00:00:00 2001 From: Damien Ostler Date: Sun, 2 Jun 2024 00:15:21 -0400 Subject: [PATCH] fix: remove scrollbar (#8) * Update .gitignore * fix: added a badge for number of tags selected * Update tag_selector.tsx * tag search * fix: search styling --- components/neroshitron/search_input.tsx | 49 ++- components/neroshitron/tag_selector.tsx | 4 +- package-lock.json | 501 +++++++++++++++++++++++- package.json | 2 + tailwind.config.js | 2 + 5 files changed, 537 insertions(+), 21 deletions(-) diff --git a/components/neroshitron/search_input.tsx b/components/neroshitron/search_input.tsx index ba39484..6a0526e 100644 --- a/components/neroshitron/search_input.tsx +++ b/components/neroshitron/search_input.tsx @@ -1,6 +1,9 @@ "use client;" import React, { useState, useEffect, useRef,forwardRef } from 'react'; import TagSelector from '../neroshitron/tag_selector'; +import Select from "react-tailwindcss-select"; +import { SelectValue } from 'react-tailwindcss-select/dist/components/type'; +import { Option } from 'react-tailwindcss-select/dist/components/type'; interface SearchInputProps { tagsChanged: (tags: string[]) => void; @@ -10,14 +13,22 @@ interface SearchInputProps { const SearchInput = ({ tagsChanged, searchChanged, nsfwChanged}: SearchInputProps) => { - const [search, setSearch] = useState(''); const [tagSearch, setTagSearch] = useState(''); const [nsfw, setNsfw] = useState(false); const [selectedTags, setSelectedTags] = useState([]); + const [selectedTagsInput, setSelectedTagsInput] = useState([]); const [selectingTags, setSelectingTags] = useState(false); const tagSelectorRef = React.useRef(null); const [tags, setTags] = useState([]); + const getData = async () => { + const tagsResponse = await fetch(`/api/galleries/tags`); + const tagsData = await tagsResponse.json(); + setTags(tagsData); + } + + + const updateTags = (newTags: string[]) => { setSelectedTags(newTags) @@ -34,9 +45,6 @@ const SearchInput = ({ tagsChanged, searchChanged, nsfwChanged}: SearchInputProp } } - useEffect(() => { - searchChanged(search); - }, [search]); useEffect(() => { tagsChanged(selectedTags); }, [selectedTags]); @@ -44,9 +52,11 @@ const SearchInput = ({ tagsChanged, searchChanged, nsfwChanged}: SearchInputProp nsfwChanged(nsfw); }, [nsfw]); useEffect(() => { + getData(); }, []); - + const tagOptions = tags.map((tag: { name: string; }) => ({ value: tag.name, label: tag.name })); + console.log(tagOptions) return ( <>
@@ -67,26 +77,41 @@ const SearchInput = ({ tagsChanged, searchChanged, nsfwChanged}: SearchInputProp ) :( <> - setSearch(e.target.value)} className="rounded-l-md h-16 bg-gray-100 text-grey-darker py-2 font-normal text-grey-darkest border border-gray-100 font-bold w-full py-1 px-2 outline-none text-lg text-gray-600" type="text" placeholder="Looking for a specific collection?" /> - - -
+