summaryrefslogtreecommitdiff
path: root/source/bower_components/foundation/scss/foundation/components/_accordion.scss
blob: 84d9611a585ebc7e102bf2dc7accff1acaf9fc9f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
// Foundation by ZURB
// foundation.zurb.com
// Licensed under MIT Open Source

@import "global";

//
// @variables
//

$include-html-accordion-classes: $include-html-classes !default;

$accordion-navigation-padding: rem-calc(16) !default;
$accordion-navigation-bg-color: $silver !default;
$accordion-navigation-hover-bg-color: scale-color($accordion-navigation-bg-color, $lightness: -5%) !default;
$accordion-navigation-active-bg-color: scale-color($accordion-navigation-bg-color, $lightness: -3%) !default;
$accordion-navigation-font-color: $jet !default;
$accordion-navigation-font-size: rem-calc(16) !default;
$accordion-navigation-font-family: $body-font-family !default;

$accordion-content-padding: $column-gutter/2 !default;
$accordion-content-active-bg-color: $white !default;


//  Mixin: accordion-container()
//  Decription: Responsible for the container component of accordions, generating styles relating to a margin of zero and a clearfix
//  Explicit Dependencies: a clearfix mixin *is* defined.
//  Implicit Dependencies: None

@mixin accordion-container() {
  @include clearfix;
  margin-bottom: 0;
}

//  Mixin: accordion-navigation( $bg, $hover-bg, $active-bg, $padding, $active_class,  $font-color, $font-size, $font-family){
//    @params $bg-color: [ color or string ]: Specify the background color for the navigation element
//    @params $hover-bg-color [ color or string ]: Specify the background color for the navigation element when hovered
//    @params $active-bg [ color or string ]: Specify the background color for the navigation element when clicked and not released.
//    @params $active_class [ string ]: Specify the class name used to keep track of which accordion tab should be visible
//    @params $font-color [ color or string ]: Color of the font for accordion
//    @params $font-size [ number ]: Specifiy the font-size of the text inside the navigation element
//    @params $font-family [ string ]: Specify the font family for the text of the navigation of the accorion

@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 ){
  display: block;
  margin-bottom: 0 !important;
  @if type-of($active_class) != "string" {
    @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."
  }
  @else {
    &.#{ $active_class } > a {
      background: $active-bg;
    }
  }
  > a {
    background: $bg;
    color: $font-color;
    @if type-of($padding) != number {
      @warn "`#{$padding}` was read as #{type-of($padding)}";
      @if $accordion-navigation-padding != null {
        @warn "#{$padding} was read as a #{type-of($padding)}";
        @warn "`#{$padding}` isn't a valid number. $accordion-navigation-padding (#{$accordion-navigation-padding}) will be used instead.)";
        padding: $accordion-navigation-padding;
      }
      @else {
        @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";
        padding: null;
      }
    }
    @else {
      padding: $padding;
    }
    display: block;
    font-family: $font-family;
    @if type-of($font-size) != number {
      @warn "`#{$font-size}` was read as a #{type-of($font-size)}";
      @if $accordion-navigation-font-size != null {
        @warn "`#{$font-size}` is not a valid number. The value of $accordion-navigation-font-size will be used instead (#{$accordion-navigation-font-size}).";
        font-size: $accordion-navigation-font-size;
      }
      @else{
        @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.";
        font-size: null;

      }
    }
    @else {
      font-size: $font-size;
    }
    &:hover {
      background: $hover-bg;
    }
  }
}

//  Mixin: accordion-content($bg, $padding, $active-class)
//    @params $padding [ number ]: Padding for the content of the container
//    @params $bg [ color  ]: Background color for the content when it's visible
//    @params $active_class [ string ]: Class name used to keep track of which accordion tab should be visible.

@mixin accordion-content($bg: $accordion-content-active-bg-color, $padding: $accordion-content-padding, $active_class: 'active'){
  display: none;
  @if type-of($padding) != "number" {
    @warn "#{$padding} was read as a #{type-of($padding)}";
    @if $accordion-content-padding != null {
      @warn "`#{$padding}` isn't a valid number. $accordion-content-padding used instead";
      padding: $accordion-content-padding;
    } @else {
      @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.";
      padding: null;
    }
  } @else {
    padding: $padding;
  }

  @if type-of($active_class) != "string" {
    @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. "
  }
  @else {
    &.#{$active_class} {
      display: block;
      background: $bg;
    }
  }
}

@include exports("accordion") {
  @if $include-html-accordion-classes {
    .accordion {
      @include clearfix;
      margin-bottom: 0;
      .accordion-navigation, dd {
        display: block;
        margin-bottom: 0 !important;
        &.active > a { background: $accordion-navigation-active-bg-color; }
        > a {
          background: $accordion-navigation-bg-color;
          color: $accordion-navigation-font-color;
          padding: $accordion-navigation-padding;
          display: block;
          font-family: $accordion-navigation-font-family;
          font-size: $accordion-navigation-font-size;
          &:hover { background: $accordion-navigation-hover-bg-color; }
        }

        > .content {
          display: none;
          padding: $accordion-content-padding;
          &.active {
            display: block;
            background: $accordion-content-active-bg-color;
          }
        }
      }
    }
  }
}