diff --git a/packages/app/src/Element/Feed/DisplayAsSelector.tsx b/packages/app/src/Element/Feed/DisplayAsSelector.tsx index 0883c66ca..51b261ef9 100644 --- a/packages/app/src/Element/Feed/DisplayAsSelector.tsx +++ b/packages/app/src/Element/Feed/DisplayAsSelector.tsx @@ -1,6 +1,7 @@ import Icon from "@/Icons/Icon"; import { LoginStore } from "@/Login"; import useLogin from "@/Hooks/useLogin"; +import { useCallback } from "react"; export type DisplayAs = "list" | "grid"; @@ -13,29 +14,32 @@ type DisplaySelectorProps = { export const DisplayAsSelector = ({ activeSelection, onSelect, show }: DisplaySelectorProps) => { const state = useLogin(); - const myOnSelect = (display: DisplayAs) => { - onSelect(display); - state.feedDisplayAs = display; - LoginStore.updateSession(state); + const getClasses = (displayType: DisplayAs) => { + const baseClasses = "border-highlight cursor-pointer flex justify-center flex-1 p-3"; + return activeSelection === displayType + ? `${baseClasses} border-b border-1` + : `${baseClasses} hover:bg-nearly-bg-color text-secondary`; }; + const myOnSelect = useCallback( + (display: DisplayAs) => { + onSelect(display); + const updatedState = { ...state, feedDisplayAs: display }; + LoginStore.updateSession(updatedState); + }, + [onSelect, state], + ); + if (show === false) return null; + return (