Skip to content

Commit 9c2d4a1

Browse files
authored
STYLE: Reduce footprint of toggle buttons (#37)
1 parent a7f4a42 commit 9c2d4a1

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

sphinx_togglebutton/_static/togglebutton.css

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,9 @@ button.toggle-button {
6565
}
6666

6767
details.toggle-details .tb-icon {
68-
height: 1.3em;
69-
width: 1.3em;
68+
height: 1.4em;
69+
width: 1.4em;
70+
margin-top: 0.1em; /* To center the button vertically */
7071
}
7172

7273
.toggle-button-hidden .tb-icon {
@@ -92,8 +93,12 @@ details.toggle-details summary {
9293
border-radius: .4em;
9394
border: 1px solid #ccc;
9495
background: #f8f8f8;
95-
padding: 0.4em 1em 0.4em 0.5em; /* Less padding on left because the SVG has left margin */
96-
font-size: .9em;
96+
padding: 0.2em 0.7em 0.3em 0.5em; /* Less padding on left because the SVG has left margin */
97+
font-size: 0.8em;
98+
}
99+
100+
.toggle-details__summary-text {
101+
margin-left: 0.2em;
97102
}
98103

99104
details.toggle-details summary:hover {

sphinx_togglebutton/_static/togglebutton.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ var initToggleItems = () => {
2525
}
2626
// This is the button that will be added to each item to trigger the toggle
2727
var collapseButton = `
28-
<button type="button" id="${buttonID}" class="toggle-button" data-target="${toggleID}" data-button="${buttonID}", data-toggle-hint="${toggleHintShow}">
28+
<button type="button" id="${buttonID}" class="toggle-button" data-target="${toggleID}" data-button="${buttonID}" data-toggle-hint="${toggleHintShow}" aria-label="Click to toggle content">
2929
${toggleChevron}
3030
</button>`;
3131

@@ -50,9 +50,9 @@ var initToggleItems = () => {
5050
// Define the structure of the details block and insert it as a sibling
5151
var detailsBlock = `
5252
<details class="toggle-details">
53-
<summary>
53+
<summary class="toggle-details__summary">
5454
${toggleChevron}
55-
<span>${toggleHintShow}</span>
55+
<span class="toggle-details__summary-text">${toggleHintShow}</span>
5656
</summary>
5757
</details>`;
5858
item.insertAdjacentHTML("beforebegin", detailsBlock);

0 commit comments

Comments
 (0)