wysiwyg block

This commit is contained in:
2025-09-04 21:46:12 +01:00
parent 89ca57e44d
commit a665235b9f
15 changed files with 822 additions and 85 deletions

View File

@@ -67,7 +67,8 @@
"wpackagist-plugin/contact-form-7": "^6.1", "wpackagist-plugin/contact-form-7": "^6.1",
"wpackagist-plugin/flamingo": "^2.6", "wpackagist-plugin/flamingo": "^2.6",
"wpackagist-plugin/resizable-editor-sidebar": "^1.02", "wpackagist-plugin/resizable-editor-sidebar": "^1.02",
"wpengine/advanced-custom-fields-pro": "^6.5" "wpengine/advanced-custom-fields-pro": "^6.5",
"ourcodeworld/name-that-color": "dev-master"
}, },
"require-dev": { "require-dev": {
"roave/security-advisories": "dev-latest", "roave/security-advisories": "dev-latest",

52
composer.lock generated
View File

@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "104ea3d29e936d8eff7dbc4db90cafe2", "content-hash": "a99bd1262162472206d7c77290fa770a",
"packages": [ "packages": [
{ {
"name": "badegguk/bad-egg-digital-login-page", "name": "badegguk/bad-egg-digital-login-page",
@@ -3484,6 +3484,55 @@
}, },
"time": "2024-12-03T01:02:28+00:00" "time": "2024-12-03T01:02:28+00:00"
}, },
{
"name": "ourcodeworld/name-that-color",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/ourcodeworld/name-that-color.git",
"reference": "758b1f9b4b521da63f0ae4226e80cae620b0f648"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/ourcodeworld/name-that-color/zipball/758b1f9b4b521da63f0ae4226e80cae620b0f648",
"reference": "758b1f9b4b521da63f0ae4226e80cae620b0f648",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"default-branch": true,
"type": "library",
"autoload": {
"psr-4": {
"ourcodeworld\\NameThatColor\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"mit"
],
"authors": [
{
"name": "Carlos Delgado",
"email": "dev@ourcodeworld.com",
"homepage": "https://ourcodeworld.com"
}
],
"description": "A non-official PHP port of the NTC JS library to find out the name of the closest matching color.",
"keywords": [
"color converted",
"hex",
"hsl",
"name that color",
"rgb"
],
"support": {
"issues": "https://github.com/ourcodeworld/name-that-color/issues",
"source": "https://github.com/ourcodeworld/name-that-color/tree/master"
},
"time": "2018-08-03T18:14:49+00:00"
},
{ {
"name": "phpoption/phpoption", "name": "phpoption/phpoption",
"version": "1.9.3", "version": "1.9.3",
@@ -7436,6 +7485,7 @@
"aliases": [], "aliases": [],
"minimum-stability": "dev", "minimum-stability": "dev",
"stability-flags": { "stability-flags": {
"ourcodeworld/name-that-color": 20,
"roave/security-advisories": 20 "roave/security-advisories": 20
}, },
"prefer-stable": true, "prefer-stable": true,

View File

@@ -33,12 +33,6 @@ class Dynamic
$field['choices'][$slug] = '<i class="fas fa-circle" style="color: '. $hex .'"></i> ' . @$NameThatColour->name($hex)['name']; $field['choices'][$slug] = '<i class="fas fa-circle" style="color: '. $hex .'"></i> ' . @$NameThatColour->name($hex)['name'];
endforeach; endforeach;
$field['choices']['quaternary-white'] = '<i class="fas fa-circle text-gradient text-gradient-quaternary-white"></i> ' . @$NameThatColour->name($colour->name2hex('quaternary'))['name'] . ' to White';
$field['choices']['quinary-white'] = '<i class="fas fa-circle text-gradient text-gradient-quinary-white"></i> ' . @$NameThatColour->name($colour->name2hex('quinary'))['name'] . ' to White';
$field['choices']['white-quaternary'] = '<i class="fas fa-circle text-gradient text-gradient-white-quaternary"></i> White to ' . @$NameThatColour->name($colour->name2hex('quaternary'))['name'];
$field['choices']['white-quinary'] = '<i class="fas fa-circle text-gradient text-gradient-white-quinary"></i> White to ' . @$NameThatColour->name($colour->name2hex('quinary'))['name'];
return $field; return $field;
} }

View File

@@ -1,71 +0,0 @@
<?php
namespace App\PostTypes;
class Driver
{
public function __construct()
{
add_action('init', [$this, 'register']);
}
public function register()
{
$td = 'sage';
$postType = 'driver';
register_extended_post_type(
$postType,
[
'labels' => [
'featured_image' => __('Portrait', $td),
],
'menu_position' => 40,
'supports' => [
'title',
'excerpt',
'thumbnail',
'page-attributes',
],
'menu_icon' => 'dashicons-car',
'rewrite' => false,
'has_archive' => false,
'publicly_queryable' => false,
'exclude_from_search' => true,
'capability_type' => 'page',
'show_in_nav_menus' => false,
'admin_cols' => [
'credentials' =>[
'title' => __('Credentials', $td),
'meta_key' => 'badegg_driver_credentials',
],
'driver_category' => [
'title' => __('Category', $td),
'taxonomy' => 'driver_category',
],
'portrait' => [
'title' => __('Portrait', $td),
'featured_image' => 'thumbnail',
'width' => 48,
// 'height' => 48,
],
],
],
);
register_extended_taxonomy(
'driver_category',
$postType,
[
// 'meta_box' => 'radio',
'rewrite' => false,
'publicly_queryable' => false,
'show_in_nav_menus' => false,
],
[
'singular' => __('Category', $td),
'plural' => __('Categories', $td),
]
);
}
}

View File

@@ -35,7 +35,8 @@
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"App\\": "app/" "App\\": "app/",
"Blocks\\": "resources/views/blocks"
} }
}, },
"require": { "require": {

View File

@@ -59,11 +59,7 @@ function autoload_psr4($name) {
} }
function autoload_psr4_blocks() { function autoload_psr4_blocks() {
$blockDir = __dir__ . '/resources/views/blocks'; $path = __dir__ . '/resources/views/blocks/*';
if(!is_dir($blockDir)) return;
$path = $blockDir . '/*';
$namespace = 'Blocks\\'; $namespace = 'Blocks\\';
foreach(glob($path, GLOB_ONLYDIR) as $directory) { foreach(glob($path, GLOB_ONLYDIR) as $directory) {

View File

@@ -0,0 +1,156 @@
{
"key": "group_block_wysiwyg",
"title": "Block: WYSIWYG",
"fields": [
{
"key": "field_68334c31c5faf",
"label": "Introduction",
"name": "introduction",
"aria-label": "",
"type": "clone",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"clone": [
"group_clone_block_intro"
],
"display": "seamless",
"layout": "block",
"prefix_label": 0,
"prefix_name": 0
},
{
"key": "field_68334c31c63fc",
"label": "Content",
"name": "",
"aria-label": "",
"type": "accordion",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"open": 1,
"multi_expand": 0,
"endpoint": 0
},
{
"key": "field_68334c31c6fab",
"label": "",
"name": "wysiwyg",
"aria-label": "",
"type": "wysiwyg",
"instructions": "All drivers will be displayed if no category is selected.",
"required": 0,
"conditional_logic": [
[
{
"field": "field_68334c31c67cb",
"operator": "==",
"value": "local"
}
]
],
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"default_value": "",
"allow_in_bindings": 0,
"tabs": "all",
"toolbar": "basic",
"media_upload": 0,
"delay": 0
},
{
"key": "field_68334c31c738b",
"label": "Content",
"name": "",
"aria-label": "",
"type": "accordion",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"open": 0,
"multi_expand": 0,
"endpoint": 1
},
{
"key": "field_68334c31c7775",
"label": "Footer",
"name": "footer",
"aria-label": "",
"type": "clone",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"clone": [
"group_clone_block_footer"
],
"display": "seamless",
"layout": "block",
"prefix_label": 0,
"prefix_name": 0
},
{
"key": "field_68334c31c7b66",
"label": "Settings",
"name": "settings",
"aria-label": "",
"type": "clone",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"clone": [
"group_clone_block_settings"
],
"display": "seamless",
"layout": "block",
"prefix_label": 0,
"prefix_name": 0
}
],
"location": [
[
{
"param": "block",
"operator": "==",
"value": "acf\/badegg-wysiwyg"
}
]
],
"menu_order": 0,
"position": "normal",
"style": "default",
"label_placement": "top",
"instruction_placement": "label",
"hide_on_screen": "",
"active": true,
"description": "",
"show_in_rest": 0,
"modified": 1748193022
}

View File

@@ -0,0 +1,126 @@
{
"key": "group_clone_background_settings",
"title": "Clone: Background Settings",
"fields": [
{
"key": "field_67325dd23234e",
"label": "Background Colour",
"name": "bg_colour",
"aria-label": "",
"type": "select",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "50",
"class": "",
"id": ""
},
"choices": {
"primary": "<i class=\"fas fa-circle\" style=\"color: #002448\"><\/i> Prussian Blue",
"secondary": "<i class=\"fas fa-circle\" style=\"color: #fc533e\"><\/i> Sunset Orange",
"tertiary": "<i class=\"fas fa-circle\" style=\"color: #fdd400\"><\/i> Gold",
"quaternary": "<i class=\"fas fa-circle\" style=\"color: #7d89d1\"><\/i> Moody Blue",
"quinary": "<i class=\"fas fa-circle\" style=\"color: #ffdab4\"><\/i> Frangipani",
"0": "<i class=\"fas fa-circle\" style=\"color: #FFFFFF\"><\/i> White",
"black": "<i class=\"fas fa-circle\" style=\"color: #000000\"><\/i> Black",
"quaternary-white": "<i class=\"fas fa-circle text-gradient text-gradient-quaternary-white\"><\/i> Moody Blue to White",
"quinary-white": "<i class=\"fas fa-circle text-gradient text-gradient-quinary-white\"><\/i> Frangipani to White",
"white-quaternary": "<i class=\"fas fa-circle text-gradient text-gradient-white-quaternary\"><\/i> White to Moody Blue",
"white-quinary": "<i class=\"fas fa-circle text-gradient text-gradient-white-quinary\"><\/i> White to Frangipani"
},
"default_value": 0,
"return_format": "value",
"multiple": 0,
"allow_null": 0,
"allow_in_bindings": 1,
"ui": 1,
"ajax": 0,
"placeholder": "",
"create_options": 0,
"save_options": 0
},
{
"key": "field_67325e213234f",
"label": "Background Tint",
"name": "bg_tint",
"aria-label": "",
"type": "select",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "50",
"class": "",
"id": ""
},
"choices": {
"lightest": "Lightest",
"lighter": "Lighter",
"light": "Light",
"0": "None",
"dark": "Dark",
"darker": "Darker",
"darkest": "Darkest"
},
"default_value": 0,
"return_format": "value",
"multiple": 0,
"allow_null": 0,
"allow_in_bindings": 1,
"ui": 1,
"ajax": 0,
"placeholder": "",
"create_options": 0,
"save_options": 0
},
{
"key": "field_67350f526abf1",
"label": "Text Contrast",
"name": "contrast",
"aria-label": "",
"type": "select",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"choices": {
"0": "Auto",
"dark": "Force dark text",
"light": "Force light text"
},
"default_value": 0,
"return_format": "value",
"multiple": 0,
"allow_null": 0,
"ui": 0,
"ajax": 0,
"placeholder": "",
"create_options": 0,
"save_options": 0
}
],
"location": [
[
{
"param": "widget",
"operator": "==",
"value": "rss"
}
]
],
"menu_order": 0,
"position": "normal",
"style": "default",
"label_placement": "top",
"instruction_placement": "label",
"hide_on_screen": "",
"active": true,
"description": "",
"show_in_rest": 0,
"modified": 1748194684
}

View File

@@ -0,0 +1,158 @@
{
"key": "group_clone_block_footer",
"title": "Clone: Block Footer",
"fields": [
{
"key": "field_67659b49a6db2",
"label": "Footer",
"name": "",
"aria-label": "",
"type": "accordion",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"open": 0,
"multi_expand": 0,
"endpoint": 0
},
{
"key": "field_67659b49a754a",
"label": "Blurb",
"name": "blurb_footer",
"aria-label": "",
"type": "textarea",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"default_value": "",
"maxlength": "",
"rows": 3,
"placeholder": "",
"new_lines": ""
},
{
"key": "field_67659b7502137",
"label": "Links",
"name": "links",
"aria-label": "",
"type": "repeater",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"layout": "block",
"pagination": 0,
"min": 0,
"max": 2,
"collapsed": "",
"button_label": "Add Button",
"rows_per_page": 20,
"sub_fields": [
{
"key": "field_67659b8702138",
"label": "Button",
"name": "button",
"aria-label": "",
"type": "clone",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"clone": [
"group_clone_button"
],
"display": "seamless",
"layout": "block",
"prefix_label": 0,
"prefix_name": 0,
"parent_repeater": "field_67659b7502137"
}
]
},
{
"key": "field_682fb9ff58080",
"label": "Alignment",
"name": "footer_alignment",
"aria-label": "",
"type": "select",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"choices": {
"centre": "Centre",
"left": "Left",
"right": "Right"
},
"default_value": "centre",
"return_format": "value",
"multiple": 0,
"allow_null": 0,
"allow_in_bindings": 0,
"ui": 0,
"ajax": 0,
"placeholder": "",
"create_options": 0,
"save_options": 0
},
{
"key": "field_6828dac95eb68",
"label": "Footer (end)",
"name": "",
"aria-label": "",
"type": "accordion",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"open": 0,
"multi_expand": 0,
"endpoint": 1
}
],
"location": [
[
{
"param": "widget",
"operator": "==",
"value": "rss"
}
]
],
"menu_order": 0,
"position": "normal",
"style": "default",
"label_placement": "top",
"instruction_placement": "label",
"hide_on_screen": "",
"active": true,
"description": "",
"show_in_rest": 0,
"modified": 1747958307
}

View File

@@ -0,0 +1,153 @@
{
"key": "group_clone_block_intro",
"title": "Clone: Block Intro",
"fields": [
{
"key": "field_67659970db415",
"label": "Introduction",
"name": "",
"aria-label": "",
"type": "accordion",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"open": 0,
"multi_expand": 0,
"endpoint": 0
},
{
"key": "field_682fb8d9f6f3f",
"label": "Overline",
"name": "overline",
"aria-label": "",
"type": "text",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"default_value": "",
"maxlength": "",
"allow_in_bindings": 0,
"placeholder": "",
"prepend": "",
"append": ""
},
{
"key": "field_676599964d3cc",
"label": "Heading",
"name": "heading",
"aria-label": "",
"type": "textarea",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "hfont",
"id": ""
},
"default_value": "",
"maxlength": "",
"allow_in_bindings": 0,
"rows": 2,
"placeholder": "",
"new_lines": "br"
},
{
"key": "field_6765999d4d3cd",
"label": "Blurb",
"name": "blurb",
"aria-label": "",
"type": "textarea",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"default_value": "",
"maxlength": "",
"rows": 3,
"placeholder": "",
"new_lines": ""
},
{
"key": "field_682fb9add5a3b",
"label": "Alignment",
"name": "intro_alignment",
"aria-label": "",
"type": "select",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"choices": {
"centre": "Centre",
"left": "Left",
"right": "Right"
},
"default_value": "centre",
"return_format": "value",
"multiple": 0,
"allow_null": 0,
"allow_in_bindings": 0,
"ui": 0,
"ajax": 0,
"placeholder": "",
"create_options": 0,
"save_options": 0
},
{
"key": "field_6828dae1d1bb0",
"label": "Intro (end)",
"name": "",
"aria-label": "",
"type": "accordion",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"open": 0,
"multi_expand": 0,
"endpoint": 1
}
],
"location": [
[
{
"param": "widget",
"operator": "==",
"value": "rss"
}
]
],
"menu_order": 0,
"position": "normal",
"style": "default",
"label_placement": "top",
"instruction_placement": "label",
"hide_on_screen": "",
"active": true,
"description": "",
"show_in_rest": 0,
"modified": 1747958910
}

View File

@@ -0,0 +1,13 @@
@extends('layouts.block', [
'block' => $block,
'data' => $data,
])
@section('block-content')
@if(@$data['wysiwyg'])
<div class="main-wysiwyg wysiwyg">
{!! @$data['wysiwyg'] !!}
</div>
@endif
@overwrite

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

View File

@@ -0,0 +1,74 @@
<?php
namespace Blocks\WYSIWYG;
use App\Utilities;
use App\ACF;
class WYSIWYG
{
public function __construct()
{
add_action('acf/init', [$this, 'init']);
}
public function init()
{
acf_register_block_type([
'name' => 'badegg/wysiwyg',
'title' => __('Basic Content'),
'description' => __('Basic text editor '),
'render_callback' => [ $this, 'render'],
'category' => 'badegg',
'icon' => 'editor-paragraph',
'supports' => [
'align' => false,
],
'example' => [
'attributes' => [
'mode' => 'preview',
'data' => [
'inserter' => true,
],
],
],
]);
}
public function render($block, $content = '', $is_preview = false)
{
$name = basename(__FILE__, '.php');
$themeURL = get_template_directory_uri();
if($is_preview && @$block['data']['inserter']):
echo '<img style="display: block; width: 100%" src="' . $themeURL . '/resources/views/blocks/' . $name . '/' . $name . '.jpg" />';
return;
endif;
$CssClasses = new Utilities\CssClasses;
$Colour = new Utilities\Colour;
$CloneGroup = new ACF\CloneGroup;
$data = [];
$fields = [
'wysiwyg',
];
$fields = array_merge($fields, $CloneGroup->block_all());
foreach($fields as $field):
$data[$field] = get_field($field);
endforeach;
unset($block['data']);
$block['name'] = str_replace('acf/', '', $block['name']);
$data = array_merge($data, $block);
$data['section_classes'] = $CssClasses->section($data);
$data['block'] = $block;
echo \Roots\view("blocks.$name.$name", [
'data' => $data,
'block' => $block,
])->render();
}
}

View File

@@ -0,0 +1,13 @@
.section-badegg-wysiwyg {
container-name: WYSIWYG;
container-type: inline-size;
.main-wysiwyg {
@container WYSIWYG (min-width: #{$screen-lg}) {
font-size: 1.25em;
}
}
.section-intro { padding-bottom: $sectionSmall; }
.section-footer { padding-top: $sectionSmall; }
}

View File

@@ -0,0 +1,73 @@
@if(@$data['section_anchor_id'])
<div id="{{ $data['section_anchor_id'] }}" class="section-anchor"></div>
@endif
<section
id="{{ $block['id'] }}"
class="badegg-block
@if(@$data['section_classes']) {{ implode(' ', $data['section_classes']) }} @endif
{{ @$block['className'] }}
">
<div class="section-{{ $block['name'] }}-inner">
@if(@$data['heading'] || @$data['blurb'])
<div class="section-intro section-medium section-zero-top container container-large bg-watermarked-content {{ @$data['knockout'] }} align-{{ @$data['intro_alignment'] ?: 'centre' }} ">
<div class="section-intro-inner wysiwyg">
@if(@$data['overline']) <p class="overline secondary"><strong>{{ $data['overline'] }}</strong></p> @endif
<h2 class="section-title">{{ @$data['heading'] }}</h2>
<p>{{ @$data['blurb'] }}</p>
</div>
</div>
@endif
<div class="container container-{{ @$data['container_width'] ?: 'large' }} block-content bg-watermarked-content">
@yield('block-content')
</div>
@if(@$data['links'] || @$data['blurb_footer'])
<div class="section-footer section-medium section-zero-bottom container container-narrow align-{{ @$data['footer_alignment'] ?: 'centre' }} wysiwyg bg-watermarked-content {{ @$data['knockout'] }}">
<p>{{ @$data['blurb_footer'] }}</p>
@if(@$data['links'])
<div class="btn-wrap">
@foreach($data['links'] as $link)
@include('components.button', $link)
@endforeach
</div>
@endif
</div>
@endif
@if(@$data['bg_image'])
<div class="bg-watermarked-image" style="opacity: {!! (@$data['bg_opacity'] ?: 30) * 0.01 !!}">
{!! $ImageSrcset->render([
'image' => $data['bg_image'],
'name' => 'hero',
'lazy' => true,
]) !!}
</div>
@endif
</div>
@if(@$data['angle_status'])
@if(@$data['angle_position'] == 'both')
@foreach(['top', 'bottom'] as $position)
@include('partials.angle', [
'position' => $position,
'direction' => @$data['angle_direction'],
'tint' => @$data['angle_tint'],
'colour' => @$data['angle_colour'] ?: 'white',
])
@endforeach
@else
@include('partials.angle', [
'position' => @$data['angle_position'],
'direction' => @$data['angle_direction'],
'tint' => @$data['angle_tint'],
'colour' => @$data['angle_colour'] ?: 'white',
])
@endif
@endif
</section>