{# SAM Page Header Component Parameters: - title: string (required) - Page title - icon: string - Icon name for the title (book, users, layers, grid, settings, chart, folder, file) - badge: string|number - Badge displayed before the title (e.g., section position) - subtitle: string - Subtitle with HTML support - status: object { visible: bool } - Shows visible/hidden pill - buttons: array - Action buttons - text: string - Button label - url: string - Link URL (not needed for sync or dataAction buttons) - style: string - primary, outline, secondary, danger, success - icon: string - plus, sync, edit, trash, download, upload, eye, link - sync: bool - If true, uses sync controller instead of link - dataAction: string - Stimulus data-action attribute (e.g., "click->controller#method") - sync: object { url: string, label: string } - Sync controller config - companySelector: object { companies, company, baseUrl, isAdmin } - Company selector for admins Usage examples: Basic: {% include 'sam/_components/page_header.html.twig' with { title: 'Gestion des cours', icon: 'book', subtitle: '102 cours', buttons: [{ text: 'Synchroniser', style: 'outline', icon: 'sync', sync: true }], sync: { url: path('app_sam_sync'), label: 'cours' } } %} With Stimulus action button: {% include 'sam/_components/page_header.html.twig' with { title: 'Gestion des cohortes', icon: 'layers', subtitle: '15 cohortes', buttons: [ { text: 'Synchroniser', style: 'outline', icon: 'sync', sync: true }, { text: 'Créer', style: 'primary', icon: 'plus', dataAction: 'click->controller#openModal' } ], sync: { url: path('app_sam_sync'), label: 'cohortes' } } %} With badge and status (for sections): {% include 'sam/_components/page_header.html.twig' with { title: 'Introduction', badge: 1, subtitle: '5 activités', status: { visible: true } } %} #} {% set iconSvgs = { 'book': '', 'users': '', 'layers': '', 'grid': '', 'settings': '', 'chart': '', 'folder': '', 'file': '' } %} {% set buttonIconSvgs = { 'plus': '', 'sync': '', 'edit': '', 'trash': '', 'download': '', 'upload': '', 'eye': '', 'link': '' } %}

{# Badge de position (pour les sections) #} {% if badge is defined and badge %} {{ badge }} {% endif %} {# Icône #} {% if icon is defined and icon %} {{ iconSvgs[icon]|default(iconSvgs['file'])|raw }} {% endif %} {{ title|default('Page') }}

{% if subtitle is defined and subtitle %}

{{ subtitle|raw }}

{% endif %}
{# Company selector (admin only) #} {% if companySelector is defined and companySelector %} {% include 'sam/_components/company_selector.html.twig' with { companies: companySelector.companies, company: companySelector.company, baseUrl: companySelector.baseUrl, isAdmin: companySelector.isAdmin } %} {% endif %} {# Status pill (visible/masqué) #} {% if status is defined and status %} {% if status.visible %} Visible {% else %} Masqué {% endif %} {% endif %} {# Buttons #} {% if buttons is defined and buttons|length > 0 %} {% for button in buttons %} {% set btnClass = 'sam-btn sam-btn--' ~ (button.style|default('outline')) %} {% if button.sync|default(false) %} {# Sync button #} {% elseif button.dataAction is defined %} {# Stimulus action button #} {% else %} {# Link button #} {% if button.icon is defined %} {{ buttonIconSvgs[button.icon]|default('')|raw }} {% endif %} {{ button.text }} {% endif %} {% endfor %} {% endif %}