### Install Storia Bundle with Composer
Source: https://github.com/iq2i/storia-bundle/blob/main/doc/pages/index.md
Installs the iq2i/storia-bundle package into your Symfony project using Composer. This is the first step to integrate the bundle's functionality.
```bash
composer require iq2i/storia-bundle
```
--------------------------------
### Storia Project Structure for Menu Generation
Source: https://context7.com/iq2i/storia-bundle/llms.txt
Visualizes the directory structure of a Storia project, showing how components and pages are organized and how this structure translates into the generated navigation menu.
```tree
storia/
├── components/
│ ├── avatar.yaml # Menu: Components > Avatar
│ ├── badge.yaml # Menu: Components > Badge
│ ├── button/
│ │ ├── button.yaml # Menu: Components > Button > Button
│ │ ├── button.md # Documentation for button
│ │ └── button_group.yaml # Menu: Components > Button > Button group
│ └── form/
│ ├── text.yaml # Menu: Components > Form > Text
│ └── textarea.yaml # Menu: Components > Form > Textarea
└── pages/
└── homepage/
├── homepage.yaml # Menu: Pages > Homepage
└── homepage.html.twig
```
--------------------------------
### Configure Storia Bundle Path
Source: https://github.com/iq2i/storia-bundle/blob/main/doc/pages/index.md
Customizes the default directory where UI Storia looks for YAML files. This allows you to organize your interface definitions in a custom location.
```yaml
# config/packages/iq2i_storia.yaml
iq2i_storia:
default_path: '%kernel.project_dir%/new-folder'
```
--------------------------------
### Add Storia Bundle Routes
Source: https://github.com/iq2i/storia-bundle/blob/main/doc/pages/index.md
Defines the routing configuration for the UI Storia bundle. This YAML file specifies the resource for the bundle's routes and sets a base prefix for them.
```yaml
# config/routes/is2i_storia.yaml
iq2i_storia:
resource: '@IQ2iStoriaBundle/config/routes.php'
prefix: '/storia'
```
--------------------------------
### Configure Component Variants and Blocks in YAML
Source: https://github.com/iq2i/storia-bundle/blob/main/doc/pages/index.md
Shows how to define different variants of a component, including arguments and HTML blocks, using the 'variants', 'args', and 'blocks' keys in a YAML configuration file. The 'content' block is noted as a default block for Twig Components.
```yaml
# storia/components/button.yaml
component: Button
variants:
plain:
args:
class: plain
blocks:
content: Plain button
svg: ''
outline:
name: My outline button
args:
class: outline
blocks:
content: Outline button
svg: ''
```
--------------------------------
### Use Twig Component in YAML
Source: https://github.com/iq2i/storia-bundle/blob/main/doc/pages/index.md
Demonstrates how to replace the 'template' key with the 'component' key to use Twig Components within a YAML configuration file for UI elements.
```yaml
# storia/components/button.yaml
component: Button
variants:
plain:
args:
class: plain
label: Plain button
outline:
args:
class: outline
label: Outline button
```
--------------------------------
### Button Component Documentation (Markdown)
Source: https://context7.com/iq2i/storia-bundle/llms.txt
Provides Markdown documentation for the Button component, detailing its variants, usage guidelines, and specific properties like icon positioning.
```markdown
## Button Component
The button component supports multiple variants for different use cases.
### Usage Guidelines
- Use **plain** variant for primary actions
- Use **outline** variant for secondary actions
- Icons can be positioned left or right using the `icon.position` property
> The button automatically handles focus states and accessibility attributes.
```
--------------------------------
### Configure UI Storia Bundle (PHP)
Source: https://context7.com/iq2i/storia-bundle/llms.txt
Configure the UI Storia bundle's default path for story files and enable/disable the bundle in your Symfony application's configuration.
```php
defaultPath('%kernel.project_dir%/storia') // Directory containing story files
->enabled(true); // Enable/disable the bundle
};
```
--------------------------------
### Mount UI Storia Routes (PHP)
Source: https://context7.com/iq2i/storia-bundle/llms.txt
Import the UI Storia bundle's routes into your Symfony application to enable the UI interface at a specified path. This configuration defines the base URL for accessing the UI Storia interface.
```php
import('@IQ2iStoriaBundle/config/routes.php')
->prefix('/storia'); // Access UI Storia at /storia
};
```
--------------------------------
### Twig Functions for Variant Arguments and Blocks
Source: https://context7.com/iq2i/storia-bundle/llms.txt
Illustrates how to use Storia's Twig functions to retrieve arguments and blocks for a 'button/button' component's 'outline' variant, enabling component reuse.
```twig
{# Get variant arguments #}
{% set args = iq2i_storia_variant_args('button/button', 'outline') %}
{# Returns: { class: 'text-blue-700 border...', ... } #}
{# Get variant blocks #}
{% set blocks = iq2i_storia_variant_blocks('button/button', 'outline') %}
{# Returns: { content: 'Outline' } #}
{# Use in component #}
This is the homepage hero
{% endblock %} {% block content %}{{ message }}
{# Reuse component variants from other stories #} {% set button_args = iq2i_storia_variant_args('button/button', 'plain_icon_right') %}