Skip to content

Commit

Permalink
Make Scroll within Panel inherit bottom rounded corners
Browse files Browse the repository at this point in the history
  • Loading branch information
acelaya committed Nov 9, 2023
1 parent 489f5e3 commit 3d6a603
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
15 changes: 14 additions & 1 deletion src/components/layout/Panel.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import classNames from 'classnames';
import type { ComponentChildren, JSX } from 'preact';

import type { IconComponent, CompositeProps } from '../../types';
Expand Down Expand Up @@ -96,7 +97,19 @@ export default function Panel({
{Icon && <Icon className="w-em h-em" />}
<CardTitle>{title}</CardTitle>
</CardHeader>
{scrollable ? <Scroll>{panelContent}</Scroll> : <>{panelContent}</>}
{scrollable ? (
<Scroll
classes={classNames({
// When no buttons are provided (which means this is the last children),
// inherit the bottom border radius from Card.
'rounded-b-[inherit]': !buttons,
})}
>
{panelContent}
</Scroll>
) : (
<>{panelContent}</>
)}
{buttons && (
<CardContent data-testid="panel-buttons">
<CardActions>{buttons}</CardActions>
Expand Down
12 changes: 1 addition & 11 deletions src/pattern-library/components/patterns/layout/PanelPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,7 @@ export default function PanelPage() {
withSource
>
<div className="h-[350px]">
<Panel
title="Scrolling content"
buttons={
<>
<Button>Buttons</Button>
<Button>do not</Button>
<Button variant="primary">Scroll</Button>
</>
}
scrollable
>
<Panel title="Scrolling content" scrollable>
<LoremIpsum />
</Panel>
</div>
Expand Down

0 comments on commit 3d6a603

Please sign in to comment.