summaryrefslogtreecommitdiffstats
path: root/afb-client/bower_components/foundation-apps/scss/components/_block-list.scss
blob: 5b1cbe4d1cea8634a6f3b57cdb0582d09136afbf (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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
/*
  BLOCK LIST
  ----------

  A generic list component that can accomodate a variety of styles and controls.

  Features:
   - Icons
   - Labels
   - Chevrons
   - Text fields
   - Dropdown menus
   - Checkbox/radio inputs
*/

/// @Foundation.settings
// Block List
$blocklist-background: #fff !default;
$blocklist-fullbleed: true !default;
$blocklist-fontsize: 1rem !default;

$blocklist-item-padding: 0.8rem 1rem !default;
$blocklist-item-color: isitlight($blocklist-background, #000, #fff) !default;
$blocklist-item-background-hover: smartscale($blocklist-background, 4.5%) !default;
$blocklist-item-color-disabled: #999 !default;
$blocklist-item-border: 1px solid smartscale($blocklist-background, 18.5%) !default;

$blocklist-item-label-color: scale-color($blocklist-item-color, $lightness: 60%) !default;
$blocklist-item-icon-size: 0.8 !default;

$blocklist-header-fontsize: 0.8em !default;
$blocklist-header-color: smartscale($blocklist-item-color, 40%) !default;
$blocklist-header-uppercase: true;

$blocklist-check-icons: true !default;
///

/*
  Adds styles for a block list container.

  $font-size: global font size for the list.
  $full-bleed: when "true", the margins of the list invert to line it up with the edge of a padded element.
*/
%block-list-container {
  margin-bottom: 1rem;
  line-height: 1;
  user-select: none;

  &, ul {
    list-style-type: none;
  }
  ul {
    margin-left: 0;
  }
}
@mixin block-list-container(
  $font-size: $blocklist-fontsize,
  $full-bleed: $blocklist-fullbleed
) {
  @extend %block-list-container;
  font-size: $font-size;

  @if $full-bleed {
    margin-left: -$global-padding;
    margin-right: -$global-padding;
  }
}

/*
  Styles block list headers on the selector you include this mixin in (normally a <header>).

  $color - color of the header.
  $font-size - font size of the header.
  $offset - left margin to add to the header, to line it up with the list items.
*/
@mixin block-list-header(
  $color: $blocklist-header-color,
  $font-size: $blocklist-header-fontsize,
  $uppercase: $blocklist-header-uppercase,
  $offset: get-side($blocklist-item-padding, left)
) {
  margin-top: 1em;
  color: $color;
  font-weight: bold;
  margin-bottom: 0.5em;
  margin-left: $offset;
  font-size: $font-size;
  cursor: default;
  @if $uppercase { text-transform: uppercase; }
}

/*
  Styles block list items on the selector you include this mixin in (normally an <li>).

  $color - color of items.
  $color-hover - color of items on hover.
  $background - background of items.
  $background-hover - background of items on hover.
  $border - border between items.
  $padding - padding on items.
*/
@mixin block-list-item(
  $color: $blocklist-item-color,
  $color-hover: $blocklist-item-color,
  $color-disabled: $blocklist-item-color-disabled,
  $background: transparent,
  $background-hover: $blocklist-item-background-hover,
  $border: $blocklist-item-border,
  $padding: $blocklist-item-padding
) {
  position: relative;

  @if hasvalue($border) {
    border-bottom: $border;
    &:first-child {
      border-top: $border;
    }
  }

  // Inner elements share the same basic styles
  > a, > span, > label {
    display: block;
    padding: $padding;
    padding-left: get-side($padding, left);
    color: $color;
    line-height: 1;
  }
  > span {
    cursor: default;
  }
  > a, > label {
    cursor: pointer;

    &:hover {
      color: $color-hover;
    }
  }
  > a, > label, select {
    &:hover {
      background: $background-hover;
    }
  }

  // Coloring classes
  &.caution > a {
    &, &:hover { color: $alert-color; }
  }
  &.disabled > a {
    cursor: default;
    &, &:hover { color: $color-disabled; }
    &:hover { background: transparent; }
  }
}

/*
  Adds label styles to the class you include this mixin in.

  $color - color of the label.
  $left-class - extra class to flip the orientation of the label.
  $left-padding - left padding to use for left-hand labels.
*/
@mixin block-list-label(
  $color: $blocklist-item-label-color,
  $left-class: 'left',
  $left-padding: get-side($blocklist-item-padding, top)
) {
  display: inline-block;
  float: right;
  padding: 0;
  color: $color;
  pointer-events: none;

  &.#{$left-class} {
    margin-left: $left-padding;
    float: none;
  }
}

/*
  Adds support for chevrons, which appear on the right-hand side of the item.

  $color - color of the chevron.
  $padding - include the global padding of block list items here.
*/
@mixin block-list-chevron(
  $color: $blocklist-header-color,
  $padding: $blocklist-item-padding,
  $label-class: 'block-list-label'
) {
  // Chevrons are a pseudo-element
  &::after {
    content: '\203A';
    display: block;
    position: absolute;
    right: get-side($padding, right);
    top: 50%;
    transform: translateY(-50%);
    font-weight: bold;
    color: $color;
    font-size: 2em;
  }

  // Labels next to links move over to make room for the chevron
  // TODO: this selector needs to be customiable, but adding a setting just for it might be weird
  .#{$label-class} {
    padding-right: get-side($padding, right) * 1.5;
  }
}

