_accordion.scss 6.6 KB

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