Skip to content

Commit 416588d

Browse files
authored
Add button to close example toolbar (#5309)
* Add button to close the example controls toolbar * Reduce spacing between example controls on smaller screens * Remove extra comma after close button * change to default button
1 parent 7a69dde commit 416588d

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

scss/docs/example.scss

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ body {
2020
box-shadow: $box-shadow--deep;
2121
display: flex;
2222
flex-flow: row wrap;
23-
gap: $sp-unit;
24-
justify-content: space-between;
23+
gap: $sph--small;
2524
left: 0;
2625
padding: $spv--x-small $sph--x-small;
2726
position: fixed;
@@ -30,6 +29,14 @@ body {
3029
// Above *all* other elements.
3130
z-index: 1000000;
3231

32+
.p-example-controls__close-button {
33+
margin-left: auto;
34+
}
35+
36+
@media (min-width: $breakpoint-small) {
37+
gap: $sph--large;
38+
}
39+
3340
@media only percy {
3441
visibility: hidden !important;
3542
}

templates/static/js/example-tools.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,17 @@ var activeTheme = DEFAULT_COLOR_THEME;
153153
);
154154
controls.appendChild(baselineGridControl);
155155

156+
const closeButtonFragment = fragmentFromString(`
157+
<button class="p-button is-dense p-example-controls__close-button" id="js-example-toolbar-close-button">
158+
Close
159+
</button>
160+
`);
161+
controls.appendChild(closeButtonFragment);
156162
body.appendChild(controls);
157163

164+
var closeButton = document.getElementById('js-example-toolbar-close-button');
165+
closeButton.addEventListener('click', () => controls.remove());
166+
158167
// Below code relies on the controls already existing in the DOM, so must come after `body.appendChild`.
159168
var themeToggleButtons = document.querySelectorAll('.p-theme-toggle__button');
160169
themeToggleButtons.forEach((themeToggleButton) => {

0 commit comments

Comments
 (0)