bootstrap 4.5.2 → 5.0.0.alpha1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (131) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/assets/javascripts/bootstrap-sprockets.js +12 -8
  4. data/assets/javascripts/bootstrap.js +1876 -1220
  5. data/assets/javascripts/bootstrap.min.js +2 -2
  6. data/assets/javascripts/bootstrap/alert.js +133 -48
  7. data/assets/javascripts/bootstrap/button.js +56 -123
  8. data/assets/javascripts/bootstrap/carousel.js +268 -129
  9. data/assets/javascripts/bootstrap/collapse.js +285 -106
  10. data/assets/javascripts/bootstrap/dom/data.js +81 -0
  11. data/assets/javascripts/bootstrap/dom/event-handler.js +311 -0
  12. data/assets/javascripts/bootstrap/dom/manipulator.js +100 -0
  13. data/assets/javascripts/bootstrap/dom/polyfill.js +110 -0
  14. data/assets/javascripts/bootstrap/dom/selector-engine.js +98 -0
  15. data/assets/javascripts/bootstrap/dropdown.js +235 -161
  16. data/assets/javascripts/bootstrap/modal.js +322 -193
  17. data/assets/javascripts/bootstrap/popover.js +72 -41
  18. data/assets/javascripts/bootstrap/scrollspy.js +151 -56
  19. data/assets/javascripts/bootstrap/tab.js +151 -64
  20. data/assets/javascripts/bootstrap/toast.js +163 -65
  21. data/assets/javascripts/bootstrap/tooltip.js +336 -155
  22. data/assets/stylesheets/_bootstrap-grid.scss +51 -15
  23. data/assets/stylesheets/_bootstrap-reboot.scss +4 -1
  24. data/assets/stylesheets/_bootstrap.scss +14 -8
  25. data/assets/stylesheets/bootstrap/_alert.scss +3 -3
  26. data/assets/stylesheets/bootstrap/_badge.scss +2 -27
  27. data/assets/stylesheets/bootstrap/_breadcrumb.scss +3 -17
  28. data/assets/stylesheets/bootstrap/_button-group.scss +16 -38
  29. data/assets/stylesheets/bootstrap/_buttons.scss +27 -45
  30. data/assets/stylesheets/bootstrap/_card.scss +18 -64
  31. data/assets/stylesheets/bootstrap/_carousel.scss +13 -15
  32. data/assets/stylesheets/bootstrap/_close.scss +9 -13
  33. data/assets/stylesheets/bootstrap/_containers.scss +41 -0
  34. data/assets/stylesheets/bootstrap/_dropdown.scss +10 -7
  35. data/assets/stylesheets/bootstrap/_forms.scss +9 -347
  36. data/assets/stylesheets/bootstrap/_functions.scss +82 -20
  37. data/assets/stylesheets/bootstrap/_grid.scss +3 -54
  38. data/assets/stylesheets/bootstrap/_helpers.scss +7 -0
  39. data/assets/stylesheets/bootstrap/_list-group.scss +6 -3
  40. data/assets/stylesheets/bootstrap/_mixins.scss +6 -12
  41. data/assets/stylesheets/bootstrap/_modal.scss +34 -39
  42. data/assets/stylesheets/bootstrap/_nav.scss +8 -8
  43. data/assets/stylesheets/bootstrap/_navbar.scss +42 -74
  44. data/assets/stylesheets/bootstrap/_pagination.scss +7 -20
  45. data/assets/stylesheets/bootstrap/_popover.scss +5 -5
  46. data/assets/stylesheets/bootstrap/_progress.scss +2 -4
  47. data/assets/stylesheets/bootstrap/_reboot.scss +300 -164
  48. data/assets/stylesheets/bootstrap/_root.scss +5 -9
  49. data/assets/stylesheets/bootstrap/_spinners.scss +2 -2
  50. data/assets/stylesheets/bootstrap/_tables.scss +80 -114
  51. data/assets/stylesheets/bootstrap/_toasts.scss +2 -4
  52. data/assets/stylesheets/bootstrap/_tooltip.scss +5 -5
  53. data/assets/stylesheets/bootstrap/_transitions.scss +0 -1
  54. data/assets/stylesheets/bootstrap/_type.scss +38 -59
  55. data/assets/stylesheets/bootstrap/_utilities.scss +503 -18
  56. data/assets/stylesheets/bootstrap/_variables.scss +544 -424
  57. data/assets/stylesheets/bootstrap/bootstrap-utilities.scss +18 -0
  58. data/assets/stylesheets/bootstrap/forms/_form-check.scss +142 -0
  59. data/assets/stylesheets/bootstrap/forms/_form-control.scss +116 -0
  60. data/assets/stylesheets/bootstrap/forms/_form-file.scss +91 -0
  61. data/assets/stylesheets/bootstrap/forms/_form-range.scss +136 -0
  62. data/assets/stylesheets/bootstrap/forms/_form-select.scss +82 -0
  63. data/assets/stylesheets/bootstrap/forms/_form-text.scss +11 -0
  64. data/assets/stylesheets/bootstrap/forms/_input-group.scss +140 -0
  65. data/assets/stylesheets/bootstrap/forms/_labels.scss +36 -0
  66. data/assets/stylesheets/bootstrap/forms/_validation.scss +12 -0
  67. data/assets/stylesheets/bootstrap/{utilities → helpers}/_clearfix.scss +0 -0
  68. data/assets/stylesheets/bootstrap/helpers/_colored-links.scss +12 -0
  69. data/assets/stylesheets/bootstrap/helpers/_embed.scss +31 -0
  70. data/assets/stylesheets/bootstrap/helpers/_position.scss +30 -0
  71. data/assets/stylesheets/bootstrap/helpers/_screenreaders.scss +8 -0
  72. data/assets/stylesheets/bootstrap/helpers/_stretched-link.scss +15 -0
  73. data/assets/stylesheets/bootstrap/helpers/_text-truncation.scss +7 -0
  74. data/assets/stylesheets/bootstrap/mixins/_alert.scss +0 -4
  75. data/assets/stylesheets/bootstrap/mixins/_breakpoints.scss +11 -8
  76. data/assets/stylesheets/bootstrap/mixins/_buttons.scss +62 -47
  77. data/assets/stylesheets/bootstrap/mixins/_caret.scss +4 -4
  78. data/assets/stylesheets/bootstrap/mixins/_clearfix.scss +2 -0
  79. data/assets/stylesheets/bootstrap/mixins/_container.scss +9 -0
  80. data/assets/stylesheets/bootstrap/mixins/_forms.scss +22 -67
  81. data/assets/stylesheets/bootstrap/mixins/_gradients.scss +9 -11
  82. data/assets/stylesheets/bootstrap/mixins/_grid.scss +84 -32
  83. data/assets/stylesheets/bootstrap/mixins/_image.scss +1 -21
  84. data/assets/stylesheets/bootstrap/mixins/_list-group.scss +2 -1
  85. data/assets/stylesheets/bootstrap/mixins/_lists.scss +1 -1
  86. data/assets/stylesheets/bootstrap/mixins/_pagination.scss +15 -8
  87. data/assets/stylesheets/bootstrap/mixins/_reset-text.scss +2 -2
  88. data/assets/stylesheets/bootstrap/mixins/_screen-reader.scss +16 -22
  89. data/assets/stylesheets/bootstrap/mixins/_table-variants.scss +21 -0
  90. data/assets/stylesheets/bootstrap/mixins/_transition.scss +1 -1
  91. data/assets/stylesheets/bootstrap/mixins/_utilities.scss +49 -0
  92. data/assets/stylesheets/bootstrap/utilities/_api.scss +47 -0
  93. data/assets/stylesheets/bootstrap/vendor/_rfs.scss +234 -126
  94. data/lib/bootstrap/version.rb +2 -2
  95. data/tasks/updater/js.rb +3 -3
  96. metadata +31 -39
  97. data/assets/javascripts/bootstrap/util.js +0 -192
  98. data/assets/stylesheets/bootstrap/_code.scss +0 -48
  99. data/assets/stylesheets/bootstrap/_custom-forms.scss +0 -523
  100. data/assets/stylesheets/bootstrap/_input-group.scss +0 -192
  101. data/assets/stylesheets/bootstrap/_jumbotron.scss +0 -17
  102. data/assets/stylesheets/bootstrap/_media.scss +0 -8
  103. data/assets/stylesheets/bootstrap/_print.scss +0 -141
  104. data/assets/stylesheets/bootstrap/mixins/_background-variant.scss +0 -23
  105. data/assets/stylesheets/bootstrap/mixins/_badge.scss +0 -17
  106. data/assets/stylesheets/bootstrap/mixins/_float.scss +0 -14
  107. data/assets/stylesheets/bootstrap/mixins/_grid-framework.scss +0 -80
  108. data/assets/stylesheets/bootstrap/mixins/_hover.scss +0 -37
  109. data/assets/stylesheets/bootstrap/mixins/_nav-divider.scss +0 -11
  110. data/assets/stylesheets/bootstrap/mixins/_size.scss +0 -7
  111. data/assets/stylesheets/bootstrap/mixins/_table-row.scss +0 -39
  112. data/assets/stylesheets/bootstrap/mixins/_text-emphasis.scss +0 -17
  113. data/assets/stylesheets/bootstrap/mixins/_text-hide.scss +0 -11
  114. data/assets/stylesheets/bootstrap/mixins/_visibility.scss +0 -8
  115. data/assets/stylesheets/bootstrap/utilities/_align.scss +0 -8
  116. data/assets/stylesheets/bootstrap/utilities/_background.scss +0 -19
  117. data/assets/stylesheets/bootstrap/utilities/_borders.scss +0 -75
  118. data/assets/stylesheets/bootstrap/utilities/_display.scss +0 -26
  119. data/assets/stylesheets/bootstrap/utilities/_embed.scss +0 -39
  120. data/assets/stylesheets/bootstrap/utilities/_flex.scss +0 -51
  121. data/assets/stylesheets/bootstrap/utilities/_float.scss +0 -11
  122. data/assets/stylesheets/bootstrap/utilities/_interactions.scss +0 -5
  123. data/assets/stylesheets/bootstrap/utilities/_overflow.scss +0 -5
  124. data/assets/stylesheets/bootstrap/utilities/_position.scss +0 -32
  125. data/assets/stylesheets/bootstrap/utilities/_screenreaders.scss +0 -11
  126. data/assets/stylesheets/bootstrap/utilities/_shadows.scss +0 -6
  127. data/assets/stylesheets/bootstrap/utilities/_sizing.scss +0 -20
  128. data/assets/stylesheets/bootstrap/utilities/_spacing.scss +0 -73
  129. data/assets/stylesheets/bootstrap/utilities/_stretched-link.scss +0 -19
  130. data/assets/stylesheets/bootstrap/utilities/_text.scss +0 -72
  131. data/assets/stylesheets/bootstrap/utilities/_visibility.scss +0 -13
