Browse Source

More responsive output of blocks.

pull/3/head
Ned Zimmerman 7 years ago
parent
commit
a9f459e698
No known key found for this signature in database
GPG Key ID: FF56334A013120CA
  1. 71
      app/controllers/Home.php
  2. 4
      app/setup.php
  3. 6
      dist/assets.json
  4. 0
      dist/scripts/customizer_4c93eef7.js
  5. 0
      dist/scripts/main_4c93eef7.js
  6. 2
      dist/styles/main_4c93eef7.css
  7. 92
      resources/assets/styles/layouts/_pages.scss
  8. 64
      resources/views/index.blade.php

71
app/controllers/Home.php

@ -6,13 +6,70 @@ use Sober\Controller\Controller;
class Home extends Controller class Home extends Controller
{ {
function block_count() { public function blockCount()
{
$c = 0; $c = 0;
foreach(['home-block-one', 'home-block-two', 'home-block-three', 'home-block-four', 'home-block-five'] as $block) { foreach ([
if (is_active_sidebar($block)) { 'home-block-one',
$c++; 'home-block-two',
} 'home-block-three',
} 'home-block-four',
return $c; 'home-block-five'
] as $block) {
if (is_active_sidebar($block)) {
$c++;
}
}
return $c;
}
public function home_blocks()
{
$blocks = [];
for ($i = 0; $i < 5; $i++) {
if ($i === 0) {
if (Home::getNextBlock()) {
$blocks[] = Home::getNextBlock();
}
} elseif ($i > 0) {
if (Home::getNextBlock($blocks[$i - 1])) {
$blocks[] = Home::getNextBlock($blocks[$i - 1]);
} else {
break;
}
}
}
return $blocks;
}
public static function getNextBlock($current_block = null)
{
switch ($current_block) {
case 'home-block-one':
$next_block = 'home-block-two';
break;
case 'home-block-two':
$next_block = 'home-block-three';
break;
case 'home-block-three':
$next_block = 'home-block-four';
break;
case 'home-block-four':
$next_block = 'home-block-five';
break;
case 'home-block-five':
$next_block = null;
break;
default:
$next_block = 'home-block-one';
}
if (! $next_block) {
return false;
} elseif (is_active_sidebar($next_block)) {
return $next_block;
} else {
Home::getNextBlock($next_block);
}
} }
} }

4
app/setup.php

