Skip to content

Commit

Permalink
feat(components): Display 1-item responsive_card_list full-width
Browse files Browse the repository at this point in the history
  • Loading branch information
delucis committed Mar 4, 2019
1 parent 84d7113 commit f33f5c8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion components/responsive_card_list.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ function responsive_card_list($opts)
{
$cards = isset($opts['cards']) ? $opts['cards'] : array();
if (!is_array($cards)) return '';
$html = '<div class="responsive-cards"><ul class="responsive-cards__list">';
$classes = array('responsive-cards');
if (count($cards) === 1) $classes[] = 'responsive-cards--single';
$html = '<div class="' . implode(' ', $classes) . '"><ul class="responsive-cards__list">';
foreach ($cards as $card) {
$html .= '<li class="responsive-cards__item">' . $card . '</li>';
}
Expand Down
8 changes: 8 additions & 0 deletions scss/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,14 @@ $item-gutter: 1em;
margin-left: 0;
}

@at-root .responsive-cards--single & {
width: 100%;

@include mq(m) {
width: calc(#{100% / $items-per-row} - #{($items-per-row - 1) / $items-per-row * $item-gutter});
}
}

@include mq(m) {
margin-bottom: $item-gutter;
width: calc(#{100% / $items-per-row} - #{($items-per-row - 1) / $items-per-row * $item-gutter});
Expand Down

0 comments on commit f33f5c8

Please sign in to comment.