Skip to content

Commit 7cc48d9

Browse files
committed
Support icons and add index content for vacancy preset
1 parent 54cb323 commit 7cc48d9

File tree

7 files changed

+46
-16
lines changed

7 files changed

+46
-16
lines changed

src/Commands/AddBlock.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class AddBlock extends Command
1919
protected $block_name = '';
2020
protected $filename = '';
2121
protected $instructions = '';
22+
protected $icon = '';
2223

2324
public function handle()
2425
{
@@ -37,14 +38,20 @@ public function handle()
3738
placeholder: 'E.g. Renders text and an image.',
3839
required: true
3940
);
41+
$this->icon = text(
42+
label: 'Which icon do you want to use for this block?',
43+
placeholder: 'file-content-list',
44+
default: 'file-content-list',
45+
required: true
46+
);
4047

4148
try {
4249
$this->checkExistence('Fieldset', "resources/fieldsets/{$this->filename}.yaml");
4350
$this->checkExistence('Partial', "resources/views/page_builder/_{$this->filename}.antlers.html");
4451

4552
$this->createFieldset();
4653
$this->createPartial();
47-
$this->updatePageBuilder($this->block_name, $this->instructions, $this->filename);
54+
$this->updatePageBuilder($this->block_name, $this->instructions, $this->icon, $this->filename);
4855
} catch (\Exception $e) {
4956
return $this->error($e->getMessage());
5057
}