/*
  Adds icon styles. Call this mixin on a block list container.

  $size - size of the icon as a percentage (decimal) of the list item's height.
  $item-selector - overrides the 'li' selector used for list items.
*/
@mixin block-list-icons(
  $size: $blocklist-item-icon-size,
  $item-selector: 'li'
) {
  // PH - need a better solution
  $item-height:
    $blocklist-fontsize
    + get-side($blocklist-item-padding, top)
    + get-side($blocklist-item-padding, top);

  $icon-height: $item-height * $blocklist-item-icon-size;
  $icon-offset: ($item-height - $icon-height) / 2;

  #{$item-selector} {
    > a, > span, > label {
      padding-left: (get-side($blocklist-item-padding, left) * 2) + $blocklist-item-icon-size;
    }
    img, .iconic {
      position: absolute;
      top: $icon-offset;
      left: $icon-offset;
      width: $icon-height;
      height: $icon-height;
      border-radius: 8px;
      pointer-events: none;
    }
  }
}

/*
  Adds support for text fields, select menus, and checkbox/radio groups in block lists.

  $color - color of select menu arrow.
  $background-hover - color of select menu when hovered over.
  $padding - include the global padding of block list items here.
  $dropdown-class - class to use for list items that contain a dropdown.
  $switch-class - class to use for switches inside list items.
*/
@mixin block-list-inputs(
  $color: $blocklist-item-color,
  $background: $blocklist-background,
  $background-hover: $blocklist-item-background-hover,
  $padding: $blocklist-item-padding,
  $icons: $blocklist-check-icons,
  $dropdown-class: 'with-dropdown',
  $switch-class: 'switch'
) {
  // Text fields
  #{$text-input-selectors} {
    margin: 0;
    border: 0;
    line-height: 1;
    height: auto;
    padding: $padding;
    color: inherit;

    &:hover, &:focus {
      border: 0;
    }
  }

  // Multiple select
  li > input[type="checkbox"], li > input[type="radio"] {
    position: absolute;
    left: -9999px;

    & + label {
      display: block;
      font-size: $blocklist-fontsize;
      margin: 0;
    }

    @if $icons == true {
      &:checked + label {
        &::before {
          @include image-checkmark($color);
          content: '';
          background-size: 100% 100%;
          width: 1.5em;
          height: 1.5em;
          color: $primary-color;
          float: right;
          pointer-events: none;
          margin-top: -0.25em;
        }
      }
    }
  }

  // Dropdowns
  .#{$dropdown-class} {
    color: inherit;

    select {
      // Reset pesky <select> styles
      -webkit-appearance: none;
         -moz-appearance: none;
      outline: 0;
      background: 0;
      border: 0;
      height: auto;
      padding: $padding;
      margin: 0;
      font-size: 1em; // Same size as its parent
      line-height: 1;
      color: inherit;
      background-color: transparent;
    }
  }

  // Switches
  .#{$switch-class} {
    position: absolute;
    top: 50%;
    right: get-side($padding, right);
    transform: translateY(-50%);
  }
}

@include exports(block-list) {
  .block-list {
    @include block-list-container;
    @include block-list-inputs;

    &.with-icons { @include block-list-icons; }
    header       { @include block-list-header; }

    li {
      @include block-list-item;

      &.with-chevron    { @include block-list-chevron; }
      .block-list-label { @include block-list-label; }
    }
  }
}