package.src.components.JumpLinks.JumpLinksItem.tsx Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of react-core Show documentation
Show all versions of react-core Show documentation
This library provides a set of common React components for use with the PatternFly reference implementation.
The newest version!
import * as React from 'react';
import { css } from '@patternfly/react-styles';
import styles from '@patternfly/react-styles/css/components/JumpLinks/jump-links';
import { JumpLinksList } from './JumpLinksList';
export interface JumpLinksItemProps extends Omit, 'onClick'> {
/** Whether this item is active. Parent JumpLinks component sets this when passed a `scrollableSelector`. */
isActive?: boolean;
/** Href for this link */
href?: string;
/** Selector or HTMLElement to spy on */
node?: string | HTMLElement;
/** Text to be rendered inside span */
children?: React.ReactNode;
/** Click handler for anchor tag. Parent JumpLinks components tap into this. */
onClick?: (ev: React.MouseEvent) => void;
/** Class to add to li */
className?: string;
}
export const JumpLinksItem: React.FunctionComponent = ({
isActive,
href,
// eslint-disable-next-line
node,
children,
onClick,
className,
...props
}: JumpLinksItemProps) => {
const childrenArr = React.Children.toArray(children) as any[];
const sublists = childrenArr.filter((child) => child.type === JumpLinksList);
children = childrenArr.filter((child) => child.type !== JumpLinksList);
return (
{children}
{sublists}
);
};
JumpLinksItem.displayName = 'JumpLinksItem';