bitstyles 0.8.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. checksums.yaml +4 -4
  2. data/.github/PULL_REQUEST_TEMPLATE.md +6 -10
  3. data/.nvmrc +1 -1
  4. data/.stylelintrc +1 -164
  5. data/.travis.yml +19 -0
  6. data/README.md +66 -33
  7. data/bitstyles.gemspec +1 -1
  8. data/lib/bitstyles/version.rb +1 -1
  9. data/package.json +21 -17
  10. data/scss/bitstyles.scss +53 -45
  11. data/scss/bitstyles/base/_all.scss +7 -0
  12. data/scss/bitstyles/base/_figure.scss +1 -1
  13. data/scss/bitstyles/base/_forms.scss +31 -26
  14. data/scss/bitstyles/base/_hr.scss +1 -1
  15. data/scss/bitstyles/base/_images.scss +1 -1
  16. data/scss/bitstyles/base/_link.scss +2 -14
  17. data/scss/bitstyles/base/_media.scss +2 -2
  18. data/scss/bitstyles/base/_typography.scss +37 -89
  19. data/scss/bitstyles/components/_expander.scss +8 -5
  20. data/scss/bitstyles/components/_modal.scss +41 -26
  21. data/scss/bitstyles/generic/_all.scss +2 -0
  22. data/scss/bitstyles/layout/_content.scss +7 -3
  23. data/scss/bitstyles/layout/_grid.scss +46 -23
  24. data/scss/bitstyles/layout/_topbar.scss +19 -4
  25. data/scss/bitstyles/layout/_width.scss +18 -11
  26. data/scss/bitstyles/objects/_absolute-center.scss +8 -2
  27. data/scss/bitstyles/objects/_absolute-cover.scss +11 -2
  28. data/scss/bitstyles/objects/_block.scss +5 -2
  29. data/scss/bitstyles/objects/_bordered-header.scss +8 -3
  30. data/scss/bitstyles/objects/_break-long-words.scss +6 -3
  31. data/scss/bitstyles/objects/_button--icon.scss +8 -4
  32. data/scss/bitstyles/objects/_button.scss +22 -13
  33. data/scss/bitstyles/objects/_clearfix.scss +7 -4
  34. data/scss/bitstyles/objects/_fixed-ratio.scss +24 -9
  35. data/scss/bitstyles/objects/_flex.scss +12 -8
  36. data/scss/bitstyles/objects/_hidden.scss +10 -7
  37. data/scss/bitstyles/objects/_icon.scss +19 -11
  38. data/scss/bitstyles/objects/_input.scss +16 -9
  39. data/scss/bitstyles/objects/_label.scss +2 -2
  40. data/scss/bitstyles/objects/_link.scss +18 -15
  41. data/scss/bitstyles/objects/_list-inline.scss +26 -0
  42. data/scss/bitstyles/objects/_list-reset.scss +5 -3
  43. data/scss/bitstyles/objects/_media.scss +9 -2
  44. data/scss/bitstyles/objects/_object-cover.scss +20 -0
  45. data/scss/bitstyles/objects/_overflow.scss +20 -0
  46. data/scss/bitstyles/objects/_truncate-with-ellipsis.scss +4 -3
  47. data/scss/bitstyles/objects/_typography.scss +8 -62
  48. data/scss/bitstyles/objects/_vertical-center.scss +5 -2
  49. data/scss/bitstyles/objects/_visuallyhidden.scss +10 -6
  50. data/scss/bitstyles/settings/_button.scss +1 -1
  51. data/scss/bitstyles/settings/_content.scss +2 -3
  52. data/scss/bitstyles/settings/_fixed-ratio.scss +3 -0
  53. data/scss/bitstyles/settings/_global.breakpoints.scss +5 -5
  54. data/scss/bitstyles/settings/_global.color-palette.scss +47 -0
  55. data/scss/bitstyles/settings/_global.layout.scss +7 -5
  56. data/scss/bitstyles/settings/_global.typography.scss +25 -17
  57. data/scss/bitstyles/settings/_grid.scss +1 -1
  58. data/scss/bitstyles/settings/_hidden.scss +1 -1
  59. data/scss/bitstyles/settings/_icon.scss +3 -3
  60. data/scss/bitstyles/settings/_input.scss +4 -4
  61. data/scss/bitstyles/settings/_link.scss +4 -0
  62. data/scss/bitstyles/settings/_modal.scss +2 -1
  63. data/scss/bitstyles/settings/_topbar.scss +4 -2
  64. data/scss/bitstyles/settings/_visuallyhidden.scss +1 -1
  65. data/scss/bitstyles/settings/_width.scss +1 -1
  66. data/scss/bitstyles/tools/_absolute-center.scss +8 -3
  67. data/scss/bitstyles/tools/_absolute-cover.scss +8 -2
  68. data/scss/bitstyles/tools/_all.scss +23 -0
  69. data/scss/bitstyles/tools/_block.scss +5 -2
  70. data/scss/bitstyles/tools/_break-long-words.scss +6 -2
  71. data/scss/bitstyles/tools/_clearfix.scss +7 -2
  72. data/scss/bitstyles/tools/_fixed-ratio.scss +41 -4
  73. data/scss/bitstyles/tools/_flex.scss +7 -3
  74. data/scss/bitstyles/tools/_font-face.scss +11 -2
  75. data/scss/bitstyles/tools/_hidden.scss +5 -2
  76. data/scss/bitstyles/tools/_link.scss +25 -0
  77. data/scss/bitstyles/tools/_list-reset.scss +7 -3
  78. data/scss/bitstyles/tools/_media-query.scss +14 -7
  79. data/scss/bitstyles/tools/_media.scss +10 -3
  80. data/scss/bitstyles/tools/_overflow.scss +19 -0
  81. data/scss/bitstyles/tools/_palette.scss +28 -0
  82. data/scss/bitstyles/tools/_spacing.scss +22 -0
  83. data/scss/bitstyles/tools/_truncate-with-ellipsis.scss +7 -3
  84. data/scss/bitstyles/tools/_typography-conversions.scss +20 -7
  85. data/scss/bitstyles/tools/_typography.scss +124 -5
  86. data/scss/bitstyles/tools/_vertical-center.scss +5 -2
  87. data/scss/bitstyles/tools/_visuallyhidden.scss +9 -6
  88. data/scss/bitstyles/tools/_width.scss +10 -1
  89. data/scss/bitstyles/tools/_zindex.scss +34 -14
  90. data/scss/bitstyles/trumps/_background-color.scss +8 -3
  91. data/scss/bitstyles/trumps/_color.scss +8 -3
  92. data/scss/bitstyles/trumps/_margin.scss +5 -5
  93. data/scss/bitstyles/trumps/_no-margin.scss +5 -5
  94. data/scss/bitstyles/trumps/_no-padding.scss +5 -5
  95. data/scss/bitstyles/trumps/_padding.scss +5 -5
  96. data/scss/bitstyles/trumps/_text-align.scss +3 -4
  97. data/scss/bitstyles/trumps/_text-style.scss +4 -2
  98. data/scss/bitstyles/trumps/_text-weight.scss +6 -3
  99. data/yarn.lock +6511 -0
  100. metadata +16 -14
  101. data/build/.gitignore +0 -4
  102. data/scripts/styleguide.sh +0 -16
  103. data/scss/bitstyles/objects/_expander.scss +0 -45
  104. data/scss/bitstyles/settings/_global.color-theme.scss +0 -11
