Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/sidebar-padding.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/react": patch
---

Fix PageLayout.Sidebar ignoring its padding prop
2 changes: 2 additions & 0 deletions packages/react/src/PageLayout/PageLayout.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,8 @@
.Sidebar {
width: var(--pane-width-size);
height: 100%;
/* stylelint-disable-next-line primer/spacing */
padding: var(--spacing);
overflow: auto;

&:where([data-resizable]) {
Expand Down
14 changes: 14 additions & 0 deletions packages/react/src/PageLayout/PageLayout.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,20 @@ describe('PageLayout', async () => {
})

describe('PageLayout.Sidebar', () => {
it.each([
{padding: 'condensed', expectedPadding: '16px'},
{padding: 'normal', expectedPadding: '24px'},
] as const)('applies $padding padding when the layout has no padding', ({padding, expectedPadding}) => {
render(
<PageLayout padding="none">
<PageLayout.Sidebar padding={padding}>Sidebar</PageLayout.Sidebar>
<PageLayout.Content>Content</PageLayout.Content>
</PageLayout>,
)

expect(getComputedStyle(page.getByText('Sidebar').element()).padding).toBe(expectedPadding)
})

it('SidebarWrapper should prevent shrinking', () => {
const {container} = render(
<PageLayout>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const SettingsPage: StoryFn<typeof SplitPageLayout> = () => (

export const WithSidebarStart: StoryFn<typeof SplitPageLayout> = () => (
<SplitPageLayout>
<SplitPageLayout.Sidebar position="start" aria-label="Inspector sidebar" style={{height: 'auto'}}>
<SplitPageLayout.Sidebar padding="none" position="start" aria-label="Inspector sidebar" style={{height: 'auto'}}>
<div className={classes.SidebarContent}>
<p className={classes.SidebarHeading}>Sidebar</p>
<p className={classes.SidebarText}>
Expand Down Expand Up @@ -86,7 +86,7 @@ export const WithSidebarStart: StoryFn<typeof SplitPageLayout> = () => (

export const WithSidebarEnd: StoryFn<typeof SplitPageLayout> = () => (
<SplitPageLayout>
<SplitPageLayout.Sidebar position="end" aria-label="Inspector sidebar" style={{height: 'auto'}}>
<SplitPageLayout.Sidebar padding="none" position="end" aria-label="Inspector sidebar" style={{height: 'auto'}}>
<div className={classes.SidebarContent}>
<p className={classes.SidebarHeading}>Inspector</p>
<p className={classes.SidebarText}>
Expand Down Expand Up @@ -121,7 +121,13 @@ export const WithSidebarEnd: StoryFn<typeof SplitPageLayout> = () => (

export const WithResizableSidebar: StoryFn<typeof SplitPageLayout> = () => (
<SplitPageLayout>
<SplitPageLayout.Sidebar resizable position="start" aria-label="Resizable sidebar" style={{height: 'auto'}}>
<SplitPageLayout.Sidebar
padding="none"
resizable
position="start"
aria-label="Resizable sidebar"
style={{height: 'auto'}}
>
<div className={classes.SidebarContent}>
<p className={classes.SidebarHeading}>Resizable Sidebar</p>
<p className={classes.SidebarText}>
Expand All @@ -146,7 +152,13 @@ export const WithResizableSidebar: StoryFn<typeof SplitPageLayout> = () => (

export const WithSidebarAndResizablePane: StoryFn<typeof SplitPageLayout> = () => (
<SplitPageLayout>
<SplitPageLayout.Sidebar resizable position="start" aria-label="Navigation sidebar" style={{height: 'auto'}}>
<SplitPageLayout.Sidebar
padding="none"
resizable
position="start"
aria-label="Navigation sidebar"
style={{height: 'auto'}}
>
<div className={classes.SidebarContent}>
<p className={classes.SidebarHeading}>Sidebar</p>
<p className={classes.SidebarText}>Full-height resizable sidebar</p>
Expand Down Expand Up @@ -178,7 +190,7 @@ export const WithSidebarAndResizablePane: StoryFn<typeof SplitPageLayout> = () =

export const WithStickySidebar: StoryFn<typeof SplitPageLayout> = () => (
<SplitPageLayout>
<SplitPageLayout.Sidebar sticky position="start" aria-label="Sticky sidebar">
<SplitPageLayout.Sidebar padding="none" sticky position="start" aria-label="Sticky sidebar">
<div className={classes.SidebarContent}>
<p className={classes.SidebarHeading}>Sticky Sidebar</p>
<p className={classes.SidebarText}>This sidebar stays fixed in the viewport as you scroll the page content.</p>
Expand Down Expand Up @@ -207,6 +219,7 @@ export const WithStickySidebar: StoryFn<typeof SplitPageLayout> = () => (
export const SidebarFullscreenResponsiveVariant: StoryFn<typeof SplitPageLayout> = () => (
<SplitPageLayout>
<SplitPageLayout.Sidebar
padding="none"
position="start"
responsiveVariant="fullscreen"
aria-label="Fullscreen sidebar"
Expand Down
Loading