export const ToggleStarred: Component<ChatProps> = (props) => {
const session = () => (props.chat.state.sessionID ? props.chat.session() : null)
const isStarred = () => session()?.state.starred ?? false
return (
<Show when={session()}>
{(s) => (
<button
onClick={() => s().setStarred(!isStarred())}
aria-pressed={isStarred()}
aria-label={isStarred() ? 'Remove Star' : 'Add Star'}
>
<StarIcon
fill={isStarred() ? 'currentColor' : 'none'}
classList={{
'text-amber-400': isStarred(),
'text-neutral-400': !isStarred(),
}}
/>
</button>
)}
</Show>
)
}
export const ToggleStarred: Component<ChatProps> = (props) => {
const session = () => (props.chat.state.sessionID ? props.chat.session() : null)
const isStarred = () => session()?.state.starred ?? false
return (
<Show when={session()}>
{(s) => (
<button
onClick={() => s().setStarred(!isStarred())}
aria-pressed={isStarred()}
aria-label={isStarred() ? 'Remove Star' : 'Add Star'}
>
<StarIcon
fill={isStarred() ? 'currentColor' : 'none'}
classList={{
'text-amber-400': isStarred(),
'text-neutral-400': !isStarred(),
}}
/>
</button>
)}
</Show>
)
}