Skip to content

Commit

Permalink
Merge pull request #726 from alphagov/new-font-loading-strategy
Browse files Browse the repository at this point in the history
Use new font loading strategy
  • Loading branch information
36degrees authored May 29, 2018
2 parents ae74ddf + 83b9e53 commit 3aabcc7
Show file tree
Hide file tree
Showing 23 changed files with 113 additions and 25 deletions.
33 changes: 33 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,39 @@ Note: We're not following semantic versioning yet, we are going to talk about th

## Unreleased

💥 Breaking changes:

- The `govuk-file-url` helper has been renamed to to `govuk-image-url`. If you
are using this function in your own styles you will need to update calls to
it. ([PR #726](https://github.com/alphagov/govuk-frontend/pull/726))

- The `$govuk-global-images` variable has been renamed to to
`$govuk-images-path`. If you are overriding this variable or using it in your
own styles you will need to update your code to use the new variable name.
([PR #726](https://github.com/alphagov/govuk-frontend/pull/726))


🔧 Fixes:

- Fixes a bug whereby print styles were being 'rasterized' into the screen
styles when generating the IE8 stylesheet (this is a bug in sass-mq, and has
also been raised upstream – https://github.com/sass-mq/sass-mq/pull/111).
([PR #726](https://github.com/alphagov/govuk-frontend/pull/726))


🆕 New features:

- Change font delivery method from Base64 encoded strings to serving WOFF2, WOFF
and EOT files as separate HTTP requests. You will need to ensure that you are
serving the fonts from the assets folder as part of your application.
([PR #726](https://github.com/alphagov/govuk-frontend/pull/726))

- The font-face is now using `font-display: fallback`. This means that the
fallback font (Arial) will be used if NTA doesn't download within 100ms. The
browser will then swap to NTA as long as it loads within the short swap period.
([PR #726](https://github.com/alphagov/govuk-frontend/pull/726))


🏠 Internal:

- Improve release steps, based on doing a release
Expand Down
Binary file added src/assets/fonts/bold-a2452cb66f-v1.woff2
Binary file not shown.
Binary file added src/assets/fonts/bold-f38c792ac2-v1.woff
Binary file not shown.
Binary file added src/assets/fonts/bold-fb2676462a-v1.eot
Binary file not shown.
Binary file added src/assets/fonts/bold-tabular-357fdfbcc3-v1.eot
Binary file not shown.
Binary file added src/assets/fonts/bold-tabular-784c21afb8-v1.woff
Binary file not shown.
Binary file added src/assets/fonts/bold-tabular-b89238d840-v1.woff2
Binary file not shown.
Binary file added src/assets/fonts/light-2c037cf7e1-v1.eot
Binary file not shown.
Binary file added src/assets/fonts/light-458f8ea81c-v1.woff
Binary file not shown.
Binary file added src/assets/fonts/light-f38ad40456-v1.woff2
Binary file not shown.
Binary file added src/assets/fonts/light-tabular-498ea8ffe2-v1.eot
Binary file not shown.
Binary file added src/assets/fonts/light-tabular-62cc6f0a28-v1.woff
Binary file not shown.
Binary file not shown.
4 changes: 2 additions & 2 deletions src/components/button/_button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,12 @@
padding-bottom: $govuk-spacing-scale-2 - $govuk-border-width-form-element;
padding-left: $govuk-spacing-scale-3;

background-image: govuk-file-url("icon-pointer.png");
background-image: govuk-image-url("icon-pointer.png");
background-repeat: no-repeat;
background-position: 100% 50%;

@include govuk-device-pixel-ratio {
background-image: govuk-file-url("icon-pointer-2x.png");
background-image: govuk-image-url("icon-pointer-2x.png");
background-size: 30px 19px;
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/components/footer/_footer.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
$govuk-footer-link: $govuk-footer-text;
$govuk-footer-link-hover: #171819;

// Based on the `govuk-file-url("govuk-crest-2x.png");` image dimensions.
// Based on the govuk-crest-2x.png image dimensions.
$govuk-footer-crest-image-width-2x: 250px;
$govuk-footer-crest-image-height-2x: 204px;
// Half the 2x image so that it fits the regular 1x size.
Expand Down Expand Up @@ -105,9 +105,9 @@
display: inline-block;
min-width: $govuk-footer-crest-image-width;
padding-top: ($govuk-footer-crest-image-height + $govuk-spacing-scale-2);
background-image: govuk-file-url("govuk-crest.png");
background-image: govuk-image-url("govuk-crest.png");
@include govuk-device-pixel-ratio {
background-image: govuk-file-url("govuk-crest-2x.png");
background-image: govuk-image-url("govuk-crest-2x.png");
}
background-repeat: no-repeat;
background-position: 50% 0%;
Expand Down
38 changes: 27 additions & 11 deletions src/helpers/_font-faces.scss

Large diffs are not rendered by default.

14 changes: 12 additions & 2 deletions src/settings/_paths.scss
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
// Set the path to your images folder
$govuk-global-images: "/assets/images/" !default;
/// Path to the assets directory, with trailing slash.
///
/// This is the directory where the images and fonts subdirectories live. You
/// will need to make this directory available via your application – see the
/// README for details.
$govuk-assets-path: "/assets/" !default;

// Path to the images folder, with trailing slash.
$govuk-images-path: "#{$govuk-assets-path}images/" !default;

// Path to the fonts folder, with trailing slash.
$govuk-fonts-path: "#{$govuk-assets-path}fonts/" !default;
3 changes: 2 additions & 1 deletion src/tools/_all.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@import "compatibility";
@import "exports";
@import "file-url";
@import "font-url";
@import "ie8";
@import "iff";
@import "image-url";
@import "px-to-em";
5 changes: 0 additions & 5 deletions src/tools/_file-url.scss

This file was deleted.

7 changes: 7 additions & 0 deletions src/tools/_font-url.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/// Font URL
///
/// Returns a URL for the given font filename

@function govuk-font-url($filename) {
@return url($govuk-fonts-path + $filename);
}
7 changes: 7 additions & 0 deletions src/tools/_image-url.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/// Image URL
///
/// Returns a URL for the given image filename

@function govuk-image-url($filename) {
@return url($govuk-images-path + $filename);
}
1 change: 1 addition & 0 deletions src/vendor/_sass-mq.scss
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ $mq-media-type: all !default;
and (
$until == false or $max-width >= $target-width
)
and $media-type != 'print'
) {
@content;
}
Expand Down
20 changes: 19 additions & 1 deletion src/vendor/sass-mq.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ describe('sass-mq', () => {
expect(results.css.toString().trim()).toBe('@media aural and (max-width: 40em){.foo{color:red}}')
})

it('only outputs static breapoint styles', async() => {
it('only outputs static breakpoint styles', async() => {
const sass = `
$mq-breakpoints: (
mobile: 320px,
Expand All @@ -281,5 +281,23 @@ describe('sass-mq', () => {

expect(results.css.toString().trim()).toBe('.foo{color:forestgreen}')
})

it('does not rasterize print queries', async() => {
const sass = `
$mq-responsive: false;
@import "vendor/sass-mq";
.foo {
color: blue;
@include mq($media-type: 'print') {
color: red;
}
}`

const results = await sassRender({ data: sass, ...sassConfig })

expect(results.css.toString().trim()).toBe('.foo{color:blue}')
})
})
})

0 comments on commit 3aabcc7

Please sign in to comment.