Skip to content

Commit

Permalink
Add ButtonGroup and Toolbar component
Browse files Browse the repository at this point in the history
  • Loading branch information
Studio384 committed Jul 18, 2022
1 parent f73b8ec commit 0b9843c
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src/components/ButtonGroup/ButtonGroup.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { ElementType, ReactNode } from 'react';

import clsx from 'clsx';

export interface ButtonGroupProps {
/**
* The button size.
*/
size?: 'sm' | 'md' | 'lg';
/**
* Custom classes for the label
*/
className?: string;
/**
* Button contents.
*/
children: ReactNode;
}

/**
* Primary UI component for user interaction
*/
export function ButtonGroup({
size = 'md',
children,
className,
...props
}: ButtonGroupProps) {
return (
<div
className={clsx(
'btn-group',
{
[`btn-group-${size}`]: size !== 'md',
},
className
)}
role="group"
{...props}
>
{children}
</div>
);
};

export default ButtonGroup;
2 changes: 2 additions & 0 deletions src/components/ButtonGroup/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { default } from './ButtonGroup';
export type { ButtonGroupProps } from './ButtonGroup';
38 changes: 38 additions & 0 deletions src/components/Toolbar/Toolbar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { ReactNode } from 'react';

import clsx from 'clsx';

export interface ToolbarProps {
/**
* Custom classes for the label
*/
className?: string;
/**
* Button contents.
*/
children: ReactNode;
}

/**
* Primary UI component for user interaction
*/
export function Toolbar({
children,
className,
...props
}: ToolbarProps) {
return (
<div
className={clsx(
'btn-toolbar',
className
)}
role="toolbar"
{...props}
>
{children}
</div>
);
};

export default Toolbar;
2 changes: 2 additions & 0 deletions src/components/Toolbar/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { default } from './Toolbar';
export type { ToolbarProps } from './Toolbar';
6 changes: 6 additions & 0 deletions src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ export type { BottomBarItemProps } from '@components/BottomBarItem';
export { default as Button } from '@components/Button';
export type { ButtonProps } from '@components/Button';

export { default as ButtonGroup } from '@components/ButtonGroup';
export type { ButtonGroupProps } from '@components/ButtonGroup';

export { default as Card } from '@components/Card';
export type { CardProps } from '@components/Card';

Expand Down Expand Up @@ -161,3 +164,6 @@ export type { SelectItemProps } from '@components/SelectItem';

export { default as SelectLabel } from '@components/SelectLabel';
export type { SelectLabelProps } from '@components/SelectLabel';

export { default as Toolbar } from '@components/Toolbar';
export type { ToolbarProps } from '@components/Toolbar';
6 changes: 6 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ export type { BottomBarItemProps } from '@components/BottomBarItem';
export { default as Button } from '@components/Button';
export type { ButtonProps } from '@components/Button';

export { default as ButtonGroup } from '@components/ButtonGroup';
export type { ButtonGroupProps } from '@components/ButtonGroup';

export { default as Card } from '@components/Card';
export type { CardProps } from '@components/Card';

Expand Down Expand Up @@ -162,4 +165,7 @@ export type { SelectItemProps } from '@components/SelectItem';
export { default as SelectLabel } from '@components/SelectLabel';
export type { SelectLabelProps } from '@components/SelectLabel';

export { default as Toolbar } from '@components/Toolbar';
export type { ToolbarProps } from '@components/Toolbar';

export { default as useColor } from '@hooks/useColor';

0 comments on commit 0b9843c

Please sign in to comment.