@@ -1,8 +1,11 @@
1
1
  // Block
2
2
  //
3
- // Display an element as a block.
3
+ // **Forces an element to display as a block**, when it otherwise may be `inline`/
4
+ // `inline-block`. This can be used to force an inline element onto a ‘new line’,
5
+ // but also has implications for an element’s size (block elements expand horizontally
6
+ // to the available width).
4
7
  //
5
- // Styleguide 2.16
8
+ // Styleguide 1.3
6
9
 
7
10
  @mixin block {
8
11
  display: block;
@@ -1,8 +1,12 @@
1
1
  // Break long words
2
2
  //
3
- // Forces text content within an element to break if longer than the element is wide.
3
+ // **Forces text content within an element to break if longer than the element is wide.**.
4
4
  //
5
- // Styleguide 2.3
5
+ // A cross-browser friendly method of ensuring no words exceed the width of the
6
+ // container. Commonly used to ensure user-generated content doesn’t break or
7
+ // overflow your page layout.
8
+ //
9
+ // Styleguide 1.4
6
10
 
7
11
  @mixin break-long-words {
8
12
  overflow-wrap: break-word;
@@ -1,8 +1,13 @@
1
1
  // Clearfix
2
2
  //
3
- // Apply to a floated element (or its parent) to ensure following elements are cleared.
3
+ // **Cleanup after `float`ed elements**.
4
4
  //
5
- // Styleguide 2.4
5
+ // Force an element to behave as if its floated children have an element after them
6
+ // with `clear: both`. The element will therefore be of the correct height (including
7
+ // backgrounds etc.) instead of collapsing on the floated children, and will be correctly separated
8
+ // from the following content, as cleared elements are.
9
+ //
10
+ // Styleguide 1.5
6
11
 
7
12
  @mixin clearfix {
8
13
  &::after {
@@ -1,10 +1,37 @@
1
1
  // Fixed Ratio
2
2
  //
3
- // An element that has intrinsic shape width will be 100%, height will be limited to keep 16:9 aspect ratio.
3
+ // **Enforces an aspect ratio on this element and its contents**.
4
4
  //
5
- // Styleguide 2.5
5
+ // An element that has intrinsic shape — width will be 100%, height will be limited
6
+ // to keep your aspect ratio. Pass in width & height parameters to set your aspect
7
+ // ratio.
8
+ //
9
+ // Use the `fixed-ratio--variant` mixin to create modifier classes with ratios
10
+ // different to your base class.
11
+ //
12
+ // e.g.
13
+ //
14
+ // ```scss
15
+ // .o-fixed-ratio {
16
+ // @include fixed-ratio(16, 9);
17
+ // }
18
+ //
19
+ // .o-fixed-ratio--16-10 {
20
+ // @include fixed-ratio--variant(16, 10);
21
+ // }
22
+ //
23
+ // .o-fixed-ratio--square {
24
+ // @include fixed-ratio--variant(10, 10);
25
+ // }
26
+ // ```
27
+ //
28
+ // @param {Number} $width Unitless number. Sets the width of the element.
29
+ //
30
+ // @param {Number} $height Unitless number. Sets the height of the element.
31
+ //
32
+ // Styleguide 1.6
6
33
 
7
- @mixin fixed-ratio {
34
+ @mixin fixed-ratio($width, $height) {
8
35
  position: relative;
9
36
  display: block;
10
37
  width: 100%;
@@ -12,11 +39,21 @@
12
39
 
13
40
  &::before {
14
41
  display: block;
15
- padding-top: 56.25%;
42
+ padding-top: percentage-aspect-ratio($width, $height);
16
43
  content: '';
17
44
  }
18
45
  }
19
46
 
47
+ @mixin fixed-ratio--variant($width, $height) {
48
+ &::before {
49
+ padding-top: percentage-aspect-ratio($width, $height);
50
+ }
51
+ }
52
+
53
+ @function percentage-aspect-ratio($width, $height) {
54
+ @return percentage($height / $width);
55
+ }
56
+
20
57
  @mixin fixed-ratio__inner {
21
58
  @include absolute-cover;
22
59
 
@@ -1,9 +1,13 @@
1
1
  // Flex
2
2
  //
3
- // Simple flex layout.
4
- // Make one of the children `.o-flex__primary` to make it take as much space as is available.
3
+ // **Basic flex layout**.
5
4
  //
6
- // Styleguide 2.17
5
+ // Apply to an element to simply make its children share the available width e.g.
6
+ // a list of links in a menu.
7
+ // Make one of the children `.o-flex__primary` to make it take as much space as is
8
+ // available i.e. all the horizontal space left after its siblings take the minimum width they need.
9
+ //
10
+ // Styleguide 1.7
7
11
 
8
12
  @mixin flex {
9
13
  display: flex;
@@ -1,10 +1,19 @@
1
1
  // Webfont
2
2
  //
3
- // Helper mixin to output a widely cross-browser-compatible `@font-face` declaration.
3
+ // Helper mixin to output a widely cross-browser-compatible `@font-face` declaration
4
+ // for importing webfonts.
4
5
  //
5
6
  // ```@include webfont(Roboto, italic, 700, 'fonts/roboto-bold-italic');```
6
7
  //
7
- // Styleguide 2.15
8
+ // @param {String} $font-family The name by which this font will be referred to.
9
+ //
10
+ // @param {String} $font-style The `font-style` of the font you’re defining e.g. `normal`, `italic`.
11
+ //
12
+ // @param {String} $font-weight The `font-weight` of the font you’re defining e.g. `100`, `400`, `bold`.
13
+ //
14
+ // @param {String} $font-url The location at which the font assets can be found. Expects `.eot`, `.woff2`, `.woff`, and `.ttf` versions to exist there.
15
+ //
16
+ // Styleguide 1.8
8
17
 
9
18
  @mixin webfont($font-family, $font-style, $font-weight, $font-url) {
10
19
  @font-face {
@@ -1,8 +1,11 @@
1
1
  // Hidden
2
2
  //
3
- // Fully hides an element & its children does not affect document flow, does not get read by google or screenreaders.
3
+ // **Hidden from everyoneyou, search engines, screenreaders…**
4
4
  //
5
- // Styleguide 2.6
5
+ // Fully hides an element & its children — the element will not affect document
6
+ // flow, nor get read by google or screenreaders.
7
+ //
8
+ // Styleguide 1.9
6
9
 
7
10
  @mixin hidden {
8
11
  /* stylelint-disable declaration-no-important */
@@ -0,0 +1,25 @@
1
+ /* @define Link */
2
+ // Link
3
+ //
4
+ // Styling for all links.
5
+ //
6
+ // Styleguide 1.22
7
+
8
+ @mixin link {
9
+ color: $bitstyles-color-link;
10
+ text-decoration: $bitstyles-text-decoration-link;
11
+ text-decoration-skip: $bitstyles-text-decoration-skip-link;
12
+ cursor: pointer;
13
+ background: $bitstyles-background-color-link;
14
+ transition: $bitstyles-link-transition;
15
+
16
+ &:visited {
17
+ color: $bitstyles-color-link-visited;
18
+ }
19
+
20
+ &:hover,
21
+ &:focus {
22
+ color: $bitstyles-color-link-hover;
23
+ text-decoration: $bitstyles-text-decoration-link-hover;
24
+ }
25
+ }
@@ -1,11 +1,15 @@
1
1
  // List reset
2
2
  //
3
- // Removes the default bullet points from a list, along with any margins and
4
- // padding.
3
+ // **Removes the default margin, padding and bullets**
4
+ //
5
+ // This makes `<ul>`s much more usable as a semantic container, without it creating
6
+ // styling issues due to browser defaults intended for bullet lists in text documents.
5
7
  //
6
8
  // Optional parameters to prevent removal of margins and padding.
7
9
  //
8
- // Styleguide 2.13
10
+ // @param {Bool} $spacing If true, all default margins & padding will removed, as well as the list’s bullets.
11
+ //
12
+ // Styleguide 1.10
9
13
 
10
14
  @mixin list-reset($spacing: true) {
11
15
  @if $spacing {
@@ -1,22 +1,29 @@
1
1
  // Media Query
2
2
  //
3
- // Helper function to ease usage of media-queries. Uses the breakpoints listed in $breakpoint sass variable.
3
+ // **Helper function to ease usage of media-queries**.
4
+ //
5
+ // By default it uses the breakpoints listed in `$bitstyles-breakpoints` sass variable,
6
+ // but you can also pass in a list as a parameter.
4
7
  //
5
8
  // Usage:
6
9
  //
7
- // `
10
+ // ```scss
8
11
  // @media-query(breakpoint-name) {
9
12
  // .selector {
10
13
  // …styles here…
11
14
  // }
12
15
  // }
13
- // `
16
+ // ```
17
+ //
18
+ // @param {String} $media-query-name Name of the media query you’re referring to, as defined in the $breakpoints parameter (see below).
19
+ //
20
+ // @param {Map} $breakpoints Optional. A map of breakpoints. By default `$bitstyles-breakpoints` will be used, but if you pass in another list of breakpoints, that will be used instead.
14
21
  //
15
- // Styleguide 2.11
22
+ // Styleguide 1.11
16
23
 
17
- @mixin media-query($mq, $breakpoints: $bitstyles-breakpoints) {
24
+ @mixin media-query($media-query-name, $breakpoints: $bitstyles-breakpoints) {
18
25
 
19
- $breakpoint-condition: map-get($breakpoints, $mq);
26
+ $breakpoint-condition: map-get($breakpoints, $media-query-name);
20
27
 
21
28
  @if ($breakpoint-condition) {
22
29
  @media #{$breakpoint-condition} {
@@ -25,6 +32,6 @@
25
32
  }
26
33
 
27
34
  @else {
28
- @error "Oops! Breakpoint ‘#{$mq}’ does not exist.";
35
+ @error "Oops! Breakpoint ‘#{$media-query-name}’ does not exist.";
29
36
  }
30
37
  }
@@ -1,8 +1,15 @@
1
1
  // Media
2
2
  //
3
- // Nicole Sullivan’s OOCSS media object.
3
+ // **[Nicole Sullivan’s OOCSS media object](http://www.stubbornella.org/content/2010/06/25/the-media-object-saves-hundreds-of-lines-of-code/)**.
4
4
  //
5
- // Styleguide 2.18
5
+ // Contains a ‘feature’ element floated left e.g. a small user image. All other content
6
+ // (perhaps the user’s comment) flows around it to the right. The feature element
7
+ // should have either implicit size (like an image or video element), or have width set.
8
+ //
9
+ // If the feature element is as wide as the viewport, any adjacent content will drop drown
10
+ // below it instead of ranging right.
11
+ //
12
+ // Styleguide 1.12
6
13
 
7
14
  @mixin media {
8
15
  display: block;
@@ -11,5 +18,5 @@
11
18
 
12
19
  @mixin media__feature {
13
20
  float: left;
14
- margin-right: $bitstyles-spacing;
21
+ margin-right: spacing('base');
15
22
  }
@@ -0,0 +1,19 @@
1
+ // Overflow
2
+ //
3
+ // **Vertical scrolling panel**
4
+ //
5
+ // Any vertical overflow on the element is allowed to scroll, horizontal overflow is not.
6
+ // Different browsers/OSes have different strategies for displaying scrollbars when they’re
7
+ // needed, this mixin at least ensures no scrollbars are displayed unless there’s
8
+ // something to scroll.
9
+ //
10
+ // Styleguide 1.23
11
+
12
+ // (1) Fixes bug in safari that causes the scrollbars to appear behind some content within the overflow element.
13
+
14
+ @mixin overflow {
15
+ max-height: 100%;
16
+ -webkit-overflow-scrolling: touch;
17
+ overflow-y: auto;
18
+ transform: translateZ(0); // (1)
19
+ }
@@ -0,0 +1,28 @@
1
+ // Palette
2
+ //
3
+ // **Returns requested colours from the global `$bitstyles-palette` map.**
4
+ // e.g. `color: palette('text');`
5
+ //
6
+ // @param {String} $color Base colour within the palette
7
+ //
8
+ // @param {String} $tone Optional. Variant of the colour e.g. 'base', light', 'dark'. Defaults to `base`.
9
+ //
10
+ // Styleguide 1.20
11
+
12
+ @function palette($color, $tone: 'base') {
13
+ @if map-has-key($bitstyles-palette, $color) {
14
+ $palette: map-get($bitstyles-palette, $color);
15
+
16
+ @if map-has-key($palette, $tone) {
17
+ @return map-get($palette, $tone);
18
+ }
19
+
20
+ @else {
21
+ @error "Oops! Color/tone ‘#{$color}/#{$tone}’ does not exist.";
22
+ }
23
+ }
24
+
25
+ @else {
26
+ @error "Oops! Color ‘#{$color}’ does not exist.";
27
+ }
28
+ }
@@ -0,0 +1,22 @@
1
+ // Spacing
2
+ //
3
+ // **Returns requested size/length from the global `$bitstyles-spacing-sizes` map**.
4
+ //
5
+ // e.g. `padding: spacing('small');`
6
+ //
7
+ // Default naming of sizes: `base`, `small`, `large` (suggested: `x-small`,
8
+ // `xx-small` etc. for further variants)
9
+ //
10
+ // @param {String} $spacing-size Name of the standardised size required, as defined in the map `$bitstyles-spacing-sizes`.
11
+ //
12
+ // Styleguide 1.21
13
+
14
+ @function spacing($spacing-size) {
15
+ @if map-has-key($bitstyles-spacing-sizes, $spacing-size) {
16
+ @return map-get($bitstyles-spacing-sizes, $spacing-size);
17
+ }
18
+
19
+ @else {
20
+ @error "Oops! Spacing size ‘#{$spacing-size}’ does not exist.";
21
+ }
22
+ }
@@ -1,9 +1,13 @@
1
1
  // Truncate with ellipsis(…)
2
2
  //
3
- // If an element is single-line inline or inline-block, this will truncate its content
4
- // and display an ellipsis (…) at the end of the line.
3
+ // **When text content is wider than parent width, truncate text with an ellipsis (…).**
4
+ // The parent element needs a set or limited width.
5
+ // Note the exact algorithm is defined per browser and is of varying quality
6
+ // — you may lose a couple of characters just to display an ellipsis instead.
5
7
  //
6
- // Styleguide 2.9
8
+ // @param {Number} $truncation-boundary CSS dimension with unit. Define the maximum allowed width of the element, before its text content will be truncated. Defaults to `100%`, so the element will fill its parent but no more.
9
+ //
10
+ // Styleguide 1.13
7
11
 
8
12
  @mixin truncate-with-ellipsis($truncation-boundary: 100%) {
9
13
  max-width: $truncation-boundary;
@@ -1,18 +1,31 @@
1
1
  // Px to Rem sizing
2
2
  //
3
- // Converts pixels to rems — use to define font-sizes etc.
3
+ // **Converts pixels to rems**.
4
4
  //
5
- // Styleguide 2.12.1
5
+ // Used to define font-sizes (within the `set-font-size` and other mixins).
6
+ //
7
+ // @param {Number} $pixel-size CSS dimension in `px` units. The font-size required, in pixels.
8
+ //
9
+ // @param {Number} $root-size CSS dimension in `px` units. The current base font-size of the page (normally the font-size of the `html` element).
10
+ //
11
+ // Styleguide 1.14.1
6
12
 
7
13
  @function px-to-rem($pixel-size, $root-size: $bitstyles-font-size-base-small) {
8
14
  @return ($pixel-size / $root-size) * 1rem;
9
15
  }
10
16
 
11
- // em sizing
17
+ // Px to em sizing
18
+ //
19
+ // **Converts pixels to ems**
12
20
  //
13
- // Converts pixels to ems use to define font-sizes etc.
21
+ // Used to define font-sizes (within the `set-font-size` and other mixins).
14
22
  //
15
- // Styleguide 2.12.2
16
- @function px-to-em($pixels, $browser-context: $bitstyles-font-size-base-small) {
17
- @return ($pixels / $browser-context) + 0em; // stylelint-disable-line length-zero-no-unit
23
+ // @param {Number} $pixel-size CSS dimension in `px` units. The font-size required, in pixels.
24
+ //
25
+ // @param {Number} $root-size CSS dimension in `px` units. The current base font-size of the page (normally the font-size of the `html` element).
26
+ //
27
+ // Styleguide 1.14.2
28
+
29
+ @function px-to-em($pixel-size, $root-size: $bitstyles-font-size-base-small) {
30
+ @return ($pixel-size / $root-size) + 0em; // stylelint-disable-line length-zero-no-unit
18
31
  }
@@ -1,17 +1,136 @@
1
+ // Typographic helpers
2
+ //
3
+ // Styleguide 1.15
4
+
5
+ // Generic heading
6
+ //
7
+ // **Shared styles for heading elements**
8
+ //
9
+ // Styleguide 1.15.1
10
+
1
11
  @mixin generic-heading {
2
- margin: 0 0 $bitstyles-spacing;
12
+ margin: 0 0 spacing('base');
3
13
  font-family: $bitstyles-font-family-header;
4
14
  font-weight: $bitstyles-font-weight-bold;
5
15
  text-rendering: optimizeLegibility;
6
16
 
7
- .fonts-loaded & {
8
- font-family: $bitstyles-font-family-header-loaded;
17
+ @if $bitstyles-font-family-header-loaded != $bitstyles-font-family-header {
18
+ .fonts-loaded & {
19
+ font-family: $bitstyles-font-family-header-loaded;
20
+ }
9
21
  }
10
22
  }
11
23
 
12
- @mixin font-size($pixel-size, $browser-context: $bitstyles-font-size-base-small) {
24
+ // Font-size helper
25
+ //
26
+ // **Standarised method to set font-size**.
27
+ //
28
+ // Sets font-sizes using `rem`s with `px` fallback.
29
+ //
30
+ // @param {Number} $pixel-size CSS dimension in `px` units. The font-size required, in pixels.
31
+ //
32
+ // @param {Number} $root-size CSS dimension in `px` units. The current base font-size of the page (normally the font-size of the `html` element).
33
+ //
34
+ // Styleguide 1.15.2
35
+
36
+ @mixin set-font-size($pixel-size, $root-size: $bitstyles-font-size-base-small) {
13
37
  /* stylelint-disable declaration-block-no-duplicate-properties */
14
38
  font-size: $pixel-size;
15
- font-size: px-to-rem($pixel-size, $browser-context);
39
+ font-size: px-to-rem($pixel-size, $root-size);
16
40
  /* stylelint-enable declaration-block-no-duplicate-properties */
17
41
  }
42
+
43
+ // Font-size generator
44
+ //
45
+ // **Generate your typographic scale**
46
+ //
47
+ // Set your font-sizes in the map `$bitstyles-font-sizes` e.g.
48
+ //
49
+ // ```scss
50
+ // $bitstyles-font-sizes: (
51
+ // 'base': (
52
+ // 'html': $bitstyles-font-size-base-small,
53
+ // 'h0': 32px,
54
+ // 'h1': 24px,
55
+ // 'h2': 20px,
56
+ // 'h3': 18px,
57
+ // 'h4': $bitstyles-font-size-base-small,
58
+ // 'h5': $bitstyles-font-size-base-small,
59
+ // 'h6': $bitstyles-font-size-base-small
60
+ // ),
61
+ // 'medium-and-up': (
62
+ // 'html': $bitstyles-font-size-base,
63
+ // 'h0': 86px,
64
+ // 'h1': 40px,
65
+ // 'h2': 28px,
66
+ // 'h3': 20px,
67
+ // 'h4': $bitstyles-font-size-base,
68
+ // 'h5': $bitstyles-font-size-base,
69
+ // 'h6': $bitstyles-font-size-base
70
+ // )
71
+ // );
72
+ // ```
73
+ //
74
+ // Use `px` to define font-sizes, the output will specify `rem`s with a `px` fallback.
75
+ //
76
+ // `base` is a reserved word, and results in font-sizes being output without an enclosing media query.
77
+ //
78
+ // The media-query names used should be defined in `$bitstyles-breakpoints`.
79
+ //
80
+ // @param {String} $prefix Optional. Provide a string that will be prepended to the element name. Can include `.` to output classname selectors instead of elements.
81
+ //
82
+ // @param {List} $subset Optional. Provide a list of element names for which to output font-sizes. Defaults to include all sizes defined in `$bitstyles-font-sizes`.
83
+ //
84
+ // Styleguide 1.15.3
85
+
86
+ @mixin generate-font-sizes($prefix: '', $subset: ()) {
87
+ @each $media-query-name, $font-sizes in $bitstyles-font-sizes {
88
+ // Don’t wrap base classes in a media-query
89
+ @if $media-query-name == 'base' {
90
+ @include output-font-sizes($font-sizes, $prefix, $subset);
91
+ }
92
+
93
+ @else {
94
+ @include media-query($media-query-name) {
95
+ @include output-font-sizes($font-sizes, $prefix, $subset);
96
+ }
97
+ }
98
+ }
99
+ }
100
+
101
+ // Output font sizes
102
+ //
103
+ // **Private mixin**
104
+ //
105
+ // Used to output font-sizes from a map of font-sizes in `element-name: font-size` pairs.
106
+ //
107
+ // @param {Map} $font-sizes A map of font-sizes in `element-name: font-size` pairs. See `$bitstyles-font-sizes` for an example.
108
+ //
109
+ // @param {String} $prefix A string to prefix to the ouput selector.
110
+ //
111
+ // @param {List} $subset Provide a list of element names for which to output font-sizes. Defaults to include all sizes defined in the `$font-sizes` parameter.
112
+
113
+ @mixin output-font-sizes($font-sizes, $prefix, $subset) {
114
+ $base-size: $bitstyles-font-size-base-small;
115
+
116
+ @if map-has-key($font-sizes, 'html') {
117
+ $base-size: map-get($font-sizes, 'html');
118
+ }
119
+
120
+ @each $element-name, $font-size in ($font-sizes) {
121
+ @if (length($subset) == 0) or (index($subset, $element-name)) {
122
+ #{$bitstyles-namespace}#{$prefix}#{$element-name} {
123
+ /* stylelint-disable max-nesting-depth */
124
+ @if $element-name == 'html' {
125
+ // Base font-size must be relative to browser default, not itself!
126
+ @include set-font-size($font-size);
127
+ }
128
+
129
+ @else {
130
+ @include set-font-size($font-size, $base-size);
131
+ }
132
+ /* stylelint-enable max-nesting-depth */
133
+ }
134
+ }
135
+ }
136
+ }