]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Change example focus order
authorLouis-Maxime Piton <louismaxime.piton@orange.com>
Thu, 24 Oct 2024 10:24:21 +0000 (12:24 +0200)
committerLouis-Maxime Piton <louismaxime.piton@orange.com>
Thu, 24 Oct 2024 10:24:21 +0000 (12:24 +0200)
site/assets/js/partials/code-examples.js
site/assets/scss/_component-examples.scss
site/layouts/shortcodes/example.html
site/layouts/shortcodes/js-docs.html
site/layouts/shortcodes/scss-docs.html

index d81191a965655f98b808163c89ccc5432f4e46d1..a5c14e10ecee0eb5887f195403115947d13e31ac 100644 (file)
@@ -19,8 +19,8 @@ export default () => {
   const btnEdit = 'Edit on StackBlitz'
 
   const btnHtml = [
-    '<div class="bd-code-snippet">',
-    '  <div class="bd-clipboard">',
+    '<div class="bd-code-snippet position-relative">',
+    '  <div class="bd-clipboard position-absolute top-0 end-0">',
     '    <button type="button" class="btn-clipboard">',
     '      <svg class="bi" role="img" aria-label="Copy"><use xlink:href="#clipboard"/></svg>',
     '    </button>',
@@ -34,7 +34,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)
       }
     })
 
