From d7659735cb53d846b01ec8e57fb6982b69655b56 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Mon, 21 Feb 2022 23:58:08 +0100 Subject: [PATCH] update default template --- assets/css/_admin_extend.scss | 6 +- assets/css/app.scss | 0 assets/js/app.js | 1 + templates/base.html.twig | 67 ++++++++++++--- templates/page/simple/default.html.twig | 103 +++--------------------- webpack.config.js | 1 + 6 files changed, 68 insertions(+), 110 deletions(-) create mode 100644 assets/css/app.scss create mode 100644 assets/js/app.js diff --git a/assets/css/_admin_extend.scss b/assets/css/_admin_extend.scss index 88f6b3d..8b13789 100644 --- a/assets/css/_admin_extend.scss +++ b/assets/css/_admin_extend.scss @@ -1,5 +1 @@ -$theme-colors: ( - "primary": #1ab5dc, - "primary-light": lighten(#3183aa, 40%), - "dark-blue": #1e2430, -) !default; + diff --git a/assets/css/app.scss b/assets/css/app.scss new file mode 100644 index 0000000..e69de29 diff --git a/assets/js/app.js b/assets/js/app.js new file mode 100644 index 0000000..0fc863e --- /dev/null +++ b/assets/js/app.js @@ -0,0 +1 @@ +import '../css/app.scss' diff --git a/templates/base.html.twig b/templates/base.html.twig index 16d7273..fa9961f 100644 --- a/templates/base.html.twig +++ b/templates/base.html.twig @@ -1,19 +1,62 @@ +{% apply spaceless %} - + - - {% block title %}Welcome!{% endblock %} - {# Run `composer require symfony/webpack-encore-bundle` - and uncomment the following Encore helpers to start using Symfony UX #} - {% block stylesheets %} - {#{{ encore_entry_link_tags('app') }}#} - {% endblock %} + + - {% block javascripts %} - {#{{ encore_entry_script_tags('app') }}#} - {% endblock %} + + + {%- block opengraph -%} + + + + + + {%- if _page.ogImage -%} + + {%- endif -%} + {%- endblock -%} + + {%- block stylesheets -%} + {{ encore_entry_link_tags('app') }} + {%- endblock -%} + + {{ _page.metaTitle }} + - {% block body %}{% endblock %} + {# + - The current node is `_node` and its menu is `_menu` + - The current navigation is `_navigation` + - The current locale is `_locale` + + - Retrieve all navigations: `_store.navigations` + - Retrieve a navigation by its code: `_store.navigation('the_code')` + + - Retrieve all navigation menus: `_navigation.menus` + - Retrieve a menu by its code: `_navigation.menu('the_code')` + - Retrieve all nodes of a menu: `menu.rootNode.children` + - Retrieve visible nodes of a menu: `menu.rootNode.children({visible: true})` + + - Test if a node is the current one: `_store.isActiveNode(node)` + - Test if a node is or contains the current one: `_store.isActiveNode(node, true)` + - Generate a node url: + ``` + {% if node.hasExternalUrl or node.hasAppUrl %} + {% set url = node.url %} + {% else %} + {% set url = safe_node_path(node) %} + {% endif %} + ``` + - Generate a node url when the navigation has several domains: `safe_node_path(node, {_domain: _domain})` + #} + + {% block page %}{% endblock %} + + {%- block javascripts -%} + {{ encore_entry_script_tags('app') }} + {%- endblock -%} +{% endapply %} diff --git a/templates/page/simple/default.html.twig b/templates/page/simple/default.html.twig index a737bca..0e314d8 100644 --- a/templates/page/simple/default.html.twig +++ b/templates/page/simple/default.html.twig @@ -1,99 +1,16 @@ -{% import _self as macros %} +{% extends 'base.html.twig' %} -{% macro item(node, store) %} - {% set isActive = store.isActiveNode(node, true) %} +{%- block page -%} +

{{ _page.title.value }}

- {% if node.isVisible %} - {% if node.code == 'post' %} - - {{ node.label }} - - {% elseif node.page %} - {% set url = node.hasExternalUrl ? node.url : url(node.routeName) %} + {{ _page.content.value|murph_url|file_attributes|raw }} - - {{ node.label }} - - {% else %} - - {{ node.label }} - - {% endif %} +
- {% if node.children|length %} - - {% endif %} + {% set image = _page.image.value %} + + {% if image %} + {{ image|file_attribute('alt') }} {% endif %} -{% endmacro %} +{%- endblock -%} -{% macro menu(menu, store) %} - -{% endmacro %} - -

{{ _page.title.value }}

- -
{{ _page.content.value|murph_url|file_attributes }}
- -{% set image = _page.image.value %} - -{% if image %} - -{% endif %} - -

Request

- - - -

Menus

- -{# {% set menu = _navigation.menu('top') %} #} - -{% for menu in _navigation.menus %} -

{{ menu.label }} / {{ menu.code }}

- - {{ macros.menu(menu, _store) }} -{% endfor %} diff --git a/webpack.config.js b/webpack.config.js index 6ceaea5..a61b3a7 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -21,6 +21,7 @@ Encore * and one CSS file (e.g. app.css) if your JavaScript imports CSS. */ .addEntry('admin', './assets/js/admin.js') + .addEntry('app', './assets/js/app.js') // When enabled, Webpack "splits" your files into smaller pieces for greater optimization. .splitEntryChunks()