Commit 9dd1b6b2 authored by Michael Iseard's avatar Michael Iseard
Browse files

Update fonts and intro layout

parent ed2af196
......@@ -2,6 +2,7 @@
# Read about how to use .gitignore: https://help.github.com/articles/ignoring-files
.cache-loader
dist
docker
node_modules
npm-debug.log
yarn-error.log
......
......@@ -4,6 +4,7 @@ namespace App\Controllers;
use Sober\Controller\Controller;
use WP_Post;
use function App\filter_handlebar;
class FrontPage extends Controller
{
......@@ -22,9 +23,9 @@ class FrontPage extends Controller
function __construct()
{
$intro_gallery = carbon_get_theme_option('intro_gallery');
if($intro_gallery) {
$this->intro_image_id = $intro_gallery[rand(0, (count($intro_gallery) - 1))];
$intro_image_id = carbon_get_theme_option('intro_image');
if($intro_image_id) {
$this->intro_image_id = $intro_image_id;
$this->intro_image = get_post($this->intro_image_id);
}
$this->intro_content = carbon_get_theme_option('intro_text');
......@@ -55,6 +56,8 @@ class FrontPage extends Controller
}
public function intro_content() {
return $this->intro_content;
$content = $this->intro_content;
return filter_handlebar($content);
}
}
......@@ -61,7 +61,7 @@ class TemplateFaq extends Controller
// Add "All" option
array_unshift($categories, (object) [
'slug' => null,
'name' => __('All', 'wisselenergie')
'name' => __('All', 'kudos-website')
]
);
......
......@@ -19,7 +19,7 @@ class Ajax
$category = isset($_POST['category']) ? $_POST['category'] : null;
$keywords = isset($_POST['keywords']) ? $_POST['keywords'] : null;
$out = '<p>' . __('Sorry, no results were found.', 'wisselenergie') . '</p>';
$out = '<p>' . __('Sorry, no results were found.', 'kudos-website') . '</p>';
$templateFaq = new TemplateFaq();
$questions = $templateFaq->questions($category, $keywords);
......@@ -37,4 +37,4 @@ class Ajax
}
}
new Ajax();
\ No newline at end of file
new Ajax();
......@@ -29,8 +29,13 @@ function we_theme_options() {
// Add second options page under 'Basic Options'
Container::make( 'theme_options', __( 'Site Options' ) )
->add_tab(__('Homepage', 'kudos-website'), [
Field::make( 'media_gallery', 'intro_gallery', __( 'Gallery', 'kudos-website' ) ),
Field::make( 'rich_text', 'intro_text', __( 'Intro Text', 'kudos-website' ) )
Field::make( 'image', 'intro_image', __( 'Image', 'kudos-website' ) ),
Field::make( 'rich_text', 'intro_text', __( 'Intro Text', 'kudos-website' ) ),
Field::make( 'complex', 'intro_variables', __('Intro Variables', 'kudos-website') )
->add_fields( 'household_number', [
Field::make( 'text', 'title' )
->set_width(50),
])
])
->add_tab(__('Site news', 'kudos-website'), [
Field::make('checkbox', 'show_site_news', __('Show Site News', 'kudos-website'))
......@@ -40,15 +45,6 @@ function we_theme_options() {
->set_default_value(false)
->set_help_text(__('When disabled only shows on home page', 'kudos-website')),
Field::make('rich_text', 'site_news', __('Site News', 'kudos-website'))
])
->add_tab(__('Household values', 'kudos-website'), [
Field::make( 'complex', 'household_values', __('Household Values', 'kudos-website') )
->add_fields( 'household_number', [
Field::make( 'text', 'title' )
->set_width(50),
Field::make( 'text', 'amount' )
->set_width(50),
])
])
// Email tab
->add_tab('Email', array(
......@@ -246,4 +242,4 @@ function we_theme_options() {
add_action( 'after_setup_theme', 'crb_load' );
function crb_load() {
Carbon_Fields::boot();
}
\ No newline at end of file
}
......@@ -136,3 +136,23 @@ function display_sidebar()
isset($display) || $display = apply_filters('sage/display_sidebar', false);
return $display;
}
/**
* @param $string
* @return array|string
*/
function filter_handlebar($string)
{
$out['string'] = $string;
$regex = '/\{\{(.+?)\}\}/';
$result = preg_match($regex, $string, $matches, PREG_OFFSET_CAPTURE);
if($result) {
$list = explode(',', str_replace(' ', '', $matches[1][0]));
$first = $list[0];
$out['string'] = preg_replace($regex, '<span id="intro-variable" class="list swap-in">' . $first . "</span>", $string);
$out['list'] = json_encode($list);
}
return $out;
}
......@@ -13,12 +13,11 @@ use Roots\Sage\Template\BladeProvider;
add_action('wp_enqueue_scripts', function () {
wp_enqueue_style('sage/main.css', asset_path('styles/main.css'), false, null);
wp_enqueue_script('sage/main.js', asset_path('scripts/main.js'), ['jquery', 'wp-api'], null, true);
wp_localize_script('sage/main.js', 'wisselenergie', [
wp_localize_script('sage/main.js', 'kudos-website', [
'ajax_url' => admin_url( 'admin-ajax.php' ),
'nonce' => wp_create_nonce('ajax-nonce'),
'site_url' => get_site_url(),
'page_name' => get_query_var('pagename'),
'household_values' => carbon_get_theme_option('household_values'),
]);
if (is_single() && comments_open() && get_option('thread_comments')) {
......@@ -51,11 +50,11 @@ add_action('after_setup_theme', function () {
* @link https://developer.wordpress.org/reference/functions/register_nav_menus/
*/
register_nav_menus([
'primary_navigation' => __('Primary Navigation', 'wisselenergie')
'primary_navigation' => __('Primary Navigation', 'kudos-website')
]);
register_nav_menus([
'footer_navigation' => __('Footer Navigation', 'wisselenergie')
'footer_navigation' => __('Footer Navigation', 'kudos-website')
]);
/**
......@@ -94,11 +93,11 @@ add_action('widgets_init', function () {
'after_title' => '</h3>'
];
register_sidebar([
'name' => __('Primary', 'wisselenergie'),
'name' => __('Primary', 'kudos-website'),
'id' => 'sidebar-primary'
] + $config);
register_sidebar([
'name' => __('Footer', 'wisselenergie'),
'name' => __('Footer', 'kudos-website'),
'id' => 'sidebar-footer',
'before_widget' => '<section class="widget col-12 col-md-4 %1$s %2$s">',
'after_widget' => '</section>',
......@@ -151,7 +150,7 @@ add_action('after_setup_theme', function () {
* Add translations
*/
add_action('after_setup_theme', function () {
load_theme_textdomain('wisselenergie', get_template_directory() . '/lang');
load_theme_textdomain('kudos-website', get_template_directory() . '/lang');
});
......@@ -166,10 +165,10 @@ add_action( 'init', function() {
// CPT Options
[
'labels' => [
'name' => __( 'Reviews', 'wisselenergie' ),
'singular_name' => __( 'Review', 'wisselenergie' ),
'add_new' => __('New Review', 'wisselenergie'),
'add_new_item' => __('Add Review', 'wisselenergie')
'name' => __( 'Reviews', 'kudos-website' ),
'singular_name' => __( 'Review', 'kudos-website' ),
'add_new' => __('New Review', 'kudos-website'),
'add_new_item' => __('Add Review', 'kudos-website')
],
'menu_icon' => 'dashicons-star-filled',
'public' => true,
......@@ -190,10 +189,10 @@ add_action( 'init', function() {
// CPT Options
[
'labels' => [
'name' => __( 'FAQ', 'wisselenergie' ),
'singular_name' => __( 'Question', 'wisselenergie' ),
'add_new' => __('New Question', 'wisselenergie'),
'add_new_item' => __('Add Question', 'wisselenergie')
'name' => __( 'FAQ', 'kudos-website' ),
'singular_name' => __( 'Question', 'kudos-website' ),
'add_new' => __('New Question', 'kudos-website'),
'add_new_item' => __('Add Question', 'kudos-website')
],
'menu_icon' => 'dashicons-editor-help',
'public' => true,
......@@ -263,4 +262,4 @@ add_action('init', function () {
if (is_admin_bar_showing()) {
remove_action('admin_bar_menu', 'wp_admin_bar_comments_menu', 60);
}
});
\ No newline at end of file
});
This diff is collapsed.
export default {
init() {
// JavaScript to be fired on the home page
let $blockCalculator = $('.block-savings-calculator');
let $blockReviews = $('.block-reviews');
// eslint-disable-next-line no-undef
let savings = wisselenergie.household_values;
if($blockCalculator) {
$blockCalculator.each(function () {
let $people = $(this).find('.person');
let $number = $(this).find('.saving-amount');
let $household = $(this).find('.household-count');
$people.each(function (i, e) {
$(e).on('click', function (e) {
e.preventDefault()
$people.removeClass('selected')
let num = i;
let $selected = $(e.currentTarget).prevAll().andSelf()
$number.text(savings[num].amount)
$household.text(savings[num].title)
$selected.addClass('selected')
})
})
});
}
let $introTarget = $('#intro-variable');
let introArray = $('.intro-text').data('list');
let index = 1;
if($blockReviews) {
$blockReviews.each(function () {
let $reviews = $(this).find('article');
if($reviews.length > 1) {
changeReview($reviews);
}
});
}
let index = 0;
let total = introArray.length;
changeText(introArray);
function changeText(introArray) {
setTimeout(() => {
$introTarget.toggleClass('swap-out swap-in');
setTimeout(() => {
$introTarget.toggleClass('swap-out swap-in');
$introTarget.text(introArray[index])
}, 500)
function changeReview($reviews) {
// let $current = $reviews[0];
let total = $reviews.length;
setTimeout(function () {
$reviews.removeClass('current')
$($reviews[index]).addClass('current')
index++;
if(index === (total)) {
index = 0;
}
changeReview($reviews);
changeText(introArray);
}, 5000);
}
},
finalize() {
// JavaScript to be fired on the home page, after the init JS
......
@font-face {
font-family: "Elephant Regular";
font-family: "libre_baskervillebold";
src:
url("../fonts/elephnt-webfont.woff2") format("woff2"),
url("../fonts/elephnt-webfont.woff") format("woff");
url("../fonts/librebaskerville-bold-webfont.woff2") format("woff2"),
url("../fonts/librebaskerville-bold-webfont.woff") format("woff");
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: "Merriweather Sans Light";
font-family: "montserratregular";
src:
url("../fonts/merriweathersans-light-webfont.woff2") format("woff2"),
url("../fonts/merriweathersans-light-webfont.woff") format("woff");
url("../fonts/montserrat-regular-webfont.woff2") format("woff2"),
url("../fonts/montserrat-regular-webfont.woff") format("woff");
font-weight: normal;
font-style: normal;
}
$font-size-base: 1.2rem;
$line-height-base: 1.6;
$h5-font-size: 1.25rem;
$font-family-light: "Merriweather Sans Light", Arial, sans-serif;
$font-family-bold: "Elephant Regular", Arial, sans-serif;
$font-sans: "montserratregular", Arial, sans-serif;
$font-serif: "libre_baskervillebold", Arial, sans-serif;
// Colours
$theme-colors: (
......@@ -23,6 +23,7 @@ $custom-select-border-radius: 0;
$btn-border-radius: 0.25rem;
$btn-padding-x: 20px;
$btn-padding-y: 10px;
$btn-border-width: 2px;
$btn-transition: color 0.6s ease;
// Modal
......@@ -42,20 +43,14 @@ $hamburger-layer-color: #182340;
$hamburger-types: (vortex);
body {
font-family: $font-family-light !important;
font-family: $font-sans !important;
}
h1,
h2,
h3,
.entry-title {
font-family: $font-family-bold;
}
h4,
p,
strong {
font-family: $font-family-light;
font-family: $font-serif;
}
h1,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment