Skip to content

Commit 399b8f5

Browse files
committed
Add availability preset
1 parent 66e689e commit 399b8f5

File tree

4 files changed

+91
-0
lines changed

4 files changed

+91
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
return [
4+
'handle' => 'availability',
5+
'name' => 'Availability',
6+
'description' => 'A global and availability component.',
7+
'operations' => [
8+
[
9+
'type' => 'copy',
10+
'input' => 'resources/blueprints/globals/availability.yaml',
11+
'output' => 'resources/blueprints/globals/availability.yaml',
12+
],
13+
[
14+
'type' => 'copy',
15+
'input' => 'content/globals/availability.yaml',
16+
'output' => 'content/globals/availability.yaml',
17+
],
18+
[
19+
'type' => 'copy',
20+
'input' => 'resources/views/components/_availability.antlers.html',
21+
'output' => 'resources/views/components/_availability.antlers.html',
22+
],
23+
[
24+
'type' => 'update_role',
25+
'role' => 'editor',
26+
'permissions' => ['edit availability globals'],
27+
],
28+
[
29+
'type' => 'notify',
30+
'content' => 'Make sure to add `{{ partial:components/availability }}` where you want to render the component.',
31+
],
32+
[
33+
'type' => 'notify',
34+
'content' => "Add this to your `lang/locale/strings.php` file:\n\n'availability' => 'available from :month',\n'availability_now' => 'available right now',",
35+
],
36+
],
37+
];
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
title: Availability
2+
data:
3+
now: false
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
tabs:
2+
main:
3+
display: Main
4+
sections:
5+
-
6+
display: 'Availability'
7+
instructions: 'Configure availability.'
8+
fields:
9+
-
10+
handle: now
11+
field:
12+
type: toggle
13+
display: 'Availability now'
14+
instructions: 'Set when you''re available right away.'
15+
instructions_position: 'below'
16+
localizable: false
17+
width: 50
18+
-
19+
handle: from
20+
field:
21+
display: 'Availability from'
22+
instructions: 'Set a date in the month you become available. If the current date is later, a month will automatically be added.'
23+
instructions_position: 'below'
24+
type: date
25+
width: 50
26+
localizable: false
27+
if:
28+
now: 'equals false'
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{{#
2+
@name Availability
3+
@desc Render availability.
4+
#}}
5+
6+
{{ if availability:now || availability:from }}
7+
<!-- /components/_availability.antlers.html -->
8+
<div class="flex items-center gap-1">
9+
<div class="relative size-3.5 p-0.75 rounded-full bg-[#1BB700]" aria-hidden="true">
10+
<div class="absolute inset-0.25 rounded-full bg-[#1BB700] animate-ping"></div>
11+
<div class="relative w-full h-full rounded-full bg-[#199C01] "></div>
12+
</div>
13+
{{ if availability:now }}
14+
{{ trans:strings.availability_now }}<br>
15+
{{ elseif availability:from | is_future }}
16+
{{ trans:strings.availability month="{ availability:from | iso_format('MMMM YYYY') }" }}
17+
{{ else }}
18+
{{? $next_month = \Carbon\Carbon::now()->addMonth(1) ?}}
19+
{{ trans:strings.availability month="{ {{ next_month }} | iso_format('MMMM YYYY') }" }}
20+
{{ /if }}
21+
</div>
22+
<!-- End: /components/_availability.antlers.html -->
23+
{{ /if }}

0 commit comments

Comments
 (0)