β¬ οΈ Back to Table of Contents
π ast/PropertyName¶
π Analysis Summary¶
| Metric | Count |
|---|---|
| π§ Functions | 1 |
| π¦ Imports | 5 |
| π JSX Elements | 1 |
| π Interfaces | 1 |
π Table of Contents¶
π οΈ File Location:¶
π packages/website/src/components/ast/PropertyName.tsx
π¦ Imports¶
| Name | Source |
|---|---|
KeyboardEvent |
react |
MouseEvent |
react |
Link |
@docusaurus/Link |
useCallback |
react |
React |
react |
JSX Elements¶
| Component | Type | Props | Children |
|---|---|---|---|
Link |
component | className={className}, href={#${value}}, onClick={onClick}, onKeyDown={onKe... |
{value} |
Functions¶
PropertyName({ className, onClick: onClickPrβ¦: PropertyNameProps): React.JSX.Element¶
Parameters:
{ className, onClick: onClickProp, onHover: onHoverProp, value, }PropertyNameProps
Returns: React.JSX.Element
Calls:
useCallback (from react)e.preventDefaultonClickProponHoverProp
Code
export default function PropertyName({
className,
onClick: onClickProp,
onHover: onHoverProp,
value,
}: PropertyNameProps): React.JSX.Element {
const onClick = useCallback(
(e: MouseEvent<HTMLElement>) => {
e.preventDefault();
onClickProp?.();
},
[onClickProp],
);
const onMouseEnter = useCallback(() => {
onHoverProp?.(true);
}, [onHoverProp]);
const onMouseLeave = useCallback(() => {
onHoverProp?.(false);
}, [onHoverProp]);
const onKeyDown = useCallback(
(e: KeyboardEvent<HTMLElement>) => {
if (e.code === 'Space') {
e.preventDefault();
onClickProp?.();
}
},
[onClickProp],
);
return (
<Link
className={className}
href={`#${value}`}
onClick={onClick}
onKeyDown={onKeyDown}
onMouseEnter={onMouseEnter}
onMouseLeave={onMouseLeave}
role="button"
tabIndex={onClickProp && 0}
>
{value}
</Link>
);
}
Interfaces¶
PropertyNameProps¶
Interface Code
Properties¶
| Name | Type | Optional | Description |
|---|---|---|---|
className |
string |
β | not shown |
onClick |
() => void |
β | not shown |
onHover |
(e: boolean) => void |
β | not shown |
value |
string |
β | not shown |
Generated by Syntax Scribe