(props)
| 278 | } |
| 279 | |
| 280 | export function SideNavLink(props) { |
| 281 | let linkRef = useRef<HTMLAnchorElement | null>(null); |
| 282 | let shouldAutoScrollOnMount = useRef(props.isSelected); |
| 283 | let selected = useContext(SideNavContext); |
| 284 | let {isExternal, ...linkProps} = props; |
| 285 | |
| 286 | useEffect(() => { |
| 287 | let link = linkRef.current; |
| 288 | if (!link || !props.isSelected || !shouldAutoScrollOnMount.current) { |
| 289 | return; |
| 290 | } |
| 291 | |
| 292 | shouldAutoScrollOnMount.current = false; |
| 293 | link.scrollIntoView({block: 'start'}); |
| 294 | }, [props.isSelected]); |
| 295 | |
| 296 | return ( |
| 297 | <BaseLink |
| 298 | {...linkProps} |
| 299 | ref={linkRef} |
| 300 | target={isExternal ? '_blank' : undefined} |
| 301 | rel={isExternal ? 'noopener noreferrer' : undefined} |
| 302 | aria-current={props.isSelected || selected === props.href ? 'page' : undefined} |
| 303 | style={pressScale(linkRef)} |
| 304 | className={style({ |
| 305 | ...focusRing(), |
| 306 | minHeight: 32, |
| 307 | boxSizing: 'border-box', |
| 308 | paddingX: 4, |
| 309 | // paddingY: centerPadding(), |
| 310 | display: 'flex', |
| 311 | alignItems: 'center', |
| 312 | gap: size(6), |
| 313 | font: 'ui', |
| 314 | fontWeight: { |
| 315 | default: 'normal', |
| 316 | isCurrent: 'bold' |
| 317 | }, |
| 318 | textDecoration: 'none', |
| 319 | borderRadius: 'default', |
| 320 | transition: 'default', |
| 321 | scrollMarginTop: 64 |
| 322 | })}> |
| 323 | {renderProps => ( |
| 324 | <> |
| 325 | <span |
| 326 | className={style({ |
| 327 | width: 2, |
| 328 | height: '[1lh]', |
| 329 | borderRadius: 'full', |
| 330 | transition: 'default', |
| 331 | backgroundColor: { |
| 332 | default: 'transparent', |
| 333 | isHovered: 'gray-400', |
| 334 | isCurrent: 'gray-800' |
| 335 | } |
| 336 | })(renderProps)} |
| 337 | /> |
nothing calls this directly
no test coverage detected