Skip to content
This repository has been archived by the owner on Apr 28, 2020. It is now read-only.

Commit

Permalink
Add prep code for self-hosted webfonts
Browse files Browse the repository at this point in the history
- Add placeholder directory for self-hosted webfonts
- Adapt config.js so that webfonts from that placholder directory
  are copied to dist/ in deploy task
- Add + include mixins for modern + legacy webfont code
- Add project-specific partial to include webfont SCSS in order to
  make sure that the webfonts SCSS gets included in the compiled
  CSS as early as possible
- Document mixin and project file
  • Loading branch information
yellowled committed Dec 7, 2016
1 parent 3ceaef6 commit b824712
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 1 deletion.
1 change: 1 addition & 0 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ module.exports = {
'robots.txt',
'apple-touch-icon.png',
'favicon.ico',
'fonts/**/*',
'scripts/jquery/dist/jquery.min.js',
'scripts/jquery/dist/jquery.min.map'
],
Expand Down
1 change: 1 addition & 0 deletions docs/scss-concepts.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Most of the partials in `src/scss` and its subdirectories are **not** meant to b
* `src/scss/master.scss` – see [Compiled CSS](#compiled-css)
* `src/scss/project/_settings.scss` – see [Settings](#settings)
* `src/scss/project/_variables.scss` – see [Overriding defaults](#overriding-defaults)
* `src/scss/project/_fonts.scss` – see [SCSS docs](scss.md#project)
* partials in `src/scss/modules` – add project-specific global styles to `_global.scss`, create new partials for project-specific modules

## Overriding defaults
Expand Down
2 changes: 2 additions & 0 deletions docs/scss.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Apart from the main SCSS file (`master.scss`), the `src/scss` directory contains

* `_settings.scss` – enable or disable parts of the partials included in the boilerplate by setting certain variables to `true` or `false`, depending on whether that part of the SCSS is being used
* `_variables.scss` – project-specific constants or overrides for existing variables
* `_fonts.scss` – project-specific SCSS for (self-hosted) [webfonts](https://github.com/yellowled/yl-bp/blob/master/src/scss/mixins/_webfonts.scss) should be added here to make sure it is included as early as possible in the compiled CSS

## `mixins/_mixins.scss`

Expand All @@ -24,6 +25,7 @@ Apart from the main SCSS file (`master.scss`), the `src/scss` directory contains
* `_tables.scss` – tables (simple, striped, responsive)
* `_tabs.scss`[tabs](http://frend.co/components/tabs/)
* `_typography.scss` – ligatures, smart blockquotes
* `_webfonts.scss` – self-hosted webfonts

## `base/_base.scss`

Expand Down
Empty file added src/fonts/.gitignore
Empty file.
1 change: 1 addition & 0 deletions src/scss/master.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// Project-specific settings
@import 'project/settings';
@import 'project/variables';
@import 'project/fonts';

// Framework
@import '../../node_modules/node-normalize-scss/normalize';
Expand Down
3 changes: 2 additions & 1 deletion src/scss/mixins/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@
@import 'shapes';
@import 'tables';
@import 'tabs';
@import 'typography';
@import 'typography';
@import 'webfonts';
32 changes: 32 additions & 0 deletions src/scss/mixins/_webfonts.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// SELF-HOSTED WEBFONTS
// --------------------------------------------------------------------
// Defaults
$font-path: '../fonts' !default;


// For modern browsers
@mixin webfont($family, $src, $style: normal, $weight: normal, $path: $font-path) {
@font-face {
font-family: $family;
src: url('#{$path}/#{$src}.woff2') format('woff2'), // new standards
url('#{$path}/#{$src}.woff') format('woff'), // standards
url('#{$path}/#{$src}.ttf') format('truetype'); // Safari, Android, iOS
font-style: $style;
font-weight: $weight;
}
}

// For legacy browsers
@mixin legacy-webfont($family, $src, $style: normal, $weight: normal, $path: $font-path) {
@font-face {
font-family: $family;
src: url('#{$path}/#{$src}.eot'); // IE9 compat
src: url('#{$path}/#{$src}.eot?#iefix') format('embedded-opentype'), // IE8 and below
url('#{$path}/#{$src}.woff2') format('woff2'), // new standards
url('#{$path}/#{$src}.woff') format('woff'), // standards
url('#{$path}/#{$src}.ttf') format('truetype'), // Safari, Android, iOS
url('#{$path}/#{$src}.svg##{$family}') format('svg'); // legacy iOS
font-style: $style;
font-weight: $weight;
}
}
2 changes: 2 additions & 0 deletions src/scss/project/_fonts.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// FONTS
// --------------------------------------------------------------------

0 comments on commit b824712

Please sign in to comment.