Building Blocks

Create or modify AEM Edge Delivery blocks with JavaScript decoration and CSS styling.

Updated Feb 15, 2024
One-click install
npx skills add https://github.com/shsteimer/shsteimer-com --skill building-blocks
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Building Blocks
Source: https://github.com/shsteimer/shsteimer-com/tree/main/.claude/skills/building-blocks
Command: npx skills add https://github.com/shsteimer/shsteimer-com --skill building-blocks

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes resources (resource) components.

What problem does it solve?

Developing AEM Edge Delivery blocks requires adherence to specific patterns for JavaScript decoration, CSS styling, and content model integration. This skill provides a structured guide, ensuring developers build high-quality, performant, and maintainable blocks that align with platform best practices.

Core Features & Use Cases

  • Structured Development Workflow: Guides through the entire block development process, from understanding content models and finding similar blocks to implementing JS decoration, CSS styling, and comprehensive testing.
  • Code Quality & Best Practices: Enforces guidelines for JavaScript (DOM manipulation, performance) and CSS (scoping, responsiveness, custom properties) to ensure robust and maintainable code.
  • Integrated Testing & Documentation: Automatically invokes the testing-blocks skill for validation and provides guidance on creating both developer and author-facing documentation.
  • Use Case: When creating a new "carousel" block, this skill walks you through setting up the block's files, writing efficient JavaScript to transform authored content into an interactive carousel, applying scoped CSS for responsive design, and ensuring all code meets quality standards before deployment.

Quick Start

Example: Basic JavaScript decoration for a new block

blocks/my-block/my-block.js

/**

  • decorate the block
  • @param {Element} block the block */ export default async function decorate(block) { const wrapper = document.createElement('div'); wrapper.className = 'my-block-content'; wrapper.append(...block.children); # Move existing content into wrapper block.append(wrapper); }

Example: Basic CSS styling for a new block

blocks/my-block/my-block.css

main .my-block { padding: 1rem; background-color: var(--background-color); }

main .my-block .my-block-content { display: flex; gap: 1rem; }

Frequently Asked Questions about Building Blocks

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create an AEM Edge Delivery block from scratch?

Creating an AEM Edge Delivery block involves setting up the block directory structure, implementing JavaScript decoration to transform content, applying scoped CSS styling, and testing against your content model. Start by understanding your content model, then build the block's JS file to handle DOM manipulation, add CSS for responsive design using custom properties, and validate with test content before deployment.

What JavaScript patterns should I follow when decorating AEM blocks?

AEM block JavaScript decoration should prioritize DOM manipulation efficiency and performance. Export a default async function that receives the block element, manipulate child nodes appropriately, avoid blocking operations, and leverage native DOM APIs. The decorator transforms authored content into the intended interactive or visual structure while maintaining code readability and maintainability.

How do I apply CSS styling to AEM Edge Delivery blocks?

CSS for AEM blocks uses scoped selectors, custom properties for theming, and flexbox or grid for responsive layouts. Prefix styles with the block class name, define reusable custom properties like `--background-color`, and test across viewports. Scoping prevents style conflicts with other blocks and ensures maintainability as your component library grows.

Can I modify existing AEM blocks or do I need to create new ones?

You can modify existing AEM blocks by updating their JavaScript decoration, CSS styling, and content model integration. The Building Blocks workflow supports both creation and modification, allowing you to enhance performance, adjust visual design, or expand content model support on established blocks during your Content Driven Development phase.

What prerequisites must be in place before developing an AEM block?

Before block development, you need a defined content model for your block's authored content, test content created and published to a live URL, and access to your AEM Edge Delivery site structure. These prerequisites ensure you can develop against realistic data and validate your block's behavior with actual content during testing.

How do I test my AEM block to ensure code quality?

Testing AEM blocks validates that JavaScript decoration correctly transforms content, CSS applies responsively across devices, and the content model integration works as designed. The Building Blocks skill invokes testing workflows automatically and provides guidance on creating both developer-facing technical documentation and author-facing usage documentation.