mirror of https://github.com/twbs/bootstrap.git
46 lines
2.7 KiB
HTML
46 lines
2.7 KiB
HTML
{{- /*
|
|
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` or `img` - default: "bd-placeholder-img"
|
|
* color: The text color (foreground) - default: "#dee2e6"
|
|
* background: The background color - default: "#868e96"
|
|
* width: default: "100%"
|
|
* height: default: "180px"
|
|
* markup: If it should render `svg` or `img` tags - default: "svg"
|
|
*/ -}}
|
|
|
|
{{- $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") -}}
|
|
|
|
{{- $markup := .Get "markup" | default "svg" -}}
|
|
|
|
|
|
{{- if eq $markup "img" -}}
|
|
<img class="bd-placeholder-img{{ with $class }} {{ . }}{{ end }}" alt="{{ $title }} : {{ $text }}" width="{{ $width }}" height="{{ $height }}" src="data:image/svg+xml,%3Csvg style='font-size: 1.125rem; font-family:system-ui,-apple-system,%22Segoe UI%22,Roboto,%22Helvetica Neue%22,%22Noto Sans%22,%22Liberation Sans%22,Arial,sans-serif,%22Apple Color Emoji%22,%22Segoe UI Emoji%22,%22Segoe UI Symbol%22,%22Noto Color Emoji%22; -webkit-user-select: none; -moz-user-select: none; user-select: none; text-anchor: middle;' width='200' height='200' xmlns='http://www.w3.org/2000/svg'%3E
|
|
{{- if $show_title }}%3Ctitle%3E{{ $title }}%3C/title%3E{{ end -}}
|
|
%3Crect width='100%25' height='100%25' fill='%23dee2e6'%3E%3C/rect%3E
|
|
{{- if $show_text }}%3Ctext x='50%25' y='50%25' fill='%23868e96' dy='.3em'%3E{{ $text }}%3C/text%3E{{ end -}}
|
|
%3C/svg%3E" />
|
|
{{- else -}}
|
|
<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>
|
|
{{- end -}}
|