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
16 changes: 13 additions & 3 deletions code/core/src/components/components/addon-panel/addon-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,30 @@ const useUpdate = (update: boolean, value: any) => {
export interface AddonPanelProps {
active: boolean;
children: ReactElement;
/** Whether the panel has a vertical scrollbar, `true` by default. */
hasScrollbar?: boolean;
/** Whether the panel has an horizontal scrollbar, `false` by default */
hasHorizontalScrollbar?: boolean;
}

const Div = styled.div(({ theme }) => ({
fontSize: theme.typography.size.s2 - 1,
height: '100%',
}));

export const AddonPanel = ({ active, children, hasScrollbar = true }: AddonPanelProps) => {
export const AddonPanel = ({
active,
children,
hasScrollbar = true,
hasHorizontalScrollbar = false,
}: AddonPanelProps) => {
return (
// the hidden attribute is an valid html element that's both accessible and works to visually hide content
<Div hidden={!active}>
{hasScrollbar ? (
<ScrollArea vertical>{useUpdate(active, children)}</ScrollArea>
{hasScrollbar || hasHorizontalScrollbar ? (
<ScrollArea vertical={hasScrollbar} horizontal={hasHorizontalScrollbar}>
{useUpdate(active, children)}
</ScrollArea>
) : (
useUpdate(active, children)
)}
Expand Down
2 changes: 1 addition & 1 deletion code/core/src/controls/manager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export default addons.register(ADDON_ID, (api) => {
return null;
}
return (
<AddonPanel active={active}>
<AddonPanel active={active} hasHorizontalScrollbar hasScrollbar>
<ControlsPanel saveStory={saveStory} createStory={createStory} />
</AddonPanel>
);
Expand Down
Loading