Skip to content
This repository was archived by the owner on Apr 21, 2026. It is now read-only.

Commit 3936ed0

Browse files
author
dpatanin
committed
add collapsible component to sidebar
1 parent f7df786 commit 3936ed0

4 files changed

Lines changed: 33 additions & 44 deletions

File tree

src/components/Collapsible.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ class Collapsible extends Component {
244244
tabIndex={this.props.tabIndex && this.props.tabIndex}
245245
{...this.props.triggerElementProps}
246246
>
247-
<div class="collapsible-header">
247+
<div className="collapsible-header">
248248
{trigger}
249249
<IoIosArrowDown
250250
style={{

src/components/ScannerExamples.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export default function ScannerExamples({ examples: allExamples }) {
2323
return (
2424
<Tabs key={targetName}>
2525
<Collapsible
26-
lazyRender
26+
lazyRender={true}
2727
transitionTime={150}
2828
trigger={targetName}
2929
triggerTagName="h3"

src/components/Sidebar.js

Lines changed: 30 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { Fragment, useState } from 'react';
22
import { Link } from 'gatsby';
3-
import { IoIosArrowDown, IoIosArrowForward } from 'react-icons/io';
3+
import Collapsible from './Collapsible';
44

55
/**
66
* Interactive Sidebar with toggleable categories.
@@ -23,50 +23,40 @@ const Sidebar = ({ categories = [], currentPathname }) => {
2323
<nav className="sidebar">
2424
{categories.map(({ categoryName, entries }) => (
2525
<Fragment key={categoryName}>
26-
<button
27-
onClick={() =>
26+
<Collapsible
27+
className="sidebar-category"
28+
openedClassName="sidebar-category"
29+
transitionTime={150}
30+
transitionCloseTime={50}
31+
trigger={categoryName}
32+
triggerTagName="div"
33+
open={selectedCategory === categoryName}
34+
onTriggerOpening={() => {
2835
selectCategory(
2936
selectedCategory === categoryName ? null : categoryName
30-
)
31-
}
32-
className="sidebar-category"
33-
>
34-
{categoryName}
35-
<IoIosArrowDown
36-
className="arrow"
37-
style={{
38-
display: selectedCategory === categoryName ? 'block' : 'none',
39-
}}
40-
/>
41-
<IoIosArrowForward
42-
className="arrow"
43-
style={{
44-
display: selectedCategory === categoryName ? 'none' : 'block',
45-
}}
46-
/>
47-
</button>
48-
<ul
49-
id={categoryName}
50-
name="Category"
51-
className="list-unstyled components show"
52-
style={{
53-
display: selectedCategory === categoryName ? 'block' : 'none',
37+
);
5438
}}
5539
>
56-
{entries.map((element) => (
57-
<li
58-
key={element.node.frontmatter.title}
59-
className="sidebar-element"
60-
>
61-
<Link
62-
to={`/integrations/${element.node.frontmatter.path}`}
63-
activeClassName="active-Link"
40+
<ul
41+
id={categoryName}
42+
name="Category"
43+
className="list-unstyled components show"
44+
>
45+
{entries.map((element) => (
46+
<li
47+
key={element.node.frontmatter.title}
48+
className="sidebar-element"
6449
>
65-
{element.node.frontmatter.title}
66-
</Link>
67-
</li>
68-
))}
69-
</ul>
50+
<Link
51+
to={`/integrations/${element.node.frontmatter.path}`}
52+
activeClassName="active-Link"
53+
>
54+
{element.node.frontmatter.title}
55+
</Link>
56+
</li>
57+
))}
58+
</ul>
59+
</Collapsible>
7060
</Fragment>
7161
))}
7262
</nav>

src/scss/components/_sidebar.scss

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ a {
6262
}
6363
}
6464
ul {
65-
display: none;
65+
margin-top: 20px;
6666
li {
6767
a {
6868
text-align: left;
@@ -89,7 +89,6 @@ a {
8989
text-align: left;
9090
}
9191
.sidebar-category:hover {
92-
cursor: pointer;
9392
box-shadow: 0 1px 18px rgba(0, 0, 0, 0.2);
9493
}
9594
.sidebar-element {

0 commit comments

Comments
 (0)