summaryrefslogtreecommitdiffstats
path: root/afb-client/bower_components/foundation-apps/scss/components/_button-group.scss
blob: 8505c84ef9c8151a2b58d86d2f8d8867b5d9a317 (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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
/// @Foundation.settings
// Button Group
$btngroup-background: $primary-color !default;
$btngroup-color: #fff !default;
$btngroup-radius: $button-radius !default;
///

$child-selectors: '> a, > label, > button';

%button-group {
  margin: 0;
  margin-bottom: 1rem;
  list-style-type: none;
  display: inline-flex;
  border-radius: $btngroup-radius;
  overflow: hidden;
  font-size: $button-font-size;

  > li {
    flex: 0 0 auto;

    // Links become buttons
    #{$child-selectors} {
      @extend %button;
      border-radius: 0;
      font-size: inherit;
      display: block;
      margin: 0;
    }
    > input + label {
      margin-left: 0;
    }
    // Add borders between items
    &:not(:last-child) {
      #{$child-selectors} {
        border-right: 1px solid scale-color($btngroup-background, $lightness: -25%);
      }
    }
  }

  @if using(iconic) {
    .iconic {
      width: 1em;
      height: 1em;
      vertical-align: middle;
      margin-right: 0.25em;
      margin-top: -2px; // The icons are oddly misaligned
    }
  }
}

%button-group-segmented {
  border: 1px solid $primary-color;
  transition-property: background color;

  > li {
    // Hide the radio button
    > input[type="radio"] {
      position: absolute;
      left: -9999px;
    }
    // This is the button
    #{$child-selectors} {
      margin-right: 0;
      background: transparent;
    }
  }
}

@mixin button-group-size($size: medium, $expand: false) {
  $size: $button-font-size * map-get($button-sizes, $size);
  font-size: $size;

  @if $expand {
    @include button-group-expand;
  }
}
@mixin button-group-expand($stretch: true) {
  display: if($stretch, flex, inline-flex);

  > li {
    flex: if($stretch, 1, 0 0 auto);

    #{$child-selectors} {
      @if $stretch { @include button-expand; }
    }
  }
}
@mixin button-group-style(
  $segmented: false,
  $background: $primary-color,
  $color: auto
) {

  @if not($segmented) {
    > li {
      #{$child-selectors} {
        @include button-style($background, auto, $color);
        border-color: scale-color($background, $lightness: -15%);
      }
      &.is-active {
        #{$child-selectors} {
          background: scale-color($background, $lightness: -15%);
        }
      }
    }
  }
  @else {
    @extend %button-group-segmented;
    $hover-color: rgba($background, 0.25);
    border-color: $background;

    > li {
      // This is the button
      #{$child-selectors} {
        border-color: $background;
        color: $background;

        // This is the button being hovered on
        &:hover {
          background: $hover-color;
          color: $background;
        }

        @if using(iconic) {
          .iconic { @include color-icon($background); }
        }
      }

      // This is the button when it's active
      &.is-active > a,
      > input:checked + label {
        &, &:hover {
          background: $background;
          color: isitlight($background);
        }

        @if using(iconic) {
          .iconic { @include color-icon(isitlight($background)); }
        }
      }
    }
  }
}

@mixin button-group(
  $segmented: false,
  $expand: false,
  $background: $primary-color,
  $color: #fff
) {
  @extend %button-group;
  @include button-group-expand($expand);
  @include button-group-style($segmented, $background, $color);
  border-radius: $btngroup-radius;
}

@include exports(button-group) {
  .button-group {
    @include button-group;

    // Colors
    &.secondary { @include button-group-style(false, $secondary-color); }
    &.success   { @include button-group-style(false, $success-color); }
    &.warning   { @include button-group-style(false, $warning-color); }
    &.alert     { @include button-group-style(false, $alert-color); }

    // Individual colors
    > li {
      &.secondary { #{$child-selectors} { @include button-style($secondary-color, auto, $btngroup: true); } }
      &.success   { #{$child-selectors} { @include button-style($success-color, auto, $btngroup: true); } }
      &.warning   { #{$child-selectors} { @include button-style($warning-color, auto, $btngroup: true); } }
      &.alert     { #{$child-selectors} { @include button-style($alert-color, auto, $btngroup: true); } }
    }

    // Segmented
    &.segmented { @include button-group-style(true);
      &.secondary { @include button-group-style(true, $secondary-color); }
      &.success   { @include button-group-style(true, $success-color); }
      &.warning   { @include button-group-style(true, $warning-color); }
      &.alert     { @include button-group-style(true, $alert-color); }
    }

    // Sizing
    &.tiny      { @include button-group-size(tiny); }
    &.small     { @include button-group-size(small); }
    &.large     { @include button-group-size(large); }
    &.expand    { @include button-group-expand; }

    // Disabled
    li.disabled {
      #{$child-selectors} {
        @include button-disabled;
      }
    }
  }
}