foundation-rails 6.2.4.0 → 6.3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/Rakefile +2 -0
  4. data/bower.json +2 -2
  5. data/lib/foundation/rails/version.rb +1 -1
  6. data/lib/generators/foundation/templates/_settings.scss +117 -70
  7. data/lib/generators/foundation/templates/foundation_and_overrides.scss +2 -1
  8. data/vendor/assets/_vendor/normalize-scss/sass/_normalize.scss +3 -0
  9. data/vendor/assets/_vendor/normalize-scss/sass/normalize/_import-now.scss +11 -0
  10. data/vendor/assets/_vendor/normalize-scss/sass/normalize/_normalize-mixin.scss +676 -0
  11. data/vendor/assets/_vendor/normalize-scss/sass/normalize/_variables.scss +36 -0
  12. data/vendor/assets/_vendor/normalize-scss/sass/normalize/_vertical-rhythm.scss +61 -0
  13. data/vendor/assets/_vendor/sassy-lists/stylesheets/functions/_purge.scss +38 -0
  14. data/vendor/assets/_vendor/sassy-lists/stylesheets/functions/_remove.scss +31 -0
  15. data/vendor/assets/_vendor/sassy-lists/stylesheets/functions/_replace.scss +46 -0
  16. data/vendor/assets/_vendor/sassy-lists/stylesheets/functions/_to-list.scss +27 -0
  17. data/vendor/assets/_vendor/sassy-lists/stylesheets/helpers/_missing-dependencies.scss +25 -0
  18. data/vendor/assets/_vendor/sassy-lists/stylesheets/helpers/_true.scss +13 -0
  19. data/vendor/assets/js/foundation.abide.js.es6 +28 -0
  20. data/vendor/assets/js/foundation.accordion.js.es6 +1 -1
  21. data/vendor/assets/js/foundation.accordionMenu.js.es6 +9 -1
  22. data/vendor/assets/js/foundation.core.js.es6 +4 -4
  23. data/vendor/assets/js/foundation.drilldown.js.es6 +128 -14
  24. data/vendor/assets/js/foundation.dropdown.js.es6 +48 -42
  25. data/vendor/assets/js/foundation.dropdownMenu.js.es6 +20 -18
  26. data/vendor/assets/js/foundation.equalizer.js.es6 +12 -6
  27. data/vendor/assets/js/foundation.interchange.js.es6 +3 -2
  28. data/vendor/assets/js/foundation.js.es6 +2 -1
  29. data/vendor/assets/js/foundation.magellan.js.es6 +28 -9
  30. data/vendor/assets/js/foundation.offcanvas.js.es6 +90 -123
  31. data/vendor/assets/js/foundation.orbit.js.es6 +61 -10
  32. data/vendor/assets/js/foundation.responsiveMenu.js.es6 +2 -0
  33. data/vendor/assets/js/foundation.responsiveToggle.js.es6 +52 -12
  34. data/vendor/assets/js/foundation.reveal.js.es6 +48 -48
  35. data/vendor/assets/js/foundation.slider.js.es6 +124 -42
  36. data/vendor/assets/js/foundation.sticky.js.es6 +11 -9
  37. data/vendor/assets/js/foundation.tabs.js.es6 +164 -35
  38. data/vendor/assets/js/foundation.toggler.js.es6 +3 -0
  39. data/vendor/assets/js/foundation.tooltip.js.es6 +20 -10
  40. data/vendor/assets/js/foundation.util.box.js.es6 +2 -2
  41. data/vendor/assets/js/foundation.util.keyboard.js.es6 +37 -0
  42. data/vendor/assets/js/foundation.util.mediaQuery.js.es6 +16 -0
  43. data/vendor/assets/js/foundation.util.motion.js.es6 +7 -1
  44. data/vendor/assets/js/foundation.util.nest.js.es6 +10 -5
  45. data/vendor/assets/js/foundation.util.timerAndImageLoader.js.es6 +6 -4
  46. data/vendor/assets/js/foundation.util.triggers.js.es6 +54 -36
  47. data/vendor/assets/js/foundation.zf.responsiveAccordionTabs.js.es6 +240 -0
  48. data/vendor/assets/scss/_global.scss +25 -450
  49. data/vendor/assets/scss/components/_accordion-menu.scss +8 -4
  50. data/vendor/assets/scss/components/_accordion.scss +43 -22
  51. data/vendor/assets/scss/components/_badge.scss +17 -9
  52. data/vendor/assets/scss/components/_breadcrumbs.scss +7 -5
  53. data/vendor/assets/scss/components/_button-group.scss +54 -6
  54. data/vendor/assets/scss/components/_button.scss +27 -16
  55. data/vendor/assets/scss/components/_callout.scss +3 -2
  56. data/vendor/assets/scss/components/_card.scss +121 -0
  57. data/vendor/assets/scss/components/_close-button.scss +54 -13
  58. data/vendor/assets/scss/components/_drilldown.scss +19 -5
  59. data/vendor/assets/scss/components/_dropdown-menu.scss +23 -18
  60. data/vendor/assets/scss/components/_dropdown.scss +14 -7
  61. data/vendor/assets/scss/components/_flex-video.scss +1 -63
  62. data/vendor/assets/scss/components/_float.scss +1 -1
  63. data/vendor/assets/scss/components/_label.scss +16 -8
  64. data/vendor/assets/scss/components/_media-object.scss +2 -3
  65. data/vendor/assets/scss/components/_menu.scss +68 -33
  66. data/vendor/assets/scss/components/_off-canvas.scss +231 -80
  67. data/vendor/assets/scss/components/_orbit.scss +8 -6
  68. data/vendor/assets/scss/components/_pagination.scss +42 -22
  69. data/vendor/assets/scss/components/_progress-bar.scss +1 -1
  70. data/vendor/assets/scss/components/_responsive-embed.scss +66 -0
  71. data/vendor/assets/scss/components/_reveal.scss +17 -11
  72. data/vendor/assets/scss/components/_slider.scss +6 -1
  73. data/vendor/assets/scss/components/_sticky.scss +3 -3
  74. data/vendor/assets/scss/components/_switch.scss +47 -36
  75. data/vendor/assets/scss/components/_table.scss +83 -23
  76. data/vendor/assets/scss/components/_tabs.scss +54 -23
  77. data/vendor/assets/scss/components/_thumbnail.scss +17 -4
  78. data/vendor/assets/scss/components/_title-bar.scss +5 -6
  79. data/vendor/assets/scss/components/_tooltip.scss +15 -12
  80. data/vendor/assets/scss/components/_top-bar.scss +11 -8
  81. data/vendor/assets/scss/forms/_checkbox.scss +2 -1
  82. data/vendor/assets/scss/forms/_error.scss +10 -6
  83. data/vendor/assets/scss/forms/_fieldset.scss +7 -7
  84. data/vendor/assets/scss/forms/_input-group.scss +17 -11
  85. data/vendor/assets/scss/forms/_label.scss +2 -0
  86. data/vendor/assets/scss/forms/_meter.scss +9 -10
  87. data/vendor/assets/scss/forms/_progress.scss +9 -9
  88. data/vendor/assets/scss/forms/_range.scss +20 -15
  89. data/vendor/assets/scss/forms/_select.scss +26 -8
  90. data/vendor/assets/scss/forms/_text.scss +19 -16
  91. data/vendor/assets/scss/foundation.scss +19 -3
  92. data/vendor/assets/scss/grid/_classes.scss +31 -14
  93. data/vendor/assets/scss/grid/_column.scss +10 -24
  94. data/vendor/assets/scss/grid/_flex-grid.scss +84 -76
  95. data/vendor/assets/scss/grid/_grid.scss +0 -16
  96. data/vendor/assets/scss/grid/_gutter.scss +53 -5
  97. data/vendor/assets/scss/grid/_layout.scss +3 -3
  98. data/vendor/assets/scss/grid/_position.scss +3 -3
  99. data/vendor/assets/scss/grid/_row.scss +24 -19
  100. data/vendor/assets/scss/settings/_settings.scss +117 -70
  101. data/vendor/assets/scss/typography/_base.scss +110 -44
  102. data/vendor/assets/scss/typography/_helpers.scss +1 -0
  103. data/vendor/assets/scss/typography/_print.scss +7 -3
  104. data/vendor/assets/scss/typography/_typography.scss +0 -2
  105. data/vendor/assets/scss/util/_breakpoint.scss +28 -19
  106. data/vendor/assets/scss/util/_color.scss +69 -16
  107. data/vendor/assets/scss/util/_flex.scss +20 -3
  108. data/vendor/assets/scss/util/_math.scss +72 -0
  109. data/vendor/assets/scss/util/_mixins.scss +63 -26
  110. data/vendor/assets/scss/util/_selector.scss +3 -2
  111. data/vendor/assets/scss/util/_unit.scss +61 -4
  112. data/vendor/assets/scss/util/_util.scss +1 -0
  113. data/vendor/assets/scss/util/_value.scss +33 -0
  114. metadata +17 -2
