init
This commit is contained in:
@@ -1,17 +1,41 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>{% block title %}Welcome!{% endblock %}</title>
|
||||
<link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 128 128%22><text y=%221.2em%22 font-size=%2296%22>⚫️</text><text y=%221.3em%22 x=%220.2em%22 font-size=%2276%22 fill=%22%23fff%22>sf</text></svg>">
|
||||
{% block stylesheets %}
|
||||
{% endblock %}
|
||||
<!doctype html>
|
||||
<html lang="fr" data-fr-scheme="system">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="format-detection" content="telephone=no">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
{# <link rel="stylesheet" href="dsfr/dsfr.min.css">#}
|
||||
{% block stylesheets %}
|
||||
{{ encore_entry_link_tags('app') }}
|
||||
{% endblock %}
|
||||
<meta name="theme-color" content="#000091"><!-- Défini la couleur de thème du navigateur (Safari/Android) -->
|
||||
<link rel="apple-touch-icon" href="favicon/apple-touch-icon.png"><!-- 180×180 -->
|
||||
<link rel="icon" href="favicon/favicon.svg" type="image/svg+xml">
|
||||
<link rel="shortcut icon" href="favicon/favicon.ico" type="image/x-icon"><!-- 32×32 -->
|
||||
<link rel="manifest" href="favicon/manifest.webmanifest" crossorigin="use-credentials">
|
||||
<!-- Modifier les chemins relatifs des favicons en fonction de la structure du projet -->
|
||||
<!-- Dans le fichier manifest.webmanifest aussi, modifier les chemins vers les images -->
|
||||
<title>{% block title %}Hello HomeController!{% endblock %}</title></head>
|
||||
{#<body> <!-- code de la page -->#}
|
||||
<!-- Script en version es6 module et nomodule pour les navigateurs le ne supportant pas -->
|
||||
{#<script type="module" src="dsfr/dsfr.module.min.js"></script>#}
|
||||
{#<script type="text/javascript" nomodule src="dsfr/dsfr.nomodule.min.js"></script>#}
|
||||
|
||||
{% block javascripts %}
|
||||
{% block importmap %}{{ importmap('app') }}{% endblock %}
|
||||
{% endblock %}
|
||||
</head>
|
||||
<body>
|
||||
{% block body %}{% endblock %}
|
||||
</body>
|
||||
</html>
|
||||
<body>
|
||||
{% block javascripts %}
|
||||
{{ encore_entry_script_tags('app') }}
|
||||
{{ encore_entry_script_tags('dsfrNoModule', attributes={nomodule: true}) }}
|
||||
{% endblock %}
|
||||
|
||||
{% block header %}
|
||||
<header role="banner">
|
||||
<nav class="fr-nav" role="navigation" aria-label="Menu Principal">
|
||||
{{ knp_menu_render('main') }}
|
||||
</nav>
|
||||
</header>
|
||||
{% endblock %}
|
||||
{% block body %}{% endblock %}
|
||||
{% block footer %}{% endblock %}
|
||||
</body>
|
||||
|
||||
</html>
|
||||
20
templates/home/index.html.twig
Normal file
20
templates/home/index.html.twig
Normal file
@@ -0,0 +1,20 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block title %}Hello HomeController!{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<style>
|
||||
.example-wrapper { margin: 1em auto; max-width: 800px; width: 95%; font: 18px/1.5 sans-serif; }
|
||||
.example-wrapper code { background: #F5F5F5; padding: 2px 6px; }
|
||||
</style>
|
||||
|
||||
<div class="example-wrapper">
|
||||
<h1>Hello {{ controller_name }}! ✅</h1>
|
||||
|
||||
This friendly message is coming from:
|
||||
<ul>
|
||||
<li>Your controller at <code><a href="{{ '/home/jerome/Projects/atos/dsfr-menu/src/Controller/HomeController.php'|file_link(0) }}">src/Controller/HomeController.php</a></code></li>
|
||||
<li>Your template at <code><a href="{{ '/home/jerome/Projects/atos/dsfr-menu/templates/home/index.html.twig'|file_link(0) }}">templates/home/index.html.twig</a></code></li>
|
||||
</ul>
|
||||
</div>
|
||||
{% endblock %}
|
||||
111
templates/menu/dfsr.html.twig
Normal file
111
templates/menu/dfsr.html.twig
Normal file
@@ -0,0 +1,111 @@
|
||||
{% extends 'knp_menu.html.twig' %}
|
||||
|
||||
{#{% macro attributes(attributes) %}#}
|
||||
{# {% for name, value in attributes %}#}
|
||||
{# {%- if value is not none and value is not same as(false) -%}#}
|
||||
{# {{- ' %s="%s"'|format(name, value is same as(true) ? name|e : value|e)|raw -}}#}
|
||||
{# {%- endif -%}#}
|
||||
{# {%- endfor -%}#}
|
||||
{#{% endmacro %}#}
|
||||
|
||||
{#{% block compressed_root %}#}
|
||||
{# {% apply spaceless %}#}
|
||||
{# {{ block('root') }}#}
|
||||
{# {% endapply %}#}
|
||||
{#{% endblock %}#}
|
||||
|
||||
{% block root %}
|
||||
{% set listAttributes = item.childrenAttributes %}
|
||||
{% set listAttributes = listAttributes|merge({'class': 'fr-nav__list'}) %}
|
||||
|
||||
{% set attributes = item.attributes %}
|
||||
{% set id = attributes.id|default(null)%}
|
||||
{% set ariaLabel = attribute(attributes, 'aria-label') | default("Menu principal")%}
|
||||
<nav class="fr-nav" id="{{ id }}" role="navigation" aria-label="{{ ariaLabel }}">
|
||||
{{ block('list') -}}
|
||||
</nav>
|
||||
{% endblock %}
|
||||
|
||||
{#{% block list %}#}
|
||||
{# {% if item.hasChildren and options.depth is not same as(0) and item.displayChildren %}#}
|
||||
{# {% import _self as knp_menu %}#}
|
||||
{# <ul{{ knp_menu.attributes(listAttributes) }}>#}
|
||||
{# {{ block('children') }}#}
|
||||
{# </ul>#}
|
||||
{# {% endif %}#}
|
||||
{#{% endblock %}#}
|
||||
|
||||
{#{% block children %}#}
|
||||
{# #}{# save current variables #}
|
||||
{# {% set currentOptions = options %}#}
|
||||
{# {% set currentItem = item %}#}
|
||||
{# #}{# update the depth for children #}
|
||||
{# {% if options.depth is not none %}#}
|
||||
{# {% set options = options|merge({'depth': currentOptions.depth - 1}) %}#}
|
||||
{# {% endif %}#}
|
||||
{# #}{# update the matchingDepth for children #}
|
||||
{# {% if options.matchingDepth is not none and options.matchingDepth > 0 %}#}
|
||||
{# {% set options = options|merge({'matchingDepth': currentOptions.matchingDepth - 1}) %}#}
|
||||
{# {% endif %}#}
|
||||
{# {% for item in currentItem.children %}#}
|
||||
{# {{ block('item') }}#}
|
||||
{# {% endfor %}#}
|
||||
{# #}{# restore current variables #}
|
||||
{# {% set item = currentItem %}#}
|
||||
{# {% set options = currentOptions %}#}
|
||||
{#{% endblock %}#}
|
||||
|
||||
{% block item %}
|
||||
{% if item.displayed %}
|
||||
{# building the class of the item #}
|
||||
{%- set classes = item.attribute('class') is not empty ? [item.attribute('class')|merge(['fr-nav__item'])] : ['fr-nav__item'] %}
|
||||
{%- if matcher.isCurrent(item) %}
|
||||
{%- set classes = classes|merge([options.currentClass]) %}
|
||||
{%- elseif matcher.isAncestor(item, options.matchingDepth) %}
|
||||
{%- set classes = classes|merge([options.ancestorClass]) %}
|
||||
{%- endif %}
|
||||
{%- if item.actsLikeFirst %}
|
||||
{%- set classes = classes|merge([options.firstClass]) %}
|
||||
{%- endif %}
|
||||
{%- if item.actsLikeLast %}
|
||||
{%- set classes = classes|merge([options.lastClass]) %}
|
||||
{%- endif %}
|
||||
|
||||
{# Mark item as "leaf" (no children) or as "branch" (has children that are displayed) #}
|
||||
{% if item.hasChildren and options.depth is not same as(0) %}
|
||||
{% if options.branch_class is not empty and item.displayChildren %}
|
||||
{%- set classes = classes|merge([options.branch_class]) %}
|
||||
{% endif %}
|
||||
{% elseif options.leaf_class is not empty %}
|
||||
{%- set classes = classes|merge([options.leaf_class]) %}
|
||||
{%- endif %}
|
||||
|
||||
{%- set attributes = item.attributes %}
|
||||
{%- if classes is not empty %}
|
||||
{%- set attributes = attributes|merge({'class': classes|join(' ')}) %}
|
||||
{%- endif %}
|
||||
{# displaying the item #}
|
||||
{% import _self as knp_menu %}
|
||||
<li{{ knp_menu.attributes(attributes) }}>
|
||||
{%- if item.uri is not empty and (not matcher.isCurrent(item) or options.currentAsLink) %}
|
||||
{{ block('linkElement') }}
|
||||
{%- else %}
|
||||
{{ block('spanElement') }}
|
||||
{%- endif %}
|
||||
{# render the list of children#}
|
||||
{%- set childrenClasses = item.childrenAttribute('class') is not empty ? [item.childrenAttribute('class')] : [] %}
|
||||
{%- set childrenClasses = childrenClasses|merge(['menu_level_' ~ item.level]) %}
|
||||
{%- set listAttributes = item.childrenAttributes|merge({'class': childrenClasses|join(' ') }) %}
|
||||
{{ block('list') }}
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block linkElement %}
|
||||
{%- set attributes = item.linkAttributes %}
|
||||
{% set attributes = attributes|merge({'class': 'fr-nav__link'}) %}
|
||||
{% import _self as knp_menu %}<a href="{{ item.uri }}"{{ knp_menu.attributes(attributes) }}>{{ block('label') }}</a>{% endblock %}
|
||||
|
||||
{% block spanElement %}{% import _self as knp_menu %}<span{{ knp_menu.attributes(item.labelAttributes) }}>{{ block('label') }}</span>{% endblock %}
|
||||
|
||||
{% block label %}{% if options.allow_safe_labels and item.getExtra('safe_label', false) %}{{ item.label|raw }}{% else %}{{ item.label }}{% endif %}{% endblock %}
|
||||
Reference in New Issue
Block a user