Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,32 @@ class Index extends Composer
@endphp
```

### Asset Loading in Blade Templates
**❌ WRONG - Don't use @php blocks for asset logic:**
```php
@php
$icon_file = match($type) {
'arrow' => 'resources/images/icons/arrow.svg',
default => 'resources/images/icons/check.svg'
};
@endphp
<img src="{{ Vite::asset($icon_file) }}">
```

**✅ CORRECT - Use Blade conditionals and Vite::asset() directly:**
```php
@if($type === 'arrow')
<img src="{{ Vite::asset('resources/images/icons/arrow.svg') }}">
@else
<img src="{{ Vite::asset('resources/images/icons/check.svg') }}">
@endif
```

**Asset Loading Rules:**
- **Blade Templates**: Use `Vite::asset('path/to/asset')` directly (no import needed)
- **PHP Files**: Use `use Illuminate\Support\Facades\Vite;` then `Vite::asset()`
- **No @php blocks**: Avoid @php for asset logic - use Blade conditionals or View Composers

**Key Benefits:**
- **Separation of Concerns**: Keep data fetching logic out of Blade templates
- **Reusability**: Share data logic across multiple templates
Expand Down
28 changes: 27 additions & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,33 @@ With View Composers, Blade templates become clean and focused:
@foreach($featured_posts as $post)
{{-- Template logic only --}}
@endforeach
```(claude.ai/code) when working with code in this repository.
```

### Asset Loading in Blade Templates
**❌ WRONG - Don't use @php blocks for asset logic:**
```php
@php
$icon_file = match($type) {
'arrow' => 'resources/images/icons/arrow.svg',
default => 'resources/images/icons/check.svg'
};
@endphp
<img src="{{ Vite::asset($icon_file) }}">
```

**✅ CORRECT - Use Blade conditionals directly:**
```php
@if($type === 'arrow')
<img src="{{ Vite::asset('resources/images/icons/arrow.svg') }}">
@else
<img src="{{ Vite::asset('resources/images/icons/check.svg') }}">
@endif
```

**Asset Loading Rules:**
- **Blade Templates**: Use `Vite::asset()` directly (no import needed)
- **PHP Files**: Use `use Illuminate\Support\Facades\Vite;` then `Vite::asset()`
- **No @php blocks**: Keep asset logic in Blade conditionals or View Composers(claude.ai/code) when working with code in this repository.

## Architecture Overview

Expand Down
171 changes: 171 additions & 0 deletions app/Blocks/ExpertiseDetailAdvantages.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
<?php

namespace App\Blocks;

use Log1x\AcfComposer\Block;
use Log1x\AcfComposer\Builder;

class ExpertiseDetailAdvantages extends Block
{
/**
* The block name.
*
* @var string
*/
public $name = 'Expertise Detail Advantages';

/**
* The block description.
*
* @var string
*/
public $description = 'Content section highlighting key benefits/advantages of a service with checkmark-style list items.';

/**
* The block category.
*
* @var string
*/
public $category = 'thyra-expertise';

/**
* The block icon.
*
* @var string|array
*/
public $icon = 'yes-alt';

/**
* The block keywords.
*
* @var array
*/
public $keywords = ['expertise', 'advantages', 'benefits', 'checkmark'];

/**
* The block post type allow list.
*
* @var array
*/
public $post_types = [];

/**
* The parent block type allow list.
*
* @var array
*/
public $parent = [];

/**
* The ancestor block type allow list.
*
* @var array
*/
public $ancestor = [];

/**
* The default block mode.
*
* @var string
*/
public $mode = 'edit';

/**
* The default block alignment.
*
* @var string
*/
public $align = '';

/**
* The default block text alignment.
*
* @var string
*/
public $align_text = '';

/**
* The default block content alignment.
*
* @var string
*/
public $align_content = '';

/**
* The default block spacing.
*
* @var array
*/
public $spacing = [
'padding' => null,
'margin' => null,
];

/**
* The supported block features.
*
* @var array
*/
public $supports = [
'align' => false,
'mode' => true,
'jsx' => true,
'anchor' => true,
];

/**
* The block styles.
*
* @var array
*/
public $styles = ['light', 'dark'];

/**
* The block preview example data.
*
* @var array
*/
public $example = [
'items' => [
['item' => 'Item one'],
['item' => 'Item two'],
['item' => 'Item three'],
],
];

/**
* The block template.
*
* @var array
*/
public $template = [
'core/heading' => ['placeholder' => 'Hello World'],
'core/paragraph' => ['placeholder' => 'Welcome to the Expertise Detail Advantages block.'],
];

/**
* Data to be passed to the block before rendering.
*/
public function with(): array
{
return [];
}

/**
* The block field group.
*/
public function fields(): array
{
return $this->get('ExpertiseDetailAdvantages');
}

/**
* Assets enqueued with 'enqueue_block_assets' when rendering the block.
*
* @link https://developer.wordpress.org/block-editor/how-to-guides/enqueueing-assets-in-the-editor/#editor-content-scripts-and-styles
*/
public function assets(array $block): void
{
//
}
}
66 changes: 66 additions & 0 deletions app/Fields/ExpertiseDetailAdvantages.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php

namespace App\Fields;

use Log1x\AcfComposer\Builder;
use Log1x\AcfComposer\Field;

class ExpertiseDetailAdvantages extends Field
{
/**
* The field group.
*/
public function fields(): array
{
$advantages = Builder::make('expertise_detail_advantages');

$advantages
->setLocation('block', '==', 'acf/expertise-detail-advantages');

$advantages
->addText('advantages_pill_text', [
'label' => 'Pill Text',
'default_value' => 'Benefits',
'instructions' => 'Text for the blue pill tag (e.g., "Benefits")'
])
->addText('advantages_main_title', [
'label' => 'Main Title',
'default_value' => 'What benefits do our services provide',
'instructions' => 'Main section heading'
])
->addTextarea('advantages_description', [
'label' => 'Description',
'default_value' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit...',
'instructions' => 'Description text below the main title'
])
->addRepeater('advantages_list', [
'label' => 'Advantages List',
'min' => 1,
'max' => 6,
'layout' => 'block',
'button_label' => 'Add Advantage'
])
->addText('title', [
'label' => 'Advantage Title',
'required' => 0,
'default_value' => 'Advantage Title'
])
->addTextarea('description', [
'label' => 'Advantage Description',
'required' => 0,
'default_value' => 'Description of this advantage...'
])
->addSelect('icon_type', [
'label' => 'Icon Type',
'choices' => [
'checkmark' => 'Checkmark',
'star' => 'Star',
'arrow' => 'Arrow'
],
'default_value' => 'checkmark'
])
->endRepeater();

return $advantages->build();
}
}
23 changes: 23 additions & 0 deletions app/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,29 @@
add_theme_support('customize-selective-refresh-widgets');
}, 20);

/**
* Register custom block categories for Thyra theme
*/
add_filter('block_categories_all', function ($categories) {
return array_merge($categories, [
[
'slug' => 'thyra-expertise',
'title' => 'Thyra Expertise Blocks',
'icon' => 'star-filled',
],
[
'slug' => 'thyra-general',
'title' => 'Thyra General Blocks',
'icon' => 'admin-customizer',
],
[
'slug' => 'thyra-home',
'title' => 'Thyra Home Blocks',
'icon' => 'admin-home',
],
]);
});

/**
* Register the theme sidebars.
*
Expand Down
6 changes: 3 additions & 3 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading