A reusable block list, especially useful for mobile apps or other places where you are displaying a list of content in a confined space
<section class="block-list">
<header>A block list header</header>
<ul>
<li>
<div>
<p class="list-header"> <img src="https://lorempixel.com/30/30/animals" class="" height="" width="" alt="">A SINGLE LINE BLOCK</p> </div>
</li>
<li>
<div>
<p class="list-header">DOUBLE LINE</p>
<p class="list-subheader dark">Now with an icon</p>
</div>
<div>
<img src="https://lorempixel.com/30/30/animals" class="" height="" width="" alt="">
</div>
</li>
<li>
<div>
<p class="list-header">DOUBLE LINE</p>
<p class="list-subheader dark">What about a two icons??</p>
</div>
<div>
<img src="https://lorempixel.com/30/30/animals" class="" height="" width="" alt="">
<img src="https://lorempixel.com/30/30/animals" class="" height="" width="" alt="">
</div>
</li>
<li>
<p class="list-header">IMAGE ON THE RIGHT</p>
<img src="https://lorempixel.com/30/30/animals" class="" height="" width="" alt="">
</li>
<li class="with-chevron"><a href="#">Independent With a Chevron</a></li>
</ul>
</section>
<section class="block-list">
<header>Radio buttons list</header>
<ul>
<li>
<input type="radio" name="delicious" id="eggs" value="eggs" checked="">
<label for="eggs">Eggs</label>
</li>
<li>
<input type="radio" name="delicious" id="bacon" value="bacon">
<label for="bacon">Bacon</label>
</li>
<li>
<input type="radio" name="delicious" id="toast" value="toast">
<label for="toast">Toast</label>
</li>
</ul>
</section>
<section class="block-list">
<header>Look, I gotta Switch</header>
<ul>
<li>
<span class="list-label">Switch!</span>
<div class="switch">
<input class="switch-input" id="exampleSwitch" type="checkbox" name="exampleSwitch">
<label class="switch-paddle" for="exampleSwitch">
<span class="show-for-sr">Download Kittens</span>
</label>
</div>
</li>
</ul>
</section>
<section class="block-list">
<header>I Hold Forms</header>
<ul>
<li><input type="text" placeholder="User name"></li>
<li><input type="password" placeholder="Password"></li>
</ul>
</section>
<section class="block-list">
<header>I Even Have Selectboxes</header>
<ul>
<li class="with-dropdown"><select name="" id="">
<option>Now</option>
<option>Later</option>
<option>Eventually</option>
<option>Forever</option>
</select></li>
</ul>
</section>
$block-list-background: $white;
$block-list-item-height: rem-calc(65);
$block-list-item-border: 1px solid $light-gray;
$block-list-item-icon-size: 0.8;
$block-list-header-background: $light-gray;
$block-list-check-icons: true;
@mixin block-list-container {
width: 100%;
line-height: 1;
user-select: none;
background: $block-list-background;
a {
width: 100%;
padding-top: $global-padding;
padding-bottom: $global-padding;
color: $primary-color;
}
img {
margin-right: $global-margin;
&.small-icon {
margin-right: 0.3rem;
}
}
&, ul {
list-style-type: none;
}
ul {
margin-left: 0;
margin-bottom: 0;
li {
height: $block-list-item-height;
display: flex;
justify-content: space-between;
align-items: center;
}
}
}
@mixin block-list-header {
padding-left: 0.75rem;
padding-bottom: 0.5rem;
height: 45px;
display: flex;
align-items: flex-end;
cursor: default;
background-color: $block-list-header-background;
font-weight: bold;
text-align: left;
text-transform: uppercase;
}
@mixin block-list-item(
$border: $block-list-item-border,
$height: $block-list-item-height
) {
position: relative;
label {
color: $body-font-color;
font-size: rem-calc(14);
letter-spacing: 0;
margin: 0;
}
input, select {
margin: 0;
}
button {
padding: $global-padding;
img {
margin: 0;
}
}
@if hasvalue($border) {
border-bottom: $border;
&:first-child {
border-top: none;
}
}
// Inner elements share the same basic styles
> a,
> span,
> label {
margin-bottom: 0;
}
p {
margin-bottom: 0;
}
> span {
cursor: default;
}
> a, > label {
cursor: pointer;
}
}
@mixin block-list-label(
) {
display: inline-block;
float: right;
padding: 0;
pointer-events: none;
}
@mixin block-list-chevron {
// Chevrons are a pseudo-element
&::after {
font: normal normal normal 14px/1 FontAwesome;
text-rendering: auto;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
content: "\f054";
display: block;
right: $global-margin;
@include vertical-center;
font-weight: bold;
font-size: 1em;
color: $dark-gray;
}
}
@mixin block-list-icons(
$size: $block-list-item-icon-size,
$item-selector: 'li'
) {
$item-height: $size;
$icon-height: $item-height * $block-list-item-icon-size;
$icon-offset: ($item-height - $icon-height) / 2;
#{$item-selector} {
> a, > span, > label {
padding-left: (get-side($block-list-item-height, left) * 2) + $block-list-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;
}
}
}
@mixin block-list-inputs(
$height: $block-list-item-height,
$color: $body-font-color,
$icons: $block-list-check-icons,
$switch-class: 'switch'
) {
// Multiple select
li > input[type="checkbox"], li > input[type="radio"] {
position: absolute;
left: -9999px;
& + label {
margin: 0;
margin-left: 0.5rem;
width: 100%;
padding-top: $global-padding;
padding-bottom: $global-padding;
}
& + label.list-header {
margin: 0;
}
@if $icons == true {
&:checked + label {
&::before {
font: normal normal normal 14px/1 FontAwesome;
text-rendering: auto;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
content: "\f00c";
background-size: 100% 100%;
width: 1.5em;
height: 1.5em;
color: $primary-color;
@include vertical-center;
right: $global-margin;
pointer-events: none;
}
}
}
}
// Switches
.#{$switch-class} {
align-self: center;
margin: 0;
}
}
.switch {
.switch-paddle {
width: 3.25rem;
}
input:checked ~ .switch-paddle::after {
left: 1.3rem;
}
}
.block-list {
@include block-list-container;
@include block-list-inputs;
li {
padding-left: rem-calc(20);
padding-right: rem-calc(20);
p {
margin: 0;
}
}
.section-header-bg {
width: 100%;
height: rem-calc(20);
border-bottom: none;
border-top: none;
color: $white;
p {
z-index: 10;
}
&.gray {
background: $medium-gray;
&:before {
content: '';
height: rem-calc(20);
position: absolute;
width: rem-calc(20);
background: $medium-gray;
left: -rem-calc(20);
}
&:after {
content: '';
height: rem-calc(20);
position: absolute;
width: rem-calc(20);
background: $medium-gray;
right: -rem-calc(20);
}
}
}
&.block-list-short {
margin-top: 2rem;
border-top: $block-list-item-border;
li {
height: rem-calc(40);
}
}
&.block-list-padded {
padding: 0 rem-calc(20);
p {
margin-left: 0;
}
}
&.with-icons { @include block-list-icons; }
header { @include block-list-header; }
li {
@include block-list-item;
&.block-list-time-item {
justify-content: flex-start;
div:first-of-type {
border-right: 1px solid $primary-color;
padding-right: rem-calc(20);
margin-right: rem-calc(10);
}
}
.list-form {
display: flex;
justify-content: center;
align-items: center;
label {
flex-basis: 100%;
text-align: right;
color: #4D4D4E;
font-weight: 400;
}
[type="text"], [type="tel"] {
border: none;
box-shadow: none;
text-align: center;
}
}
p {
margin-left: 0.5rem;
}
&.list-header-selected {
padding: 1.25rem 2rem 1.25rem;
border: none;
}
&.with-chevron {
@include block-list-chevron;
a {
color: $dark-gray;
}
img {
vertical-align: bottom;
}
}
.block-list-label {
@include block-list-label;
}
}
}
.block-list-item-highlight {
span,
p {
color: $primary-color;
}
}
.switch .switch-paddle {
width: 3.25rem;
}
.switch input:checked ~ .switch-paddle::after {
left: 1.3rem;
}
.block-list {
width: 100%;
line-height: 1;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
background: #fefefe;
}
.block-list a {
width: 100%;
padding-top: 1rem;
padding-bottom: 1rem;
color: #1779ba;
}
.block-list img {
margin-right: 1rem;
}
.block-list img.small-icon {
margin-right: 0.3rem;
}
.block-list, .block-list ul {
list-style-type: none;
}
.block-list ul {
margin-left: 0;
margin-bottom: 0;
}
.block-list ul li {
height: 4.0625rem;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-justify-content: space-between;
-ms-flex-pack: justify;
justify-content: space-between;
-webkit-align-items: center;
-ms-flex-align: center;
align-items: center;
}
.block-list li > input[type="checkbox"], .block-list li > input[type="radio"] {
position: absolute;
left: -9999px;
}
.block-list li > input[type="checkbox"] + label, .block-list li > input[type="radio"] + label {
margin: 0;
margin-left: 0.5rem;
width: 100%;
padding-top: 1rem;
padding-bottom: 1rem;
}
.block-list li > input[type="checkbox"] + label.list-header, .block-list li > input[type="radio"] + label.list-header {
margin: 0;
}
.block-list li > input[type="checkbox"]:checked + label::before, .block-list li > input[type="radio"]:checked + label::before {
font: normal normal normal 14px/1 FontAwesome;
text-rendering: auto;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
content: "\f00c";
background-size: 100% 100%;
width: 1.5em;
height: 1.5em;
color: #1779ba;
position: absolute;
top: 50%;
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
right: 1rem;
pointer-events: none;
}
.block-list .switch {
-webkit-align-self: center;
-ms-flex-item-align: center;
-ms-grid-row-align: center;
align-self: center;
margin: 0;
}
.block-list li {
padding-left: 1.25rem;
padding-right: 1.25rem;
}
.block-list li p {
margin: 0;
}
.block-list .section-header-bg {
width: 100%;
height: 1.25rem;
border-bottom: none;
border-top: none;
color: #fefefe;
}
.block-list .section-header-bg p {
z-index: 10;
}
.block-list .section-header-bg.gray {
background: #cacaca;
}
.block-list .section-header-bg.gray:before {
content: '';
height: 1.25rem;
position: absolute;
width: 1.25rem;
background: #cacaca;
left: -rem-calc(20);
}
.block-list .section-header-bg.gray:after {
content: '';
height: 1.25rem;
position: absolute;
width: 1.25rem;
background: #cacaca;
right: -rem-calc(20);
}
.block-list.block-list-short {
margin-top: 2rem;
border-top: 1px solid #e6e6e6;
}
.block-list.block-list-short li {
height: 2.5rem;
}
.block-list.block-list-padded {
padding: 0 1.25rem;
}
.block-list.block-list-padded p {
margin-left: 0;
}
.block-list.with-icons li > a, .block-list.with-icons li > span, .block-list.with-icons li > label {
padding-left: 8.925rem;
}
.block-list.with-icons li img, .block-list.with-icons li .iconic {
position: absolute;
top: 0.08;
left: 0.08;
width: 0.64;
height: 0.64;
border-radius: 8px;
pointer-events: none;
}
.block-list header {
padding-left: 0.75rem;
padding-bottom: 0.5rem;
height: 45px;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-align-items: flex-end;
-ms-flex-align: end;
align-items: flex-end;
cursor: default;
background-color: #e6e6e6;
font-weight: bold;
text-align: left;
text-transform: uppercase;
}
.block-list li {
position: relative;
border-bottom: 1px solid #e6e6e6;
}
.block-list li label {
color: #0a0a0a;
font-size: 0.875rem;
letter-spacing: 0;
margin: 0;
}
.block-list li input, .block-list li select {
margin: 0;
}
.block-list li button {
padding: 1rem;
}
.block-list li button img {
margin: 0;
}
.block-list li:first-child {
border-top: none;
}
.block-list li > a,
.block-list li > span,
.block-list li > label {
margin-bottom: 0;
}
.block-list li p {
margin-bottom: 0;
}
.block-list li > span {
cursor: default;
}
.block-list li > a, .block-list li > label {
cursor: pointer;
}
.block-list li.block-list-time-item {
-webkit-justify-content: flex-start;
-ms-flex-pack: start;
justify-content: flex-start;
}
.block-list li.block-list-time-item div:first-of-type {
border-right: 1px solid #1779ba;
padding-right: 1.25rem;
margin-right: 0.625rem;
}
.block-list li .list-form {
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-justify-content: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-align-items: center;
-ms-flex-align: center;
align-items: center;
}
.block-list li .list-form label {
-webkit-flex-basis: 100%;
-ms-flex-preferred-size: 100%;
flex-basis: 100%;
text-align: right;
color: #4D4D4E;
font-weight: 400;
}
.block-list li .list-form [type="text"], .block-list li .list-form [type="tel"] {
border: none;
box-shadow: none;
text-align: center;
}
.block-list li p {
margin-left: 0.5rem;
}
.block-list li.list-header-selected {
padding: 1.25rem 2rem 1.25rem;
border: none;
}
.block-list li.with-chevron::after {
font: normal normal normal 14px/1 FontAwesome;
text-rendering: auto;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
content: "\f054";
display: block;
right: 1rem;
position: absolute;
top: 50%;
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
font-weight: bold;
font-size: 1em;
color: #8a8a8a;
}
.block-list li.with-chevron a {
color: #8a8a8a;
}
.block-list li.with-chevron img {
vertical-align: bottom;
}
.block-list li .block-list-label {
display: inline-block;
float: right;
padding: 0;
pointer-events: none;
}
.block-list-item-highlight span,
.block-list-item-highlight p {
color: #1779ba;
}