From ae8c43a9c628793b0f010d2ef5bcafbecad89ffb Mon Sep 17 00:00:00 2001 From: Louis-Maxime Piton Date: Mon, 2 Sep 2024 17:26:37 +0200 Subject: [PATCH] Docs: Add transparency option --- site/assets/js/transparency.js | 23 +++++++++++++++++++++++ site/assets/scss/_component-examples.scss | 19 +++++++++++++++++++ site/layouts/partials/docs-navbar.html | 9 +++++++++ site/layouts/partials/scripts.html | 3 +++ 4 files changed, 54 insertions(+) create mode 100644 site/assets/js/transparency.js diff --git a/site/assets/js/transparency.js b/site/assets/js/transparency.js new file mode 100644 index 000000000000..5c8a38e682f0 --- /dev/null +++ b/site/assets/js/transparency.js @@ -0,0 +1,23 @@ +// NOTICE!! DO NOT USE ANY OF THIS JAVASCRIPT +// IT'S ALL JUST JUNK FOR OUR DOCS! +// ++++++++++++++++++++++++++++++++++++++++++ + +/*! + * JavaScript for Bootstrap's docs (https://getbootstrap.com/) + * Copyright 2024 The Bootstrap Authors + * Licensed under the Creative Commons Attribution 3.0 Unported License. + * For details, see https://creativecommons.org/licenses/by/3.0/. + */ + +(() => { + const transparencyToggler = document.querySelector('.transparency-toggle') + const examplesContainer = document.querySelector('.bd-content') + + transparencyToggler.addEventListener('click', () => { + const altText = `Toggle examples' transparency (${examplesContainer.classList.contains('transparency') ? 'inactive' : 'active'})` + transparencyToggler.title = altText + transparencyToggler.querySelector('span.d-lg-none').textContent = altText + transparencyToggler.setAttribute('aria-label', altText) + examplesContainer.classList.toggle('transparency') + }) +})() diff --git a/site/assets/scss/_component-examples.scss b/site/assets/scss/_component-examples.scss index fde8b7f4164a..51464740a324 100644 --- a/site/assets/scss/_component-examples.scss +++ b/site/assets/scss/_component-examples.scss @@ -109,6 +109,25 @@ } } +.transparency .bd-example { + @include media-breakpoint-up(md) { + &::before { + @include border-radius(subtract(var(--bs-border-radius), 1px)); + } + } + + &::before { + position: absolute; + top: 0; + right: 0; + bottom: 0; + left: 0; + z-index: -9999; + content: ""; + background: repeating-linear-gradient(-45deg, var(--bs-secondary-bg) 0, var(--bs-secondary-bg) 15px, transparent 15px, transparent 30px); + } +} + // // Grid examples // diff --git a/site/layouts/partials/docs-navbar.html b/site/layouts/partials/docs-navbar.html index 3576ef4a48d0..6fd275f5a570 100644 --- a/site/layouts/partials/docs-navbar.html +++ b/site/layouts/partials/docs-navbar.html @@ -82,6 +82,15 @@
Bootstrap
+ + diff --git a/site/layouts/partials/scripts.html b/site/layouts/partials/scripts.html index e224c4b3775d..87a0b110f582 100644 --- a/site/layouts/partials/scripts.html +++ b/site/layouts/partials/scripts.html @@ -37,4 +37,7 @@ {{- $esbuildOptions = merge $esbuildOptions (dict "params" $esbuildParams) -}} {{- $stackblitzJs := resources.Get "js/stackblitz.js" | js.Build $esbuildOptions | resources.Copy (path.Join $targetDocsJSPath "/assets/js/stackblitz.js") }} + +{{- $transparencyJs := resources.Get "js/transparency.js" | js.Build $esbuildOptions | resources.Copy (path.Join $targetDocsJSPath "/assets/js/transparency.js") }} + {{- end -}}