2021-11-16 05:33:01 -07:00
|
|
|
import { PropsWithChildren } from 'react';
|
|
|
|
import clsx from 'clsx';
|
|
|
|
|
2021-11-21 11:39:26 +02:00
|
|
|
export type Size = 'xsmall' | 'small' | 'large';
|
2021-11-16 05:33:01 -07:00
|
|
|
export interface Props {
|
|
|
|
size?: Size;
|
2021-11-21 11:39:26 +02:00
|
|
|
className?: string;
|
2021-11-16 05:33:01 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
export function ButtonGroup({
|
|
|
|
size = 'small',
|
|
|
|
children,
|
2021-11-21 11:39:26 +02:00
|
|
|
className,
|
2021-11-16 05:33:01 -07:00
|
|
|
}: PropsWithChildren<Props>) {
|
|
|
|
return (
|
2021-11-21 11:39:26 +02:00
|
|
|
<div className={clsx('btn-group', sizeClass(size), className)} role="group">
|
2021-11-16 05:33:01 -07:00
|
|
|
{children}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function sizeClass(size: Size | undefined) {
|
|
|
|
switch (size) {
|
2023-02-23 01:43:33 +05:30
|
|
|
case 'small':
|
|
|
|
return 'btn-group-sm';
|
2021-11-16 05:33:01 -07:00
|
|
|
case 'xsmall':
|
|
|
|
return 'btn-group-xs';
|
|
|
|
case 'large':
|
|
|
|
return 'btn-group-lg';
|
|
|
|
default:
|
2022-01-04 14:16:09 +02:00
|
|
|
return '';
|
2021-11-16 05:33:01 -07:00
|
|
|
}
|
|
|
|
}
|