From b9e491d6ab0ab7a8d900d127ef1d3a0fdaa2ffe1 Mon Sep 17 00:00:00 2001 From: "Thomas F. K. Jorna" Date: Mon, 2 Aug 2021 18:31:18 +0200 Subject: feature: tag filtering lotic and ui --- components/tweaks.tsx | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) (limited to 'components/tweaks.tsx') diff --git a/components/tweaks.tsx b/components/tweaks.tsx index 3c9ee00..e46baf3 100644 --- a/components/tweaks.tsx +++ b/components/tweaks.tsx @@ -6,6 +6,8 @@ import { InfoOutlineIcon, RepeatIcon, ArrowRightIcon, + AddIcon, + DeleteIcon, } from '@chakra-ui/icons' import { Accordion, @@ -38,6 +40,7 @@ import { Grid, Portal, SlideFade, + Input, } from '@chakra-ui/react' import React, { useState, useContext } from 'react' import Scrollbars from 'react-custom-scrollbars-2' @@ -64,6 +67,7 @@ export interface TweakProps { setMouse: any behavior: typeof initialBehavior setBehavior: any + tags: string[] } export const Tweaks = (props: TweakProps) => { @@ -80,6 +84,7 @@ export const Tweaks = (props: TweakProps) => { setMouse, behavior, setBehavior, + tags, } = props const [showTweaks, setShowTweaks] = useState(true) const { highlightColor, setHighlightColor } = useContext(ThemeContext) @@ -107,6 +112,7 @@ export const Tweaks = (props: TweakProps) => { 'gray.900', 'black', ] + return ( <> @@ -223,6 +229,24 @@ export const Tweaks = (props: TweakProps) => { > + + + + Tag filters + + + + + + + + + Tag colors + + + + + @@ -1242,3 +1266,54 @@ export const ColorMenu = (props: ColorMenuProps) => { ) } + +export interface TagPanelProps { + tags: string[] + filter: typeof initialFilter + setFilter: any +} + +export const TagPanel = (props: TagPanelProps) => { + const { filter, setFilter, tags } = props + const [tagFilterText, setTagFilterText] = useState('') + + return ( + + + setTagFilterText(v.target.value)} + /> + { + if (!tags.includes(tagFilterText)) { + return + } + setFilter({ ...filter, tags: [...filter.tags, tagFilterText] }) + setTagFilterText('') + }} + aria-label="add tag" + icon={} + /> + + {filter.tags.map((tag) => { + return ( + + {tag} + } + onClick={() => + setFilter({ + ...filter, + tags: filter.tags.filter((t) => t !== tag), + }) + } + /> + + ) + })} + + ) +} -- cgit v1.2.3