From 5b0b7d07e8872519ab5d37ef9d59a854e206923a Mon Sep 17 00:00:00 2001 From: Louis-Maxime Piton Date: Mon, 14 Oct 2024 14:25:41 +0200 Subject: [PATCH] fix(docs): change focus order for code examples and their copy button (#2699) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Hannah Issermann Co-authored-by: Julien Déramond --- site/assets/js/partials/code-examples.js | 9 +++++---- site/assets/scss/_component-examples.scss | 6 ++++++ site/layouts/shortcodes/example.html | 18 +++++++++++------- site/layouts/shortcodes/js-docs.html | 16 ++++++++++------ site/layouts/shortcodes/scss-docs.html | 19 ++++++++++++------- 5 files changed, 44 insertions(+), 24 deletions(-) diff --git a/site/assets/js/partials/code-examples.js b/site/assets/js/partials/code-examples.js index 68d931350b..b84f7ac662 100644 --- a/site/assets/js/partials/code-examples.js +++ b/site/assets/js/partials/code-examples.js @@ -19,10 +19,11 @@ export default () => { const btnEdit = 'Edit on StackBlitz' // Boosted mod: removed unused svg height, width and fill="currentColor" + // Boosted mod: changed the positioning to improve the focus order const btnHtml = [ - '
', - '
', - ' ', '
', @@ -35,7 +36,7 @@ export default () => { // Ignore examples made by shortcode if (!element.closest('.bd-example-snippet')) { element.insertAdjacentHTML('beforebegin', btnHtml) - element.previousElementSibling.append(element) + element.previousElementSibling.prepend(element) } }) diff --git a/site/assets/scss/_component-examples.scss b/site/assets/scss/_component-examples.scss index 834f43b80a..983088f095 100644 --- a/site/assets/scss/_component-examples.scss +++ b/site/assets/scss/_component-examples.scss @@ -3,6 +3,8 @@ // .bd-code-snippet { + display: flex; // Boosted mod + flex-direction: column; // Boosted mod margin: 0 ($bd-gutter-x * -.5) 1rem; border: solid var(--bs-border-color-subtle); // Boosted mod: instead of `var(--bs-border-color)` border-width: 1px 0; @@ -394,7 +396,11 @@ } .bd-file-ref { + position: relative; // Boosted mod + .highlight-toolbar { + min-height: $spacer * 2.5; // Boosted mod + @include media-breakpoint-up(md) { @include border-top-radius(calc(var(--bs-border-radius) - 1px)); } diff --git a/site/layouts/shortcodes/example.html b/site/layouts/shortcodes/example.html index 7740c18629..f7121f183b 100644 --- a/site/layouts/shortcodes/example.html +++ b/site/layouts/shortcodes/example.html @@ -21,14 +21,23 @@
{{- if eq $show_preview true }} - + + {{ $content }}
{{- end }} {{- if eq $show_markup true -}} + + {{- $content = replaceRE `` `...` $content -}} + {{- $content = replaceRE `` `...` $content -}} + {{- $content = replaceRE ` (class=" *?")` "" $content -}} + {{- highlight (trim $content "\n") $lang "" -}} + + {{- if eq $show_preview true -}} -
+ +
{{ $lang }}
{{- end -}} - - {{- $content = replaceRE `` `...` $content -}} - {{- $content = replaceRE `` `...` $content -}} - {{- $content = replaceRE ` (class=" *?")` "" $content -}} - {{- highlight (trim $content "\n") $lang "" -}} {{- end }}
diff --git a/site/layouts/shortcodes/js-docs.html b/site/layouts/shortcodes/js-docs.html index f0b4753cb7..16ad75b69d 100644 --- a/site/layouts/shortcodes/js-docs.html +++ b/site/layouts/shortcodes/js-docs.html @@ -35,14 +35,10 @@
{{- $unindent := 0 -}} @@ -67,5 +63,13 @@ {{- $output = $match -}} {{- end -}} {{- highlight $output "js" "" -}} + + +
+ +
+
{{- end -}} diff --git a/site/layouts/shortcodes/scss-docs.html b/site/layouts/shortcodes/scss-docs.html index f0f7103f5a..fb0e91506e 100644 --- a/site/layouts/shortcodes/scss-docs.html +++ b/site/layouts/shortcodes/scss-docs.html @@ -48,15 +48,12 @@
+ {{- $unindent := 0 -}} {{- $found := false -}} {{- $first_line:= index (split $match "\n") 0 -}} @@ -79,5 +76,13 @@ {{- $output = $match -}} {{- end -}} {{- highlight $output "scss" "" -}} + + +
+ +
+
-{{- end -}} \ No newline at end of file +{{- end -}}