summaryrefslogtreecommitdiffstats
path: root/site/layouts/shortcodes
diff options
context:
space:
mode:
Diffstat (limited to 'site/layouts/shortcodes')
-rw-r--r--site/layouts/shortcodes/added-in.html5
-rw-r--r--site/layouts/shortcodes/bs-table.html9
-rw-r--r--site/layouts/shortcodes/callout.html9
-rw-r--r--site/layouts/shortcodes/docsref.html1
-rw-r--r--site/layouts/shortcodes/example.html47
-rw-r--r--site/layouts/shortcodes/js-dismiss.html15
-rw-r--r--site/layouts/shortcodes/markdown.html1
-rw-r--r--site/layouts/shortcodes/param.html14
-rw-r--r--site/layouts/shortcodes/partial.html1
-rw-r--r--site/layouts/shortcodes/placeholder.html33
-rw-r--r--site/layouts/shortcodes/scss-docs.html43
-rw-r--r--site/layouts/shortcodes/table.html31
-rw-r--r--site/layouts/shortcodes/year.html3
13 files changed, 212 insertions, 0 deletions
diff --git a/site/layouts/shortcodes/added-in.html b/site/layouts/shortcodes/added-in.html
new file mode 100644
index 0000000..ca461c2
--- /dev/null
+++ b/site/layouts/shortcodes/added-in.html
@@ -0,0 +1,5 @@
+{{- /* Outputs badge to identify the first version something was added */ -}}
+
+{{- $version := .Get 0 -}}
+
+<small class="d-inline-flex mb-3 px-2 py-1 fw-semibold text-success bg-success bg-opacity-10 border border-success border-opacity-10 rounded-2">Added in v{{ $version }}</small>
diff --git a/site/layouts/shortcodes/bs-table.html b/site/layouts/shortcodes/bs-table.html
new file mode 100644
index 0000000..9eec109
--- /dev/null
+++ b/site/layouts/shortcodes/bs-table.html
@@ -0,0 +1,9 @@
+{{- /*
+ Usage: `bs-table "class class-foo"`, where class can be any string
+*/ -}}
+
+{{- $css_class := .Get 0 | default "table" -}}
+{{- $html_table := .Inner | markdownify -}}
+{{- $html_table = replace $html_table "<table>" (printf `<div class="table-responsive"><table class="%s">` $css_class) -}}
+{{- $html_table = replace $html_table "</table>" "</table></div>" -}}
+{{- $html_table | safeHTML -}}
diff --git a/site/layouts/shortcodes/callout.html b/site/layouts/shortcodes/callout.html
new file mode 100644
index 0000000..86683ec
--- /dev/null
+++ b/site/layouts/shortcodes/callout.html
@@ -0,0 +1,9 @@
+{{- /*
+ Usage: `callout "type"`, where `type` is one of info (default), danger, or warning
+*/ -}}
+
+{{- $css_class := .Get 0 | default "info" -}}
+
+<div class="bd-callout bd-callout-{{ $css_class }}">
+{{ .Inner | markdownify }}
+</div>
diff --git a/site/layouts/shortcodes/docsref.html b/site/layouts/shortcodes/docsref.html
new file mode 100644
index 0000000..2379de2
--- /dev/null
+++ b/site/layouts/shortcodes/docsref.html
@@ -0,0 +1 @@
+{{- relref . ((path.Join "docs" $.Site.Params.docs_version (.Get 0)) | relURL) -}}
diff --git a/site/layouts/shortcodes/example.html b/site/layouts/shortcodes/example.html
new file mode 100644
index 0000000..c6dcddb
--- /dev/null
+++ b/site/layouts/shortcodes/example.html
@@ -0,0 +1,47 @@
+{{- /*
+ Usage: `example args`
+
+ `args` are all optional and can be one of the following:
+ * id: the `div`'s id - default: ""
+ * class: any extra class(es) to be added to the `div` - default: ""
+ * lang: language used to display the code - default: "html"
+ * show_markup: if the markup should be output in the HTML - default: `true`
+ * show_preview: if the preview should be output in the HTML - default: `true`
+ * stackblitz_add_js: if extra JS snippet should be added to StackBlitz - default: `false`
+*/ -}}
+
+{{- $id := .Get "id" -}}
+{{- $class := .Get "class" -}}
+{{- $lang := .Get "lang" | default "html" -}}
+{{- $stackblitz_add_js := .Get "stackblitz_add_js" | default false -}}
+{{- $show_markup := .Get "show_markup" | default true -}}
+{{- $show_preview := .Get "show_preview" | default true -}}
+{{- $input := .Inner -}}
+
+<div class="bd-example-snippet bd-code-snippet">
+ {{- if eq $show_preview true -}}
+ <div{{ with $id }} id="{{ . }}"{{ end }} class="bd-example{{ with $class }} {{ . }}{{ end }}">
+ {{- $input -}}
+ </div>
+ {{- end -}}
+
+ {{- if eq $show_markup true -}}
+ {{- if eq $show_preview true -}}
+ <div class="d-flex align-items-center highlight-toolbar bg-light ps-3 pe-2 py-1">
+ <small class="font-monospace text-muted 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">
+ <svg class="bi" role="img" aria-label="Try it"><use xlink:href="#lightning-charge-fill"/></svg>
+ </button>
+ <button type="button" class="btn-clipboard mt-0 me-0" title="Copy to clipboard">
+ <svg class="bi" role="img" aria-label="Copy"><use xlink:href="#clipboard"/></svg>
+ </button>
+ </div>
+ </div>
+ {{- end -}}
+
+ {{- $content := replaceRE `<svg class="bd-placeholder-img(?:-lg)?(?: *?bd-placeholder-img-lg)? ?(.*?)".*?<\/svg>\n` `<img src="..." class="$1" alt="...">` $input -}}
+ {{- $content = replaceRE ` (class=" *?")` "" $content -}}
+ {{- highlight (trim $content "\n") $lang "" -}}
+ {{- end -}}
+</div>
diff --git a/site/layouts/shortcodes/js-dismiss.html b/site/layouts/shortcodes/js-dismiss.html
new file mode 100644
index 0000000..45d72d0
--- /dev/null
+++ b/site/layouts/shortcodes/js-dismiss.html
@@ -0,0 +1,15 @@
+{{- /* Usage: js-dismiss "ComponentName" */ -}}
+
+{{- $name := .Get 0 -}}
+
+Dismissal can be achieved with the `data` attribute on a button **within the {{ $name }}** as demonstrated below:
+
+```html
+<button type="button" class="btn-close" data-bs-dismiss="{{ $name }}" aria-label="Close"></button>
+```
+
+or on a button **outside the {{ $name }}** using the `data-bs-target` as demonstrated below:
+
+```html
+<button type="button" class="btn-close" data-bs-dismiss="{{ $name }}" data-bs-target="#my-{{ $name }}" aria-label="Close"></button>
+```
diff --git a/site/layouts/shortcodes/markdown.html b/site/layouts/shortcodes/markdown.html
new file mode 100644
index 0000000..82107bc
--- /dev/null
+++ b/site/layouts/shortcodes/markdown.html
@@ -0,0 +1 @@
+{{- .Inner | markdownify -}}
diff --git a/site/layouts/shortcodes/param.html b/site/layouts/shortcodes/param.html
new file mode 100644
index 0000000..34ad00c
--- /dev/null
+++ b/site/layouts/shortcodes/param.html
@@ -0,0 +1,14 @@
+{{- /*
+ Work around wrong escapes in integrity attributes.
+ Original: https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/shortcodes/param.html
+*/ -}}
+
+{{- $name := .Get 0 -}}
+{{- with $name -}}
+{{- $value := $.Page.Param . -}}
+{{- /* If any parameter ends with `_hash`, mark the string as safe HTML */ -}}
+{{- if (strings.HasSuffix $name "_hash") -}}
+ {{- $value = $value | safeHTML -}}
+{{- end -}}
+{{- with $value }}{{ . }}{{ else }}{{ errorf "Param %q not found: %s" $name $.Position }}{{ end -}}
+{{- else }}{{ errorf "Missing param key: %s" $.Position }}{{ end -}}
diff --git a/site/layouts/shortcodes/partial.html b/site/layouts/shortcodes/partial.html
new file mode 100644
index 0000000..c9d3496
--- /dev/null
+++ b/site/layouts/shortcodes/partial.html
@@ -0,0 +1 @@
+{{ partial (.Get 0) . }}
diff --git a/site/layouts/shortcodes/placeholder.html b/site/layouts/shortcodes/placeholder.html
new file mode 100644
index 0000000..c267bf4
--- /dev/null
+++ b/site/layouts/shortcodes/placeholder.html
@@ -0,0 +1,33 @@
+{{- /*
+ Usage: `placeholder args`
+
+ `args` are all optional and can be one of the following:
+ * title: Used in the SVG `title` tag - default: "Placeholder"
+ * text: The text to show in the image - default: "width x height"
+ * class: Class to add to the `svg` - default: "bd-placeholder-img"
+ * color: The text color (foreground) - default: "#dee2e6"
+ * background: The background color - default: "#868e96"
+ * width: default: "100%"
+ * height: default: "180px"
+*/ -}}
+
+{{- $grays := $.Site.Data.grays -}}
+{{- $default_color := (index $grays 2).hex -}}
+{{- $default_background := (index $grays 5).hex -}}
+
+{{- $title := .Get "title" | default "Placeholder" -}}
+{{- $class := .Get "class" -}}
+{{- $color := .Get "color" | default $default_color -}}
+{{- $background := .Get "background" | default $default_background -}}
+{{- $width := .Get "width" | default "100%" -}}
+{{- $height := .Get "height" | default "180" -}}
+{{- $text := .Get "text" | default (printf "%sx%s" $width $height) -}}
+
+{{- $show_title := not (eq $title "false") -}}
+{{- $show_text := not (eq $text "false") -}}
+
+<svg class="bd-placeholder-img{{ with $class }} {{ . }}{{ end }}" width="{{ $width }}" height="{{ $height }}" xmlns="http://www.w3.org/2000/svg"{{ if (or $show_title $show_text) }} role="img" aria-label="{{ if $show_title }}{{ $title }}{{ if $show_text }}: {{ end }}{{ end }}{{ if ($show_text) }}{{ $text }}{{ end }}"{{ else }} aria-hidden="true"{{ end }} preserveAspectRatio="xMidYMid slice" focusable="false">
+ {{- if $show_title }}<title>{{ $title }}</title>{{ end -}}
+ <rect width="100%" height="100%" fill="{{ $background }}"/>
+ {{- if $show_text }}<text x="50%" y="50%" fill="{{ $color }}" dy=".3em">{{ $text }}</text>{{ end -}}
+</svg>
diff --git a/site/layouts/shortcodes/scss-docs.html b/site/layouts/shortcodes/scss-docs.html
new file mode 100644
index 0000000..3d1cd09
--- /dev/null
+++ b/site/layouts/shortcodes/scss-docs.html
@@ -0,0 +1,43 @@
+{{- /*
+ Usage: `scss-docs name="name" file="file/_location.scss"`
+
+ Prints everything between `// scss-docs-start "name"` and `// scss-docs-end "name"`
+ comments in the docs.
+
+ Optional parameters:
+ * strip-default: Remove the ` !default` flag from variable assignments - default: `true`
+*/ -}}
+
+{{- $name := .Get "name" -}}
+{{- $file := .Get "file" -}}
+{{- $strip_default := .Get "strip-default" | default "true" -}}
+
+{{- /* If any parameters are missing, print an error and exit */ -}}
+{{- if or (not $name) (not $file) -}}
+ {{- errorf "%s: %q: Missing required parameters! Got: name=%q file=%q!" .Position .Name $name $file -}}
+{{- else -}}
+ {{- $capture_start := printf "// scss-docs-start %s\n" $name -}}
+ {{- $capture_end := printf "// scss-docs-end %s" $name -}}
+ {{- $regex := printf `%s((?:.|\n)*)%s` $capture_start $capture_end -}}
+
+ {{- /*
+ TODO: figure out why we can't do the following and get the first group (the only capturing one)...
+ $regex := printf `(?:// scss-docs-start %s\n)((?:.|\n)*)(?:\n// scss-docs-end %s)` $name $name
+ */ -}}
+
+ {{- $match := findRE $regex (readFile $file) -}}
+ {{- $match = index $match 0 -}}
+
+ {{- if not $match -}}
+ {{- errorf "%s: %q: Got no matches for name=%q in file=%q!" .Position .Name $name $file -}}
+ {{- end -}}
+
+ {{- $match = replace $match $capture_start "" -}}
+ {{- $match = replace $match $capture_end "" -}}
+
+ {{- if (ne $strip_default "false") -}}
+ {{- $match = replace $match " !default" "" -}}
+ {{- end -}}
+
+ {{- highlight $match "scss" "" -}}
+{{- end -}}
diff --git a/site/layouts/shortcodes/table.html b/site/layouts/shortcodes/table.html
new file mode 100644
index 0000000..a98b5eb
--- /dev/null
+++ b/site/layouts/shortcodes/table.html
@@ -0,0 +1,31 @@
+{{- /*
+ Usage: `table [args]`
+
+ `args` are optional and can be one of the following:
+ * class: any class(es) to be added to the `table` - default ""
+ * simplified: show a simplified version in the examples - default `true`
+*/ -}}
+
+{{- $class := .Get "class" -}}
+{{- $simplified := .Get "simplified" | default true -}}
+
+{{- $table_attributes := "" -}}
+{{- $table_content := " ...\n" -}}
+
+{{- with $class -}}
+ {{- $table_attributes = printf ` class="%s"` . -}}
+{{- end -}}
+
+{{- if eq $simplified "false" -}}
+ {{- $table_content = partialCached "table-content" . -}}
+{{- end -}}
+
+{{- $table := printf "<table%s>\n%s</table>" $table_attributes $table_content -}}
+
+<div class="bd-example">
+ <table{{ with $class }} class="{{ . }}"{{ end }}>
+ {{ partialCached "table-content" . }}
+ </table>
+</div>
+
+{{- highlight $table "html" "" -}}
diff --git a/site/layouts/shortcodes/year.html b/site/layouts/shortcodes/year.html
new file mode 100644
index 0000000..db7f18e
--- /dev/null
+++ b/site/layouts/shortcodes/year.html
@@ -0,0 +1,3 @@
+{{- /* Outputs the current year */ -}}
+
+{{- now.Format "2006" -}}