Skip to content

Commit

Permalink
Deprecrate the $weight and $style arguments in the font-face mixin
Browse files Browse the repository at this point in the history
Now that the `font-face` mixin accepts additional CSS rules via the `@content`
directive (2356719), it no longer makes sense
to have weight and style as arguments, which we never need to manipulate.
  • Loading branch information
Tyson Gach committed Feb 5, 2016
1 parent bf81bfa commit 5641ef7
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 70 deletions.
20 changes: 7 additions & 13 deletions core/bourbon/addons/_font-face.scss
@@ -1,17 +1,17 @@
@charset "UTF-8";

/// Generates an @font-face declaration. Accepts arguments for weight, style,
/// usage with the Rails Asset Pipeline and file formats. Also possible to
/// pass additional `@content` to the mixin, for instance `unicode-range`.
/// Generates an `@font-face` declaration. You can choose the specific file
/// formats you need to output; the mixin supports `eot`, `ttf`, `svg`, `woff2`
/// and `woff`. The mixin also supports usage with the Rails Asset Pipeline,
/// which you can enable per use, or globally in the `$bourbon()` settings.
/// Finally, any additional CSS properties that are included in the `@include`
/// directive will be output within the `@font-face` declaration, e.g. you can
/// pass in `font-weight`, `font-style` and/or `unicode-range`.
///
/// @argument {string} $font-family
///
/// @argument {string} $file-path
///
/// @argument {string} $weight [normal]
///
/// @argument {string} $style [normal]
///
/// @argument {string} $asset-pipeline [false]
/// Set to `true` if you’re using the Rails Asset Pipeline (place the fonts
/// in `app/assets/fonts/`).
Expand All @@ -30,8 +30,6 @@
/// @example css
/// @font-face {
/// font-family: "source-sans-pro";
/// font-style: normal;
/// font-weight: normal;
/// src: url("fonts/source-sans-pro-regular.eot?#iefix")
/// format("embedded-opentype"),
/// url("fonts/source-sans-pro-regular.ttf")
Expand All @@ -47,8 +45,6 @@
@mixin font-face(
$font-family,
$file-path,
$weight: normal,
$style: normal,
$asset-pipeline: _bourbon-get-setting("rails-asset-pipeline"),
$file-formats: _bourbon-get-setting("global-font-file-formats")
) {
Expand All @@ -57,8 +53,6 @@

@font-face {
font-family: $font-family;
font-style: $style;
font-weight: $weight;
src: _font-source-declaration(
$font-family,
$file-path,
Expand Down
2 changes: 0 additions & 2 deletions spec/bourbon/addons/font_face_spec_1.rb
Expand Up @@ -8,8 +8,6 @@
context "called with defaults" do
it "outputs defaults" do
ruleset = 'font-family: "source-sans-pro"; ' +
'font-style: normal; ' +
'font-weight: normal; ' +
'src: url("/fonts/source-sans-pro/source-sans-pro-regular.woff2") format("woff2"), url("/fonts/source-sans-pro/source-sans-pro-regular.woff") format("woff"), url("/fonts/source-sans-pro/source-sans-pro-regular.ttf") format("truetype");'

expect("@font-face").to have_ruleset(ruleset)
Expand Down
18 changes: 10 additions & 8 deletions spec/bourbon/addons/font_face_spec_2.rb
Expand Up @@ -2,16 +2,18 @@

describe "font-face" do
before(:all) do
ParserSupport.parse_file("css3/font-face-2")
ParserSupport.parse_file("css3/font-face-5")
end

context "called with defaults" do
it "outputs defaults" do
ruleset = 'font-family: "roboto"; ' +
'font-style: italic; ' +
'font-weight: bold; ' +
'src: url("/assets/fonts/Roboto-BoldItalic.ttf") ' +
'format("truetype");'
context "called with additional CSS rules" do
it "outputs defaults with additional content" do
ruleset = 'font-family: "calibre"; ' +
'src: url("fonts/calibre.woff2") format("woff2"), ' +
'url("fonts/calibre.woff") format("woff"), ' +
'url("fonts/calibre.ttf") format("truetype"); ' +
"font-style: normal;" +
"font-weight: 600;" +
"unicode-range: U+26;"

expect("@font-face").to have_ruleset(ruleset)
end
Expand Down
6 changes: 2 additions & 4 deletions spec/bourbon/addons/font_face_spec_3.rb
Expand Up @@ -7,10 +7,8 @@

context "called with defaults" do
it "outputs defaults" do
ruleset = 'font-family: "pitch"; ' +
'font-style: normal; ' +
'font-weight: normal; ' +
'src: url("/fonts/pitch.woff") format("woff");'
ruleset = 'font-family: "pitch";' +
'src: font-url("/fonts/pitch.woff2") format("woff2");'

expect("@font-face").to have_ruleset(ruleset)
end
Expand Down
2 changes: 0 additions & 2 deletions spec/bourbon/addons/font_face_spec_4.rb
Expand Up @@ -8,8 +8,6 @@
context "called with defaults" do
it "outputs defaults" do
ruleset = 'font-family: "circular"; ' +
'font-style: normal; ' +
'font-weight: normal; ' +
'src: url("/circular.woff2") format("woff2"), ' +
'url("/circular.svg#circular") format("svg");'

Expand Down
21 changes: 0 additions & 21 deletions spec/bourbon/addons/font_face_spec_5.rb

This file was deleted.

2 changes: 0 additions & 2 deletions spec/bourbon/settings/bourbon_get_setting_spec.rb
Expand Up @@ -20,8 +20,6 @@
context "called from the font-face mixin" do
it "outputs user-overridden font file formats" do
ruleset = 'font-family: "source-sans-pro"; ' +
"font-style: normal; " +
"font-weight: normal; " +
'src: font-url("source-sans-pro-regular.woff2") ' +
'format("woff2"), ' +
'font-url("source-sans-pro-regular.woff") ' +
Expand Down
13 changes: 7 additions & 6 deletions spec/fixtures/addons/font-face-2.scss
@@ -1,9 +1,10 @@
@import "setup";

@include font-face(
"roboto",
"/assets/fonts/Roboto-BoldItalic",
bold,
italic,
$file-formats: "ttf"
);
"calibre",
"fonts/calibre"
) {
font-style: normal;
font-weight: 600;
unicode-range: U+26;
}
6 changes: 2 additions & 4 deletions spec/fixtures/addons/font-face-3.scss
Expand Up @@ -3,8 +3,6 @@
@include font-face(
"pitch",
"/fonts/pitch",
normal,
normal,
false,
"woff"
true,
"woff2"
);
8 changes: 0 additions & 8 deletions spec/fixtures/addons/font-face-5.scss

This file was deleted.

0 comments on commit 5641ef7

Please sign in to comment.