Browse Source

Okay, widgets.

pull/11/head
Ned Zimmerman 7 years ago
parent
commit
3519663dd7
No known key found for this signature in database
GPG Key ID: FF56334A013120CA
  1. 43
      app/admin.php
  2. 16
      app/controllers/FrontPage.php
  3. 8
      app/setup.php
  4. 2
      resources/assets/styles/components/_buttons.scss
  5. 220
      resources/assets/styles/layouts/_pages.scss
  6. 47
      resources/views/front-page.blade.php
  7. 10
      resources/views/partials/front-page-block.blade.php

43
app/admin.php

@ -66,49 +66,6 @@ add_action('customize_register', function (\WP_Customize_Manager $wp_customize)
'section' => 'pb_network_social', 'section' => 'pb_network_social',
'settings' => 'pb_network_twitter', 'settings' => 'pb_network_twitter',
]); ]);
$wp_customize->add_section('pb_front_page_content', [
'title' => __('Front Page Content', 'aldine'),
'priority' => 20,
]);
for ($i = 1; $i < 5; $i++) {
$wp_customize->add_setting("pb_front_page_block_${i}_title", [
'type' => 'option',
'sanitize_callback' => 'sanitize_text_field',
]);
$wp_customize->add_control("pb_front_page_block_${i}_title", [
'label' => sprintf(__('Block %d Title', 'aldine'), $i),
'section' => 'pb_front_page_content',
'settings' => "pb_front_page_block_${i}_title",
]);
$wp_customize->add_setting("pb_front_page_block_${i}_content", [
'type' => 'option',
'sanitize_callback' => 'sanitize_textarea_field',
]);
$wp_customize->add_control("pb_front_page_block_${i}_content", [
'label' => sprintf(__('Block %d Content', 'aldine'), $i),
'type' => 'textarea',
'section' => 'pb_front_page_content',
'settings' => "pb_front_page_block_${i}_content",
]);
$wp_customize->add_setting("pb_front_page_block_${i}_button_title", [
'type' => 'option',
'sanitize_callback' => 'sanitize_text_field',
]);
$wp_customize->add_control("pb_front_page_block_${i}_button_title", [
'label' => sprintf(__('Block %d Button Title', 'aldine'), $i),
'section' => 'pb_front_page_content',
'settings' => "pb_front_page_block_${i}_button_title",
]);
$wp_customize->add_setting("pb_front_page_block_${i}_button_url", [
'type' => 'option',
'sanitize_callback' => 'esc_url_raw',
]);
$wp_customize->add_control("pb_front_page_block_${i}_button_url", [
'label' => sprintf(__('Block %d Button URL', 'aldine'), $i),
'section' => 'pb_front_page_content',
'settings' => "pb_front_page_block_${i}_button_url",
]);
}
$wp_customize->add_section('pb_front_page_catalog', [ $wp_customize->add_section('pb_front_page_catalog', [
'title' => __('Front Page Catalog', 'aldine'), 'title' => __('Front Page Catalog', 'aldine'),
'priority' => 25, 'priority' => 25,

16
app/controllers/FrontPage.php

@ -8,13 +8,15 @@ class FrontPage extends Controller
{ {
public function blockCount() public function blockCount()
{ {
$c = 0; global $_wp_sidebars_widgets;
for ($i = 1; $i < 5; $i++) { if (empty($_wp_sidebars_widgets)) {
if (get_option("pb_front_page_block_${i}_content")) { $_wp_sidebars_widgets = get_option('sidebars_widgets', []);
$c++; }
} $sidebars_widgets_count = $_wp_sidebars_widgets;
} if (isset($sidebars_widgets_count['front-page-block'])) {
return $c; return count($sidebars_widgets_count['front-page-block']);
}
return 1;
} }
public function blocks() public function blocks()

8
app/setup.php

@ -109,8 +109,12 @@ add_action('widgets_init', function () {
]; ];
register_sidebar([ register_sidebar([
'name' => __('Front Page Content', 'aldine'), 'name' => __('Front Page Content', 'aldine'),
'id' => 'front-page-block' 'id' => 'front-page-block',
] + $config); 'before_widget' => '<section class="widget %1$s %2$s">',
'after_widget' => '</section>',
'before_title' => '<h3 class="tc ttu">',
'after_title' => '</h3>'
]);
register_sidebar([ register_sidebar([
'name' => __('Network Footer Block 1', 'aldine'), 'name' => __('Network Footer Block 1', 'aldine'),
'id' => 'network-footer-block-1' 'id' => 'network-footer-block-1'

2
resources/assets/styles/components/_buttons.scss

@ -3,7 +3,7 @@
width: 250px; width: 250px;
height: 60px; height: 60px;
margin-top: 2em; margin-top: 2em;
padding: 1.25em; padding: 1em;
border: 2px solid $black; border: 2px solid $black;
border-radius: 3px; border-radius: 3px;
background: $black; background: $black;

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

@ -1,7 +1,9 @@
.home { .home {
.block { .widget,
.latest-books {
height: 445px; height: 445px;
background-color: $white; background-color: $white;
text-align: center;
h3 { h3 {
font-size: em(30); font-size: em(30);
@ -20,106 +22,99 @@
} }
} }
.widget p { p {
font-size: em(16); font-size: em(16);
line-height: (32/16); line-height: (32/16);
} }
}
.widget {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
&.latest-books { .blocks.blocks-2 {
.widget_text:nth-child(2) {
border: solid 2px $brand-primary;
box-shadow: unset; box-shadow: unset;
height: auto; }
padding-bottom: 50px; }
h3 { .blocks.blocks-4 {
margin-top: 70px; .widget_text:nth-child(2) {
} color: $white;
background: $brand-secondary;
.inside { h3::before {
padding: 0; background-color: $white;
} }
.navigation { .button {
a { border-color: $white;
&.slick-disabled { background: transparent;
opacity: 0;
} &:hover,
&:focus {
color: $brand-secondary;
background: $white;
} }
} }
} }
.books { .widget_text:nth-child(3) {
.book, border: solid 2px $brand-primary;
.slick-slide { box-shadow: unset;
width: 100vw;
height: 386px;
margin: 45px 0 0;
padding: 0 29.5px;
border: solid 2px;
a {
font-family: $font-family-sans-serif;
color: $white;
text-decoration: none;
}
.subject {
height: 91px;
margin-top: 24px;
font-size: em(24);
}
.title {
height: 329px - 115px;
font-size: em(30);
font-weight: 500;
}
.read-more {
font-size: em(18);
}
}
} }
} }
.one-two { .latest-books {
width: 100%; box-shadow: unset;
display: flex; height: auto;
flex-direction: column; padding-bottom: 0 0 50px;
.block-2 { h3 {
background: $brand-secondary; margin-top: 70px;
}
p, .book,
h3 { .slick-slide {
width: 100vw;
height: 386px;
margin: 45px 0 0;
padding: 0 29.5px;
border: solid 2px;
a {
font-family: $font-family-sans-serif;
color: $white; color: $white;
text-decoration: none;
} }
h3::before { .subject {
background-color: $white; height: 91px;
margin-top: 24px;
font-size: em(24);
}
.title {
height: 329px - 115px;
font-size: em(30);
font-weight: 500;
}
.read-more {
font-size: em(18);
} }
} }
}
.main > .block-2, .navigation {
.one-two + .block { a {
background: transparent; &.slick-disabled {
border: solid 2px $brand-primary; opacity: 0;
// margin-bottom: 401px; }
}
&::after {
position: absolute;
left: 0;
top: 1840px;
content: "";
display: block;
display: none;
width: 100vw;
height: 600px;
z-index: -1;
// background: url('../images/banner-two.jpg');
background-position: center;
background-repeat: no-repeat;
background-size: cover;
} }
} }
} }
@ -130,9 +125,10 @@
margin-top: -366px; margin-top: -366px;
} }
.block { .widget {
width: 775px; width: 775px;
margin-bottom: 119px; margin-bottom: 119px;
padding: 0 90px;
box-shadow: -3px 5px 4px 2px rgba(135, 135, 135, 0.09); box-shadow: -3px 5px 4px 2px rgba(135, 135, 135, 0.09);
h3 { h3 {
@ -148,33 +144,11 @@
font-size: em(18); font-size: em(18);
line-height: (32/18); line-height: (32/18);
} }
.inside {
width: 595px;
}
} }
.one-two { .latest-books {
align-items: center;
}
.main > .block-2,
.one-two + .block {
border: solid 2px $brand-primary;
box-shadow: unset;
&::after {
top: 2020px;
}
}
.block.latest-books {
width: 100%; width: 100%;
.inside {
width: 100%;
}
.books { .books {
flex-direction: row; flex-direction: row;
justify-content: space-between; justify-content: space-between;
@ -195,26 +169,15 @@
@media (min-width: $large) { @media (min-width: $large) {
.home { .home {
.block { .widget {
width: 1115px; width: 1115px;
height: 494px; height: 494px;
} }
.main > .block-2, .latest-books {
.one-two + .block {
&::after {
top: 2150px;
}
}
.block.latest-books {
width: 1200px; width: 1200px;
margin-bottom: 0; margin-bottom: 0;
.inside {
width: 100%;
}
.book, .book,
.slick-slide { .slick-slide {
width: 367px; width: 367px;
@ -230,30 +193,29 @@
@media (min-width: $extra-large) { @media (min-width: $extra-large) {
.home { .home {
.block { .widget {
width: 1115px; width: 1115px;
box-shadow: -3px 5px 4px 2px rgba(135, 135, 135, 0.09); box-shadow: -3px 5px 4px 2px rgba(135, 135, 135, 0.09);
} }
.one-two { .blocks.blocks-4 {
flex-direction: row; display: flex;
justify-content: space-between; flex-flow: row wrap;
width: 1615px; width: 1615px;
.block { .widget_text {
border-radius: 4px; width: 1115px;
width: 775px; margin-right: auto;
margin-left: auto;
}
.inside { .widget_text:nth-child(1),
width: 595px; .widget_text:nth-child(2) {
} width: 775px;
} }
}
.main > .block-2, .widget_text:nth-child(1) {
.one-two + .block { margin-right: 65px;
&::after {
top: 1550px;
} }
} }
} }

47
resources/views/front-page.blade.php

@ -1,8 +1,11 @@
@extends('layouts.app') @extends('layouts.app')
@section('content') @section('content')
@if($block_count === 0) <section class="blocks blocks-{{ $block_count }}">
@component('partials.front-page-block', ['index' => 1]) @if(is_active_sidebar('front-page-block'))
@php(dynamic_sidebar('front-page-block'))
@else
@component('front-page-block')
@slot('title') @slot('title')
{{ __('About Pressbooks', 'aldine') }} {{ __('About Pressbooks', 'aldine') }}
@endslot @endslot
@ -14,47 +17,9 @@
{{ network_home_url('/about/') }} {{ network_home_url('/about/') }}
@endslot @endslot
@endcomponent @endcomponent
@elseif($block_count < 4)
@foreach($blocks as $block)
@component('partials.front-page-block', [
'index' => $loop->iteration,
'title' => (isset($block['title'])) ? $block['title'] : false,
'button_title' => (isset($block['button_title'])) ? $block['button_title'] : false,
'button_url' => (isset($block['button_url'])) ? $block['button_url'] : false,
])
{!! $block['content'] !!}
@endcomponent
@endforeach
@elseif($block_count === 4)
<div class="one-two">
@for($i = 0; $i < 2; $i++)
@component('partials.front-page-block', [
'index' => $i + 1,
'title' => (isset($blocks[$i]['title'])) ? $blocks[$i]['title'] : false,
'button_title' => (isset($blocks[$i]['button_title'])) ? $blocks[$i]['button_title'] : false,
'button_url' => (isset($blocks[$i]['button_url'])) ? $blocks[$i]['button_url'] : false,
])
{!! $blocks[$i]['content'] !!}
@endcomponent
@endfor
</div>
@for($i = 2; $i < $block_count; $i++)
@component('partials.front-page-block', [
'index' => $i + 1,
'title' => (isset($blocks[$i]['title'])) ? $blocks[$i]['title'] : false,
'button_title' => (isset($blocks[$i]['button_title'])) ? $blocks[$i]['button_title'] : false,
'button_url' => (isset($blocks[$i]['button_url'])) ? $blocks[$i]['button_url'] : false,
])
{!! $blocks[$i]['content'] !!}
@endcomponent
@endfor
@endif
@if(is_active_sidebar('front-page-block'))
@component('partials.front-page-block', ['index' => 'custom', 'title' => false, 'button_title' => false, 'button_url' => false])
@php(dynamic_sidebar('front-page-block'))
@endcomponent
@endif @endif
@if(get_option('pb_front_page_catalog')) @if(get_option('pb_front_page_catalog'))
@include('partials.front-page-catalog') @include('partials.front-page-catalog')
@endif @endif
</section>
@endsection @endsection

10
resources/views/partials/front-page-block.blade.php

@ -1,11 +1,7 @@
<div class="block block-{{ $index }} flex flex-column items-center justify-center p-0 w-100"> <div class="block flex flex-column items-center justify-center p-0 w-100">
<div class="inside tc"> <div class="inside tc">
@if($title) <h3 class="tc ttu primary">{{ $title }}</h3>
<h3 class="tc ttu primary">{{ $title }}</h3>
@endif
{{ $slot }} {{ $slot }}
@if($button_url && $button_title) <a class="button button-primary" href="{{ $button_url }}">{{ $button_title }}</a>
<a class="button button-primary" href="{{ $button_url }}">{{ $button_title }}</a>
@endif
</div> </div>
</div> </div>

Loading…
Cancel
Save