Skip to content

Commit 715a065

Browse files
authored
alt-details does not need javascript (#1381)
1 parent 0fc3c45 commit 715a065

File tree

4 files changed

+34
-24
lines changed

4 files changed

+34
-24
lines changed

_includes/alt-details.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
<div {% if include.id %} id="{{include.id}}" {% endif %} class="alt-details">
2-
<button class="alt-details-toggle">{{include.title}}</button>
1+
<div id="{{include.id}}" class="alt-details">
2+
<input class="alt-details-control" type="checkbox" id="{{include.id}}__control">
3+
<label class="alt-details-toggle" for="{{include.id}}__control">{{include.title}}</label>
34
<div class="alt-details-detail">
45
{{include.detail}}
56
</div>

_install_tabs/1-macos.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
</div>
1414
{% endcapture %}
1515
{% include alt-details.html
16+
id='cs-setup-macos-nobrew'
1617
title=homebrewAlt
1718
detail=homebrewDetail
1819
%}

_sass/components/alt-details.scss

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,16 @@
44

55
.alt-details {
66

7+
.alt-details-control {
8+
display: none;
9+
}
10+
711
.alt-details-toggle {
812
width: 100%;
13+
display: block;
14+
font-family: $base-font-family;
15+
line-height: normal;
16+
text-align: center;
917
border: none;
1018
background-color: $brand-tertiary;
1119
padding: 5px 10px;
@@ -20,24 +28,39 @@
2028
}
2129

2230
&:after {
23-
content: "\f13a"; // <i class="fa-solid fa-circle-chevron-down"></i>
31+
// show a right arrow at the end of the toggle element
32+
content: "\f138"; // <i class="fa-solid fa-circle-chevron-right"></i>
2433
font-family: "FontAwesome";
2534
font-weight: 900;
2635
font-size: 15px;
2736
float: right;
2837
margin-top: 2px;
2938
}
3039

31-
&.alt-details-closed:after {
32-
content: "\f138"; // <i class="fa-solid fa-circle-chevron-right"></i>
33-
}
40+
}
41+
42+
.alt-details-control + .alt-details-toggle + .alt-details-detail {
43+
// by default, hide the details
44+
display: none;
45+
}
46+
47+
.alt-details-control:checked + .alt-details-toggle + .alt-details-detail {
48+
// show the details when the control is checked
49+
display: block;
50+
}
51+
52+
.alt-details-control:checked + .alt-details-toggle:after {
53+
// change the marker on the toggle label to a down arrow
54+
content: "\f13a"; // <i class="fa-solid fa-circle-chevron-down"></i>
3455
}
3556

3657
.alt-details-detail {
3758
// The detail box appears to be underneath the toggle button
3859
// so we add a padding to the top and push it up.
39-
border: $base-border-gray;
40-
padding-top: 15px;
41-
margin-top: -15px;
60+
border-bottom: $base-border-gray;
61+
border-left: $base-border-gray;
62+
border-right: $base-border-gray;
63+
padding-top: 10px;
64+
margin-top: -10px;
4265
}
4366
}

resources/js/functions.js

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -178,21 +178,6 @@ var toggleStickyToc = function() {
178178
}
179179
}
180180

181-
$(document).ready(function() {
182-
// for each .alt-details div, find the .alt-details-toggle button,
183-
// and add a click handler to toggle the visibility of the .alt-details-detail
184-
185-
$('.alt-details').each(function() {
186-
var toggle = $(this).find('.alt-details-toggle');
187-
var details = $(this).find('.alt-details-detail');
188-
toggle.click(function() {
189-
details.css('display') === 'none' ? details.show() : details.hide();
190-
toggle.toggleClass('alt-details-closed');
191-
});
192-
toggle.click();
193-
});
194-
});
195-
196181
// Blog search
197182
$(document).ready(function() {
198183
if ($("#blog-search-bar").length) {

0 commit comments

Comments
 (0)