-
-
Notifications
You must be signed in to change notification settings - Fork 437
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
109 additions
and
119 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { FC } from 'react'; | ||
import classNames from 'classnames'; | ||
|
||
import { ListGroupItem } from './ListGroupItem'; | ||
|
||
export type ListGroupProps = { | ||
className?: string; | ||
}; | ||
|
||
const ListGroupComponent: FC<ListGroupProps> = ({ children, className }) => ( | ||
<div | ||
className={classNames( | ||
'list-none rounded-lg border border-gray-200 bg-white text-sm font-medium text-gray-900 dark:border-gray-600 dark:bg-gray-700 dark:text-white', | ||
className, | ||
)} | ||
> | ||
{children} | ||
</div> | ||
); | ||
|
||
ListGroupItem.displayName = 'ListGroup.Item'; | ||
|
||
export const ListGroup = Object.assign(ListGroupComponent, { Item: ListGroupItem }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { ComponentProps, FC, PropsWithChildren } from 'react'; | ||
import classNames from 'classnames'; | ||
|
||
export type ListGroupItemProps = { | ||
className?: string; | ||
href?: string; | ||
icon?: FC<ComponentProps<'svg'>>; | ||
active?: boolean; | ||
onClick?: () => void; | ||
disabled?: boolean; | ||
}; | ||
|
||
export const ListGroupItem: FC<ListGroupItemProps> = ({ children, className, href, onClick, active, icon: Icon }) => { | ||
const Wrapper = ({ children, className }: PropsWithChildren<{ className?: string }>) => | ||
!href ? ( | ||
<button className={classNames('text-left', className)} onClick={onClick} type="button"> | ||
{children} | ||
</button> | ||
) : ( | ||
<a className={className} href={href}> | ||
{children} | ||
</a> | ||
); | ||
|
||
return ( | ||
<Wrapper | ||
className={classNames( | ||
'flex w-full cursor-pointer border-b border-gray-200 py-2 px-4 first:rounded-t-lg last:rounded-b-lg last:border-b-0 dark:border-gray-600', | ||
{ | ||
'bg-blue-700 text-white dark:bg-gray-800': active, | ||
'hover:bg-gray-100 hover:text-blue-700 focus:text-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-700 dark:border-gray-600 dark:hover:bg-gray-600 dark:hover:bg-gray-600 dark:hover:text-white dark:hover:text-white dark:focus:text-white dark:focus:ring-gray-500': | ||
!active, | ||
}, | ||
className, | ||
)} | ||
> | ||
{Icon && <Icon className="mr-2 h-4 w-4 fill-current" />} | ||
{children} | ||
</Wrapper> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters