-
Notifications
You must be signed in to change notification settings - Fork 69
[LG-5473] feat(drawer): add hasPadding prop to decouple padding from scrollable behavior #3078
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🦋 Changeset detectedLatest commit: 9c68bbf The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new hasPadding
prop to the Drawer component, decoupling padding control from scroll behavior. Previously, developers could only remove padding by disabling scrolling, but now these two concerns can be controlled independently.
Key changes:
- Added
hasPadding
prop (defaults totrue
) that controls content padding independently fromscrollable
- Updated
scrollable
prop to only control scroll behavior, not padding - Enhanced Storybook stories with play tests for visual regression testing
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
packages/drawer/src/utils/getLgIds.ts |
Added scrollContainer ID for test targeting |
packages/drawer/src/DrawerToolbarLayout/DrawerToolbarLayout/DrawerToolbarLayoutContent.tsx |
Integrated hasPadding prop into toolbar layout content |
packages/drawer/src/DrawerToolbarLayout/DrawerToolbarLayout/DrawerToolbarLayout.types.ts |
Added hasPadding type definitions and updated documentation |
packages/drawer/src/Drawer/Drawer.types.ts |
Added hasPadding prop to main Drawer interface |
packages/drawer/src/Drawer/Drawer.tsx |
Implemented hasPadding logic and updated container rendering |
packages/drawer/src/Drawer/Drawer.styles.ts |
Refactored styles to separate padding and scroll concerns |
packages/drawer/src/Drawer/Drawer.spec.tsx |
Removed obsolete scrollable-specific tests |
packages/drawer/src/Drawer.stories.tsx |
Enhanced stories with play tests and better coverage of prop combinations |
packages/drawer/README.md |
Updated documentation with behavior matrix and clearer explanations |
.changeset/wise-queens-take.md |
Added changeset documenting the new feature |
@@ -198,6 +198,26 @@ export const getDrawerStyles = ({ | |||
drawerClassName, | |||
); | |||
|
|||
export const getResizerStyles = ({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The getResizerStyles
function has been moved to an unexpected location in the middle of the file. Consider keeping function definitions grouped logically - this function was previously defined after getScrollContainerStyles
and should remain near other layout-related style functions for better code organization.
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer ordering these in order of usage 🤷
@@ -67,44 +67,6 @@ describe('packages/drawer', () => { | |||
}); | |||
}); | |||
|
|||
describe('scrollable prop', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nothing to see here folks... just removing some AI-generated tests that were definitely doing something 🤡
const fullWidthHeightContentStyles = css` | ||
width: 100%; | ||
height: 100%; | ||
background: linear-gradient( | ||
135deg, | ||
${palette.green.light1}, | ||
${palette.green.dark1} | ||
); | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
`; | ||
const FullWidthHeightContent = () => ( | ||
<div className={fullWidthHeightContentStyles}> | ||
<Subtitle>Full Width/Height Content</Subtitle> | ||
</div> | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Decided it was better to consistently render LongContent
as children in these stories and use play tests to show the scroll behavior
Size Change: +224 B (+0.01%) Total Size: 2.01 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No concerns technically. Curious why we went with a prop that controls styling here instead of exposing a class name constant that consumers can use to style things themselves? I just know I've seen us doing the latter a bit in the recent past.
2 reasons for this:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No concerns technically. Curious why we went with a prop that controls styling here instead of exposing a class name constant that consumers can use to style things themselves? I just know I've seen us doing the latter a bit in the recent past.
2 reasons for this:
- we already have
scrollable
and preserving that parallel pattern can be less mental overhead for consumers- we're opinionated about styling the
Drawer
and don't want to give too much flexibility here. Consumers should either have the standard padding or use the full-width/height
I feel like when we want to lock down style, a more common approach I've seen lately is to use variants. Such as the default vs compact Menu
, where primarily one has less padding. Does this component not lend itself to that well?
I'm just concerned that we're starting to make it so that some components export child classes, while others have style props, without very clear justification as to why. This seems like more mental overhead for consumers in general when using LG. This is something we should codify more in our future architecture/philosophy doc.
I'm not a hard blocker, just want to make sure we're looking at all options since I feel its a bit of a different pattern than I've seen lately.
@stephl3 and I spoke offline. We agree that a class name opens things up a bit much. Though it is done elsewhere and could be useful, it might not be the best general approach. A variant is probably a good option, but in cases like this where there are already |
✍️ Proposed changes
This PR adds a new
hasPadding
prop to theDrawer
component to allow independent control of padding and scrollable behavior. Previously, padding could only be removed by settingscrollable
tofalse
, which tightly coupled these two concerns. Now developers can control padding and scroll behavior independently, providing more flexibility for full-width/height content scenarios.The changes include:
hasPadding
prop (defaults totrue
) that controls content padding independentlyscrollable
prop to only control scroll behaviorhasPadding
inDrawerToolbarLayout
components🎟️ Jira ticket: LG-5473
✅ Checklist
pnpm changeset
and documented my changes🧪 How to test changes
Test independent padding control:
hasPadding={true/false}
andscrollable={true/false}
Test visual regression with play tests:
Test DrawerToolbarLayout integration:
hasPadding
prop is properly exposed in toolbar data objectsscrollable
usage