chore: Add docs and onClick to List/Item component
This commit is contained in:
@@ -6,13 +6,23 @@ import Flex from "~/components/Flex";
|
|||||||
import NavLink from "~/components/NavLink";
|
import NavLink from "~/components/NavLink";
|
||||||
|
|
||||||
export type Props = Omit<React.HTMLAttributes<HTMLAnchorElement>, "title"> & {
|
export type Props = Omit<React.HTMLAttributes<HTMLAnchorElement>, "title"> & {
|
||||||
|
/** An icon or image to display to the left of the list item */
|
||||||
image?: React.ReactNode;
|
image?: React.ReactNode;
|
||||||
|
/** An internal location to navigate to on click, if provided the list item will have hover styles */
|
||||||
to?: LocationDescriptor;
|
to?: LocationDescriptor;
|
||||||
|
/** An optional click handler, if provided the list item will have hover styles */
|
||||||
|
onClick?: React.MouseEventHandler<HTMLAnchorElement>;
|
||||||
|
/** Whether to match the location exactly */
|
||||||
exact?: boolean;
|
exact?: boolean;
|
||||||
|
/** The title of the list item */
|
||||||
title: React.ReactNode;
|
title: React.ReactNode;
|
||||||
|
/** The subtitle of the list item, displayed below the title */
|
||||||
subtitle?: React.ReactNode;
|
subtitle?: React.ReactNode;
|
||||||
|
/** Actions to display to the right of the list item */
|
||||||
actions?: React.ReactNode;
|
actions?: React.ReactNode;
|
||||||
|
/** Whether to display a border below the list item */
|
||||||
border?: boolean;
|
border?: boolean;
|
||||||
|
/** Whether to display the list item in a compact style */
|
||||||
small?: boolean;
|
small?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -74,6 +84,7 @@ const ListItem = (
|
|||||||
const Wrapper = styled.a<{
|
const Wrapper = styled.a<{
|
||||||
$small?: boolean;
|
$small?: boolean;
|
||||||
$border?: boolean;
|
$border?: boolean;
|
||||||
|
onClick?: React.MouseEventHandler<HTMLAnchorElement>;
|
||||||
to?: LocationDescriptor;
|
to?: LocationDescriptor;
|
||||||
}>`
|
}>`
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -89,7 +100,13 @@ const Wrapper = styled.a<{
|
|||||||
border-bottom: 0;
|
border-bottom: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
cursor: ${({ to }) => (to ? "var(--pointer)" : "default")};
|
&:hover {
|
||||||
|
background: ${(props) =>
|
||||||
|
props.onClick ? props.theme.secondaryBackground : "inherit"};
|
||||||
|
}
|
||||||
|
|
||||||
|
cursor: ${(props) =>
|
||||||
|
props.to || props.onClick ? "var(--pointer)" : "default"};
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const Image = styled(Flex)`
|
const Image = styled(Flex)`
|
||||||
|
|||||||
Reference in New Issue
Block a user