diff --git a/src/renderer/components/channel/ChannelButton.tsx b/src/renderer/components/channel/ChannelButton.tsx index a8adb13..d269a31 100644 --- a/src/renderer/components/channel/ChannelButton.tsx +++ b/src/renderer/components/channel/ChannelButton.tsx @@ -1,6 +1,7 @@ import { ChannelType } from '@/discord/structures/channel/BaseChannel'; import RendererChannel from '@/discord/structures/channel/RendererChannel'; import { getChannelIcon } from '@/utils/channelUtils'; +import { useLocation } from 'react-router-dom'; type ChannelButtonProps = { channel: RendererChannel; @@ -11,13 +12,23 @@ export default function ChannelButton({ channel, onClick, }: ChannelButtonProps) { + const location = useLocation(); + + const isCategory = channel.type === ChannelType.GuildCategory; + const isSelected = + !isCategory && location.pathname.includes(`/channel/${channel.id}`); + + let classes = !isCategory + ? `ChannelButton--normal` + : 'ChannelButton--category'; + + if (isSelected) { + classes += ' ChannelButton--selected'; + } + return (
onClick(channel)} role="presentation" > diff --git a/src/renderer/styles/channel/ChannelButton.css b/src/renderer/styles/channel/ChannelButton.css index 22847fc..f21250f 100644 --- a/src/renderer/styles/channel/ChannelButton.css +++ b/src/renderer/styles/channel/ChannelButton.css @@ -36,7 +36,8 @@ width: 0px; } -.ChannelButton--normal:hover { +.ChannelButton--normal:hover, +.ChannelButton--selected { background: #1f1e25; color: #fff; } @@ -44,5 +45,5 @@ .ChannelButton--icon { width: 23px; filter: invert(57%) sepia(0%) saturate(256%) hue-rotate(170deg) - brightness(101%) contrast(84%); + brightness(101%) contrast(84%); }