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. 12
      app/controllers/FrontPage.php
  3. 8
      app/setup.php
  4. 2
      resources/assets/styles/components/_buttons.scss
  5. 174
      resources/assets/styles/layouts/_pages.scss
  6. 47
      resources/views/front-page.blade.php
  7. 6
      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',
'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', [
'title' => __('Front Page Catalog', 'aldine'),
'priority' => 25,

12
app/controllers/FrontPage.php

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

8
app/setup.php

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

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

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

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

@ -1,7 +1,9 @@
.home {
.block {
.widget,
.latest-books {
height: 445px;
background-color: $white;
text-align: center;
h3 {
font-size: em(30);
@ -20,34 +22,62 @@
}
}
.widget p {
p {
font-size: em(16);
line-height: (32/16);
}
}
&.latest-books {
box-shadow: unset;
height: auto;
padding-bottom: 50px;
.widget {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
h3 {
margin-top: 70px;
.blocks.blocks-2 {
.widget_text:nth-child(2) {
border: solid 2px $brand-primary;
box-shadow: unset;
}
}
.blocks.blocks-4 {
.widget_text:nth-child(2) {
color: $white;
background: $brand-secondary;
.inside {
padding: 0;
h3::before {
background-color: $white;
}
.navigation {
a {
&.slick-disabled {
opacity: 0;
.button {
border-color: $white;
background: transparent;
&:hover,
&:focus {
color: $brand-secondary;
background: $white;
}
}
}
.widget_text:nth-child(3) {
border: solid 2px $brand-primary;
box-shadow: unset;
}
}
.books {
.latest-books {
box-shadow: unset;
height: auto;
padding-bottom: 0 0 50px;
h3 {
margin-top: 70px;
}
.book,
.slick-slide {
width: 100vw;
@ -78,50 +108,15 @@
font-size: em(18);
}
}
}
}
.one-two {
width: 100%;
display: flex;
flex-direction: column;
.block-2 {
background: $brand-secondary;
p,
h3 {
color: $white;
.navigation {
a {
&.slick-disabled {
opacity: 0;
}
h3::before {
background-color: $white;
}
}
}
.main > .block-2,
.one-two + .block {
background: transparent;
border: solid 2px $brand-primary;
// 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;
}
}
}
@media (min-width: $medium) {
@ -130,9 +125,10 @@
margin-top: -366px;
}
.block {
.widget {
width: 775px;
margin-bottom: 119px;
padding: 0 90px;
box-shadow: -3px 5px 4px 2px rgba(135, 135, 135, 0.09);
h3 {
@ -148,33 +144,11 @@
font-size: em(18);
line-height: (32/18);
}
.inside {
width: 595px;
}
}
.one-two {
align-items: center;
}
.main > .block-2,
.one-two + .block {
border: solid 2px $brand-primary;
box-shadow: unset;
&::after {
top: 2020px;
}
}
.block.latest-books {
.latest-books {
width: 100%;
.inside {
width: 100%;
}
.books {
flex-direction: row;
justify-content: space-between;
@ -195,26 +169,15 @@
@media (min-width: $large) {
.home {
.block {
.widget {
width: 1115px;
height: 494px;
}
.main > .block-2,
.one-two + .block {
&::after {
top: 2150px;
}
}
.block.latest-books {
.latest-books {
width: 1200px;
margin-bottom: 0;
.inside {
width: 100%;
}
.book,
.slick-slide {
width: 367px;
@ -230,30 +193,29 @@
@media (min-width: $extra-large) {
.home {
.block {
.widget {
width: 1115px;
box-shadow: -3px 5px 4px 2px rgba(135, 135, 135, 0.09);
}
.one-two {
flex-direction: row;
justify-content: space-between;
.blocks.blocks-4 {
display: flex;
flex-flow: row wrap;
width: 1615px;
.block {
border-radius: 4px;
width: 775px;
.inside {
width: 595px;
}
.widget_text {
width: 1115px;
margin-right: auto;
margin-left: auto;
}
.widget_text:nth-child(1),
.widget_text:nth-child(2) {
width: 775px;
}
.main > .block-2,
.one-two + .block {
&::after {
top: 1550px;
.widget_text:nth-child(1) {
margin-right: 65px;
}
}
}

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

@ -1,8 +1,11 @@
@extends('layouts.app')
@section('content')
@if($block_count === 0)
@component('partials.front-page-block', ['index' => 1])
<section class="blocks blocks-{{ $block_count }}">
@if(is_active_sidebar('front-page-block'))
@php(dynamic_sidebar('front-page-block'))
@else
@component('front-page-block')
@slot('title')
{{ __('About Pressbooks', 'aldine') }}
@endslot
@ -14,47 +17,9 @@
{{ network_home_url('/about/') }}
@endslot
@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
@if(get_option('pb_front_page_catalog'))
@include('partials.front-page-catalog')
@endif
</section>
@endsection

6
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">
@if($title)
<h3 class="tc ttu primary">{{ $title }}</h3>
@endif
{{ $slot }}
@if($button_url && $button_title)
<a class="button button-primary" href="{{ $button_url }}">{{ $button_title }}</a>
@endif
</div>
</div>

Loading…
Cancel
Save