_accordion.scss 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. // Foundation by ZURB
  2. // foundation.zurb.com
  3. // Licensed under MIT Open Source
  4. @import 'global';
  5. //
  6. // @variables
  7. //
  8. $include-html-accordion-classes: $include-html-classes !default;
  9. $accordion-navigation-padding: rem-calc(16) !default;
  10. $accordion-navigation-bg-color: $silver !default;
  11. $accordion-navigation-hover-bg-color: scale-color($accordion-navigation-bg-color, $lightness: -5%) !default;
  12. $accordion-navigation-active-bg-color: scale-color($accordion-navigation-bg-color, $lightness: -3%) !default;
  13. $accordion-navigation-active-font-color: $jet !default;
  14. $accordion-navigation-font-color: $jet !default;
  15. $accordion-navigation-font-size: rem-calc(16) !default;
  16. $accordion-navigation-font-family: $body-font-family !default;
  17. $accordion-content-padding: ($column-gutter/2) !default;
  18. $accordion-content-active-bg-color: $white !default;
  19. // Mixin: accordion-container()
  20. // Decription: Responsible for the container component of accordions, generating styles relating to a margin of zero and a clearfix
  21. // Explicit Dependencies: a clearfix mixin *is* defined.
  22. // Implicit Dependencies: None
  23. @mixin accordion-container() {
  24. @include clearfix;
  25. margin-bottom: 0;
  26. }
  27. // Mixin: accordion-navigation( $bg, $hover-bg, $active-bg, $padding, $active_class, $font-color, $font-size, $font-family) {
  28. // @params $bg-color: [ color or string ]: Specify the background color for the navigation element
  29. // @params $hover-bg-color [ color or string ]: Specify the background color for the navigation element when hovered
  30. // @params $active-bg [ color or string ]: Specify the background color for the navigation element when clicked and not released.
  31. // @params $active_class [ string ]: Specify the class name used to keep track of which accordion tab should be visible
  32. // @params $font-color [ color or string ]: Color of the font for accordion
  33. // @params $font-size [ number ]: Specifiy the font-size of the text inside the navigation element
  34. // @params $font-family [ string ]: Specify the font family for the text of the navigation of the accorion
  35. // @params $active-font [ color or string ]: Specify the font color for the navigation element when active.
  36. @mixin accordion-navigation( $bg: $accordion-navigation-bg-color, $hover-bg: $accordion-navigation-hover-bg-color, $active-bg: $accordion-navigation-active-bg-color, $padding: $accordion-navigation-padding, $active_class: 'active', $font-color: $accordion-navigation-font-color, $font-size: $accordion-navigation-font-size, $font-family: $accordion-navigation-font-family, $active-font: $accordion-navigation-active-font-color ) {
  37. display: block;
  38. margin-bottom: 0 !important;
  39. @if type-of($active_class) != "string" {
  40. @warn "`#{$active_class}` isn't a valid string. A valid string is needed to correctly be interpolated as a CSS class. CSS classes cannot start with a number or consist of only numbers. CSS will not be generated for the active state of this navigation component."
  41. }
  42. @else {
  43. &.#{ $active_class } > a {
  44. background: $active-bg;
  45. color: $active-font;
  46. }
  47. }
  48. > a {
  49. background: $bg;
  50. color: $font-color;
  51. @if type-of($padding) != number {
  52. @warn "`#{$padding}` was read as #{type-of($padding)}";
  53. @if $accordion-navigation-padding != null {
  54. @warn "#{$padding} was read as a #{type-of($padding)}";
  55. @warn "`#{$padding}` isn't a valid number. $accordion-navigation-padding (#{$accordion-navigation-padding}) will be used instead.)";
  56. padding: $accordion-navigation-padding;
  57. }
  58. @else {
  59. @warn "`#{$padding}` isn't a valid number and $accordion-navigation-padding is missing. A value of `null` is returned to not output an invalid value for padding";
  60. padding: null;
  61. }
  62. }
  63. @else {
  64. padding: $padding;
  65. }
  66. display: block;
  67. font-family: $font-family;
  68. @if type-of($font-size) != number {
  69. @warn "`#{$font-size}` was read as a #{type-of($font-size)}";
  70. @if $accordion-navigation-font-size != null {
  71. @warn "`#{$font-size}` is not a valid number. The value of $accordion-navigation-font-size will be used instead (#{$accordion-navigation-font-size}).";
  72. font-size: $accordion-navigation-font-size;
  73. }
  74. @else{
  75. @warn "`#{$font-size}` is not a valid number and the default value of $accordion-navigation-font-size is not defined. A value of `null` will be returned to not generate an invalid value for font-size.";
  76. font-size: null;
  77. }
  78. }
  79. @else {
  80. font-size: $font-size;
  81. }
  82. &:hover {
  83. background: $hover-bg;
  84. }
  85. }
  86. }
  87. // Mixin: accordion-content($bg, $padding, $active-class)
  88. // @params $padding [ number ]: Padding for the content of the container
  89. // @params $bg [ color ]: Background color for the content when it's visible
  90. // @params $active_class [ string ]: Class name used to keep track of which accordion tab should be visible.
  91. @mixin accordion-content($bg: $accordion-content-active-bg-color, $padding: $accordion-content-padding, $active_class: 'active') {
  92. display: none;
  93. @if type-of($padding) != "number" {
  94. @warn "#{$padding} was read as a #{type-of($padding)}";
  95. @if $accordion-content-padding != null {
  96. @warn "`#{$padding}` isn't a valid number. $accordion-content-padding used instead";
  97. padding: $accordion-content-padding;
  98. } @else {
  99. @warn "`#{$padding}` isn't a valid number and the default value of $accordion-content-padding is not defined. A value of `null` is returned to not output an invalid value for padding.";
  100. padding: null;
  101. }
  102. } @else {
  103. padding: $padding;
  104. }
  105. @if type-of($active_class) != "string" {
  106. @warn "`#{$active_class}` isn't a valid string. A valid string is needed to correctly be interpolated as a CSS class. CSS classes cannot start with a number or consist of only numbers. CSS will not be generated for the active state of the content. "
  107. }
  108. @else {
  109. &.#{$active_class} {
  110. background: $bg;
  111. display: block;
  112. }
  113. }
  114. }
  115. @include exports("accordion") {
  116. @if $include-html-accordion-classes {
  117. .accordion {
  118. @include clearfix;
  119. margin-bottom: 0;
  120. margin-left: 0;
  121. .accordion-navigation, dd {
  122. display: block;
  123. margin-bottom: 0 !important;
  124. &.active > a { background: $accordion-navigation-active-bg-color; color: $accordion-navigation-active-font-color; }
  125. > a {
  126. background: $accordion-navigation-bg-color;
  127. color: $accordion-navigation-font-color;
  128. display: block;
  129. font-family: $accordion-navigation-font-family;
  130. font-size: $accordion-navigation-font-size;
  131. padding: $accordion-navigation-padding;
  132. &:hover { background: $accordion-navigation-hover-bg-color; }
  133. }
  134. > .content {
  135. display: none;
  136. padding: $accordion-content-padding;
  137. &.active {
  138. background: $accordion-content-active-bg-color;
  139. display: block;
  140. }
  141. }
  142. }
  143. }
  144. }
  145. }