5 A generic list component that can accomodate a variety of styles and controls.
13 - Checkbox/radio inputs
16 /// @Foundation.settings
18 $blocklist-background: #fff !default;
19 $blocklist-fullbleed: true !default;
20 $blocklist-fontsize: 1rem !default;
22 $blocklist-item-padding: 0.8rem 1rem !default;
23 $blocklist-item-color: isitlight($blocklist-background, #000, #fff) !default;
24 $blocklist-item-background-hover: smartscale($blocklist-background, 4.5%) !default;
25 $blocklist-item-color-disabled: #999 !default;
26 $blocklist-item-border: 1px solid smartscale($blocklist-background, 18.5%) !default;
28 $blocklist-item-label-color: scale-color($blocklist-item-color, $lightness: 60%) !default;
29 $blocklist-item-icon-size: 0.8 !default;
31 $blocklist-header-fontsize: 0.8em !default;
32 $blocklist-header-color: smartscale($blocklist-item-color, 40%) !default;
33 $blocklist-header-uppercase: true;
35 $blocklist-check-icons: true !default;
39 Adds styles for a block list container.
41 $font-size: global font size for the list.
42 $full-bleed: when "true", the margins of the list invert to line it up with the edge of a padded element.
44 %block-list-container {
50 list-style-type: none;
56 @mixin block-list-container(
57 $font-size: $blocklist-fontsize,
58 $full-bleed: $blocklist-fullbleed
60 @extend %block-list-container;
61 font-size: $font-size;
64 margin-left: -$global-padding;
65 margin-right: -$global-padding;
70 Styles block list headers on the selector you include this mixin in (normally a <header>).
72 $color - color of the header.
73 $font-size - font size of the header.
74 $offset - left margin to add to the header, to line it up with the list items.
76 @mixin block-list-header(
77 $color: $blocklist-header-color,
78 $font-size: $blocklist-header-fontsize,
79 $uppercase: $blocklist-header-uppercase,
80 $offset: get-side($blocklist-item-padding, left)
87 font-size: $font-size;
89 @if $uppercase { text-transform: uppercase; }
93 Styles block list items on the selector you include this mixin in (normally an <li>).
95 $color - color of items.
96 $color-hover - color of items on hover.
97 $background - background of items.
98 $background-hover - background of items on hover.
99 $border - border between items.
100 $padding - padding on items.
102 @mixin block-list-item(
103 $color: $blocklist-item-color,
104 $color-hover: $blocklist-item-color,
105 $color-disabled: $blocklist-item-color-disabled,
106 $background: transparent,
107 $background-hover: $blocklist-item-background-hover,
108 $border: $blocklist-item-border,
109 $padding: $blocklist-item-padding
113 @if hasvalue($border) {
114 border-bottom: $border;
120 // Inner elements share the same basic styles
121 > a, > span, > label {
124 padding-left: get-side($padding, left);
138 > a, > label, select {
140 background: $background-hover;
146 &, &:hover { color: $alert-color; }
150 &, &:hover { color: $color-disabled; }
151 &:hover { background: transparent; }
156 Adds label styles to the class you include this mixin in.
158 $color - color of the label.
159 $left-class - extra class to flip the orientation of the label.
160 $left-padding - left padding to use for left-hand labels.
162 @mixin block-list-label(
163 $color: $blocklist-item-label-color,
165 $left-padding: get-side($blocklist-item-padding, top)
167 display: inline-block;
171 pointer-events: none;
174 margin-left: $left-padding;
180 Adds support for chevrons, which appear on the right-hand side of the item.
182 $color - color of the chevron.
183 $padding - include the global padding of block list items here.
185 @mixin block-list-chevron(
186 $color: $blocklist-header-color,
187 $padding: $blocklist-item-padding,
188 $label-class: 'block-list-label'
190 // Chevrons are a pseudo-element
195 right: get-side($padding, right);
197 transform: translateY(-50%);
203 // Labels next to links move over to make room for the chevron
204 // TODO: this selector needs to be customiable, but adding a setting just for it might be weird
206 padding-right: get-side($padding, right) * 1.5;
211 Adds icon styles. Call this mixin on a block list container.
213 $size - size of the icon as a percentage (decimal) of the list item's height.
214 $item-selector - overrides the 'li' selector used for list items.
216 @mixin block-list-icons(
217 $size: $blocklist-item-icon-size,
220 // PH - need a better solution
223 + get-side($blocklist-item-padding, top)
224 + get-side($blocklist-item-padding, top);
226 $icon-height: $item-height * $blocklist-item-icon-size;
227 $icon-offset: ($item-height - $icon-height) / 2;
230 > a, > span, > label {
231 padding-left: (get-side($blocklist-item-padding, left) * 2) + $blocklist-item-icon-size;
238 height: $icon-height;
240 pointer-events: none;
246 Adds support for text fields, select menus, and checkbox/radio groups in block lists.
248 $color - color of select menu arrow.
249 $background-hover - color of select menu when hovered over.
250 $padding - include the global padding of block list items here.
251 $dropdown-class - class to use for list items that contain a dropdown.
252 $switch-class - class to use for switches inside list items.
254 @mixin block-list-inputs(
255 $color: $blocklist-item-color,
256 $background: $blocklist-background,
257 $background-hover: $blocklist-item-background-hover,
258 $padding: $blocklist-item-padding,
259 $icons: $blocklist-check-icons,
260 $dropdown-class: 'with-dropdown',
261 $switch-class: 'switch'
264 #{$text-input-selectors} {
278 li > input[type="checkbox"], li > input[type="radio"] {
284 font-size: $blocklist-fontsize;
291 @include image-checkmark($color);
293 background-size: 100% 100%;
296 color: $primary-color;
298 pointer-events: none;
306 .#{$dropdown-class} {
310 // Reset pesky <select> styles
311 -webkit-appearance: none;
312 -moz-appearance: none;
319 font-size: 1em; // Same size as its parent
322 background-color: transparent;
330 right: get-side($padding, right);
331 transform: translateY(-50%);
335 @include exports(block-list) {
337 @include block-list-container;
338 @include block-list-inputs;
340 &.with-icons { @include block-list-icons; }
341 header { @include block-list-header; }
344 @include block-list-item;
346 &.with-chevron { @include block-list-chevron; }
347 .block-list-label { @include block-list-label; }