Skip to content

Commit

Permalink
feat: Mark active item in bold
Browse files Browse the repository at this point in the history
  • Loading branch information
gianklug committed Jan 15, 2024
1 parent 6023f4d commit 6ed0feb
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/Item.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type Component } from 'solid-js'
import { type Component, createEffect, createSignal } from 'solid-js'
import { useAppContext } from './context'

type itemProps = {
Expand All @@ -9,7 +9,6 @@ type itemProps = {

const Item: Component<itemProps> = props => {
const { contextValue, updateContext } = useAppContext()

function handleClick() {
if (!props.path.endsWith('/') && props.path !== '') {
updateContext({ page: 'view', kv: props.kv, path: props.path })
Expand All @@ -21,7 +20,7 @@ const Item: Component<itemProps> = props => {
return (
<span onClick={handleClick}>
{props.icon}
<span class={`${contextValue().path === props.path ? 'text-bold' : ''}`}>
<span class={`${props.path === contextValue().path && props.kv === contextValue().kv ? 'font-bold' : ''}`}>
{props.path === '' ? props.kv : props.path.replace(/\/+$/, '').split('/').pop()}
</span>
</span>
Expand Down

0 comments on commit 6ed0feb

Please sign in to comment.