blob: 41e90fc4ec4688871d9c1208de96b508e2f0078f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
import {
forwardRef,
type LiHTMLAttributes,
type ForwardRefRenderFunction,
} from 'react';
import styles from './list.module.scss';
export type ListItemProps = LiHTMLAttributes<HTMLElement> & {
/**
* Should we hide the marker in front of the list item?
*
* @default false
*/
hideMarker?: boolean;
};
const ListItemWithRef: ForwardRefRenderFunction<
HTMLLIElement,
ListItemProps
> = ({ children, className = '', hideMarker = false, ...props }, ref) => {
const itemClass = [
styles.item,
styles[hideMarker ? 'item--no-marker' : ''],
className,
].join(' ');
return (
<li {...props} className={itemClass} ref={ref}>
{children}
</li>
);
};
/**
* ListItem component
*
* Used it inside a `<List />` component.
*/
export const ListItem = forwardRef(ListItemWithRef);
|