0
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-02-07 04:54:24 +01:00
Bootstrap/site/_includes/icons/placeholder.svg
XhmikosR 2ac3db8384 Tweak placeholder.svg.
* always include the title
* make it possible to skip adding the title by passing `title=' '`
* remove viewBox since we don't need it
2018-11-20 21:31:28 +02:00

36 lines
1.4 KiB
XML

{%- comment -%}
Usage: include icons/placeholder.svg args
args can be one of the following:
title: Used in the SVG `title` tag
text: The text to show in the image - default: 'width x height'
class: default: 'bd-placeholder-img'
color: The text color (foreground) - default: '#ddd'
background: The background color - default: '#777'
width: default: 100%
height: default: 180px
{%- endcomment -%}
{%- assign title = include.title | default: 'Generic Placeholder Image' -%}
{%- assign class = include.class | default: '' -%}
{%- assign color = include.color | default: '#ddd' -%}
{%- assign background = include.background | default: '#777' -%}
{%- assign width = include.width | default: '100%' -%}
{%- assign height = include.height | default: '180' -%}
{%- if include.text -%}
{%- assign text = include.text -%}
{%- else -%}
{%- assign text = width | append: 'x' | append: height -%}
{%- endif -%}
{%- capture svg -%}
<svg class="bd-placeholder-img{% if class != '' %} {{ class }}{% endif %}" width="{{ width }}" height="{{ height }}" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid slice">
{% if title != ' ' %}<title>{{ title }}</title>{% endif %}
<rect fill="{{ background }}" width="100%" height="100%"/>
{% if text != ' ' %}<text fill="{{ color }}" dy=".3em" x="50%" y="50%">{{ text }}</text>{% endif %}
</svg>
{%- endcapture -%}
{{- svg | replace: ' ', '' | strip_newlines -}}