Skip to content

Commit 885064e

Browse files
authored
PageLayout: Add padding prop to subcomponents (#2201)
* Add a padding prop to PageLayout subcomponents * Create funny-roses-impress.md
1 parent 3756a1e commit 885064e

File tree

4 files changed

+236
-114
lines changed

4 files changed

+236
-114
lines changed

.changeset/funny-roses-impress.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@primer/react": minor
3+
---
4+
5+
Add `padding` prop to `PageLayout.Header`, `PageLayout.Content`, `PageLayout.Pane`, and `PageLayout.Footer`

docs/content/PageLayout.mdx

Lines changed: 57 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,25 @@ See [storybook](https://primer.style/react/storybook?path=/story/layout-pagelayo
5858
</PageLayout>
5959
```
6060

61+
### With connected dividers
62+
63+
```jsx live
64+
<PageLayout padding="none" rowGap="none" columnGap="none">
65+
<PageLayout.Header padding="normal" divider="line">
66+
<Placeholder label="Header" height={64} />
67+
</PageLayout.Header>
68+
<PageLayout.Content padding="normal">
69+
<Placeholder label="Content" height={240} />
70+
</PageLayout.Content>
71+
<PageLayout.Pane padding="normal" divider="line">
72+
<Placeholder label="Pane" height={120} />
73+
</PageLayout.Pane>
74+
<PageLayout.Footer padding="normal" divider="line">
75+
<Placeholder label="Footer" height={64} />
76+
</PageLayout.Footer>
77+
</PageLayout>
78+
```
79+
6180
### With pane on left
6281

6382
```jsx live
@@ -145,23 +164,23 @@ See [storybook](https://primer.style/react/storybook?path=/story/layout-pagelayo
145164
<PropsTableRow
146165
name="padding"
147166
type={`| 'none'
148-
| 'normal'
149-
| 'condensed'`}
167+
| 'condensed'
168+
| 'normal'`}
150169
defaultValue="'normal'"
151170
description="The spacing between the outer edges of the page container and the viewport"
152171
/>
153172
<PropsTableRow
154173
name="columnGap"
155174
type={`| 'none'
156-
| 'normal'
157-
| 'condensed'`}
175+
| 'condensed'
176+
| 'normal'`}
158177
defaultValue="'normal'"
159178
/>
160179
<PropsTableRow
161180
name="rowGap"
162181
type={`| 'none'
163-
| 'normal'
164-
| 'condensed'`}
182+
| 'condensed'
183+
| 'normal'`}
165184
defaultValue="'normal'"
166185
/>
167186
<PropsTableSxRow />
@@ -170,6 +189,14 @@ See [storybook](https://primer.style/react/storybook?path=/story/layout-pagelayo
170189
### PageLayout.Header
171190

172191
<PropsTable>
192+
<PropsTableRow
193+
name="padding"
194+
type={`| 'none'
195+
| 'condensed'
196+
| 'normal'`}
197+
defaultValue="'normal'"
198+
description="The amount of padding inside the header."
199+
/>
173200
<PropsTableRow
174201
name="divider"
175202
type={`| 'none'
@@ -224,6 +251,14 @@ See [storybook](https://primer.style/react/storybook?path=/story/layout-pagelayo
224251
defaultValue="'full'"
225252
description="The maximum width of the content region."
226253
/>
254+
<PropsTableRow
255+
name="padding"
256+
type={`| 'none'
257+
| 'condensed'
258+
| 'normal'`}
259+
defaultValue="'normal'"
260+
description="The amount of padding inside the content."
261+
/>
227262
<PropsTableRow
228263
name="hidden"
229264
type={`| boolean
@@ -275,6 +310,14 @@ See [storybook](https://primer.style/react/storybook?path=/story/layout-pagelayo
275310
defaultValue="'medium'"
276311
description="The width of the pane."
277312
/>
313+
<PropsTableRow
314+
name="padding"
315+
type={`| 'none'
316+
| 'condensed'
317+
| 'normal'`}
318+
defaultValue="'normal'"
319+
description="The amount of padding inside the pane."
320+
/>
278321
<PropsTableRow
279322
name="divider"
280323
type={`| 'none'
@@ -320,6 +363,14 @@ See [storybook](https://primer.style/react/storybook?path=/story/layout-pagelayo
320363
### PageLayout.Footer
321364

322365
<PropsTable>
366+
<PropsTableRow
367+
name="padding"
368+
type={`| 'none'
369+
| 'condensed'
370+
| 'normal'`}
371+
defaultValue="'normal'"
372+
description="The amount of padding inside the footer."
373+
/>
323374
<PropsTableRow
324375
name="divider"
325376
type={`| 'none'

src/PageLayout/PageLayout.tsx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ const VerticalDivider: React.FC<React.PropsWithChildren<DividerProps>> = ({varia
171171
// PageLayout.Header
172172

173173
export type PageLayoutHeaderProps = {
174+
padding?: keyof typeof SPACING_MAP
174175
divider?: 'none' | 'line' | ResponsiveValue<'none' | 'line', 'none' | 'line' | 'filled'>
175176
/**
176177
* @deprecated Use the `divider` prop with a responsive value instead.
@@ -191,6 +192,7 @@ export type PageLayoutHeaderProps = {
191192
} & SxProp
192193

193194
const Header: React.FC<React.PropsWithChildren<PageLayoutHeaderProps>> = ({
195+
padding = 'none',
194196
divider = 'none',
195197
dividerWhenNarrow = 'inherit',
196198
hidden = false,
@@ -219,7 +221,7 @@ const Header: React.FC<React.PropsWithChildren<PageLayoutHeaderProps>> = ({
219221
sx
220222
)}
221223
>
222-
{children}
224+
<Box sx={{padding: SPACING_MAP[padding]}}>{children}</Box>
223225
<HorizontalDivider variant={dividerVariant} sx={{marginTop: SPACING_MAP[rowGap]}} />
224226
</Box>
225227
)
@@ -232,6 +234,7 @@ Header.displayName = 'PageLayout.Header'
232234

233235
export type PageLayoutContentProps = {
234236
width?: keyof typeof contentWidths
237+
padding?: keyof typeof SPACING_MAP
235238
hidden?: boolean | ResponsiveValue<boolean>
236239
} & SxProp
237240

@@ -245,6 +248,7 @@ const contentWidths = {
245248

246249
const Content: React.FC<React.PropsWithChildren<PageLayoutContentProps>> = ({
247250
width = 'full',
251+
padding = 'none',
248252
hidden = false,
249253
children,
250254
sx = {}
@@ -268,7 +272,9 @@ const Content: React.FC<React.PropsWithChildren<PageLayoutContentProps>> = ({
268272
sx
269273
)}
270274
>
271-
<Box sx={{width: '100%', maxWidth: contentWidths[width], marginX: 'auto'}}>{children}</Box>
275+
<Box sx={{width: '100%', maxWidth: contentWidths[width], marginX: 'auto', padding: SPACING_MAP[padding]}}>
276+
{children}
277+
</Box>
272278
</Box>
273279
)
274280
}
@@ -296,6 +302,7 @@ export type PageLayoutPaneProps = {
296302
*/
297303
positionWhenNarrow?: 'inherit' | keyof typeof panePositions
298304
width?: keyof typeof paneWidths
305+
padding?: keyof typeof SPACING_MAP
299306
divider?: 'none' | 'line' | ResponsiveValue<'none' | 'line', 'none' | 'line' | 'filled'>
300307
/**
301308
* @deprecated Use the `divider` prop with a responsive value instead.
@@ -330,6 +337,7 @@ const Pane: React.FC<React.PropsWithChildren<PageLayoutPaneProps>> = ({
330337
position = 'end',
331338
positionWhenNarrow = 'inherit',
332339
width = 'medium',
340+
padding = 'none',
333341
divider = 'none',
334342
dividerWhenNarrow = 'inherit',
335343
hidden = false,
@@ -388,7 +396,7 @@ const Pane: React.FC<React.PropsWithChildren<PageLayoutPaneProps>> = ({
388396
sx={{[responsivePosition === 'end' ? 'marginRight' : 'marginLeft']: SPACING_MAP[columnGap]}}
389397
/>
390398

391-
<Box sx={{width: paneWidths[width]}}>{children}</Box>
399+
<Box sx={{width: paneWidths[width], padding: SPACING_MAP[padding]}}>{children}</Box>
392400
</Box>
393401
)
394402
}
@@ -399,6 +407,7 @@ Pane.displayName = 'PageLayout.Pane'
399407
// PageLayout.Footer
400408

401409
export type PageLayoutFooterProps = {
410+
padding?: keyof typeof SPACING_MAP
402411
divider?: 'none' | 'line' | ResponsiveValue<'none' | 'line', 'none' | 'line' | 'filled'>
403412
/**
404413
* @deprecated Use the `divider` prop with a responsive value instead.
@@ -419,6 +428,7 @@ export type PageLayoutFooterProps = {
419428
} & SxProp
420429

421430
const Footer: React.FC<React.PropsWithChildren<PageLayoutFooterProps>> = ({
431+
padding = 'none',
422432
divider = 'none',
423433
dividerWhenNarrow = 'inherit',
424434
hidden = false,
@@ -448,7 +458,7 @@ const Footer: React.FC<React.PropsWithChildren<PageLayoutFooterProps>> = ({
448458
)}
449459
>
450460
<HorizontalDivider variant={dividerVariant} sx={{marginBottom: SPACING_MAP[rowGap]}} />
451-
{children}
461+
<Box sx={{padding: SPACING_MAP[padding]}}>{children}</Box>
452462
</Box>
453463
)
454464
}

0 commit comments

Comments
 (0)