@@ -58,15 +58,15 @@ $orbit-control-zindex: 10 !default;
58
58
  /// Adds styles for the inner Orbit slide container. These styles are used on the `.orbit-container` class.
59
59
  @mixin orbit-container {
60
60
  position: relative;
61
+ height: 0; // Prevent FOUC by not showing until JS sets height
61
62
  margin: 0;
62
- overflow: hidden;
63
63
  list-style: none;
64
+ overflow: hidden;
64
65
  }
65
66
 
66
67
  /// Adds styles for the individual slides of an Orbit slider. These styles are used on the `.orbit-slide` class.
67
68
  @mixin orbit-slide {
68
69
  width: 100%;
69
- max-height: 100%;
70
70
 
71
71
  &.no-motionui {
72
72
  &.is-active {
@@ -82,9 +82,9 @@ $orbit-control-zindex: 10 !default;
82
82
 
83
83
  /// Adds styles for a slide containing an image. These styles are used on the `.orbit-image` class.
84
84
  @mixin orbit-image {
85
- margin: 0;
86
85
  width: 100%;
87
86
  max-width: 100%;
87
+ margin: 0;
88
88
  }
89
89
 
90
90
  /// Adds styles for an orbit slide caption. These styles are used on the `.orbit-caption` class.
@@ -92,10 +92,11 @@ $orbit-control-zindex: 10 !default;
92
92
  position: absolute;
93
93
  bottom: 0;
94
94
  width: 100%;
95
- padding: $orbit-caption-padding;
96
95
  margin-bottom: 0;
97
- color: foreground($orbit-caption-background);
96
+ padding: $orbit-caption-padding;
97
+
98
98
  background-color: $orbit-caption-background;
99
+ color: color-pick-contrast($orbit-caption-background);
99
100
  }
100
101
 
101
102
  /// Adds base styles for the next/previous buttons in an Orbit slider. These styles are shared between the `.orbit-next` and `.orbit-previous` classes in the default CSS.
@@ -136,8 +137,9 @@ $orbit-control-zindex: 10 !default;
136
137
  width: $orbit-bullet-diameter;
137
138
  height: $orbit-bullet-diameter;
138
139
  margin: $orbit-bullet-margin;
139
- background-color: $orbit-bullet-background;
140
+
140
141
  border-radius: 50%;
142
+ background-color: $orbit-bullet-background;
141
143
 
142
144
  &:hover {
143
145
  background-color: $orbit-bullet-background-active;
@@ -40,7 +40,7 @@ $pagination-item-background-current: $primary-color !default;
40
40
 
41
41
  /// Text color of the pagination item for the current page.
42
42
  /// @type Color
43
- $pagination-item-color-current: foreground($pagination-item-background-current) !default;
43
+ $pagination-item-color-current: $white !default;
44
44
 
45
45
  /// Text color of a disabled pagination item.
46
46
  /// @type Color
@@ -55,7 +55,9 @@ $pagination-ellipsis-color: $black !default;
55
55
  /// @type Boolean
56
56
  $pagination-mobile-items: false !default;
57
57
 
58
- /// If `false`, don't display current page number on mobile.
58
+ /// If `true`, display the current page number on mobile even if `$pagination-mobile-items` is set to `false`.
59
+ /// This parameter will only override the visibility setting of the current item for `$pagination-mobile-items: false;`,
60
+ /// it will not affect the current page number visibility when `$pagination-mobile-items` is set to `true`.
59
61
  /// @type Boolean
60
62
  $pagination-mobile-current-item: false !default;
61
63
 
@@ -64,16 +66,24 @@ $pagination-mobile-current-item: false !default;
64
66
  $pagination-arrows: true !default;
65
67
 
66
68
  /// Adds styles for a pagination container. Apply this to a `<ul>`.
67
- @mixin pagination-container {
69
+ @mixin pagination-container (
70
+ $margin-bottom: $pagination-margin-bottom,
71
+ $font-size: $pagination-font-size,
72
+ $spacing: $pagination-item-spacing,
73
+ $radius: $pagination-radius,
74
+ $color: $pagination-item-color,
75
+ $padding: $pagination-item-padding,
76
+ $background-hover: $pagination-item-background-hover
77
+ ) {
68
78
  @include clearfix;
69
79
  margin-#{$global-left}: 0;
70
- margin-bottom: $pagination-margin-bottom;
80
+ margin-bottom: $margin-bottom;
71
81
 
72
82
  // List item
73
83
  li {
74
- font-size: $pagination-font-size;
75
- margin-#{$global-right}: $pagination-item-spacing;
76
- border-radius: $pagination-radius;
84
+ margin-#{$global-right}: $spacing;
85
+ border-radius: $radius;
86
+ font-size: $font-size;
77
87
 
78
88
  @if $pagination-mobile-items {
79
89
  display: inline-block;
@@ -101,29 +111,36 @@ $pagination-arrows: true !default;
101
111
  // Page links
102
112
  a,
103
113
  button {
104
- color: $pagination-item-color;
105
114
  display: block;
106
- padding: $pagination-item-padding;
115
+ padding: $padding;
107
116
  border-radius: $global-radius;
117
+ color: $color;
108
118
 
109
119
  &:hover {
110
- background: $pagination-item-background-hover;
120
+ background: $background-hover;
111
121
  }
112
122
  }
113
123
  }
114
124
 
115
125
  /// Adds styles for the current pagination item. Apply this to an `<a>`.
116
- @mixin pagination-item-current {
117
- padding: $pagination-item-padding;
118
- background: $pagination-item-background-current;
119
- color: $pagination-item-color-current;
126
+ @mixin pagination-item-current (
127
+ $padding: $pagination-item-padding,
128
+ $background-current: $pagination-item-background-current,
129
+ $color-current: $pagination-item-color-current
130
+ ) {
131
+ padding: $padding;
132
+ background: $background-current;
133
+ color: $color-current;
120
134
  cursor: default;
121
135
  }
122
136
 
123
137
  /// Adds styles for a disabled pagination item. Apply this to an `<a>`.
124
- @mixin pagination-item-disabled {
125
- padding: $pagination-item-padding;
126
- color: $pagination-item-color-disabled;
138
+ @mixin pagination-item-disabled (
139
+ $padding: $pagination-item-padding,
140
+ $color: $pagination-item-color-disabled
141
+ ) {
142
+ padding: $padding;
143
+ color: $color;
127
144
  cursor: not-allowed;
128
145
 
129
146
  &:hover {
@@ -132,10 +149,13 @@ $pagination-arrows: true !default;
132
149
  }
133
150
 
134
151
  /// Adds styles for an ellipsis for use in a pagination list.
135
- @mixin pagination-ellipsis {
152
+ @mixin pagination-ellipsis (
153
+ $padding: $pagination-item-padding,
154
+ $color: $pagination-ellipsis-color
155
+ ) {
156
+ padding: $padding;
136
157
  content: '\2026';
137
- padding: $pagination-item-padding;
138
- color: $pagination-ellipsis-color;
158
+ color: $color;
139
159
  }
140
160
 
141
161
  @mixin foundation-pagination {
@@ -158,16 +178,16 @@ $pagination-arrows: true !default;
158
178
  @if $pagination-arrows {
159
179
  .pagination-previous a::before,
160
180
  .pagination-previous.disabled::before {
161
- content: '\00ab';
162
181
  display: inline-block;
163
182
  margin-#{$global-right}: 0.5rem;
183
+ content: '\00ab';
164
184
  }
165
185
 
166
186
  .pagination-next a::after,
167
187
  .pagination-next.disabled::after {
168
- content: '\00bb';
169
188
  display: inline-block;
170
189
  margin-#{$global-left}: 0.5rem;
190
+ content: '\00bb';
171
191
  }
172
192
  }
173
193
  }
@@ -4,10 +4,10 @@
4
4
 
5
5
  /// Adds styles for a progress bar container.
6
6
  @mixin progress-container {
7
- background-color: $progress-background;
8
7
  height: $progress-height;
9
8
  margin-bottom: $progress-margin-bottom;
10
9
  border-radius: $progress-radius;
10
+ background-color: $progress-background;
11
11
  }
12
12
 
13
13
  /// Adds styles for the inner meter of a progress bar.
@@ -0,0 +1,66 @@
1
+ // Foundation for Sites by ZURB
2
+ // foundation.zurb.com
3
+ // Licensed under MIT Open Source
4
+
5
+ ////
6
+ /// @group responsive-embed
7
+ ////
8
+
9
+ /// Margin below a responsive embed container.
10
+ /// @type Number
11
+ $responsive-embed-margin-bottom: rem-calc(16) !default;
12
+
13
+ /// Aspect ratios used to determine padding-bottom of responsive embed containers.
14
+ /// @type Map
15
+ $responsive-embed-ratios: (
16
+ default: 4 by 3,
17
+ widescreen: 16 by 9,
18
+ ) !default;
19
+
20
+ /// Creates a responsive embed container.
21
+ /// @param {String|List} $ratio [default] - Ratio of the container. Can be a key from the `$responsive-embed-ratios` map or a list formatted as `x by y`.
22
+ @mixin responsive-embed($ratio: default) {
23
+ @if type-of($ratio) == 'string' {
24
+ $ratio: map-get($responsive-embed-ratios, $ratio);
25
+ }
26
+ position: relative;
27
+ height: 0;
28
+ margin-bottom: $responsive-embed-margin-bottom;
29
+ padding-bottom: ratio-to-percentage($ratio);
30
+ overflow: hidden;
31
+
32
+ iframe,
33
+ object,
34
+ embed,
35
+ video {
36
+ position: absolute;
37
+ top: 0;
38
+ #{$global-left}: 0;
39
+ width: 100%;
40
+ height: 100%;
41
+ }
42
+ }
43
+
44
+ @mixin foundation-responsive-embed {
45
+ .responsive-embed, .flex-video {
46
+ @include responsive-embed($ratio: default);
47
+
48
+ $ratios: map-remove($responsive-embed-ratios,default);
49
+
50
+ @each $name, $ratio in $ratios {
51
+ &.#{$name} {
52
+ padding-bottom: ratio-to-percentage($ratio);
53
+ }
54
+ }
55
+ }
56
+ }
57
+
58
+ @mixin foundation-flex-video {
59
+ @warn 'This mixin is being replaced by foundation-responsive-embed(). foundation-flex-video() will be removed in Foundation 6.4.';
60
+ @include foundation-responsive-embed;
61
+ }
62
+
63
+ @mixin flex-video($ratio: $responsive-embed-ratio) {
64
+ @warn 'This mixin is being replaced by responsive-embed(). flex-video() will be removed in Foundation 6.4.';
65
+ @include responsive-embed;
66
+ }
@@ -41,13 +41,14 @@ $reveal-overlay-background: rgba($black, 0.45) !default;
41
41
  /// Adds styles for a modal overlay.
42
42
  /// @param {Color} $background [$reveal-overlay-background] - Background color of the overlay.
43
43
  @mixin reveal-overlay($background: $reveal-overlay-background) {
44
- display: none;
45
44
  position: fixed;
46
45
  top: 0;
46
+ right: 0;
47
47
  bottom: 0;
48
48
  left: 0;
49
- right: 0;
50
49
  z-index: $reveal-zindex;
50
+
51
+ display: none;
51
52
  background-color: $background;
52
53
  overflow-y: scroll;
53
54
  }
@@ -55,12 +56,16 @@ $reveal-overlay-background: rgba($black, 0.45) !default;
55
56
  /// Adds base styles for a modal.
56
57
  @mixin reveal-modal-base {
57
58
  @include disable-mouse-outline;
58
- display: none;
59
59
  z-index: $reveal-zindex + 1;
60
+ // Workaround android browser z-index bug
61
+ backface-visibility: hidden;
62
+
63
+ display: none;
60
64
  padding: $reveal-padding;
65
+
61
66
  border: $reveal-border;
62
- background-color: $reveal-background;
63
67
  border-radius: $reveal-radius;
68
+ background-color: $reveal-background;
64
69
 
65
70
  @include breakpoint(medium) {
66
71
  min-height: 0;
@@ -94,25 +99,26 @@ $reveal-overlay-background: rgba($black, 0.45) !default;
94
99
 
95
100
  /// Creates a full-screen modal, which stretches the full width and height of the window.
96
101
  @mixin reveal-modal-fullscreen {
97
- // scss-lint:disable DuplicateProperty
98
102
  top: 0;
99
103
  left: 0;
104
+
100
105
  width: 100%;
106
+ max-width: none;
101
107
  height: 100%;
102
- height: 100vh;
108
+ height: 100vh; // sass-lint:disable-line no-duplicate-properties
103
109
  min-height: 100vh;
104
- max-width: none;
105
110
  margin-left: 0;
111
+
106
112
  border: 0;
107
113
  border-radius: 0;
108
114
  }
109
115
 
110
116
  @mixin foundation-reveal {
111
117
  // [TODO] Is this necessary?
112
- // scss-lint:disable QualifyingElement
113
- body.is-reveal-open {
118
+ body.is-reveal-open { // sass-lint:disable-line no-qualifying-elements
114
119
  overflow: hidden;
115
120
  }
121
+
116
122
  // html gets this class only in iOS
117
123
  html.is-reveal-open,
118
124
  html.is-reveal-open body {
@@ -132,16 +138,16 @@ $reveal-overlay-background: rgba($black, 0.45) !default;
132
138
  @include reveal-modal-width($reveal-width);
133
139
  position: relative;
134
140
  top: 100px;
135
- margin-left: auto;
136
141
  margin-right: auto;
142
+ margin-left: auto;
137
143
  overflow-y: auto;
138
144
 
139
145
  // Placeholder selector for medium-and-up modals
140
146
  // Prevents duplicate CSS when defining multiple Reveal sizes
141
147
  @include breakpoint(medium) {
142
148
  %reveal-centered {
143
- left: auto;
144
149
  right: auto;
150
+ left: auto;
145
151
  margin: 0 auto;
146
152
  }
147
153
  }
@@ -23,6 +23,7 @@ $slider-transition: all 0.2s ease-in-out !default;
23
23
  height: $slider-height;
24
24
  margin-top: 1.25rem;
25
25
  margin-bottom: 2.25rem;
26
+
26
27
  background-color: $slider-background;
27
28
  cursor: pointer;
28
29
  user-select: none;
@@ -34,9 +35,11 @@ $slider-transition: all 0.2s ease-in-out !default;
34
35
  position: absolute;
35
36
  top: 0;
36
37
  left: 0;
38
+
37
39
  display: inline-block;
38
40
  max-width: 100%;
39
41
  height: $slider-height;
42
+
40
43
  background-color: $slider-fill-background;
41
44
  transition: $slider-transition;
42
45
 
@@ -52,13 +55,15 @@ $slider-transition: all 0.2s ease-in-out !default;
52
55
  position: absolute;
53
56
  left: 0;
54
57
  z-index: 1;
58
+
55
59
  display: inline-block;
56
60
  width: $slider-handle-width;
57
61
  height: $slider-handle-height;
62
+
63
+ border-radius: $slider-radius;
58
64
  background-color: $slider-handle-background;
59
65
  transition: $slider-transition;
60
66
  touch-action: manipulation;
61
- border-radius: $slider-radius;
62
67
 
63
68
  &:hover {
64
69
  background-color: scale-color($slider-handle-background, $lightness: -15%);
@@ -8,7 +8,7 @@
8
8
  }
9
9
 
10
10
  .sticky {
11
- position: absolute;
11
+ position: relative;
12
12
  z-index: 0;
13
13
  transform: translate3d(0, 0, 0);
14
14
  }
@@ -27,9 +27,9 @@
27
27
  }
28
28
 
29
29
  .sticky.is-anchored {
30
- position: absolute;
31
- left: auto;
30
+ position: relative;
32
31
  right: auto;
32
+ left: auto;
33
33
 
34
34
  &.is-at-bottom {
35
35
  bottom: 0;
@@ -60,38 +60,46 @@ $switch-paddle-transition: all 0.25s ease-out !default;
60
60
 
61
61
  /// Adds styles for a switch container. Apply this to a container class.
62
62
  @mixin switch-container {
63
+ position: relative;
63
64
  margin-bottom: $switch-margin;
64
65
  outline: 0;
65
- position: relative;
66
- user-select: none;
67
66
 
68
67
  // These properties cascade down to the switch text
69
- color: $white;
70
- font-weight: bold;
71
68
  font-size: rem-calc(14);
69
+ font-weight: bold;
70
+ color: $white;
71
+
72
+ user-select: none;
72
73
  }
73
74
 
74
75
  /// Adds styles for a switch input. Apply this to an `<input>` within a switch.
75
76
  @mixin switch-input {
76
- opacity: 0;
77
77
  position: absolute;
78
78
  margin-bottom: 0;
79
+ opacity: 0;
79
80
  }
80
81
 
81
82
  /// Adds styles for the background and paddle of a switch. Apply this to a `<label>` within a switch.
82
83
  @mixin switch-paddle {
83
- background: $switch-background;
84
- cursor: pointer;
85
- display: block;
84
+ $switch-width: $switch-height * 2;
85
+ $paddle-height: $switch-height - ($switch-paddle-offset * 2);
86
+ $paddle-width: $switch-height - ($switch-paddle-offset * 2);
87
+ $paddle-active-offest: $switch-width - $paddle-width - $switch-paddle-offset;
88
+
86
89
  position: relative;
87
- width: 4rem;
90
+ display: block;
91
+ width: $switch-width;
88
92
  height: $switch-height;
89
- transition: $switch-paddle-transition;
93
+
90
94
  border-radius: $switch-radius;
95
+ background: $switch-background;
96
+ transition: $switch-paddle-transition;
91
97
 
92
98
  // Resetting these <label> presets so type styles cascade down
93
- color: inherit;
94
99
  font-weight: inherit;
100
+ color: inherit;
101
+
102
+ cursor: pointer;
95
103
 
96
104
  // Needed to override specificity
97
105
  input + & {
@@ -100,17 +108,19 @@ $switch-paddle-transition: all 0.25s ease-out !default;
100
108
 
101
109
  // The paddle itself
102
110
  &::after {
103
- background: $switch-paddle-background;
104
- content: '';
105
- display: block;
106
111
  position: absolute;
107
- height: 1.5rem;
108
- #{$global-left}: 0.25rem;
109
- top: 0.25rem;
110
- width: 1.5rem;
111
- transition: $switch-paddle-transition;
112
+ top: $switch-paddle-offset;
113
+ #{$global-left}: $switch-paddle-offset;
114
+
115
+ display: block;
116
+ width: $paddle-width;
117
+ height: $paddle-height;
118
+
112
119
  transform: translate3d(0, 0, 0);
113
120
  border-radius: $switch-paddle-radius;
121
+ background: $switch-paddle-background;
122
+ transition: $switch-paddle-transition;
123
+ content: '';
114
124
  }
115
125
 
116
126
  // Change the visual style when the switch is active
@@ -118,7 +128,7 @@ $switch-paddle-transition: all 0.25s ease-out !default;
118
128
  background: $switch-background-active;
119
129
 
120
130
  &::after {
121
- #{$global-left}: 2.25rem;
131
+ #{$global-left}: $paddle-active-offest;
122
132
  }
123
133
  }
124
134
 
@@ -155,35 +165,36 @@ $switch-paddle-transition: all 0.25s ease-out !default;
155
165
 
156
166
  /// Changes the size of a switch by modifying the size of the body and paddle. Apply this to a switch container.
157
167
  /// @param {Number} $font-size [1rem] - Font size of label text within the switch.
158
- /// @param {Number} $width [4rem] - Width of the switch body.
159
- /// @param {Number} $height [2rem] - Height of the switch body.
160
- /// @param {Number} $paddle-width [1.5rem] - Width of the switch paddle.
168
+ /// @param {Number} $switch-height [2rem] - Height of the switch body.
161
169
  /// @param {Number} $paddle-offset [0.25rem] - Spacing between the switch paddle and the edge of the switch body.
162
170
  @mixin switch-size(
163
171
  $font-size: 1rem,
164
- $width: 4rem,
165
- $height: 2rem,
166
- $paddle-width: 1.5rem,
172
+ $switch-height: 2rem,
167
173
  $paddle-offset: 0.25rem
168
174
  ) {
169
- $paddle-height: $height - ($paddle-offset * 2);
170
- $paddle-left-active: $width - $paddle-width - $paddle-offset;
171
175
 
172
- height: $height;
173
-
176
+ $switch-width: $switch-height * 2;
177
+ $paddle-width: $switch-height - ($paddle-offset * 2);
178
+ $paddle-height: $switch-height - ($paddle-offset * 2);
179
+ $paddle-active-offest: $switch-width - $paddle-width - $paddle-offset;
180
+
181
+ height: $switch-height;
182
+
174
183
  .switch-paddle {
175
- width: $width;
176
- height: $height;
184
+ width: $switch-width;
185
+ height: $switch-height;
177
186
  font-size: $font-size;
178
187
  }
179
188
 
180
189
  .switch-paddle::after {
190
+ top: $paddle-offset;
191
+ #{$global-left}: $paddle-offset;
181
192
  width: $paddle-width;
182
193
  height: $paddle-height;
183
194
  }
184
195
 
185
196
  input:checked ~ .switch-paddle::after {
186
- #{$global-left}: $paddle-left-active;
197
+ #{$global-left}: $paddle-active-offest;
187
198
  }
188
199
  }
189
200
 
@@ -223,14 +234,14 @@ $switch-paddle-transition: all 0.25s ease-out !default;
223
234
 
224
235
  // Switch sizes
225
236
  .switch.tiny {
226
- @include switch-size(rem-calc(10), 3rem, $switch-height-tiny, 1rem, $switch-paddle-offset);
237
+ @include switch-size(rem-calc(10), $switch-height-tiny, $switch-paddle-offset);
227
238
  }
228
239
 
229
240
  .switch.small {
230
- @include switch-size(rem-calc(12), 3.5rem, $switch-height-small, 1.25rem, $switch-paddle-offset);
241
+ @include switch-size(rem-calc(12), $switch-height-small, $switch-paddle-offset);
231
242
  }
232
243
 
233
244
  .switch.large {
234
- @include switch-size(rem-calc(16), 5rem, $switch-height-large, 2rem, $switch-paddle-offset);
245
+ @include switch-size(rem-calc(16), $switch-height-large, $switch-paddle-offset);
235
246
  }
236
247
  }