Files
bridget/assets/ts/mobile/galleryNav.tsx
Sped0n d1a1dba210 feat(gallery): enhance close button accessibility
Add .navClose styles for 30% min-width, right alignment, and pointer cursor.
Apply class to close div in mobile gallery nav for consistent keyboard support.

Signed-off-by: Sped0n <hi@sped0n.com>
2025-11-25 21:13:53 +08:00

47 lines
1.4 KiB
TypeScript

import { createMemo, type Accessor, type JSX, type Setter } from 'solid-js'
import { useState } from '../state'
import { expand } from '../utils'
export function capitalizeFirstLetter(str: string): string {
return str.charAt(0).toUpperCase() + str.slice(1)
}
export default function GalleryNav(props: {
children?: JSX.Element
closeText: string
isAnimating: Accessor<boolean>
setIsOpen: Setter<boolean>
}): JSX.Element {
// states
const [state] = useState()
const indexValue = createMemo(() => expand(state().index + 1))
const indexLength = createMemo(() => expand(state().length))
const onClick: () => void = () => {
if (props.isAnimating()) return
props.setIsOpen(false)
}
return (
<>
<div class="nav">
<div>
<span class="num">{indexValue()[0]}</span>
<span class="num">{indexValue()[1]}</span>
<span class="num">{indexValue()[2]}</span>
<span class="num">{indexValue()[3]}</span>
<span>/</span>
<span class="num">{indexLength()[0]}</span>
<span class="num">{indexLength()[1]}</span>
<span class="num">{indexLength()[2]}</span>
<span class="num">{indexLength()[3]}</span>
</div>
<div class="navClose" onClick={onClick} onKeyDown={onClick}>
{capitalizeFirstLetter(props.closeText)}
</div>
</div>
</>
)
}