Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

README.md

andculturecode-javascript-react-components

andculturecode-javascript-react-components

Index

Interfaces

Variables

Functions

Variables

Const Anchor

Anchor: RefForwardingComponent‹Link, AnchorProps = forwardRef( (props: AnchorProps, ref: React.Ref) => { let cssClassNames = [];

    if (props.cssClassName) {
        cssClassNames.push(props.cssClassName);
    }

    const onClickHandler = (e: React.MouseEvent<HTMLElement>) => {
        if (props.onClick != null) {
            props.onClick(e);
        }
    };

    let relAttribute: string | undefined = undefined;
    if (props.target != null) {
        // Using target="_blank" without rel="noopener noreferrer" is a security risk: see
        // https://mathiasbynens.github.io/rel-noopener  react/jsx-no-target-blank
        relAttribute = "noopener noreferrer";
    }

    const commonProps = {
        "aria-label": props.ariaLabel,
        className: cssClassNames.join(" "),
        id: props.id,
        onClick: onClickHandler,
        ref: ref,
        target: props.target,
        rel: relAttribute,
        title: props.title,
        onKeyDown: props.onKeyDown,
    };

    if (props.external === true) {
        return (
            <a href={props.to} {...commonProps}>
                {props.children}
            </a>
        );
    }

    return (
        <Link to={props.to} {...commonProps}>
            {props.children}
        </Link>
    );
}

)

Defined in atoms/anchors/anchor.tsx:30


Const FactoryType

FactoryType: object

Defined in tests/factories/factory-type.ts:1

Type declaration:

Functions

Const anchorDefault

anchorDefault(): Element‹›

Defined in atoms/anchors/anchor.stories.tsx:14

Returns: Element‹›