Skip to content

Commit 0a1fa82

Browse files
authored
Expandable sidebar option (#732)
1 parent 2ede9e3 commit 0a1fa82

File tree

4 files changed

+61
-9
lines changed

4 files changed

+61
-9
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@nordcloud/gnui",
33
"description": "Nordcloud Design System - a collection of reusable React components used in Nordcloud's SaaS products",
4-
"version": "10.4.3",
4+
"version": "10.4.4",
55
"license": "MIT",
66
"repository": {
77
"type": "git",

src/components/sidebar/Sidebar.stories.tsx

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,3 +249,36 @@ export const CustomWidth: StoryObj = {
249249
},
250250
},
251251
};
252+
253+
export const Expandable: StoryObj = {
254+
render: () => {
255+
const { isOpen, open, close } = useDisclosure();
256+
257+
return (
258+
<Container>
259+
<Row justify="center">
260+
<Button onClick={open}>Click button to open sidebar</Button>
261+
</Row>
262+
<Sidebar
263+
showExpandButton
264+
title="Default sidebar"
265+
caption="Default sidebar caption"
266+
isOpen={isOpen}
267+
onClick={close}
268+
onExpandClick={() => alert("clicked")}
269+
>
270+
Sidebar Content
271+
</Sidebar>
272+
</Container>
273+
);
274+
},
275+
276+
name: "expandable",
277+
parameters: {
278+
docs: {
279+
story: {
280+
height: "450px",
281+
},
282+
},
283+
},
284+
};

src/components/sidebar/Sidebar.tsx

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import * as React from "react";
2+
import { When } from "react-if";
23
import { Button } from "../button";
4+
import { FlexContainer } from "../container";
35
import { Background } from "../modal/styles";
46
import { SVGIcon } from "../svgicon";
57
import {
@@ -34,6 +36,8 @@ export function Sidebar({
3436
headerStyles,
3537
contentStyles,
3638
onClick = () => undefined,
39+
showExpandButton = false,
40+
onExpandClick = () => undefined,
3741
...props
3842
}: SidebarProps) {
3943
React.useEffect(() => {
@@ -69,14 +73,27 @@ export function Sidebar({
6973
</Title>
7074
{caption && <Caption>{caption}</Caption>}
7175
</header>
72-
<Button
73-
severity="low"
74-
size="md"
75-
icon="close"
76-
title="Close sidebar"
77-
type="button"
78-
onClick={onClick}
79-
/>
76+
<FlexContainer justifyContent="space-evenly">
77+
<When condition={showExpandButton}>
78+
<Button
79+
severity="low"
80+
size="md"
81+
icon="externalLink"
82+
title="Expand"
83+
type="button"
84+
marginRight={1}
85+
onClick={onExpandClick}
86+
/>
87+
</When>
88+
<Button
89+
severity="low"
90+
size="md"
91+
icon="close"
92+
title="Close sidebar"
93+
type="button"
94+
onClick={onClick}
95+
/>
96+
</FlexContainer>
8097
</Header>
8198
<Container style={contentStyles}>
8299
<Content tag="div">{children}</Content>

src/components/sidebar/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ export type SidebarProps = {
1010
width?: number | string;
1111
reverse?: boolean;
1212
onClick?: () => void;
13+
showExpandButton?: boolean;
14+
onExpandClick?: () => void;
1315
footer?: React.ReactNode;
1416
headerStyles?: React.CSSProperties;
1517
contentStyles?: React.CSSProperties;

0 commit comments

Comments
 (0)