Skip to content

Commit

Permalink
feat: add cta box (#310)
Browse files Browse the repository at this point in the history
  • Loading branch information
JimSeven authored Oct 15, 2024
1 parent 98f99a6 commit df0952f
Show file tree
Hide file tree
Showing 35 changed files with 427 additions and 46 deletions.
5 changes: 5 additions & 0 deletions app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Illuminate\Support\Facades\Event;
use Illuminate\Support\ServiceProvider;
use Statamic\Facades\Collection;
use Statamic\Statamic;

class AppServiceProvider extends ServiceProvider
Expand All @@ -29,5 +30,9 @@ public function boot(): void
Event::listen(function (\SocialiteProviders\Manager\SocialiteWasCalled $event) {
$event->extendSocialite('google', \SocialiteProviders\Google\Provider::class);
});

Collection::computed('experts', 'calendly_url', function ($entry, $value) {
return "https://calendly.com/{$entry->calendly_handle}";
});
}
}
33 changes: 33 additions & 0 deletions app/View/Components/Layout.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace App\View\Components;

use Closure;
use Illuminate\Contracts\View\View;
use Illuminate\View\Component;

class Layout extends Component
{
/**
* Create a new component instance.
*
* @return void
*/
public function __construct(public $context)
{
$this->context = $context;
}

public function data()
{
return array_merge(parent::data(), $this->context);
}

/**
* Get the view / contents that represent the component.
*/
public function render(): View|Closure|string
{
return view('components.layout');
}
}
43 changes: 43 additions & 0 deletions app/View/Components/Layout/CtaBox.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

namespace App\View\Components\Layout;

use Closure;
use Illuminate\Contracts\View\View;
use Illuminate\View\Component;
use Statamic\Facades\Cascade;
use Statamic\Facades\GlobalSet as GlobalSetFacade;
use Statamic\Globals\GlobalSet;

class CtaBox extends Component
{
public function data()
{
/** @var GlobalSet $global_general_set */
$global_general_set = GlobalSetFacade::findByHandle('general');
$global_cta_box = $global_general_set->inCurrentSite()->cta_box;
$content = Cascade::content();
if ($content->cta_box->override_defaults) {
$cta_box = $content->cta_box->cta_box;
$headline = $cta_box->headline ?? $global_cta_box->headline;
$text = $cta_box->text ?? $global_cta_box->text;
$expert = $cta_box->expert ?? $global_cta_box->expert;
}

$data = [
'headline' => $headline ?? $global_cta_box->headline,
'text' => $text ?? $global_cta_box->text,
'expert' => $expert ?? $global_cta_box->expert,
];

return array_merge(parent::data(), $data);
}

/**
* Get the view / contents that represent the component.
*/
public function render(): View|Closure|string
{
return view('components.layout.cta-box');
}
}
5 changes: 1 addition & 4 deletions app/View/Components/Layout/Footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ class Footer extends Component
/**
* Create a new component instance.
*/
public function __construct()
{
//
}
public function __construct() {}

/**
* Get the view / contents that represent the component.
Expand Down
4 changes: 2 additions & 2 deletions app/View/Components/Layout/ModuleWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ class ModuleWrapper extends Component
*/
public function __construct(public $context)
{
// dd($context);
$this->context = $context;
dd($this->context);
}

public function data()
Expand All @@ -27,6 +27,6 @@ public function data()
*/
public function render(): View|Closure|string
{
return view('components.layout.modules');
return view('components.layout.module-wrapper');
}
}
26 changes: 26 additions & 0 deletions app/View/Components/Layout/modal.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace App\View\Components\layout;

use Closure;
use Illuminate\Contracts\View\View;
use Illuminate\View\Component;

class modal extends Component
{
/**
* Create a new component instance.
*/
public function __construct()
{
//
}

/**
* Get the view / contents that represent the component.
*/
public function render(): View|Closure|string
{
return view('components.layout.modal');
}
}
3 changes: 1 addition & 2 deletions app/View/Components/LayoutModules/Quote.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ class Quote extends Module
{
public function data()
{

$quote_data = [
'author_name' => $this->context['author']->title,
'author_job_title' => $this->context['author']->job_title,
Expand All @@ -26,7 +25,7 @@ public function data()
]);
}

return array_merge(parent::data(), $this->context->toArray(), $quote_data);
return array_merge(parent::data(), $quote_data);
}