src/Commands/AddCollection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ protected function installAndSetIndexContentBlock()
325325
{
326326
File::put(base_path("resources/fieldsets/index_content.yaml"), $this->getStub('/blocks/index_content.yaml.stub'));
327327
File::put(base_path("resources/views/page_builder/_index_content.antlers.html"), $this->getStub('/blocks/index_content.antlers.html.stub'));
328-
$this->updatePageBuilder('Index content', 'Render the currently mounted entries if available.', 'index_content');
328+
$this->updatePageBuilder('Index content', 'Render the currently mounted entries if available.', 'file-content-list', 'index_content');
329329

330330
$pageBuilder = Entry::find($this->mount)
331331
->get('page_builder');

src/Commands/InstallBlock.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class InstallBlock extends Command
1919
protected $choices = '';
2020
protected $filename = '';
2121
protected $instructions = '';
22+
protected $icon = '';
2223

2324
public function handle()
2425
{
@@ -35,14 +36,16 @@ public function handle()
3536
foreach($this->choices as $choice) {
3637
$this->block_name = Stringy::split($this->getBlocks()[$choice], ':')[0];
3738
$this->filename = $choice;
38-
$this->instructions = Stringy::split($this->getBlocks()[$choice], ': ')[1];
39+
$description = Stringy::split($this->getBlocks()[$choice], ': ')[1];
40+
$this->instructions = Stringy::split($description, ' \[')[0];
41+
$this->icon = rtrim(Stringy::split($description, ' \[')[1], "]");
3942

4043
try {
4144
$this->checkExistence('Fieldset', "resources/fieldsets/{$this->filename}.yaml");
4245
$this->checkExistence('Partial', "resources/views/page_builder/_{$this->filename}.antlers.html");
4346

4447
$this->copyStubs();
45-
$this->updatePageBuilder($this->block_name, $this->instructions, $this->filename);
48+
$this->updatePageBuilder($this->block_name, $this->instructions, $this->icon, $this->filename);
4649
} catch (\Exception $e) {
4750
return $this->error($e->getMessage());
4851
}

src/Commands/InstallBlockBlocks.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ trait InstallBlockBlocks {
77
public function getBlocks() {
88
return
99
[
10-
'call_to_action' => 'Call to action: Show a call to action.',
11-
'cards' => 'Cards: Cards that link using the button fieldset.',
12-
'collection' => 'Collection: Show collection entries.',
13-
'columns' => 'Columns: Text columns with optional images and buttons.',
14-
'divider' => 'Divider: A visual divider between blocks.',
15-
'full_width_image' => 'Full width image: A full width image with optional text and button(s).',
16-
'index_content' => 'Index content: Render the currently mounted entries if available.',
17-
'image_and_text' => 'Image and text: An image and text side by side.',
18-
'images_grid' => 'Images grid: A multi row image grid.',
19-
'text_columns' => 'Text columns: Text wrapping in two columns.',
10+
'call_to_action' => 'Call to action: Show a call to action. [alert-alarm-bell]',
11+
'cards' => 'Cards: Cards that link using the button fieldset. [link]',
12+
'collection' => 'Collection: Show collection entries. [file-content-list]',
13+
'columns' => 'Columns: Text columns with optional images and buttons. [layout-three-columns]',
14+
'divider' => 'Divider: A visual divider between blocks. [layout-table-row-insert]',
15+
'full_width_image' => 'Full width image: A full width image with optional text and button(s). [media-image-picture-orientation]',
16+
'index_content' => 'Index content: Render the currently mounted entries if available. [file-content-list]',
17+
'image_and_text' => 'Image and text: An image and text side by side. [text-formatting-image-left]',
18+
'images_grid' => 'Images grid: A multi row image grid. [layout-grid-dots]',
19+
'text_columns' => 'Text columns: Text wrapping in two columns. [layout-three-columns]',
2020
]
2121
;
2222
}

src/Commands/InstallPreset.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,11 @@ public function handle()
112112
->replace('{{ name }}', $this->rename_name);
113113
$instructions = (string)Str::of($operation['block']['instructions'])
114114
->replace('{{ name }}', $this->rename_name);
115+
$icon = (string)Str::of($operation['block']['icon']);
115116
$handle = (string)Str::of($operation['block']['handle'])
116117
->replace('{{ handle }}', $this->rename_handle);
117118

118-
$this->updatePageBuilder($name, $instructions, $handle);
119+
$this->updatePageBuilder($name, $instructions, $icon, $handle);
119120
$this->info("Installed page builder block: '{$name}'.");
120121
}
121122

src/Commands/InstallPresetPresets.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ public function getPresets() {
100100
'block' => [
101101
'name' => '{{ name }}',
102102
'instructions' => 'A {{ name }} logo cloud.',
103+
'icon' => 'favorite-award',
103104
'handle' => '{{ handle }}',
104105
]
105106
],
@@ -177,6 +178,7 @@ public function getPresets() {
177178
'block' => [
178179
'name' => 'Index content',
179180
'instructions' => 'Render the currently mounted entries if available.',
181+
'icon' => 'file-content-list',
180182
'handle' => 'index_content',
181183
]
182184
],
@@ -185,6 +187,7 @@ public function getPresets() {
185187
'block' => [
186188
'name' => '{{ name }}',
187189
'instructions' => 'List upcoming {{ name }}.',
190+
'icon' => 'calendar-date',
188191
'handle' => '{{ handle }}',
189192
]
190193
],
@@ -238,6 +241,7 @@ public function getPresets() {
238241
'block' => [
239242
'name' => 'FAQ',
240243
'instructions' => 'List frequently asked questions in an accordion.',
244+
'icon' => 'alert-help-question',
241245
'handle' => 'faq',
242246
]
243247
],
@@ -277,6 +281,7 @@ public function getPresets() {
277281
'block' => [
278282
'name' => 'Image credits',
279283
'instructions' => 'List images with their credits.',
284+
'icon' => 'content-book-open',
280285
'handle' => 'image_credits',
281286
]
282287
],
@@ -326,6 +331,7 @@ public function getPresets() {
326331
'type' => 'update_article_sets',
327332
'block' => [
328333
'name' => 'Invoke modal',
334+
'icon' => 'alert-warning-exclamation-mark',
329335
'handle' => 'invoke_modal',
330336
]
331337
],
@@ -403,6 +409,7 @@ public function getPresets() {
403409
'block' => [
404410
'name' => 'Index content',
405411
'instructions' => 'Render the currently mounted entries if available.',
412+
'icon' => 'file-content-list',
406413
'handle' => 'index_content',
407414
]
408415
],
@@ -411,6 +418,7 @@ public function getPresets() {
411418
'block' => [
412419
'name' => '{{ name }}',
413420
'instructions' => 'List the most recent {{ name }}.',
421+
'icon' => 'share-mega-phone',
414422
'handle' => '{{ handle }}',
415423
]
416424
],
@@ -499,6 +507,7 @@ public function getPresets() {
499507
'block' => [
500508
'name' => '{{ name }}',
501509
'instructions' => 'List {{ name }}.',
510+
'icon' => 'user-multiple',
502511
'handle' => '{{ handle }}',
503512
]
504513
],
@@ -581,6 +590,15 @@ public function getPresets() {
581590
'input' => 'vacancies_collection.yaml.stub',
582591
'output' => 'content/collections/{{ handle }}.yaml'
583592
],
593+
[
594+
'type' => 'update_page_builder',
595+
'block' => [
596+
'name' => 'Index content',
597+
'instructions' => 'Render the currently mounted entries if available.',
598+
'icon' => 'file-content-list',
599+
'handle' => 'index_content',
600+
]
601+
],
584602
[
585603
'type' => 'update_role',
586604
'role' => 'editor',

src/Commands/SharedFunctions.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,13 @@ protected function updateArticleSets($name, $filename)
7171
*
7272
* @return bool|null
7373
*/
74-
protected function updatePageBuilder($name, $instructions, $filename)
74+
protected function updatePageBuilder($name, $instructions, $icon, $filename)
7575
{
7676
$fieldset = Yaml::parseFile(base_path('resources/fieldsets/page_builder.yaml'));
7777
$newSet = [
7878
'display' => $name,
7979
'instructions' => $instructions,
80+
'icon' => $icon,
8081
'fields' => [
8182
[
8283
'import' => $filename

0 commit comments

Comments
 (0)