diff --git a/src/Root.tsx b/src/Root.tsx index 50ef524a7..17bd50d63 100644 --- a/src/Root.tsx +++ b/src/Root.tsx @@ -4,6 +4,7 @@ import { HiBadgeCheck, HiBell, HiChevronDoubleRight, + HiClipboardList, HiCollection, HiCreditCard, HiDuplicate, @@ -24,6 +25,7 @@ const BreadcrumbPage = lazy(() => import('./pages/BreadcrumbPage')); const ButtonsPage = lazy(() => import('./pages/ButtonsPage')); const CardPage = lazy(() => import('./pages/CardPage')); const CarouselPage = lazy(() => import('./pages/CarouselPage')); +const ListGroupPage = lazy(() => import('./pages/ListGroupPage')); const SpinnersPage = lazy(() => import('./pages/SpinnersPage')); const TooltipsPage = lazy(() => import('./pages/TooltipsPage')); @@ -79,6 +81,12 @@ export const Root: FC = () => { title: 'Carousel', href: '/carousel', }, + { + group: false, + icon: HiClipboardList, + title: 'List group', + href: '/list-group', + }, { group: false, icon: FaSpinner, @@ -135,6 +143,7 @@ export const Root: FC = () => { } /> } /> } /> + } /> } /> } /> diff --git a/src/components/ListGroup.tsx b/src/components/ListGroup.tsx new file mode 100644 index 000000000..da7a6bd84 --- /dev/null +++ b/src/components/ListGroup.tsx @@ -0,0 +1,55 @@ +import { ComponentProps, FC, Fragment, ReactNode } from 'react'; +import classNames from 'classnames'; + +export type ListGroupProps = { + items: ListGroupItem[]; +}; +export type ListGroupItem = { + title: ReactNode; + link?: string; + icon?: FC>; + active?: boolean; + onClick?: () => void; + disabled?: boolean; +}; + +export const ListGroup: FC = ({ items }) => { + return ( +
+ {items.map((item, index) => ( + + {!item.link ? ( + + ) : ( + + {item.title} + + )} + + ))} +
+ ); +}; diff --git a/src/pages/ListGroupPage.tsx b/src/pages/ListGroupPage.tsx new file mode 100644 index 000000000..962412f13 --- /dev/null +++ b/src/pages/ListGroupPage.tsx @@ -0,0 +1,87 @@ +import { FC } from 'react'; +import { ListGroup, ListGroupItem } from '../components/ListGroup'; +import { CodeExample, DemoPage } from './DemoPage'; +import { HiCloudDownload, HiInbox, HiOutlineAdjustments, HiUserCircle } from 'react-icons/hi'; + +const ListGroupPage: FC = () => { + const defaultItems: ListGroupItem[] = [ + { + title: 'Profile', + }, + { + title: 'Settings', + }, + { + title: 'Messages', + }, + { + title: 'Download', + }, + ]; + + const itemsWithLinks: ListGroupItem[] = [ + { + title: 'Profile', + link: '#/list-group', + active: true, + }, + { + title: 'Settings', + link: '#/list-group', + }, + { + title: 'Messages', + link: '#/list-group', + }, + { + title: 'Download', + link: '#/list-group', + }, + ]; + + const itemsWithIcons: ListGroupItem[] = [ + { + title: 'Profile', + icon: HiUserCircle, + onClick: () => alert('profile'), + }, + { + title: 'Settings', + icon: HiOutlineAdjustments, + }, + { + title: 'Messages', + icon: HiInbox, + }, + { + title: 'Download', + icon: HiCloudDownload, + }, + ]; + + const examples: CodeExample[] = [ + { + title: 'Default list', + code: , + }, + { + title: 'List group with links', + code: , + }, + { + title: 'List group with buttons', + code: , + }, + { + title: 'List group with icons', + code: , + codeStringifierOptions: { + functionValue: (fn) => (fn.name === 'onClick' ? fn : fn.name), + }, + }, + ]; + + return ; +}; + +export default ListGroupPage;