Skip to content

Commit 9e3563c

Browse files
committed
fix(accordion): fix list item alignment and styling
1 parent 3d26225 commit 9e3563c

File tree

3 files changed

+30
-27
lines changed

3 files changed

+30
-27
lines changed

src/Block/variations/AccordionMenu.jsx

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import React, { useEffect, useState, useRef } from 'react';
77
import PropTypes from 'prop-types';
8+
import cx from 'classnames';
89
import { FormattedMessage, injectIntl } from 'react-intl';
910
import AnchorLink from 'react-anchor-link-smooth-scroll';
1011
import { Accordion, Icon } from 'semantic-ui-react';
@@ -18,6 +19,7 @@ import './less/accordion-menu.less';
1819
* @extends Component
1920
*/
2021
const View = ({ data, tocEntries }) => {
22+
const { bulleted_list = false } = data;
2123
const tocRef = useRef(); // Ref for the ToC component
2224
const spacerRef = useRef(); // Ref for the spacer div
2325
const [activeItems, setActiveItems] = useState({});
@@ -105,29 +107,30 @@ const View = ({ data, tocEntries }) => {
105107

106108
return (
107109
<li key={id}>
108-
{hasSubItems ? (
109-
<Accordion fluid styled>
110-
<Accordion.Title
111-
active={isActive}
112-
onClick={() => handleClick(id, hasSubItems)}
113-
>
114-
{subItems && subItems.length > 0 && (
115-
<Icon name={isActive ? 'angle up' : 'angle right'} />
116-
)}
117-
118-
<AnchorLink href={`#${slug}`}>{title}</AnchorLink>
119-
</Accordion.Title>
110+
<Accordion fluid styled>
111+
<Accordion.Title
112+
active={isActive}
113+
onClick={() => handleClick(id, hasSubItems)}
114+
>
115+
{subItems && subItems.length > 0 && (
116+
<Icon name={isActive ? 'angle up' : 'angle right'} />
117+
)}
118+
<AnchorLink href={`#${slug}`}>{title}</AnchorLink>
119+
</Accordion.Title>
120+
{hasSubItems && (
120121
<Accordion.Content active={isActive}>
121-
<ul className="accordion-list">
122+
<ul
123+
className={cx('accordion-list', {
124+
'accordion-list-bulleted': bulleted_list,
125+
})}
126+
>
122127
{subItems.map((child) =>
123128
RenderAccordionItems({ item: child, level: level + 1 }),
124129
)}
125130
</ul>
126131
</Accordion.Content>
127-
</Accordion>
128-
) : (
129-
<AnchorLink href={`#${slug}`}>{title}</AnchorLink>
130-
)}
132+
)}
133+
</Accordion>
131134
</li>
132135
);
133136
};
@@ -146,7 +149,7 @@ const View = ({ data, tocEntries }) => {
146149
)}
147150
<div ref={spacerRef} /> {/* Spacer div */}
148151
<div ref={tocRef} className="accordionMenu">
149-
<ul style={{ listStyle: 'none' }}>
152+
<ul className="accordion-list">
150153
{tocEntries.map((item) => RenderAccordionItems({ item }))}
151154
</ul>
152155
</div>

src/Block/variations/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const ToCVariations = [
2424
schema.properties.bulleted_list = {
2525
title: 'Use bullet list',
2626
type: 'boolean',
27+
description: 'Bullet point for child items',
2728
};
2829
return schema;
2930
},

src/Block/variations/less/accordion-menu.less

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,22 @@
33
font-size: 1.2rem !important;
44
}
55

6+
.accordion-list {
7+
list-style: none;
8+
}
9+
610
.content.active {
711
padding: 0 !important;
812
margin: 0 !important;
913

14+
.accordion-list-bulleted {
15+
list-style: disc;
16+
}
17+
1018
.title {
1119
padding: 4px !important;
1220
border: none !important;
1321
background-color: #f9f9f9 !important;
14-
15-
li[role='listitem'] {
16-
padding: 10px 1.5em !important;
17-
font-size: 0.95em;
18-
}
19-
20-
& > a {
21-
padding: 10px 30px !important;
22-
}
2322
}
2423
}
2524

0 commit comments

Comments
 (0)