ddtcorex/maestro-skills / skills/magento2-hyva-dev
magento2-hyva-dev
FlaggedUse when creating a Hyvä theme or child theme, building an Alpine.js component, making markup CSP-compliant, adding Tailwind classes, or converting Luma to Hyvä. DEPENDENT on magento2-dev-core.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 8.2 KB |
| references/alpine.md | markdown | 3.7 KB |
| references/compatibility-modules.md | markdown | 1.3 KB |
| references/csp.md | markdown | 3.2 KB |
| references/migration.md | markdown | 1.2 KB |
| references/review-checklist.md | markdown | 4.3 KB |
| references/tailwind.md | markdown | 2.7 KB |
| references/theme-and-child.md | markdown | 2.4 KB |
| references/view-models.md | markdown | 1.6 KB |
references/view-models.md
View on GitHub# View models
The view model contract, registration and the patterns the theme expects.
Prefer view models (Magento's `Magento\Framework\View\Element\Block\ArgumentInterface`, which Hyva's own view models implement) over blocks for passing data to templates: they keep PHP logic out of the theme directory (which should hold only templates, layout, `i18n`, and `web/` assets) and in a proper `app/code` module where Magento's DI can autoload the class.
```php
// app/code/Vendor/Module/ViewModel/ProductInfo.php
declare(strict_types=1);
namespace Vendor\Module\ViewModel;
use Magento\Framework\View\Element\Block\ArgumentInterface;
use Magento\Framework\View\LayoutInterface;
class ProductInfo implements ArgumentInterface
{
public function __construct(
private readonly LayoutInterface $layout
) {}
public function isInStock(): bool
{
$product = $this->layout->getBlock('product.info')->getProduct();
return $product && $product->isInStock();
}
}
```
```xml
<!-- Magento_Theme/layout/default.xml -->
<referenceBlock name="product.info">
<arguments>
<argument name="product_info_view_model" xsi:type="object">Vendor\Module\ViewModel\ProductInfo</argument>
</arguments>
</referenceBlock>
```
```php
<?php
/** @var \Vendor\Module\ViewModel\ProductInfo $productInfoViewModel */
// A layout <argument> is block data, not a template variable: read it from the block.
$productInfoViewModel = $block->getData('product_info_view_model');
?>
<?php if ($productInfoViewModel->isInStock()): ?>
<button class="btn-cart">Add to Cart</button>
<?php endif; ?>
```
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation). | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK). | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |