Skip to content

Commit

Permalink
feat(buttons): allow only icons buttons, fix margins
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrobonamin committed Sep 28, 2023
1 parent 9f4abe1 commit 09ffc6f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
11 changes: 2 additions & 9 deletions src/primitives/button/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ export interface ButtonProps extends ResponsivePaddingProps, ResponsiveRadiusPro
selected?: boolean
space?: number | number[]
textAlign?: ButtonTextAlign
/**
* @default primary
*/
textStyle?: ButtonTextStyle
text?: React.ReactNode
tone?: ButtonTone
Expand Down Expand Up @@ -140,7 +137,7 @@ export const Button = forwardRef(function Button(

{(icon || text || iconRight) && (
<Box as="span" {...boxProps}>
<Flex as="span" justify={justify}>
<Flex as="span" justify={justify} gap={space}>
{icon && (
<Text size={fontSize} muted={textStyle === 'secondary'}>
{isValidElement(icon) && icon}
Expand All @@ -149,11 +146,7 @@ export const Button = forwardRef(function Button(
)}

{text && (
<Box
flex={iconRight ? 1 : undefined}
marginLeft={icon ? space : undefined}
marginRight={iconRight ? space : undefined}
>
<Box flex={iconRight ? 1 : undefined}>
<Text
muted={textStyle === 'secondary'}
align={textAlign}
Expand Down
3 changes: 3 additions & 0 deletions src/types/button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@ export type ButtonTextAlign = 'left' | 'right' | 'center'
*/
export type ButtonTone = 'default' | 'primary' | 'positive' | 'caution' | 'critical'

/**
* @public
*/
export type ButtonTextStyle = 'primary' | 'secondary'
15 changes: 9 additions & 6 deletions stories/primitives/Button.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,18 @@ const modesConversion: {
const rows: Array<(typeof buttonTones)[number]> = ['default', 'positive', 'caution', 'critical']
export const StudioButtons: Story = {
args: {
text: 'Button',
// Defaults button props.
padding: 3,
space: 3,
fontSize: 1,
radius: 2,
icon: 'square',
iconRight: 'square',
// For small buttons:
// Small buttons:
// space: 2,
// padding: 2,

text: 'Button',
icon: 'square',
iconRight: 'square',
},
parameters: {
controls: {
Expand All @@ -194,7 +197,7 @@ export const StudioButtons: Story = {
title: 'Tone / Mode',
subHeader: <SubHeader />,
renderItem: ({row, column}) => (
<Flex gap={1} justify={'center'} align={'center'}>
<Flex gap={1} justify={'center'} align={'center'} wrap={'wrap'}>
<Button
{...props}
tone={row}
Expand Down Expand Up @@ -232,7 +235,7 @@ export const StudioButtons: Story = {
subHeader: <SubHeader />,

renderItem: ({row, column}) => (
<Flex gap={1} justify={'center'} align={'center'}>
<Flex gap={1} justify={'center'} align={'center'} wrap={'wrap'}>
<Button
{...props}
tone={row}
Expand Down

0 comments on commit 09ffc6f

Please sign in to comment.