Skip to content

Commit

Permalink
chore: move toggle func to store
Browse files Browse the repository at this point in the history
  • Loading branch information
allison-truhlar committed Jul 31, 2024
1 parent 7f22452 commit 5aa1739
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/components/projects/FilterMenu.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { useState, useEffect } from "react";
import { useStore } from "@nanostores/react";
import { TbMinus, TbPlus, TbX } from "react-icons/tb";
import { isFilterMenuVisible } from "../../stores/isFilterMenuVisibleStore.js";
import {
isFilterMenuVisible,
toggleVisibility,
} from "../../stores/isFilterMenuVisibleStore.js";
import {
selectedTags,
handleTagSelection,
Expand Down Expand Up @@ -55,7 +58,7 @@ export default function FilterMenu({ uniqueTags }) {
>
<button
className="md:hidden self-end m-2 btn-secondary rounded-full"
onClick={() => isFilterMenuVisible.set(!$isFilterMenuVisible)}
onClick={() => toggleVisibility}
>
<TbX />
</button>
Expand Down
5 changes: 5 additions & 0 deletions src/stores/isFilterMenuVisibleStore.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import { atom } from "nanostores";

export const isFilterMenuVisible = atom(false);

export function toggleVisibility() {
const prevVisbility = isFilterMenuVisible.get();
isFilterMenuVisible.set(!prevVisbility);
}

0 comments on commit 5aa1739

Please sign in to comment.