@@ -7,30 +7,10 @@
7
7
  //
8
8
  // Keep images from scaling beyond the width of their parents.
9
9
 
10
- @mixin img-fluid() {
10
+ @mixin img-fluid {
11
11
  // Part 1: Set a maximum relative to the parent
12
12
  max-width: 100%;
13
13
  // Part 2: Override the height to auto, otherwise images will be stretched
14
14
  // when setting a width and height attribute on the img element.
15
15
  height: auto;
16
16
  }
17
-
18
-
19
- // Retina image
20
- //
21
- // Short retina mixin for setting background-image and -size.
22
-
23
- @mixin img-retina($file-1x, $file-2x, $width-1x, $height-1x) {
24
- background-image: url($file-1x);
25
-
26
- // Autoprefixer takes care of adding -webkit-min-device-pixel-ratio and -o-min-device-pixel-ratio,
27
- // but doesn't convert dppx=>dpi.
28
- // There's no such thing as unprefixed min-device-pixel-ratio since it's nonstandard.
29
- // Compatibility info: https://caniuse.com/#feat=css-media-resolution
30
- @media only screen and (min-resolution: 192dpi), // IE9-11 don't support dppx
31
- only screen and (min-resolution: 2dppx) { // Standardized
32
- background-image: url($file-2x);
33
- background-size: $width-1x $height-1x;
34
- }
35
- @include deprecate("`img-retina()`", "v4.3.0", "v5");
36
- }
@@ -6,7 +6,8 @@
6
6
  background-color: $background;
7
7
 
8
8
  &.list-group-item-action {
9
- @include hover-focus() {
9
+ &:hover,
10
+ &:focus {
10
11
  color: $color;
11
12
  background-color: darken($background, 5%);
12
13
  }
@@ -1,7 +1,7 @@
1
1
  // Lists
2
2
 
3
3
  // Unstyled keeps list items block level, just removes default browser padding and list-style
4
- @mixin list-unstyled() {
4
+ @mixin list-unstyled {
5
5
  padding-left: 0;
6
6
  list-style: none;
7
7
  }
@@ -1,21 +1,28 @@
1
1
  // Pagination
2
2
 
3
- @mixin pagination-size($padding-y, $padding-x, $font-size, $line-height, $border-radius) {
3
+ @mixin pagination-size($padding-y, $padding-x, $font-size, $border-radius) {
4
4
  .page-link {
5
5
  padding: $padding-y $padding-x;
6
6
  @include font-size($font-size);
7
- line-height: $line-height;
8
7
  }
9
8
 
10
9
  .page-item {
11
- &:first-child {
12
- .page-link {
13
- @include border-left-radius($border-radius);
10
+ @if $pagination-margin-left == (-$pagination-border-width) {
11
+ &:first-child {
12
+ .page-link {
13
+ @include border-left-radius($border-radius);
14
+ }
14
15
  }
15
- }
16
- &:last-child {
16
+
17
+ &:last-child {
18
+ .page-link {
19
+ @include border-right-radius($border-radius);
20
+ }
21
+ }
22
+ } @else {
23
+ //Add border-radius to all pageLinks in case they have left margin
17
24
  .page-link {
18
- @include border-right-radius($border-radius);
25
+ @include border-radius($border-radius);
19
26
  }
20
27
  }
21
28
  }
@@ -1,6 +1,6 @@
1
- @mixin reset-text() {
1
+ @mixin reset-text {
2
2
  font-family: $font-family-base;
3
- // We deliberately do NOT reset font-size or word-wrap.
3
+ // We deliberately do NOT reset font-size or overflow-wrap / word-wrap.
4
4
  font-style: normal;
5
5
  font-weight: $font-weight-normal;
6
6
  line-height: $line-height-base;
@@ -1,34 +1,28 @@
1
+ // stylelint-disable declaration-no-important
2
+
1
3
  // Only display content to screen readers
2
4
  //
3
5
  // See: https://a11yproject.com/posts/how-to-hide-content/
4
6
  // See: https://hugogiraudel.com/2016/10/13/css-hide-and-seek/
5
7
 
6
- @mixin sr-only() {
7
- position: absolute;
8
- width: 1px;
9
- height: 1px;
10
- padding: 0;
11
- margin: -1px; // Fix for https://github.com/twbs/bootstrap/issues/25686
12
- overflow: hidden;
13
- clip: rect(0, 0, 0, 0);
14
- white-space: nowrap;
15
- border: 0;
8
+ @mixin sr-only {
9
+ position: absolute !important;
10
+ width: 1px !important;
11
+ height: 1px !important;
12
+ padding: 0 !important;
13
+ margin: -1px !important; // Fix for https://github.com/twbs/bootstrap/issues/25686
14
+ overflow: hidden !important;
15
+ clip: rect(0, 0, 0, 0) !important;
16
+ white-space: nowrap !important;
17
+ border: 0 !important;
16
18
  }
17
19
 
18
- // Use in conjunction with .sr-only to only display content when it's focused.
20
+ // Use to only display content when it's focused.
19
21
  //
20
22
  // Useful for "Skip to main content" links; see https://www.w3.org/TR/2013/NOTE-WCAG20-TECHS-20130905/G1
21
- //
22
- // Credit: HTML5 Boilerplate
23
23
 
24
- @mixin sr-only-focusable() {
25
- &:active,
26
- &:focus {
27
- position: static;
28
- width: auto;
29
- height: auto;
30
- overflow: visible;
31
- clip: auto;
32
- white-space: normal;
24
+ @mixin sr-only-focusable {
25
+ &:not(:focus) {
26
+ @include sr-only();
33
27
  }
34
28
  }
@@ -0,0 +1,21 @@
1
+ // scss-docs-start table-variant
2
+ @mixin table-variant($state, $background) {
3
+ .table-#{$state} {
4
+ $color: color-contrast(opaque($body-bg, $background));
5
+ $hover-bg: mix($color, $background, percentage($table-hover-bg-factor));
6
+ $striped-bg: mix($color, $background, percentage($table-striped-bg-factor));
7
+ $active-bg: mix($color, $background, percentage($table-active-bg-factor));
8
+
9
+ --bs-table-bg: #{$background};
10
+ --bs-table-striped-bg: #{$striped-bg};
11
+ --bs-table-striped-color: #{color-contrast($striped-bg)};
12
+ --bs-table-active-bg: #{$active-bg};
13
+ --bs-table-active-color: #{color-contrast($active-bg)};
14
+ --bs-table-hover-bg: #{$hover-bg};
15
+ --bs-table-hover-color: #{color-contrast($hover-bg)};
16
+
17
+ color: $color;
18
+ border-color: mix($color, $background, percentage($table-border-factor));
19
+ }
20
+ }
21
+ // scss-docs-end table-variant
@@ -17,7 +17,7 @@
17
17
  transition: $transition;
18
18
  }
19
19
 
20
- @if $enable-prefers-reduced-motion-media-query and nth($transition, 1) != null and nth($transition, 1) != none {
20
+ @if $enable-reduced-motion and nth($transition, 1) != null and nth($transition, 1) != none {
21
21
  @media (prefers-reduced-motion: reduce) {
22
22
  transition: none;
23
23
  }
@@ -0,0 +1,49 @@
1
+ // Utility generator
2
+ // Used to generate utilities & print utilities
3
+ @mixin generate-utility($utility, $infix, $is-rfs-media-query: false) {
4
+ $values: map-get($utility, values);
5
+
6
+ // If the values are a list or string, convert it into a map
7
+ @if type-of($values) == "string" or type-of(nth($values, 1)) != "list" {
8
+ $values: zip($values, $values);
9
+ }
10
+
11
+ @each $key, $value in $values {
12
+ $properties: map-get($utility, property);
13
+
14
+ // Multiple properties are possible, for example with vertical or horizontal margins or paddings
15
+ @if type-of($properties) == "string" {
16
+ $properties: append((), $properties);
17
+ }
18
+
19
+ // Use custom class if present
20
+ $property-class: if(map-has-key($utility, class), map-get($utility, class), nth($properties, 1));
21
+ $property-class: if($property-class == null, "", $property-class);
22
+
23
+ $infix: if($property-class == "" and str-slice($infix, 1, 1) == "-", str-slice($infix, 2), $infix);
24
+
25
+ // Don't prefix if value key is null (eg. with shadow class)
26
+ $property-class-modifier: if($key, if($property-class == "" and $infix == "", "", "-") + $key, "");
27
+
28
+ @if map-get($utility, rfs) {
29
+ // Inside the media query
30
+ @if $is-rfs-media-query {
31
+ $val: rfs-value($value);
32
+
33
+ // Do not render anything if fluid and non fluid values are the same
34
+ $value: if($val == rfs-fluid-value($value), null, $val);
35
+ }
36
+ @else {
37
+ $value: rfs-fluid-value($value);
38
+ }
39
+ }
40
+
41
+ @if $value != null {
42
+ .#{$property-class + $infix + $property-class-modifier} {
43
+ @each $property in $properties {
44
+ #{$property}: $value if($enable-important-utilities, !important, null);
45
+ }
46
+ }
47
+ }
48
+ }
49
+ }
@@ -0,0 +1,47 @@
1
+ // Loop over each breakpoint
2
+ @each $breakpoint in map-keys($grid-breakpoints) {
3
+
4
+ // Generate media query if needed
5
+ @include media-breakpoint-up($breakpoint) {
6
+ $infix: breakpoint-infix($breakpoint, $grid-breakpoints);
7
+
8
+ // Loop over each utility property
9
+ @each $key, $utility in $utilities {
10
+ // The utility can be disabled with `false`, thus check if the utility is a map first
11
+ // Only proceed if responsive media queries are enabled or if it's the base media query
12
+ @if type-of($utility) == "map" and (map-get($utility, responsive) or $infix == "") {
13
+ @include generate-utility($utility, $infix);
14
+ }
15
+ }
16
+ }
17
+ }
18
+
19
+ // RFS rescaling
20
+ @media (min-width: $rfs-mq-value) {
21
+ @each $breakpoint in map-keys($grid-breakpoints) {
22
+ $infix: breakpoint-infix($breakpoint, $grid-breakpoints);
23
+
24
+ @if (map-get($grid-breakpoints, $breakpoint) < $rfs-breakpoint) {
25
+ // Loop over each utility property
26
+ @each $key, $utility in $utilities {
27
+ // The utility can be disabled with `false`, thus check if the utility is a map first
28
+ // Only proceed if responsive media queries are enabled or if it's the base media query
29
+ @if type-of($utility) == "map" and map-get($utility, rfs) {
30
+ @include generate-utility($utility, $infix, true);
31
+ }
32
+ }
33
+ }
34
+ }
35
+ }
36
+
37
+
38
+ // Print utilities
39
+ @media print {
40
+ @each $key, $utility in $utilities {
41
+ // The utility can be disabled with `false`, thus check if the utility is a map first
42
+ // Then check if the utility needs print styles
43
+ @if type-of($utility) == "map" and map-get($utility, print) == true {
44
+ @include generate-utility($utility, "-print");
45
+ }
46
+ }
47
+ }
@@ -2,30 +2,41 @@
2
2
 
3
3
  // SCSS RFS mixin
4
4
  //
5
- // Automated font-resizing
5
+ // Automated responsive values for font sizes, paddings, margins and much more
6
6
  //
7
- // See https://github.com/twbs/rfs
7
+ // Licensed under MIT (https://github.com/twbs/rfs/blob/master/LICENSE)
8
8
 
9
9
  // Configuration
10
10
 
11
- // Base font size
12
- $rfs-base-font-size: 1.25rem !default;
13
- $rfs-font-size-unit: rem !default;
11
+ // Base value
12
+ $rfs-base-value: 1.25rem !default;
13
+ $rfs-unit: rem !default;
14
14
 
15
- // Breakpoint at where font-size starts decreasing if screen width is smaller
15
+ @if $rfs-unit != rem and $rfs-unit != px {
16
+ @error "`#{$rfs-unit}` is not a valid unit for $rfs-unit. Use `px` or `rem`.";
17
+ }
18
+
19
+ // Breakpoint at where values start decreasing if screen width is smaller
16
20
  $rfs-breakpoint: 1200px !default;
17
21
  $rfs-breakpoint-unit: px !default;
18
22
 
19
- // Resize font-size based on screen height and width
23
+ @if $rfs-breakpoint-unit != px and $rfs-breakpoint-unit != em and $rfs-breakpoint-unit != rem {
24
+ @error "`#{$rfs-breakpoint-unit}` is not a valid unit for $rfs-breakpoint-unit. Use `px`, `em` or `rem`.";
25
+ }
26
+
27
+ // Resize values based on screen height and width
20
28
  $rfs-two-dimensional: false !default;
21
29
 
22
30
  // Factor of decrease
23
31
  $rfs-factor: 10 !default;
24
32
 
25
- @if type-of($rfs-factor) != "number" or $rfs-factor <= 1 {
33
+ @if type-of($rfs-factor) != number or $rfs-factor <= 1 {
26
34
  @error "`#{$rfs-factor}` is not a valid $rfs-factor, it must be greater than 1.";
27
35
  }
28
36
 
37
+ // Mode. Possibilities: "min-media-query", "max-media-query"
38
+ $rfs-mode: min-media-query !default;
39
+
29
40
  // Generate enable or disable classes. Possibilities: false, "enable" or "disable"
30
41
  $rfs-class: false !default;
31
42
 
@@ -35,170 +46,267 @@ $rfs-rem-value: 16 !default;
35
46
  // Safari iframe resize bug: https://github.com/twbs/rfs/issues/14
36
47
  $rfs-safari-iframe-resize-bug-fix: false !default;
37
48
 
38
- // Disable RFS by setting $enable-responsive-font-sizes to false
39
- $enable-responsive-font-sizes: true !default;
49
+ // Disable RFS by setting $enable-rfs to false
50
+ $enable-rfs: true !default;
40
51
 
41
- // Cache $rfs-base-font-size unit
42
- $rfs-base-font-size-unit: unit($rfs-base-font-size);
52
+ // Cache $rfs-base-value unit
53
+ $rfs-base-value-unit: unit($rfs-base-value);
43
54
 
44
- // Remove px-unit from $rfs-base-font-size for calculations
45
- @if $rfs-base-font-size-unit == "px" {
46
- $rfs-base-font-size: $rfs-base-font-size / ($rfs-base-font-size * 0 + 1);
55
+ // Remove px-unit from $rfs-base-value for calculations
56
+ @if $rfs-base-value-unit == px {
57
+ $rfs-base-value: $rfs-base-value / ($rfs-base-value * 0 + 1);
47
58
  }
48
- @else if $rfs-base-font-size-unit == "rem" {
49
- $rfs-base-font-size: $rfs-base-font-size / ($rfs-base-font-size * 0 + 1 / $rfs-rem-value);
59
+ @else if $rfs-base-value-unit == rem {
60
+ $rfs-base-value: $rfs-base-value / ($rfs-base-value * 0 + 1 / $rfs-rem-value);
50
61
  }
51
62
 
52
63
  // Cache $rfs-breakpoint unit to prevent multiple calls
53
64
  $rfs-breakpoint-unit-cache: unit($rfs-breakpoint);
54
65
 
55
66
  // Remove unit from $rfs-breakpoint for calculations
56
- @if $rfs-breakpoint-unit-cache == "px" {
67
+ @if $rfs-breakpoint-unit-cache == px {
57
68
  $rfs-breakpoint: $rfs-breakpoint / ($rfs-breakpoint * 0 + 1);
58
69
  }
59
- @else if $rfs-breakpoint-unit-cache == "rem" or $rfs-breakpoint-unit-cache == "em" {
70
+ @else if $rfs-breakpoint-unit-cache == rem or $rfs-breakpoint-unit-cache == "em" {
60
71
  $rfs-breakpoint: $rfs-breakpoint / ($rfs-breakpoint * 0 + 1 / $rfs-rem-value);
61
72
  }
62
73
 
63
- // Responsive font-size mixin
64
- @mixin rfs($fs, $important: false) {
65
- // Cache $fs unit
66
- $fs-unit: if(type-of($fs) == "number", unit($fs), false);
67
-
68
- // Add !important suffix if needed
69
- $rfs-suffix: if($important, " !important", "");
70
-
71
- // If $fs isn't a number (like inherit) or $fs has a unit (not px or rem, like 1.5em) or $ is 0, just print the value
72
- @if not $fs-unit or $fs-unit != "" and $fs-unit != "px" and $fs-unit != "rem" or $fs == 0 {
73
- font-size: #{$fs}#{$rfs-suffix};
74
+ // Calculate the media query value
75
+ $rfs-mq-value: if($rfs-breakpoint-unit == px, #{$rfs-breakpoint}px, #{$rfs-breakpoint / $rfs-rem-value}#{$rfs-breakpoint-unit});
76
+ $rfs-mq-property-width: if($rfs-mode == max-media-query, max-width, min-width);
77
+ $rfs-mq-property-height: if($rfs-mode == max-media-query, max-height, min-height);
78
+
79
+ // Internal mixin used to determine which media query needs to be used
80
+ @mixin _rfs-media-query {
81
+ @if $rfs-two-dimensional {
82
+ @if $rfs-mode == max-media-query {
83
+ @media (#{$rfs-mq-property-width}: #{$rfs-mq-value}), (#{$rfs-mq-property-height}: #{$rfs-mq-value}) {
84
+ @content;
85
+ }
86
+ }
87
+ @else {
88
+ @media (#{$rfs-mq-property-width}: #{$rfs-mq-value}) and (#{$rfs-mq-property-height}: #{$rfs-mq-value}) {
89
+ @content;
90
+ }
91
+ }
74
92
  }
75
93
  @else {
76
- // Variables for storing static and fluid rescaling
77
- $rfs-static: null;
78
- $rfs-fluid: null;
94
+ @media (#{$rfs-mq-property-width}: #{$rfs-mq-value}) {
95
+ @content;
96
+ }
97
+ }
98
+ }
79
99
 
80
- // Remove px-unit from $fs for calculations
81
- @if $fs-unit == "px" {
82
- $fs: $fs / ($fs * 0 + 1);
100
+ // Internal mixin that adds disable classes to the selector if needed.
101
+ @mixin _rfs-rule {
102
+ @if $rfs-class == disable and $rfs-mode == max-media-query {
103
+ // Adding an extra class increases specificity, which prevents the media query to override the property
104
+ &,
105
+ .disable-rfs &,
106
+ &.disable-rfs {
107
+ @content;
108
+ }
109
+ }
110
+ @else if $rfs-class == enable and $rfs-mode == min-media-query {
111
+ .enable-rfs &,
112
+ &.enable-rfs {
113
+ @content;
83
114
  }
84
- @else if $fs-unit == "rem" {
85
- $fs: $fs / ($fs * 0 + 1 / $rfs-rem-value);
115
+ }
116
+ @else {
117
+ @content;
118
+ }
119
+ }
120
+
121
+ // Internal mixin that adds enable classes to the selector if needed.
122
+ @mixin _rfs-media-query-rule {
123
+
124
+ @if $rfs-class == enable {
125
+ @if $rfs-mode == min-media-query {
126
+ @content;
86
127
  }
87
128
 
88
- // Set default font-size
89
- @if $rfs-font-size-unit == rem {
90
- $rfs-static: #{$fs / $rfs-rem-value}rem#{$rfs-suffix};
129
+ @include _rfs-media-query {
130
+ .enable-rfs &,
131
+ &.enable-rfs {
132
+ @content;
133
+ }
91
134
  }
92
- @else if $rfs-font-size-unit == px {
93
- $rfs-static: #{$fs}px#{$rfs-suffix};
135
+ }
136
+ @else {
137
+ @if $rfs-class == disable and $rfs-mode == min-media-query {
138
+ .disable-rfs &,
139
+ &.disable-rfs {
140
+ @content;
141
+ }
94
142
  }
95
- @else {
96
- @error "`#{$rfs-font-size-unit}` is not a valid unit for $rfs-font-size-unit. Use `px` or `rem`.";
143
+ @include _rfs-media-query {
144
+ @content;
97
145
  }
146
+ }
147
+ }
98
148
 
99
- // Only add media query if font-size is bigger as the minimum font-size
100
- // If $rfs-factor == 1, no rescaling will take place
101
- @if $fs > $rfs-base-font-size and $enable-responsive-font-sizes {
102
- $min-width: null;
103
- $variable-unit: null;
149
+ // Helper function to get the formatted non-responsive value
150
+ @function rfs-value($values) {
151
+ // Convert to list
152
+ $values: if(type-of($values) != list, ($values,), $values);
104
153
 
105
- // Calculate minimum font-size for given font-size
106
- $fs-min: $rfs-base-font-size + ($fs - $rfs-base-font-size) / $rfs-factor;
154
+ $val: '';
107
155
 
108
- // Calculate difference between given font-size and minimum font-size for given font-size
109
- $fs-diff: $fs - $fs-min;
156
+ // Loop over each value and calculate value
157
+ @each $value in $values {
158
+ @if $value == 0 {
159
+ $val: $val + ' 0';
160
+ }
161
+ @else {
162
+ // Cache $value unit
163
+ $unit: if(type-of($value) == "number", unit($value), false);
110
164
 
111
- // Base font-size formatting
112
- // No need to check if the unit is valid, because we did that before
113
- $min-width: if($rfs-font-size-unit == rem, #{$fs-min / $rfs-rem-value}rem, #{$fs-min}px);
165
+ @if $unit == px {
166
+ // Convert to rem if needed
167
+ $val: $val + ' ' + if($rfs-unit == rem, #{$value / ($value * 0 + $rfs-rem-value)}rem, $value);
168
+ }
169
+ @else if $unit == rem {
170
+ // Convert to px if needed
171
+ $val: $val + ' ' + if($rfs-unit == px, #{$value / ($value * 0 + 1) * $rfs-rem-value}px, $value);
172
+ }
173
+ @else {
174
+ // If $value isn't a number (like inherit) or $value has a unit (not px or rem, like 1.5em) or $ is 0, just print the value
175
+ $val: $val + ' ' + $value;
176
+ }
177
+ }
178
+ }
114
179
 
115
- // If two-dimensional, use smallest of screen width and height
116
- $variable-unit: if($rfs-two-dimensional, vmin, vw);
180
+ // Remove first space
181
+ @return unquote(str-slice($val, 2));
182
+ }
117
183
 
118
- // Calculate the variable width between 0 and $rfs-breakpoint
119
- $variable-width: #{$fs-diff * 100 / $rfs-breakpoint}#{$variable-unit};
184
+ // Helper function to get the responsive value calculated by RFS
185
+ @function rfs-fluid-value($values) {
186
+ // Convert to list
187
+ $values: if(type-of($values) != list, ($values,), $values);
120
188
 
121
- // Set the calculated font-size.
122
- $rfs-fluid: calc(#{$min-width} + #{$variable-width}) #{$rfs-suffix};
123
- }
189
+ $val: '';
124
190
 
125
- // Rendering
126
- @if $rfs-fluid == null {
127
- // Only render static font-size if no fluid font-size is available
128
- font-size: $rfs-static;
191
+ // Loop over each value and calculate value
192
+ @each $value in $values {
193
+ @if $value == 0 {
194
+ $val: $val + ' 0';
129
195
  }
196
+
130
197
  @else {
131
- $mq-value: null;
198
+ // Cache $value unit
199
+ $unit: if(type-of($value) == "number", unit($value), false);
132
200
 
133
- // RFS breakpoint formatting
134
- @if $rfs-breakpoint-unit == em or $rfs-breakpoint-unit == rem {
135
- $mq-value: #{$rfs-breakpoint / $rfs-rem-value}#{$rfs-breakpoint-unit};
136
- }
137
- @else if $rfs-breakpoint-unit == px {
138
- $mq-value: #{$rfs-breakpoint}px;
201
+ // If $value isn't a number (like inherit) or $value has a unit (not px or rem, like 1.5em) or $ is 0, just print the value
202
+ @if not $unit or $unit != px and $unit != rem {
203
+ $val: $val + ' ' + $value;
139
204
  }
205
+
140
206
  @else {
141
- @error "`#{$rfs-breakpoint-unit}` is not a valid unit for $rfs-breakpoint-unit. Use `px`, `em` or `rem`.";
142
- }
207
+ // Remove unit from $value for calculations
208
+ $value: $value / ($value * 0 + if($unit == px, 1, 1 / $rfs-rem-value));
143
209
 
144
- @if $rfs-class == "disable" {
145
- // Adding an extra class increases specificity,
146
- // which prevents the media query to override the font size
147
- &,
148
- .disable-responsive-font-size &,
149
- &.disable-responsive-font-size {
150
- font-size: $rfs-static;
210
+ // Only add the media query if the value is greater than the minimum value
211
+ @if abs($value) <= $rfs-base-value or not $enable-rfs {
212
+ $val: $val + ' ' + if($rfs-unit == rem, #{$value / $rfs-rem-value}rem, #{$value}px);
151
213
  }
152
- }
153
- @else {
154
- font-size: $rfs-static;
155
- }
214
+ @else {
215
+ // Calculate the minimum value
216
+ $value-min: $rfs-base-value + (abs($value) - $rfs-base-value) / $rfs-factor;
217
+
218
+ // Calculate difference between $value and the minimum value
219
+ $value-diff: abs($value) - $value-min;
156
220
 
157
- @if $rfs-two-dimensional {
158
- @media (max-width: #{$mq-value}), (max-height: #{$mq-value}) {
159
- @if $rfs-class == "enable" {
160
- .enable-responsive-font-size &,
161
- &.enable-responsive-font-size {
162
- font-size: $rfs-fluid;
163
- }
164
- }
165
- @else {
166
- font-size: $rfs-fluid;
167
- }
168
-
169
- @if $rfs-safari-iframe-resize-bug-fix {
170
- // stylelint-disable-next-line length-zero-no-unit
171
- min-width: 0vw;
172
- }
221
+ // Base value formatting
222
+ $min-width: if($rfs-unit == rem, #{$value-min / $rfs-rem-value}rem, #{$value-min}px);
223
+
224
+ // Use negative value if needed
225
+ $min-width: if($value < 0, -$min-width, $min-width);
226
+
227
+ // Use `vmin` if two-dimensional is enabled
228
+ $variable-unit: if($rfs-two-dimensional, vmin, vw);
229
+
230
+ // Calculate the variable width between 0 and $rfs-breakpoint
231
+ $variable-width: #{$value-diff * 100 / $rfs-breakpoint}#{$variable-unit};
232
+
233
+ // Return the calculated value
234
+ $val: $val + ' calc(' + $min-width + if($value < 0, ' - ', ' + ') + $variable-width + ')';
173
235
  }
174
236
  }
175
- @else {
176
- @media (max-width: #{$mq-value}) {
177
- @if $rfs-class == "enable" {
178
- .enable-responsive-font-size &,
179
- &.enable-responsive-font-size {
180
- font-size: $rfs-fluid;
181
- }
182
- }
183
- @else {
184
- font-size: $rfs-fluid;
185
- }
186
-
187
- @if $rfs-safari-iframe-resize-bug-fix {
188
- // stylelint-disable-next-line length-zero-no-unit
189
- min-width: 0vw;
190
- }
191
- }
237
+ }
238
+ }
239
+
240
+ // Remove first space
241
+ @return unquote(str-slice($val, 2));
242
+ }
243
+
244
+ // RFS mixin
245
+ @mixin rfs($values, $property: font-size) {
246
+ @if $values != null {
247
+ $val: rfs-value($values);
248
+ $fluidVal: rfs-fluid-value($values);
249
+
250
+ // Do not print the media query if responsive & non-responsive values are the same
251
+ @if $val == $fluidVal {
252
+ #{$property}: $val;
253
+ }
254
+ @else {
255
+ @include _rfs-rule {
256
+ #{$property}: if($rfs-mode == max-media-query, $val, $fluidVal);
257
+
258
+ // Include safari iframe resize fix if needed
259
+ min-width: if($rfs-safari-iframe-resize-bug-fix, (0 * 1vw), null);
260
+ }
261
+
262
+ @include _rfs-media-query-rule {
263
+ #{$property}: if($rfs-mode == max-media-query, $fluidVal, $val);
192
264
  }
193
265
  }
194
266
  }
195
267
  }
196
268
 
197
- // The font-size & responsive-font-size mixin uses RFS to rescale font sizes
198
- @mixin font-size($fs, $important: false) {
199
- @include rfs($fs, $important);
269
+ // Shorthand helper mixins
270
+ @mixin font-size($value) {
271
+ @include rfs($value);
272
+ }
273
+
274
+ @mixin padding($value) {
275
+ @include rfs($value, padding);
276
+ }
277
+
278
+ @mixin padding-top($value) {
279
+ @include rfs($value, padding-top);
280
+ }
281
+
282
+ @mixin padding-right($value) {
283
+ @include rfs($value, padding-right);
284
+ }
285
+
286
+ @mixin padding-bottom($value) {
287
+ @include rfs($value, padding-bottom);
288
+ }
289
+
290
+ @mixin padding-left($value) {
291
+ @include rfs($value, padding-left);
292
+ }
293
+
294
+ @mixin margin($value) {
295
+ @include rfs($value, margin);
296
+ }
297
+
298
+ @mixin margin-top($value) {
299
+ @include rfs($value, margin-top);
300
+ }
301
+
302
+ @mixin margin-right($value) {
303
+ @include rfs($value, margin-right);
304
+ }
305
+
306
+ @mixin margin-bottom($value) {
307
+ @include rfs($value, margin-bottom);
200
308
  }
201
309
 
202
- @mixin responsive-font-size($fs, $important: false) {
203
- @include rfs($fs, $important);
310
+ @mixin margin-left($value) {
311
+ @include rfs($value, margin-left);
204
312
  }