Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace holder.js with inline SVG #27633

Merged
merged 7 commits into from
Nov 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions build/vnu-jar.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ childProcess.exec('java -version', (error, stdout, stderr) => {
// Firefox's non-standard autocomplete behavior - see https://bugzilla.mozilla.org/show_bug.cgi?id=654072
'Attribute “autocomplete” is only allowed when the input type is.*',
'Attribute “autocomplete” not allowed on element “button” at this point.',
// We use holder.js with `data-src` and no `src` to avoid 404 errors;
// we could work around this, but I'm not sure it's worth it.
'Element “img” is missing required attribute “src”.',
// Markup used in Components → Forms → Layout → Form grid → Horizontal form is currently invalid,
// but used this way due to lack of support for flexbox layout on <fieldset> element in most browsers
'Element “legend” not allowed as child of element “div” in this context.*',
Expand Down
4 changes: 2 additions & 2 deletions js/tests/visual/toast.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ <h1>Toast <small>Bootstrap Visual Test</small></h1>
<div class="notifications">
<div id="toastAutoHide" class="toast" role="alert" aria-live="assertive" aria-atomic="true" data-delay="2000">
<div class="toast-header">
<img class="rounded mr-2" data-src="holder.js/20x20?size=1&text=.&bg=#007aff" alt="">
<span class="d-block bg-primary rounded mr-2" style="width: 20px; height: 20px;"></span>
XhmikosR marked this conversation as resolved.
Show resolved Hide resolved
<strong class="mr-auto">Bootstrap</strong>
<small>11 mins ago</small>
</div>
Expand All @@ -39,7 +39,7 @@ <h1>Toast <small>Bootstrap Visual Test</small></h1>

<div class="toast" data-autohide="false" role="alert" aria-live="assertive" aria-atomic="true">
<div class="toast-header">
<img class="rounded mr-2" data-src="holder.js/20x20?size=1&text=.&bg=#007aff" alt="">
<span class="d-block bg-primary rounded mr-2" style="width: 20px; height: 20px;"></span>
<strong class="mr-auto">Bootstrap</strong>
<small class="text-muted">2 seconds ago</small>
<button type="button" class="ml-2 mb-1 close" data-dismiss="toast" aria-label="Close">
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"js-minify-main": "npm-run-all js-minify-standalone js-minify-bundle",
"js-minify-standalone": "uglifyjs --compress typeofs=false --mangle --comments \"/^!/\" --source-map \"content=dist/js/bootstrap.js.map,includeSources,url=bootstrap.min.js.map\" --output dist/js/bootstrap.min.js dist/js/bootstrap.js",
"js-minify-bundle": "uglifyjs --compress typeofs=false --mangle --comments \"/^!/\" --source-map \"content=dist/js/bootstrap.bundle.js.map,includeSources,url=bootstrap.bundle.min.js.map\" --output dist/js/bootstrap.bundle.min.js dist/js/bootstrap.bundle.js",
"js-minify-docs": "cross-env-shell uglifyjs --mangle --comments \\\"/^!/\\\" --output site/docs/$npm_package_version_short/assets/js/docs.min.js site/docs/$npm_package_version_short/assets/js/vendor/clipboard.min.js site/docs/$npm_package_version_short/assets/js/vendor/holder.min.js site/docs/$npm_package_version_short/assets/js/vendor/bs-custom-file-input.min.js \"site/docs/$npm_package_version_short/assets/js/src/*.js\"",
"js-minify-docs": "cross-env-shell uglifyjs --mangle --comments \\\"/^!/\\\" --output site/docs/$npm_package_version_short/assets/js/docs.min.js site/docs/$npm_package_version_short/assets/js/vendor/clipboard.min.js site/docs/$npm_package_version_short/assets/js/vendor/bs-custom-file-input.min.js \"site/docs/$npm_package_version_short/assets/js/src/*.js\"",
"js-test": "npm-run-all js-test-karma*",
"js-test-karma": "karma start js/tests/karma.conf.js",
"js-test-karma-old": "cross-env USE_OLD_JQUERY=true npm run js-test-karma",
Expand Down
6 changes: 3 additions & 3 deletions site/_includes/bugify.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{%- comment -%}
Usage: {% include bugify.html content=text %},
where content is a string that contains a bug reference name and id.
e.g. Bootstrap#19984
Usage: include bugify.html content=text,
where content is a string that contains a bug reference name and id.
e.g. Bootstrap#19984
{%- endcomment -%}

{%- assign words = include.content | split: " " -%}
Expand Down
6 changes: 3 additions & 3 deletions site/_includes/callout.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{%- comment -%}
Usage: {% include callout.html content=callout type="type" %},
where content is a capture with the content
and type is one of: info (default), danger, warning
Usage: include callout.html content=callout type="type",
where content is a capture with the content
and type is one of: info (default), danger, warning
{%- endcomment -%}
{%- assign css_class = include.type | default: "info" -%}
<div class="bd-callout bd-callout-{{ css_class }} no_toc_section">
Expand Down
14 changes: 0 additions & 14 deletions site/_includes/docs-sidebar.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,6 @@
<a href="{{ site.baseurl }}/docs/{{ site.docs_version }}/{{ group_slug }}/{{ doc_slug }}/">
{{ doc.title }}
</a>

{%- comment -%}
{% unless doc.sections == nil %}
<ul class="nav">
{% for section in doc.sections %}
<li>
<a href="#{{ section.title | downcase | replace: ' ', '-' }}">
{{ section.title }}
</a>
</li>
{% endfor %}
</ul>
{% endunless %}
{%- endcomment -%}
XhmikosR marked this conversation as resolved.
Show resolved Hide resolved
</li>
{%- endfor -%}
</ul>
Expand Down
47 changes: 33 additions & 14 deletions site/_includes/example.html
Original file line number Diff line number Diff line change
@@ -1,32 +1,51 @@
{%- comment -%}
Usage: {% include example.html content=markup %},
where content is a capture with the HTML content
id - null (default)
class - "bd-example" (default)
optional: hide_preview - disabled (default)
optional: hide_markup - disabled (default)
Usage: include example.html content=markup [args],
where content is a capture with the HTML content

args can be one of the following:
id - null (default)
class - "bd-example" (default)
optional: hide_preview - disabled (default)
optional: hide_markup - disabled (default)
{%- endcomment -%}

{%- assign preview_id = include.id -%}
{%- assign preview_class = include.class -%}
{%- assign id = include.id -%}
{%- assign class = include.class -%}

{%- if include.hide_preview == null -%}
<div{% if preview_id %} id="{{ preview_id }}"{% endif %} class="bd-example{% if preview_class %} {{ preview_class }}{% endif %}">
<div{% if id %} id="{{ id }}"{% endif %} class="bd-example{% if class %} {{ class }}{% endif %}">
{{- include.content -}}
</div>
{%- endif -%}

{%- if include.hide_markup == null -%}
{%- highlight html -%}
{%- if include.content contains 'data-src="holder.js' -%}
{%- if include.content contains '<svg class="bd-placeholder-img' -%}
{%- assign modified_content = include.content
| replace: 'data-src="holder.js', 'src="✂️holder.js'
| replace: '" ', '✂️" '
| replace: '<svg class="bd-placeholder-img', '✂️<svg class="bd-placeholder-img'
| replace: '</svg>', '</svg>✂️'
| split: '✂️' -%}

{%- if include.content contains 'bd-placeholder-img ' -%}
{%- assign image_class = include.content
| replace_first: 'bd-placeholder-img', 'bd-placeholder-img ✂️'
| replace: '" width="', '✂️" width="'
| split: '✂️' -%}
{%- assign image_class = image_class[1] | replace: 'bd-placeholder-img-lg', '' | strip -%}
{%- endif -%}

{%- assign image_alt = include.content
| replace: '<title>', '<title>✂️'
| replace: '</title>', '✂️</title>'
| split: '✂️' -%}
{%- assign image_alt = image_alt[1] -%}

{%- for content_chunk in modified_content -%}
{%- if content_chunk contains 'holder.js' -%}
{{- "..." -}}
{%- if content_chunk contains '<svg class="bd-placeholder-img' -%}
{%- capture img_placeholder -%}
<img src="..." {% if image_class %}class="{{ image_class }}" {% endif %}alt="{{ image_alt }}">
{%- endcapture -%}
{{- img_placeholder -}}
{%- else -%}
{{- content_chunk -}}
{%- endif -%}
Expand Down
35 changes: 35 additions & 0 deletions site/_includes/icons/placeholder.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion site/_includes/scripts.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
<script src="{{ site.baseurl }}/docs/{{ site.docs_version }}/assets/js/docs.min.js"></script>
{%- else -%}
<script src="{{ site.baseurl }}/docs/{{ site.docs_version }}/assets/js/vendor/clipboard.min.js"></script>
<script src="{{ site.baseurl }}/docs/{{ site.docs_version }}/assets/js/vendor/holder.min.js"></script>
<script src="{{ site.baseurl }}/docs/{{ site.docs_version }}/assets/js/vendor/bs-custom-file-input.min.js"></script>
<script src="{{ site.baseurl }}/docs/{{ site.docs_version }}/assets/js/src/application.js"></script>
<script src="{{ site.baseurl }}/docs/{{ site.docs_version }}/assets/js/src/search.js"></script>
Expand Down
17 changes: 13 additions & 4 deletions site/_layouts/examples.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,19 @@

{% include stylesheet.html %}

<style>
.bd-placeholder-img {
font-size: 1.125rem;
text-anchor: middle;
}

@media (min-width: 768px) {
.bd-placeholder-img-lg {
font-size: 3.5rem;
}
}
</style>

{%- for css in page.extra_css %}
<!-- Custom styles for this template -->
<link href="{{ css }}" rel="stylesheet">
Expand All @@ -28,10 +41,6 @@
<script src="{{ site.baseurl }}/docs/{{ site.docs_version }}/dist/js/bootstrap.bundle.js"></script>
{%- endif -%}

{%- if page.include_holder == true -%}
<script src="{{ site.baseurl }}/docs/{{ site.docs_version }}/assets/js/vendor/holder.min.js"></script>
{%- endif -%}

{%- for js in page.extra_js %}
<script src="{{ js }}"></script>
{%- endfor %}
Expand Down
10 changes: 1 addition & 9 deletions site/docs/4.1/assets/js/src/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* details, see https://creativecommons.org/licenses/by/3.0/.
*/

/* global ClipboardJS: false, Holder: false, bsCustomFileInput: false */
/* global ClipboardJS: false, bsCustomFileInput: false */

(function ($) {
'use strict'
Expand Down Expand Up @@ -103,14 +103,6 @@

$('.bd-content > h2, .bd-content > h3, .bd-content > h4, .bd-content > h5').wrapInner('<div></div>')

// Holder
Holder.addTheme('gray', {
bg: '#777',
fg: 'rgba(255,255,255,.75)',
font: 'Helvetica',
fontweight: 'normal'
})

bsCustomFileInput.init()
})
}(jQuery))
13 changes: 0 additions & 13 deletions site/docs/4.1/assets/js/vendor/holder.min.js

This file was deleted.

5 changes: 3 additions & 2 deletions site/docs/4.1/assets/scss/_component-examples.scss
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,9 @@
}

// Images
.bd-example > img {
+ img {
.bd-example {
> svg + svg,
> img + img {
margin-left: .5rem;
}
}
Expand Down
16 changes: 16 additions & 0 deletions site/docs/4.1/assets/scss/_placeholder-img.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// Placeholder svg used in the docs.
//

// Remember to update `site/_layouts/examples.html` too if this changes!

.bd-placeholder-img {
font-size: 1.125rem;
text-anchor: middle;
}

.bd-placeholder-img-lg {
@include media-breakpoint-up(md) {
font-size: 3.5rem;
}
}
1 change: 1 addition & 0 deletions site/docs/4.1/assets/scss/docs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
@import "brand";
@import "colors";
@import "clipboard-js";
@import "placeholder-img";

// Load docs dependencies
@import "syntax";
Expand Down
Loading