forked from twentyhq/twenty
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
In storybook, I see a ButtonIconGroup component (twentyhq#1039)
Add ButtonIconGroup storybook components Co-authored-by: v1b3m <[email protected]> Co-authored-by: RubensRafael <[email protected]>
- Loading branch information
1 parent
4e8429a
commit a123779
Showing
2 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
front/src/modules/ui/button/components/IconButtonGroup.tsx
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,35 @@ | ||
import React from 'react'; | ||
import styled from '@emotion/styled'; | ||
|
||
import { IconButtonSize, IconButtonVariant } from './IconButton'; | ||
const StyledIconButtonGroupContainer = styled.div` | ||
align-items: flex-start; | ||
background: ${({ theme }) => theme.background.transparent.primary}; | ||
border-radius: ${({ theme }) => theme.spacing(1)}; | ||
display: flex; | ||
gap: ${({ theme }) => theme.spacing(0.5)}; | ||
padding: ${({ theme }) => theme.spacing(0.5)}; | ||
`; | ||
|
||
type IconButtonGroupProps = { | ||
variant: IconButtonVariant; | ||
size: IconButtonSize; | ||
children: React.ReactElement[]; | ||
}; | ||
|
||
export function IconButtonGroup({ | ||
children, | ||
variant, | ||
size, | ||
}: IconButtonGroupProps) { | ||
return ( | ||
<StyledIconButtonGroupContainer> | ||
{React.Children.map(children, (child) => | ||
React.cloneElement(child, { | ||
...(variant ? { variant } : {}), | ||
...(size ? { size } : {}), | ||
}), | ||
)} | ||
</StyledIconButtonGroupContainer> | ||
); | ||
} |
57 changes: 57 additions & 0 deletions
57
front/src/modules/ui/button/components/__stories__/IconButtonGroup.stories.tsx
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,57 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import { IconBell } from '@tabler/icons-react'; | ||
|
||
import { CatalogDecorator } from '~/testing/decorators/CatalogDecorator'; | ||
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator'; | ||
|
||
import { IconButton } from '../IconButton'; | ||
import { IconButtonGroup } from '../IconButtonGroup'; | ||
|
||
const meta: Meta<typeof IconButtonGroup> = { | ||
title: 'UI/Button/IconButtonGroup', | ||
component: IconButtonGroup, | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof IconButtonGroup>; | ||
|
||
const args = { | ||
children: [ | ||
<IconButton icon={<IconBell />} />, | ||
<IconButton icon={<IconBell />} />, | ||
], | ||
}; | ||
|
||
export const Default: Story = { | ||
args, | ||
decorators: [ComponentDecorator], | ||
}; | ||
|
||
export const Catalog: Story = { | ||
args, | ||
argTypes: { | ||
size: { control: false }, | ||
variant: { control: false }, | ||
}, | ||
parameters: { | ||
catalog: { | ||
dimensions: [ | ||
{ | ||
name: 'variants', | ||
values: ['transparent', 'border', 'shadow', 'white'], | ||
props: (variant: string) => ({ | ||
variant, | ||
}), | ||
}, | ||
{ | ||
name: 'sizes', | ||
values: ['large', 'medium', 'small'], | ||
props: (size: string) => ({ | ||
size, | ||
}), | ||
}, | ||
], | ||
}, | ||
}, | ||
decorators: [CatalogDecorator], | ||
}; |