{% extends 'base.html.twig' %} {% block title %}Context Banner - Design System - Bubul{% endblock %} {% block body %}
{% include '_atoms/icon/icon.html.twig' with { name: 'chevron-left', size: 'sm', color: 'gray' } %}
Organisme /

Context Banner

Bandeau contextuel pleine largeur — sélection et affichage du contexte actif

{# ===== PRÉSENTATION ===== #}
{% include '_atoms/icon/icon.html.twig' with { name: 'building', size: 'lg', color: 'white' } %}

Bandeau de contexte

SAM · Réutilisable

Le context-banner est un bandeau pleine largeur collé en haut de chaque section. Il affiche le contexte actif (ex : entreprise sélectionnée) et propose un sélecteur pour en changer. Conçu pour s'échapper du padding de la <main> via des marges négatives -mx-6 lg:-mx-8.

1

Atome

4

Variantes couleur

7

Pages SAM

sticky

Position

{# ===== PARAMÈTRES ===== #}

Paramètres

Paramètre Type Défaut Description
titlestringrequisTitre du contexte (ex: nom d'entreprise)
subtitlestringnullSous-titre (HTML autorisé via |raw)
iconstring'building'Nom de l'icône Solar (atom icon)
colorstring'primary'Variante: primary, cohorts, success, warning
selectorobjectnullConfig sélecteur: {items, selected, controller, baseUrl}
actionsarraynullBoutons d'action: [{label, href, icon}]
stickybooltrueFixe le bandeau en haut au scroll
classstring''Classes Tailwind additionnelles
{# ===== THÈME CLAIR (défaut) ===== #}

Thème clair theme: 'light' (défaut)

Fond blanc avec trait de couleur en haut et icône tintée. Recommandé pour s'intégrer dans un layout existant.

{# cohorts light (SAM) #}

color: 'cohorts', theme: 'light' — SAM (utilisé en production)

{% include '_organisms/context-banner/context-banner.html.twig' with { title: 'Acme Corporation', subtitle: '24 apprenants · 8 cours · 3 cohortes', icon: 'building', color: 'cohorts', theme: 'light', sticky: false } %}
{# primary light #}

color: 'primary', theme: 'light'

{% include '_organisms/context-banner/context-banner.html.twig' with { title: 'Formation React Avancé', subtitle: 'Moodia · 6 sections · 24 activités', icon: 'book', color: 'primary', theme: 'light', sticky: false } %}
{# success light #}

color: 'success', theme: 'light'

{% include '_organisms/context-banner/context-banner.html.twig' with { title: 'Contrat actif', subtitle: 'Valide jusqu\'au 31/12/2025', icon: 'check-circle', color: 'success', theme: 'light', sticky: false } %}
{# ===== THÈME SOMBRE ===== #}

Thème sombre theme: 'dark'

Fond plein coloré avec texte blanc. Pour les bandeaux à fort impact visuel.

{# cohorts dark #}

color: 'cohorts', theme: 'dark'

{% include '_organisms/context-banner/context-banner.html.twig' with { title: 'Acme Corporation', subtitle: '24 apprenants · 8 cours · 3 cohortes', icon: 'building', color: 'cohorts', theme: 'dark', sticky: false } %}
{# primary dark #}

color: 'primary', theme: 'dark'

{% include '_organisms/context-banner/context-banner.html.twig' with { title: 'Formation React Avancé', subtitle: 'Moodia · 6 sections · 24 activités', icon: 'book', color: 'primary', theme: 'dark', sticky: false } %}
{# warning dark #}

color: 'warning', theme: 'dark'

{% include '_organisms/context-banner/context-banner.html.twig' with { title: 'Configuration incomplète', subtitle: 'Moodle n\'est pas encore configuré', icon: 'alert', theme: 'dark', color: 'warning', sticky: false } %}
{# ===== AVEC SÉLECTEUR ===== #}

Avec sélecteur de contexte

Affiché uniquement si selector.items contient plus d'un élément.

{% include '_organisms/context-banner/context-banner.html.twig' with { title: 'Acme Corporation', subtitle: '24 apprenants · 8 cours', icon: 'building', color: 'cohorts', theme: 'light', sticky: false, selector: { items: [ { label: 'Acme Corporation', value: 'uuid-1' }, { label: 'Globex Industries', value: 'uuid-2' }, { label: 'Initech', value: 'uuid-3' } ], selected: 'uuid-1', controller: 'sam--company-selector', baseUrl: '/sam' } } %}
{# ===== UTILISATION DANS SAM ===== #}

Utilisation dans SAM

{%- verbatim %}
{# Dans sam/layout.html.twig — hérité automatiquement par toutes les pages SAM #}

{% include '_organisms/context-banner/context-banner.html.twig' with {
    title: company ? company.name : 'Toutes les entreprises',
    subtitle: company
        ? stats.users ~ ' apprenants · ' ~ stats.courses ~ ' cours'
        : 'Vue d\'ensemble — toutes entreprises',
    icon: 'building',
    color: 'cohorts',
    selector: (isAdmin and companies|length > 1) ? {
        items: companies|map(c => { label: c.name, value: c.uuid }),
        selected: company ? company.uuid : null,
        controller: 'sam--company-selector',
        baseUrl: currentPageUrl
    } : null
} %}
{% endverbatim -%}
{# ===== NOTE TECHNIQUE ===== #}

Note technique — Pleine largeur

{% include '_atoms/icon/icon.html.twig' with { name: 'alert', size: 'md', color: 'warning' } %}

Marges négatives requises

Le context-banner s'échappe automatiquement du padding px-6 lg:px-8 py-8 de la <main> grâce aux classes internes -mx-6 lg:-mx-8 -mt-8 lg:-mt-12 mb-8. Il doit être placé en premier enfant du block body.

{% endblock %}