index fde8b7f4164ac89a988c6d56bce0b27d968a9572..2ec19ec347696a9a3c6227affbbf62ef1635a701 100644 (file)
@@ -3,6 +3,8 @@
 //
 
 .bd-code-snippet {
+  display: flex;
+  flex-direction: column;
   margin: 0 ($bd-gutter-x * -.5) 1rem;
   border: solid var(--bs-border-color);
   border-width: 1px 0;
 }
 
 .bd-file-ref {
+  position: relative;
+
   .highlight-toolbar {
+    min-height: $spacer * 2.625;
+
     @include media-breakpoint-up(md) {
       @include border-top-radius(calc(var(--bs-border-radius) - 1px));
     }
index 5b398e6814fce25da5e3971c5289dd92e95d36ff..8168dc11b6a24053a80e6425615e7d58b526b71b 100644 (file)
 
 <div class="bd-example-snippet bd-code-snippet">
   {{- if eq $show_preview true }}
-  <div{{ with $id }} id="{{ . }}"{{ end }} class="bd-example m-0 border-0{{ with $class }} {{ . }}{{ end }}">
+  <div{{ with $id }} id="{{ . }}"{{ end }} class="bd-example order-first m-0 border-0{{ with $class }} {{ . }}{{ end }}">
     {{ $content }}
   </div>
   {{- end }}
 
   {{- if eq $show_markup true -}}
+
+    {{- $content = replaceRE `<svg class="bd-placeholder-img(?:-lg)?(?: *?bd-placeholder-img-lg)? ?(.*?)".*?<\/svg>` `<img src="..." class="$1" alt="...">` $content -}}
+    {{- $content = replaceRE `<img class="bd-placeholder-img(?:-lg)?(?: *?bd-placeholder-img-lg)? ?(.*?)".*?>` `<img src="..." class="$1" alt="...">` $content -}}
+    {{- $content = replaceRE ` (class=" *?")` "" $content -}}
+    {{- highlight (trim $content "\n") $lang "" -}}
+
     {{- if eq $show_preview true -}}
-      <div class="d-flex align-items-center highlight-toolbar ps-3 pe-2 py-1 border-0 border-top border-bottom">
+    <div class="d-flex order-first align-items-center highlight-toolbar ps-3 pe-2 py-1 border-0 border-top border-bottom">
         <small class="font-monospace text-body-secondary text-uppercase">{{ $lang }}</small>
         <div class="d-flex ms-auto">
           <button type="button" class="btn-edit text-nowrap"{{ with $stackblitz_add_js }} data-sb-js-snippet="{{ $stackblitz_add_js }}"{{ end }} title="Try it on StackBlitz">
         </div>
       </div>
     {{- end -}}
-
-    {{- $content = replaceRE `<svg class="bd-placeholder-img(?:-lg)?(?: *?bd-placeholder-img-lg)? ?(.*?)".*?<\/svg>` `<img src="..." class="$1" alt="...">` $content -}}
-    {{- $content = replaceRE `<img class="bd-placeholder-img(?:-lg)?(?: *?bd-placeholder-img-lg)? ?(.*?)".*?>` `<img src="..." class="$1" alt="...">` $content -}}
-    {{- $content = replaceRE ` (class=" *?")` "" $content -}}
-    {{- highlight (trim $content "\n") $lang "" -}}
   {{- end }}
 </div>
index 8eed4a0eb18eec6e86a6e8b86afe0852e10e36fc..691b236cb1b7508322ee4845f89d62876315f4f3 100644 (file)
 
   <div class="bd-example-snippet bd-code-snippet bd-file-ref">
     <div class="d-flex align-items-center highlight-toolbar ps-3 pe-2 py-1 border-bottom">
-      <a class="font-monospace link-secondary link-underline-secondary link-underline-opacity-0 link-underline-opacity-100-hover small" href="{{ .Site.Params.repo }}/blob/v{{ .Site.Params.current_version }}/{{ $file | replaceRE `\\` "/" }}">
+      <a class="me-5 font-monospace link-secondary link-underline-secondary link-underline-opacity-0 link-underline-opacity-100-hover small" href="{{ .Site.Params.repo }}/blob/v{{ .Site.Params.current_version }}/{{ $file | replaceRE `\\` "/" }}">
         {{- $file -}}
       </a>
-      <div class="d-flex ms-auto">
-        <button type="button" class="btn-clipboard mt-0 me-0" title="Copy to clipboard">
-          <svg class="bi" aria-hidden="true"><use xlink:href="#clipboard"/></svg>
-        </button>
-      </div>
     </div>
 
     {{- $unindent := 0 -}}
@@ -66,5 +61,9 @@
       {{- $output = $match -}}
     {{- end -}}
     {{- highlight $output "js" "" -}}
+
+    <button type="button" class="btn-clipboard position-absolute top-0 mt-1 end-0 me-2" title="Copy to clipboard">
+      <svg class="bi" aria-hidden="true"><use xlink:href="#clipboard"/></svg>
+    </button>
   </div>
 {{- end -}}
index 6e7c129f4c298f97dd8c4d9e6ed9e9d79fd4f61a..4c454c037d2e1ba4e1b9d6eac0a04cea3e03eeb4 100644 (file)
 
   <div class="bd-example-snippet bd-code-snippet bd-file-ref">
     <div class="d-flex align-items-center highlight-toolbar ps-3 pe-2 py-1 border-bottom">
-      <a class="font-monospace link-secondary link-underline-secondary link-underline-opacity-0 link-underline-opacity-100-hover small" href="{{ .Site.Params.repo }}/blob/v{{ .Site.Params.current_version }}/{{ $file | replaceRE `\\` "/" }}">
+      <a class="me-5 font-monospace link-secondary link-underline-secondary link-underline-opacity-0 link-underline-opacity-100-hover small" href="{{ .Site.Params.repo }}/blob/v{{ .Site.Params.current_version }}/{{ $file | replaceRE `\\` "/" }}">
         {{- $file -}}
       </a>
-      <div class="d-flex ms-auto">
-        <button type="button" class="btn-clipboard mt-0 me-0" title="Copy to clipboard">
-          <svg class="bi" aria-hidden="true"><use xlink:href="#clipboard"/></svg>
-        </button>
-      </div>
     </div>
     {{- $unindent := 0 -}}
     {{- $found := false -}}
@@ -78,5 +73,9 @@
       {{- $output = $match -}}
     {{- end -}}
     {{- highlight $output "scss" "" -}}
+
+    <button type="button" class="btn-clipboard position-absolute top-0 mt-1 end-0 me-2" title="Copy to clipboard">
+      <svg class="bi" aria-hidden="true"><use xlink:href="#clipboard"/></svg>
+    </button>
   </div>
 {{- end -}}