/**
Expand Down
14 changes: 14 additions & 0 deletions content/collections/experts/fabian-pahl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
id: 81347864-bc8e-4d1a-96f0-a0b5280146c8
blueprint: expert
title: 'Fabian Pahl'
forename: Fabian
surname: Pahl
job_title: 'Senior Developer'
linkedin_handle: fabianpahl
image: experts/fabian-pahl.jpg
updated_by: 7b2bf1c2-0b8e-44d9-a774-98d3580bee37
updated_at: 1727882559
email: [email protected]
calendly_handle: 21stdigital/meeting
---
14 changes: 14 additions & 0 deletions content/collections/experts/steffen-ruether.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
id: c175f756-0f0b-45c7-afd9-f99cbfe4fca0
blueprint: expert
title: 'Steffen Rüther'
forename: Steffen
surname: Rüther
job_title: 'Senior Developer'
linkedin_handle: steffen-ruether
updated_by: 7b2bf1c2-0b8e-44d9-a774-98d3580bee37
updated_at: 1728989581
image: experts/steffen-ruether.jpg
email: [email protected]
calendly_handle: steffen-21st/30min
---
9 changes: 8 additions & 1 deletion content/collections/pages/home.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ id: 763e6082-7a1f-4da4-994b-68f51aff53e5
blueprint: page
title: Startseite
updated_by: 7b2bf1c2-0b8e-44d9-a774-98d3580bee37
updated_at: 1727776121
updated_at: 1727878302
layout_modules:
-
id: m1hwi1k4
Expand Down Expand Up @@ -124,4 +124,11 @@ page_title: 'Von Deiner Vision zur digitalen Erfolgsgeschichte'
intro_text: '21st digital ist Dein Partner für die Entwicklung innovativer digitaler Produkte. Wir begleiten Dich durch die digitale Transformation, hinterfragen bestehende Prozesse und entwickeln maßgeschneiderte Strategien, um sowohl digitale Produkte als auch Geschäftsmodelle erfolgreich zu gestalten.'
cta: 'https://calendly.com/21stdigital/meeting?month=2024-09'
cta_label: 'Sprich mit uns'
enable_cta_box: true
cta_box:
override_defaults: false
cta_box:
headline: null
text: null
expert: null
---
6 changes: 6 additions & 0 deletions content/globals/general.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
title: General
data:
cta_box:
headline: 'Dir schwebt auch eine preisgekrönte Plattform vor?'
text: 'Wir helfen Dir bei Deinem Vorhaben.'
expert: c175f756-0f0b-45c7-afd9-f99cbfe4fca0
5 changes: 5 additions & 0 deletions lang/de/labels.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

return [
'close_modal' => 'Schließen',
];
5 changes: 5 additions & 0 deletions lang/en/labels.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

return [
'close_modal' => 'Close',
];
21 changes: 16 additions & 5 deletions resources/blueprints/collections/experts/expert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,33 @@ tabs:
main:
display: 'Main Information'
sections:
- fields:
- handle: title
-
fields:
-
handle: title
field:
type: hidden
required: false
display: 'Full Name'
instructions: 'This field is automatically generated by combining the forename and surname. It is used for internal purposes.'
- import: person
-
import: person
sidebar:
display: Sidebar
sections:
- fields:
- handle: slug
-
fields:
-
handle: slug
field:
type: slug
localizable: true
validate: 'max:200'
instructions: 'Enter a URL-friendly slug for this expert. This slug will be used in the expert’s profile URL and should be unique. Maximum 200 characters.'
listable: false
-
handle: image
field: common.image
config:
validate:
- image
31 changes: 31 additions & 0 deletions resources/blueprints/collections/pages/page.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,34 @@ tabs:
max_items: 1
listable: false
localizable: true
settings:
display: Settings
sections:
-
display: Settings
fields:
-
handle: enable_cta_box
field:
default: true
type: toggle
display: 'Enable CTA Box'
width: 50
-
handle: cta_box
field:
type: group
display: 'CTA Box'
fields:
-
handle: override_defaults
field:
type: toggle
display: 'Override Defaults'
width: 50
-
handle: cta_box
field: common.cta_box
config:
if:
override_defaults: 'equals true'
9 changes: 9 additions & 0 deletions resources/blueprints/globals/general.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
tabs:
main:
display: Main
sections:
-
fields:
-
handle: cta_box
field: common.cta_box
33 changes: 33 additions & 0 deletions resources/fieldsets/common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -287,3 +287,36 @@ fields:
fields:
-
import: element_teaser_list_solution
-
handle: cta_box
field:
type: group
display: 'CTA Box'
fields:
-
handle: headline
field:
type: text
display: Headline
-
handle: text
field:
type: textarea
display: Text
-
handle: expert
field:
max_items: 1
collections:
- experts
type: entries
display: Expert
create: false
-
handle: email
field:
input_type: email
type: text
display: Email
validate:
- email
20 changes: 20 additions & 0 deletions resources/fieldsets/layout_module_cta_box.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
title: '03 - Layout Module | CTA Box'
fields:
-
handle: headline
field:
type: text
display: Headline
-
handle: text
field:
type: textarea
display: Text
-
handle: expert
field:
max_items: 1
collections:
- experts
type: entries
display: Expert
14 changes: 14 additions & 0 deletions resources/fieldsets/person.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,17 @@ fields:
-
regex: '^[A-Za-z0-9_-]+$'
error: 'The LinkedIn handle should only contain letters, numbers, underscores, or hyphens.'
-
handle: email
field: common.email
config:
validate:
- email
width: 50
-
handle: calendly_handle
field:
type: text
display: 'Calendly Handle'
instructions: 'Enter the Calendly handle (the part of the URL after https://calendly.com/"). Do not include "https://calendly.com/".'
width: 50
Loading

0 comments on commit df0952f

Please sign in to comment.