Skip to content

Commit 046043b

Browse files
Merge pull request #7002 from SplinterSword/collapseDocs
Collapse docs
2 parents 5176139 + 34eefb6 commit 046043b

File tree

5 files changed

+474
-62
lines changed

5 files changed

+474
-62
lines changed

src/components/SistentNavigation/content.js

Lines changed: 64 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -45,86 +45,89 @@ export const content = [
4545
{ id: 32, link: "/projects/sistent/components/circularprogress/guidance", text: "Circular Progress" },
4646
{ id: 33, link: "/projects/sistent/components/circularprogress/code", text: "Circular Progress" },
4747

48-
{ id: 34, link: "/projects/sistent/components/container", text: "Container" },
49-
{ id: 35, link: "/projects/sistent/components/container/guidance", text: "Container" },
50-
{ id: 36, link: "/projects/sistent/components/container/code", text: "Container" },
48+
{ id: 34, link: "/projects/sistent/components/collapse", text: "Collapse" },
49+
{ id: 35, link: "/projects/sistent/components/collapse/guidance", text: "Collapse" },
50+
{ id: 36, link: "/projects/sistent/components/collapse/code", text: "Collapse" },
5151

52-
{ id: 37, link: "/projects/sistent/components/dialog", text: "Dialog" },
53-
{ id: 38, link: "/projects/sistent/components/dialog/guidance", text: "Dialog" },
54-
{ id: 39, link: "/projects/sistent/components/dialog/code", text: "Dialog" },
52+
{ id: 37, link: "/projects/sistent/components/container", text: "Container" },
53+
{ id: 38, link: "/projects/sistent/components/container/guidance", text: "Container" },
54+
{ id: 39, link: "/projects/sistent/components/container/code", text: "Container" },
5555

56-
{ id: 40, link: "/projects/sistent/components/formcontrollabel", text: "FormControlLabel" },
57-
{ id: 41, link: "/projects/sistent/components/formcontrollabel/guidance", text: "FormControlLabel" },
58-
{ id: 42, link: "/projects/sistent/components/formcontrollabel/code", text: "FormControlLabel" },
56+
{ id: 40, link: "/projects/sistent/components/dialog", text: "Dialog" },
57+
{ id: 41, link: "/projects/sistent/components/dialog/guidance", text: "Dialog" },
58+
{ id: 42, link: "/projects/sistent/components/dialog/code", text: "Dialog" },
5959

60-
{ id: 43, link: "/projects/sistent/components/grid", text: "Grid" },
61-
{ id: 44, link: "/projects/sistent/components/grid/guidance", text: "Grid" },
62-
{ id: 45, link: "/projects/sistent/components/grid/code", text: "Grid" },
60+
{ id: 43, link: "/projects/sistent/components/formcontrollabel", text: "FormControlLabel" },
61+
{ id: 44, link: "/projects/sistent/components/formcontrollabel/guidance", text: "FormControlLabel" },
62+
{ id: 45, link: "/projects/sistent/components/formcontrollabel/code", text: "FormControlLabel" },
6363

64-
{ id: 46, link: "/projects/sistent/components/iconbutton", text: "IconButton" },
65-
{ id: 47, link: "/projects/sistent/components/iconbutton/guidance", text: "IconButton" },
66-
{ id: 48, link: "/projects/sistent/components/iconbutton/code", text: "IconButton" },
64+
{ id: 46, link: "/projects/sistent/components/grid", text: "Grid" },
65+
{ id: 47, link: "/projects/sistent/components/grid/guidance", text: "Grid" },
66+
{ id: 48, link: "/projects/sistent/components/grid/code", text: "Grid" },
6767

68-
{ id: 49, link: "/projects/sistent/components/icons", text: "Icons" },
68+
{ id: 49, link: "/projects/sistent/components/iconbutton", text: "IconButton" },
69+
{ id: 50, link: "/projects/sistent/components/iconbutton/guidance", text: "IconButton" },
70+
{ id: 51, link: "/projects/sistent/components/iconbutton/code", text: "IconButton" },
6971

70-
{ id: 50, link: "/projects/sistent/components/link", text: "Link" },
71-
{ id: 51, link: "/projects/sistent/components/link/guidance", text: "Link" },
72-
{ id: 52, link: "/projects/sistent/components/link/code", text: "Link" },
72+
{ id: 52, link: "/projects/sistent/components/icons", text: "Icons" },
7373

74-
{ id: 53, link: "/projects/sistent/components/list", text: "List" },
75-
{ id: 54, link: "/projects/sistent/components/list/guidance", text: "List" },
76-
{ id: 55, link: "/projects/sistent/components/list/code", text: "List" },
74+
{ id: 53, link: "/projects/sistent/components/link", text: "Link" },
75+
{ id: 54, link: "/projects/sistent/components/link/guidance", text: "Link" },
76+
{ id: 55, link: "/projects/sistent/components/link/code", text: "Link" },
7777

78-
{ id: 56, link: "/projects/sistent/components/modal", text: "Modal" },
79-
{ id: 57, link: "/projects/sistent/components/modal/guidance", text: "Modal" },
80-
{ id: 58, link: "/projects/sistent/components/modal/code", text: "Modal" },
78+
{ id: 56, link: "/projects/sistent/components/list", text: "List" },
79+
{ id: 57, link: "/projects/sistent/components/list/guidance", text: "List" },
80+
{ id: 58, link: "/projects/sistent/components/list/code", text: "List" },
8181

82-
{ id: 59, link: "/projects/sistent/components/pagination", text: "Pagination" },
83-
{ id: 60, link: "/projects/sistent/components/pagination/guidance", text: "Pagination" },
84-
{ id: 61, link: "/projects/sistent/components/pagination/code", text: "Pagination" },
82+
{ id: 59, link: "/projects/sistent/components/modal", text: "Modal" },
83+
{ id: 60, link: "/projects/sistent/components/modal/guidance", text: "Modal" },
84+
{ id: 61, link: "/projects/sistent/components/modal/code", text: "Modal" },
8585

86-
{ id: 62, link: "/projects/sistent/components/paper", text: "Paper" },
87-
{ id: 63, link: "/projects/sistent/components/paper/guidance", text: "Paper" },
88-
{ id: 64, link: "/projects/sistent/components/paper/code", text: "Paper" },
86+
{ id: 62, link: "/projects/sistent/components/pagination", text: "Pagination" },
87+
{ id: 63, link: "/projects/sistent/components/pagination/guidance", text: "Pagination" },
88+
{ id: 64, link: "/projects/sistent/components/pagination/code", text: "Pagination" },
8989

90-
{ id: 65, link: "/projects/sistent/components/popper", text: "Popper" },
91-
{ id: 66, link: "/projects/sistent/components/popper/guidance", text: "Popper" },
92-
{ id: 67, link: "/projects/sistent/components/popper/code", text: "Popper" },
90+
{ id: 65, link: "/projects/sistent/components/paper", text: "Paper" },
91+
{ id: 66, link: "/projects/sistent/components/paper/guidance", text: "Paper" },
92+
{ id: 67, link: "/projects/sistent/components/paper/code", text: "Paper" },
9393

94-
{ id: 68, link: "/projects/sistent/components/radiogroup", text: "RadioGroup" },
95-
{ id: 69, link: "/projects/sistent/components/radiogroup/guidance", text: "RadioGroup" },
96-
{ id: 70, link: "/projects/sistent/components/radiogroup/code", text: "RadioGroup" },
94+
{ id: 68, link: "/projects/sistent/components/popper", text: "Popper" },
95+
{ id: 69, link: "/projects/sistent/components/popper/guidance", text: "Popper" },
96+
{ id: 70, link: "/projects/sistent/components/popper/code", text: "Popper" },
9797

98-
{ id: 71, link: "/projects/sistent/components/select", text: "Select" },
99-
{ id: 72, link: "/projects/sistent/components/select/guidance", text: "Select" },
100-
{ id: 73, link: "/projects/sistent/components/select/code", text: "Select" },
98+
{ id: 71, link: "/projects/sistent/components/radiogroup", text: "RadioGroup" },
99+
{ id: 72, link: "/projects/sistent/components/radiogroup/guidance", text: "RadioGroup" },
100+
{ id: 73, link: "/projects/sistent/components/radiogroup/code", text: "RadioGroup" },
101101

102-
{ id: 74, link: "/projects/sistent/components/stepper", text: "Stepper" },
103-
{ id: 75, link: "/projects/sistent/components/stepper/guidance", text: "Stepper" },
104-
{ id: 76, link: "/projects/sistent/components/stepper/code", text: "Stepper" },
102+
{ id: 74, link: "/projects/sistent/components/select", text: "Select" },
103+
{ id: 75, link: "/projects/sistent/components/select/guidance", text: "Select" },
104+
{ id: 76, link: "/projects/sistent/components/select/code", text: "Select" },
105105

106-
{ id: 77, link: "/projects/sistent/components/switch", text: "Switch" },
107-
{ id: 78, link: "/projects/sistent/components/switch/guidance", text: "Switch" },
108-
{ id: 79, link: "/projects/sistent/components/switch/code", text: "Switch" },
106+
{ id: 77, link: "/projects/sistent/components/stepper", text: "Stepper" },
107+
{ id: 78, link: "/projects/sistent/components/stepper/guidance", text: "Stepper" },
108+
{ id: 79, link: "/projects/sistent/components/stepper/code", text: "Stepper" },
109109

110-
{ id: 80, link: "/projects/sistent/components/tabs", text: "Tabs" },
111-
{ id: 81, link: "/projects/sistent/components/tabs/guidance", text: "Tabs" },
112-
{ id: 82, link: "/projects/sistent/components/tabs/code", text: "Tabs" },
110+
{ id: 80, link: "/projects/sistent/components/switch", text: "Switch" },
111+
{ id: 81, link: "/projects/sistent/components/switch/guidance", text: "Switch" },
112+
{ id: 82, link: "/projects/sistent/components/switch/code", text: "Switch" },
113113

114-
{ id: 83, link: "/projects/sistent/components/text-field", text: "Text Field" },
115-
{ id: 84, link: "/projects/sistent/components/text-field/guidance", text: "Text Field" },
116-
{ id: 85, link: "/projects/sistent/components/text-field/code", text: "Text Field" },
114+
{ id: 83, link: "/projects/sistent/components/tabs", text: "Tabs" },
115+
{ id: 84, link: "/projects/sistent/components/tabs/guidance", text: "Tabs" },
116+
{ id: 85, link: "/projects/sistent/components/tabs/code", text: "Tabs" },
117117

118-
{ id: 86, link: "/projects/sistent/components/text-input", text: "Text Input" },
119-
{ id: 87, link: "/projects/sistent/components/text-input/guidance", text: "Text Input" },
120-
{ id: 88, link: "/projects/sistent/components/text-input/code", text: "Text Input" },
118+
{ id: 86, link: "/projects/sistent/components/text-field", text: "Text Field" },
119+
{ id: 87, link: "/projects/sistent/components/text-field/guidance", text: "Text Field" },
120+
{ id: 88, link: "/projects/sistent/components/text-field/code", text: "Text Field" },
121121

122-
{ id: 89, link: "/projects/sistent/components/toolbar", text: "Toolbar" },
123-
{ id: 90, link: "/projects/sistent/components/toolbar/guidance", text: "Toolbar" },
124-
{ id: 91, link: "/projects/sistent/components/toolbar/code", text: "Toolbar" },
122+
{ id: 89, link: "/projects/sistent/components/text-input", text: "Text Input" },
123+
{ id: 90, link: "/projects/sistent/components/text-input/guidance", text: "Text Input" },
124+
{ id: 91, link: "/projects/sistent/components/text-input/code", text: "Text Input" },
125125

126-
{ id: 92, link: "/projects/sistent/components/tooltip", text: "Tooltip" },
127-
{ id: 93, link: "/projects/sistent/components/tooltip/guidance", text: "Tooltip" },
128-
{ id: 94, link: "/projects/sistent/components/tooltip/code", text: "Tooltip" },
126+
{ id: 92, link: "/projects/sistent/components/toolbar", text: "Toolbar" },
127+
{ id: 93, link: "/projects/sistent/components/toolbar/guidance", text: "Toolbar" },
128+
{ id: 94, link: "/projects/sistent/components/toolbar/code", text: "Toolbar" },
129129

130+
{ id: 95, link: "/projects/sistent/components/tooltip", text: "Tooltip" },
131+
{ id: 96, link: "/projects/sistent/components/tooltip/guidance", text: "Tooltip" },
132+
{ id: 97, link: "/projects/sistent/components/tooltip/code", text: "Tooltip" },
130133
];
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
import React, { useState } from "react";
2+
import { Collapse, Button, SistentThemeProvider } from "@sistent/sistent";
3+
import { SistentLayout } from "../../sistent-layout";
4+
import TabButton from "../../../../../reusecore/Button";
5+
import { useStyledDarkMode } from "../../../../../theme/app/useStyledDarkMode";
6+
import { CodeBlock } from "../button/code-block";
7+
import { navigate } from "gatsby";
8+
import { useLocation } from "@reach/router";
9+
10+
const codes = [
11+
" <SistentThemeProvider>\n <Button onClick={() => setExpanded(!expanded)}>\n {expanded ? 'Collapse' : 'Expand'}\n </Button>\n <Collapse in={expanded}>\n <div>Content to be collapsed/expanded</div>\n </Collapse>\n </SistentThemeProvider>",
12+
" <SistentThemeProvider>\n <Button onClick={() => setExpanded(!expanded)}>\n {expanded ? 'Collapse' : 'Expand'}\n </Button>\n <Collapse in={expanded}>\n <div>Content that's expanded by default</div>\n </Collapse>\n </SistentThemeProvider>",
13+
" <SistentThemeProvider>\n <Button onClick={() => setExpanded(!expanded)}>\n {expanded ? 'Collapse' : 'Expand'}\n </Button>\n <Collapse in={expanded} unmountOnExit>\n <div>Content that unmounts when collapsed</div>\n </Collapse>\n </SistentThemeProvider>",
14+
" <SistentThemeProvider>\n <Button onClick={() => setExpanded(!expanded)}>\n {expanded ? 'Fast Collapse' : 'Slow Expand'}\n </Button>\n <Collapse in={expanded} timeout={expanded ? 1000 : 300} easing={expanded ? 'cubic-bezier(0.4, 0, 0.2, 1)' : 'ease-out'}>\n <div>Custom transition content</div>\n </Collapse>\n </SistentThemeProvider>",
15+
];
16+
17+
const CollapseComponent = () => {
18+
const { isDark } = useStyledDarkMode();
19+
const location = useLocation();
20+
21+
const [expanded1, setExpanded1] = useState(false);
22+
const [expanded2, setExpanded2] = useState(true);
23+
const [expanded3, setExpanded3] = useState(false);
24+
const [expanded4, setExpanded4] = useState(false);
25+
26+
return (
27+
<SistentLayout title="Collapse">
28+
<section className="content">
29+
<a id="Identity">
30+
<h2>Collapse</h2>
31+
</a>
32+
<p>
33+
The Collapse component provides a smooth, animated way to show and hide content.
34+
Below are various examples demonstrating its capabilities and usage patterns.
35+
</p>
36+
37+
<div className="filterBtns">
38+
<TabButton
39+
className={
40+
location.pathname === "/projects/sistent/components/collapse"
41+
? "active"
42+
: ""
43+
}
44+
onClick={() => navigate("/projects/sistent/components/collapse")}
45+
title="Overview"
46+
/>
47+
<TabButton
48+
className={
49+
location.pathname === "/projects/sistent/components/collapse/guidance"
50+
? "active"
51+
: ""
52+
}
53+
onClick={() => navigate("/projects/sistent/components/collapse/guidance")}
54+
title="Guidance"
55+
/>
56+
<TabButton
57+
className={
58+
location.pathname === "/projects/sistent/components/collapse/code"
59+
? "active"
60+
: ""
61+
}
62+
onClick={() => navigate("/projects/sistent/components/collapse/code")}
63+
title="Code"
64+
/>
65+
</div>
66+
67+
<div className="main-content">
68+
<p>
69+
The Collapse component provides a smooth, animated way to show and hide content.
70+
Below are various examples demonstrating its capabilities and usage patterns.
71+
</p>
72+
<a id="Basic Collapse">
73+
<h2>Basic Collapse</h2>
74+
</a>
75+
<p>A simple collapsible section that can be toggled with a button click.</p>
76+
<div className="showcase">
77+
<div className="items">
78+
<SistentThemeProvider initialMode={isDark ? "dark" : "light"}>
79+
<Button variant="contained" onClick={() => setExpanded1(!expanded1)}>
80+
{expanded1 ? "Collapse" : "Expand"}
81+
</Button>
82+
<Collapse in={expanded1}>
83+
<div>Content to be collapsed/expanded</div>
84+
</Collapse>
85+
</SistentThemeProvider>
86+
</div>
87+
<CodeBlock name="collapse-basic" code={codes[0]} />
88+
</div>
89+
90+
<a id="Default Expanded">
91+
<h2>Default Expanded</h2>
92+
</a>
93+
<p>A collapsible section that starts expanded by default.</p>
94+
<div className="showcase">
95+
<div className="items">
96+
<SistentThemeProvider initialMode={isDark ? "dark" : "light"}>
97+
<Button variant="outlined" onClick={() => setExpanded2(!expanded2)}>
98+
{expanded2 ? "Collapse" : "Expand"}
99+
</Button>
100+
<Collapse in={expanded2}>
101+
<div>Content that's expanded by default</div>
102+
</Collapse>
103+
</SistentThemeProvider>
104+
</div>
105+
<CodeBlock name="collapse-default-expanded" code={codes[1]} />
106+
</div>
107+
108+
<a id="Unmount on Exit">
109+
<h2>Unmount on Exit</h2>
110+
</a>
111+
<p>Unmounts the content when collapsed for better performance with large content.</p>
112+
<div className="showcase">
113+
<div className="items">
114+
<SistentThemeProvider initialMode={isDark ? "dark" : "light"}>
115+
<Button variant="text" onClick={() => setExpanded3(!expanded3)}>
116+
{expanded3 ? "Collapse" : "Expand"}
117+
</Button>
118+
<Collapse in={expanded3} unmountOnExit>
119+
<div>Content that unmounts when collapsed</div>
120+
</Collapse>
121+
</SistentThemeProvider>
122+
</div>
123+
<CodeBlock name="collapse-unmount-on-exit" code={codes[2]} />
124+
</div>
125+
126+
<a id="Custom Transition">
127+
<h2>Custom Transition</h2>
128+
</a>
129+
<p>Customize the transition duration and easing function.</p>
130+
<div className="showcase">
131+
<div className="items">
132+
<SistentThemeProvider initialMode={isDark ? "dark" : "light"}>
133+
<Button variant="contained" onClick={() => setExpanded4(!expanded4)}>
134+
{expanded4 ? "Fast Collapse" : "Slow Expand"}
135+
</Button>
136+
<Collapse in={expanded4} timeout={expanded4 ? 1000 : 300} easing={expanded4 ? "cubic-bezier(0.4, 0, 0.2, 1)" : "ease-out"}>
137+
<div>Custom transition content</div>
138+
</Collapse>
139+
</SistentThemeProvider>
140+
</div>
141+
<CodeBlock name="collapse-custom-transition" code={codes[3]} />
142+
</div>
143+
</div>
144+
</section>
145+
</SistentLayout>
146+
);
147+
};
148+
149+
export default CollapseComponent;

0 commit comments

Comments
 (0)