(props)
| 257 | } |
| 258 | |
| 259 | export function SideNavLink(props) { |
| 260 | let linkRef = useRef<HTMLAnchorElement | null>(null); |
| 261 | let shouldAutoScrollOnMount = useRef(props.isSelected); |
| 262 | let selected = useContext(SideNavContext); |
| 263 | let {isExternal, ...linkProps} = props; |
| 264 | |
| 265 | useEffect(() => { |
| 266 | let link = linkRef.current; |
| 267 | if (!link || !props.isSelected || !shouldAutoScrollOnMount.current) { |
| 268 | return; |
| 269 | } |
| 270 | |
| 271 | shouldAutoScrollOnMount.current = false; |
| 272 | link.scrollIntoView({block: 'start'}); |
| 273 | }, [props.isSelected]); |
| 274 | |
| 275 | // oxlint-disable react/react-compiler |
| 276 | return ( |
| 277 | <BaseLink |
| 278 | {...linkProps} |
| 279 | ref={linkRef} |
| 280 | target={isExternal ? '_blank' : undefined} |
| 281 | rel={isExternal ? 'noopener noreferrer' : undefined} |
| 282 | aria-current={props.isSelected || selected === props.href ? 'page' : undefined} |
| 283 | style={pressScale(linkRef)} |
| 284 | className={style({ |
| 285 | ...focusRing(), |
| 286 | minHeight: 32, |
| 287 | boxSizing: 'border-box', |
| 288 | paddingX: 4, |
| 289 | // paddingY: centerPadding(), |
| 290 | display: 'flex', |
| 291 | alignItems: 'center', |
| 292 | gap: size(6), |
| 293 | font: 'ui', |
| 294 | fontWeight: { |
| 295 | default: 'normal', |
| 296 | isCurrent: 'bold' |
| 297 | }, |
| 298 | textDecoration: 'none', |
| 299 | borderRadius: 'default', |
| 300 | transition: 'default', |
| 301 | scrollMarginTop: 64 |
| 302 | })}> |
| 303 | {renderProps => ( |
| 304 | <> |
| 305 | <span |
| 306 | className={style({ |
| 307 | width: 2, |
| 308 | height: '[1lh]', |
| 309 | borderRadius: 'full', |
| 310 | transition: 'default', |
| 311 | backgroundColor: { |
| 312 | default: 'transparent', |
| 313 | isHovered: 'gray-400', |
| 314 | isCurrent: 'gray-800' |
| 315 | } |
| 316 | })(renderProps)} |
nothing calls this directly
no test coverage detected