@ -100,6 +100,10 @@ add_action('widgets_init', function () {
'name' => __('Home Block Four', 'pressbooks-aldine'), 'name' => __('Home Block Four', 'pressbooks-aldine'),
'id' => 'home-block-four' 'id' => 'home-block-four'
] + $config); ] + $config);
register_sidebar([
'name' => __('Home Block Five', 'pressbooks-aldine'),
'id' => 'home-block-five'
] + $config);
}); });
/** /**

6
dist/assets.json vendored

@ -10,7 +10,7 @@
"vendor/fontawesome-webfont.ttf?v=4.7.0": "vendor/fontawesome-webfont_b06871f2.ttf", "vendor/fontawesome-webfont.ttf?v=4.7.0": "vendor/fontawesome-webfont_b06871f2.ttf",
"vendor/fontawesome-webfont.woff2?v=4.7.0": "vendor/fontawesome-webfont_af7ae505.woff2", "vendor/fontawesome-webfont.woff2?v=4.7.0": "vendor/fontawesome-webfont_af7ae505.woff2",
"vendor/fontawesome-webfont.woff?v=4.7.0": "vendor/fontawesome-webfont_fee66e71.woff", "vendor/fontawesome-webfont.woff?v=4.7.0": "vendor/fontawesome-webfont_fee66e71.woff",
"scripts/customizer.js": "scripts/customizer_9ceb9969.js", "scripts/customizer.js": "scripts/customizer_4c93eef7.js",
"styles/main.css": "styles/main_9ceb9969.css", "styles/main.css": "styles/main_4c93eef7.css",
"scripts/main.js": "scripts/main_9ceb9969.js" "scripts/main.js": "scripts/main_4c93eef7.js"
} }

0
dist/scripts/customizer_9ceb9969.js → dist/scripts/customizer_4c93eef7.js vendored

0
dist/scripts/main_9ceb9969.js → dist/scripts/main_4c93eef7.js vendored

2
dist/styles/main_9ceb9969.css → dist/styles/main_4c93eef7.css vendored

File diff suppressed because one or more lines are too long

92
resources/assets/styles/layouts/_pages.scss

@ -4,6 +4,7 @@
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
padding: 0 12.5px;
width: 100%; width: 100%;
height: 445px; height: 445px;
background-color: $white; background-color: $white;
@ -15,6 +16,7 @@
text-transform: uppercase; text-transform: uppercase;
letter-spacing: 2px; letter-spacing: 2px;
line-height: 36px; line-height: 36px;
color: $brand-primary;
margin: 0; margin: 0;
&::before { &::before {
@ -30,6 +32,7 @@
p { p {
font-size: 16px; font-size: 16px;
line-height: 32px; line-height: 32px;
text-align: center;
} }
.inside { .inside {
@ -41,23 +44,41 @@
width: 100%; width: 100%;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
}
.block.two { .block-2 {
color: $white; background: $brand-secondary;
background: $brand-secondary;
p,
h3 {
color: $white;
}
h3::before { h3::before {
background-color: $white; background-color: $white;
}
} }
} }
.block.one, .main > .block-2,
.block.two, .one-two + .block {
.block.three, background: transparent;
.block.four, border: solid 2px $brand-primary;
.block.five { margin-bottom: 401px;
padding: 0 12.5px;
&::after {
position: absolute;
left: 0;
top: 1840px;
content: "";
display: block;
width: 100vw;
height: 600px;
z-index: -1;
background: url('../images/banner-two.jpg');
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
} }
} }
@ -94,6 +115,16 @@
.one-two { .one-two {
align-items: center; align-items: center;
} }
.main > .block-2,
.one-two + .block {
border: solid 2px $brand-primary;
box-shadow: unset;
&::after {
top: 2020px;
}
}
} }
} }
@ -103,34 +134,43 @@
width: 1115px; width: 1115px;
height: 494px; height: 494px;
} }
.main > .block-2,
.one-two + .block {
&::after {
top: 2150px;
}
}
} }
} }
@media (min-width: $extra-large) { @media (min-width: $extra-large) {
.home { .home {
.block {
width: 1115px;
box-shadow: -3px 5px 4px 2px rgba(135, 135, 135, 0.09);
}
.one-two { .one-two {
flex-direction: row; flex-direction: row;
justify-content: space-between; justify-content: space-between;
width: 1615px; width: 1615px;
}
.block.one, .block {
.block.two { border-radius: 4px;
border-radius: 4px; width: 775px;
width: 775px;
.inside { .inside {
width: 595px; width: 595px;
}
} }
} }
.block.three { .main > .block-2,
width: 100%; .one-two + .block {
} &::after {
top: 1550px;
.block.four { }
width: 1115px;
box-shadow: -3px 5px 4px 2px rgba(135, 135, 135, 0.09);
} }
} }
} }

64
resources/views/index.blade.php

@ -1,49 +1,37 @@
@extends('layouts.app') @extends('layouts.app')
@section('content') @section('content')
@debug('dump') @if($block_count < 5)
@if(is_active_sidebar('home-block-one') && is_active_sidebar('home-block-two')) @for($i = 0; $i < $block_count; $i++)
<div class="one-two"> <div class="block block-{{ $i + 1 }}">
@endif <div class="inside">
<div class="block one"> @php(dynamic_sidebar($home_blocks[$i]))
<div class="inside"> </div>
@if(is_active_sidebar('home-block-one'))
@php(dynamic_sidebar('home-block-one'))
@else
<h3>{{ __('About Pressbooks', 'pressbooks-aldine')}}</h3>
<p>{{ __('Pressbooks is easy-to-use book writing software that lets you create a book in all the formats you need to publish.', 'pressbooks-aldine')}}</p>
@endif
</div> </div>
@endfor
@elseif($block_count === 5)
<div class="one-two">
@for($i = 0; $i < 2; $i++)
<div class="block block-{{ $i + 1 }}">
<div class="inside">
@php(dynamic_sidebar($home_blocks[$i]))
</div>
</div>
@endfor
</div> </div>
@if(is_active_sidebar('home-block-two')) @for($i = 2; $i < $block_count; $i++)
<div class="block two"> <div class="block block-{{ $i + 1 }}">
<div class="inside"> <div class="inside">
@php(dynamic_sidebar('home-block-two')) @php(dynamic_sidebar($home_blocks[$i]))
</div> </div>
</div> </div>
@endif @endfor
@if(is_active_sidebar('home-block-one') && is_active_sidebar('home-block-two')) @else
</div> <div class="block block-1">
@endif <div class="inside">
@if(is_active_sidebar('home-block-three')) <h3>{{ __('About Pressbooks', 'pressbooks-aldine')}}</h3>
<div class="block three"> <p>{{ __('Pressbooks is easy-to-use book writing software that lets you create a book in all the formats you need to publish.', 'pressbooks-aldine')}}</p>
<div class="inside"> </div>
@php(dynamic_sidebar('home-block-three'))
</div>
</div>
@endif
@if(is_active_sidebar('home-block-four'))
<div class="block four">
<div class="inside">
@php(dynamic_sidebar('home-block-four'))
</div>
</div>
@endif
@if(is_active_sidebar('home-block-five'))
<div class="block five">
<div class="inside">
@php(dynamic_sidebar('home-block-five'))
</div> </div>
</div>
@endif @endif
@endsection @endsection

Loading…
Cancel
Save