Skip to content
Closed
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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ The changelog only includes changes specific to the RubyGem.
The Bootstrap framework changes can be found in [the Releases section of twbs/bootstrap](https://github.com/twbs/bootstrap/releases).
Release announcement posts on [the official Bootstrap blog](http://blog.getbootstrap.com) contain summaries of the most noteworthy changes made in each release of Bootstrap.

# Unreleased

* Bundle [Bootstrap Icons](https://icons.getbootstrap.com/) v1.13.1 (Sass + web fonts), opt-in via
`@import "bootstrap-icons-sprockets"` (Sprockets), `@import "bootstrap-icons-propshaft"`
(Propshaft), or `@import "bootstrap-icons"`.
[#276](https://github.com/twbs/bootstrap-rubygem/issues/276)

# 5.3.4

* Autoprefixer is now optional.
Expand Down
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,38 @@ the concatenated `bootstrap` for faster compilation:
//= require bootstrap
```

#### Bootstrap Icons

The gem also bundles [Bootstrap Icons](https://icons.getbootstrap.com/) (Sass and the icon web fonts),
so icons can be served from your own app through the asset pipeline instead of a CDN.
Their use is entirely optional — nothing is included unless you import them.

With Sprockets (`dartsass-sprockets` or `sassc-rails`), import the Sprockets variant,
which resolves the fonts through the asset pipeline:

```scss
@import "bootstrap-icons-sprockets";
```

With Propshaft (`dartsass-rails`), import the Propshaft variant, which emits
root-relative font URLs that Propshaft rewrites to the digested paths
(without upstream's `?hash` query string, so the URLs also match
`preload_link_tag "bootstrap-icons.woff2"` if you preload the font):

```scss
@import "bootstrap-icons-propshaft";
```

Otherwise, import `bootstrap-icons` and override
[`$bootstrap-icons-font-dir` or `$bootstrap-icons-font-src`](assets/stylesheets/_bootstrap-icons.scss)
to wherever the fonts (in [assets/fonts](assets/fonts)) are served from.

Then use icons as usual:

```html
<i class="bi bi-alarm"></i>
```

### b. Other Ruby frameworks

If your framework uses Sprockets or Hanami,
Expand Down
6 changes: 6 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ task :update, :branch do |t, args|
Updater.new(branch: args[:branch]).update_bootstrap
end

desc 'Update Bootstrap Icons from the bootstrap-icons npm package'
task :update_icons, :version do |t, args|
require './tasks/updater/icons'
IconsUpdater.new(version: args[:version]).update_icons
end

desc 'Start a dummy Rails app server'
task :rails_server do
require 'rack'
Expand Down
Binary file added assets/fonts/bootstrap-icons.woff
Binary file not shown.
Binary file added assets/fonts/bootstrap-icons.woff2
Binary file not shown.
12 changes: 12 additions & 0 deletions assets/stylesheets/_bootstrap-icons-propshaft.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Bootstrap Icons for Propshaft: resolves the icon fonts through the asset pipeline.
// Import this instead of "bootstrap-icons" when using Propshaft (e.g. with dartsass-rails):
//
// @import "bootstrap-icons-propshaft";
//
// The root-relative URLs are logical asset paths that Propshaft rewrites to digested
// paths. Upstream's "?hash" cache-buster is dropped: Propshaft already fingerprints
// the filename, and the query string would make the CSS font URL differ from
// preload_link_tag's URL, causing browsers to download the font twice.
$bootstrap-icons-font-src: url("/bootstrap-icons.woff2") format("woff2"), url("/bootstrap-icons.woff") format("woff") !default;

@import "bootstrap-icons";
7 changes: 7 additions & 0 deletions assets/stylesheets/_bootstrap-icons-sprockets.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Bootstrap Icons for Sprockets: resolves the icon fonts through the asset pipeline.
// Import this instead of "bootstrap-icons" when using Sprockets:
//
// @import "bootstrap-icons-sprockets";
$bootstrap-icons-font-src: font-url("bootstrap-icons.woff2") format("woff2"), font-url("bootstrap-icons.woff") format("woff") !default;

@import "bootstrap-icons";
Loading