diff --git a/src/components/IconGrid/TagCloud.css b/src/components/IconGrid/TagCloud.css new file mode 100644 index 0000000..1ee8f94 --- /dev/null +++ b/src/components/IconGrid/TagCloud.css @@ -0,0 +1,32 @@ +.tag-cloud { + display: flex; + flex-wrap: wrap; + justify-content: center; + padding: 24px; +} + +button.tag-button { + margin: 4px; + border-radius: 4px; + background-color: rgba(194, 186, 196, 0.25); + outline: none; + cursor: pointer; + transition: background-color 200ms ease, box-shadow 200ms ease; +} + +button.tag-button:hover { + background-color: rgba(194, 186, 196, 0.7); +} + +button.tag-button:focus { + box-shadow: 0 0 0 1px rgba(194, 186, 196, 0.7); +} + +.tag-button code { + padding: 4px; + font-size: 12px; +} + +.dark { + color: white; +} \ No newline at end of file diff --git a/src/components/IconGrid/TagCloud.tsx b/src/components/IconGrid/TagCloud.tsx new file mode 100644 index 0000000..5d376b4 --- /dev/null +++ b/src/components/IconGrid/TagCloud.tsx @@ -0,0 +1,38 @@ +import React, { useCallback } from "react"; +import { useSetRecoilState } from "recoil"; + +import { searchQueryAtom } from "../../state/atoms"; +import "./TagCloud.css"; + +interface TagCloudProps { + name: string; + tags: string[]; + isDark: boolean; +} + +const TagCloud: React.FC = ({ name, tags, isDark }) => { + const setQuery = useSetRecoilState(searchQueryAtom); + const handleTagClick = useCallback( + (tag: string) => { + setQuery(tag); + document.getElementById("search-input")?.focus(); + }, + [setQuery] + ); + + return ( +
+ {tags.map((tag) => ( + + ))} +
+ ); +}; + +export default TagCloud;