Skip to content

Commit cfb8cf7

Browse files
committed
refactor: rename flush to withPadding boolean prop on Box
Rename the padding toggle from flush to withPadding (defaults to true) for clearer intent in the partner-facing adapter API. Made-with: Cursor
1 parent 28112af commit cfb8cf7

File tree

6 files changed

+19
-16
lines changed

6 files changed

+19
-16
lines changed

.storybook/adapters/PlainComponentAdapter.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,10 @@ export const PlainComponentAdapter: ComponentsContextType = {
136136
)
137137
},
138138

139-
Box: ({ children, header, footer, flush, className }: BoxProps) => (
139+
Box: ({ children, header, footer, withPadding = true, className }: BoxProps) => (
140140
<div className={`box ${className || ''}`}>
141141
{header && <div className="box-header">{header}</div>}
142-
<div className="box-body" style={flush ? { padding: 0 } : undefined}>
142+
<div className="box-body" style={withPadding ? undefined : { padding: 0 }}>
143143
{children}
144144
</div>
145145
{footer && <div className="box-footer">{footer}</div>}

docs/component-adapter/component-inventory.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,13 @@
9898

9999
## BoxProps
100100

101-
| Prop | Type | Required | Description |
102-
| ------------- | ----------------- | -------- | ----------- |
103-
| **children** | `React.ReactNode` | Yes | - |
104-
| **header** | `React.ReactNode` | No | - |
105-
| **footer** | `React.ReactNode` | No | - |
106-
| **flush** | `boolean` | No | - |
107-
| **className** | `string` | No | - |
101+
| Prop | Type | Required | Description |
102+
| --------------- | ----------------- | -------- | ----------- |
103+
| **children** | `React.ReactNode` | Yes | - |
104+
| **header** | `React.ReactNode` | No | - |
105+
| **footer** | `React.ReactNode` | No | - |
106+
| **withPadding** | `boolean` | No | - |
107+
| **className** | `string` | No | - |
108108

109109
## BoxSectionProps
110110

src/components/Common/UI/Box/Box.stories.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export const FlushContent: Story = {
104104
render: () => {
105105
const Components = useComponentContext()
106106
return (
107-
<Components.Box flush>
107+
<Components.Box withPadding={false}>
108108
<Components.Text>This content has no padding (flush variant).</Components.Text>
109109
</Components.Box>
110110
)
@@ -115,7 +115,10 @@ export const WithEmbeddedTable: Story = {
115115
render: () => {
116116
const Components = useComponentContext()
117117
return (
118-
<Components.Box header={<Components.Heading as="h3">Team Members</Components.Heading>} flush>
118+
<Components.Box
119+
header={<Components.Heading as="h3">Team Members</Components.Heading>}
120+
withPadding={false}
121+
>
119122
<Components.Table
120123
aria-label="Team members"
121124
variant="embedded"

src/components/Common/UI/Box/Box.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ describe('Box Component', () => {
3636
})
3737

3838
test('renders flush content variant', () => {
39-
renderWithProviders(<Box flush>Flush Content</Box>)
39+
renderWithProviders(<Box withPadding={false}>Flush Content</Box>)
4040

4141
expect(screen.getByText('Flush Content')).toBeInTheDocument()
4242
})
@@ -46,7 +46,7 @@ describe('Box Component', () => {
4646
const defaultWrapper = screen.getByText('Default Content').closest('div')!
4747
const defaultClassName = defaultWrapper.className
4848

49-
rerender(<Box flush>Flush Content</Box>)
49+
rerender(<Box withPadding={false}>Flush Content</Box>)
5050
const flushWrapper = screen.getByText('Flush Content').closest('div')!
5151
expect(defaultClassName).not.toBe(flushWrapper.className)
5252
})

src/components/Common/UI/Box/Box.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ import cn from 'classnames'
22
import styles from './Box.module.scss'
33
import type { BoxProps } from '@/components/Common/UI/Box/BoxTypes'
44

5-
export function Box({ children, header, footer, flush, className }: BoxProps) {
5+
export function Box({ children, header, footer, withPadding = true, className }: BoxProps) {
66
return (
77
<div className={cn(styles.root, className)} data-testid="data-box">
88
{header && <div className={styles.header}>{header}</div>}
9-
<div className={flush ? styles.contentFlush : styles.content}>{children}</div>
9+
<div className={withPadding ? styles.content : styles.contentFlush}>{children}</div>
1010
{footer && <div className={styles.footer}>{footer}</div>}
1111
</div>
1212
)

src/components/Common/UI/Box/BoxTypes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export interface BoxProps {
44
children: ReactNode
55
header?: ReactNode
66
footer?: ReactNode
7-
flush?: boolean
7+
withPadding?: boolean
88
className?: string
99
}
1010

0 commit comments

Comments
 (0)