mirror of
https://github.com/vitest-dev/vitest.git
synced 2025-12-08 18:26:03 +00:00
33 lines
602 B
TypeScript
33 lines
602 B
TypeScript
import React, { useState } from 'react'
|
|
|
|
const STATUS = {
|
|
HOVERED: 'hovered',
|
|
NORMAL: 'normal',
|
|
}
|
|
|
|
function Link({ page, children }: React.PropsWithChildren<{ page: string }>) {
|
|
const [status, setStatus] = useState(STATUS.NORMAL)
|
|
|
|
const onMouseEnter = () => {
|
|
setStatus(STATUS.HOVERED)
|
|
}
|
|
|
|
const onMouseLeave = () => {
|
|
setStatus(STATUS.NORMAL)
|
|
}
|
|
|
|
return (
|
|
<a
|
|
className={status}
|
|
href={page || '#'}
|
|
aria-label={`Link is ${status}`}
|
|
onMouseEnter={onMouseEnter}
|
|
onMouseLeave={onMouseLeave}
|
|
>
|
|
{children}
|
|
</a>
|
|
)
|
|
}
|
|
|
|
export default Link
|