From a5376ee9374bd11747c50ecb2b429e1e3e2f92ec Mon Sep 17 00:00:00 2001 From: Jonas Leder <jonas.leder@jobrouter.com> Date: Fri, 25 Nov 2022 10:41:32 +0100 Subject: [PATCH] add navItemComponent --- composer.json | 3 +- composer.lock | 727 +++++++++++++---------- config/bundles.php | 1 + src/Twig/Components/NavItemComponent.php | 12 + symfony.lock | 3 + templates/components/header.html.twig | 8 +- templates/components/nav_item.html.twig | 10 + 7 files changed, 434 insertions(+), 330 deletions(-) create mode 100644 src/Twig/Components/NavItemComponent.php create mode 100644 templates/components/nav_item.html.twig diff --git a/composer.json b/composer.json index 28cf660..bb7a045 100644 --- a/composer.json +++ b/composer.json @@ -19,9 +19,10 @@ "symfony/runtime": "6.1.*", "symfony/security-bundle": "6.1.*", "symfony/twig-bridge": "6.1.*", - "symfony/yaml": "6.1.*", "symfony/twig-bundle": "6.1.*", + "symfony/ux-twig-component": "^2.5", "symfony/webpack-encore-bundle": "^1.16", + "symfony/yaml": "6.1.*", "twig/extra-bundle": "^2.12|^3.0", "twig/twig": "^2.12|^3.0" }, diff --git a/composer.lock b/composer.lock index b0daf06..4ba1d70 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "4c61d070bdd88d6ea03acdfbc455d1d1", + "content-hash": "90312621b119ec26917d89d87dfbbf28", "packages": [ { "name": "doctrine/annotations", @@ -1726,6 +1726,78 @@ }, "time": "2021-07-14T16:46:02+00:00" }, + { + "name": "symfony/asset", + "version": "v6.1.5", + "source": { + "type": "git", + "url": "https://github.com/symfony/asset.git", + "reference": "6065b5edc36442cb1ba98dc40f7c7f6b9e154729" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/asset/zipball/6065b5edc36442cb1ba98dc40f7c7f6b9e154729", + "reference": "6065b5edc36442cb1ba98dc40f7c7f6b9e154729", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "conflict": { + "symfony/http-foundation": "<5.4" + }, + "require-dev": { + "symfony/http-client": "^5.4|^6.0", + "symfony/http-foundation": "^5.4|^6.0", + "symfony/http-kernel": "^5.4|^6.0" + }, + "suggest": { + "symfony/http-foundation": "" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Asset\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Manages URL generation and versioning of web assets such as CSS stylesheets, JavaScript files and image files", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/asset/tree/v6.1.5" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2022-08-31T08:17:45+00:00" + }, { "name": "symfony/cache", "version": "v6.1.7", @@ -4675,6 +4747,169 @@ ], "time": "2022-10-19T08:10:53+00:00" }, + { + "name": "symfony/twig-bundle", + "version": "v6.1.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/twig-bundle.git", + "reference": "a2abab10068525a7f5a879e40e411d369d688545" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/twig-bundle/zipball/a2abab10068525a7f5a879e40e411d369d688545", + "reference": "a2abab10068525a7f5a879e40e411d369d688545", + "shasum": "" + }, + "require": { + "composer-runtime-api": ">=2.1", + "php": ">=8.1", + "symfony/config": "^5.4|^6.0", + "symfony/dependency-injection": "^5.4|^6.0", + "symfony/http-foundation": "^5.4|^6.0", + "symfony/http-kernel": "^5.4|^6.0", + "symfony/polyfill-ctype": "~1.8", + "symfony/twig-bridge": "^5.4|^6.0", + "twig/twig": "^2.13|^3.0.4" + }, + "conflict": { + "symfony/framework-bundle": "<5.4", + "symfony/translation": "<5.4" + }, + "require-dev": { + "doctrine/annotations": "^1.10.4", + "symfony/asset": "^5.4|^6.0", + "symfony/expression-language": "^5.4|^6.0", + "symfony/finder": "^5.4|^6.0", + "symfony/form": "^5.4|^6.0", + "symfony/framework-bundle": "^5.4|^6.0", + "symfony/routing": "^5.4|^6.0", + "symfony/stopwatch": "^5.4|^6.0", + "symfony/translation": "^5.4|^6.0", + "symfony/web-link": "^5.4|^6.0", + "symfony/yaml": "^5.4|^6.0" + }, + "type": "symfony-bundle", + "autoload": { + "psr-4": { + "Symfony\\Bundle\\TwigBundle\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides a tight integration of Twig into the Symfony full-stack framework", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/twig-bundle/tree/v6.1.1" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2022-05-27T16:55:36+00:00" + }, + { + "name": "symfony/ux-twig-component", + "version": "v2.5.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/ux-twig-component.git", + "reference": "a669df9c8f4f154d36957b2f2c3c8b53d7a0e225" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/ux-twig-component/zipball/a669df9c8f4f154d36957b2f2c3c8b53d7a0e225", + "reference": "a669df9c8f4f154d36957b2f2c3c8b53d7a0e225", + "shasum": "" + }, + "require": { + "php": ">=8.0", + "symfony/dependency-injection": "^5.4|^6.0", + "symfony/event-dispatcher": "^5.4|^6.0", + "symfony/property-access": "^5.4|^6.0", + "twig/twig": "^2.0|^3.0" + }, + "conflict": { + "symfony/config": "<5.4.0" + }, + "require-dev": { + "symfony/framework-bundle": "^5.4|^6.0", + "symfony/phpunit-bridge": "^6.0", + "symfony/twig-bundle": "^5.4|^6.0" + }, + "type": "symfony-bundle", + "extra": { + "thanks": { + "name": "symfony/ux", + "url": "https://github.com/symfony/ux" + } + }, + "autoload": { + "psr-4": { + "Symfony\\UX\\TwigComponent\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Twig components for Symfony", + "homepage": "https://symfony.com", + "keywords": [ + "components", + "symfony-ux", + "twig" + ], + "support": { + "source": "https://github.com/symfony/ux-twig-component/tree/v2.5.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2022-11-07T13:45:36+00:00" + }, { "name": "symfony/var-dumper", "version": "v6.1.6", @@ -4836,31 +5071,104 @@ "time": "2022-07-04T16:01:56+00:00" }, { - "name": "symfony/yaml", - "version": "v6.1.6", + "name": "symfony/webpack-encore-bundle", + "version": "v1.16.0", "source": { "type": "git", - "url": "https://github.com/symfony/yaml.git", - "reference": "66c6b0cf52b00f74614a2cf7ae7db08ea1095931" + "url": "https://github.com/symfony/webpack-encore-bundle.git", + "reference": "bb399930c0299866258b616a74a27b50b94c5d45" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/66c6b0cf52b00f74614a2cf7ae7db08ea1095931", - "reference": "66c6b0cf52b00f74614a2cf7ae7db08ea1095931", + "url": "https://api.github.com/repos/symfony/webpack-encore-bundle/zipball/bb399930c0299866258b616a74a27b50b94c5d45", + "reference": "bb399930c0299866258b616a74a27b50b94c5d45", "shasum": "" }, "require": { - "php": ">=8.1", - "symfony/polyfill-ctype": "^1.8" - }, - "conflict": { - "symfony/console": "<5.4" + "php": ">=7.1.3", + "symfony/asset": "^4.4 || ^5.0 || ^6.0", + "symfony/config": "^4.4 || ^5.0 || ^6.0", + "symfony/dependency-injection": "^4.4 || ^5.0 || ^6.0", + "symfony/deprecation-contracts": "^2.1 || ^3.0", + "symfony/http-kernel": "^4.4 || ^5.0 || ^6.0", + "symfony/polyfill-php80": "^1.25.0", + "symfony/service-contracts": "^1.0 || ^2.0 || ^3.0" }, "require-dev": { - "symfony/console": "^5.4|^6.0" + "symfony/framework-bundle": "^4.4 || ^5.0 || ^6.0", + "symfony/phpunit-bridge": "^5.3 || ^6.0", + "symfony/twig-bundle": "^4.4 || ^5.0 || ^6.0", + "symfony/web-link": "^4.4 || ^5.0 || ^6.0" }, - "suggest": { - "symfony/console": "For validating YAML files using the lint command" + "type": "symfony-bundle", + "extra": { + "thanks": { + "name": "symfony/webpack-encore", + "url": "https://github.com/symfony/webpack-encore" + } + }, + "autoload": { + "psr-4": { + "Symfony\\WebpackEncoreBundle\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Integration with your Symfony app & Webpack Encore!", + "support": { + "issues": "https://github.com/symfony/webpack-encore-bundle/issues", + "source": "https://github.com/symfony/webpack-encore-bundle/tree/v1.16.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2022-10-18T15:21:06+00:00" + }, + { + "name": "symfony/yaml", + "version": "v6.1.6", + "source": { + "type": "git", + "url": "https://github.com/symfony/yaml.git", + "reference": "66c6b0cf52b00f74614a2cf7ae7db08ea1095931" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/yaml/zipball/66c6b0cf52b00f74614a2cf7ae7db08ea1095931", + "reference": "66c6b0cf52b00f74614a2cf7ae7db08ea1095931", + "shasum": "" + }, + "require": { + "php": ">=8.1", + "symfony/polyfill-ctype": "^1.8" + }, + "conflict": { + "symfony/console": "<5.4" + }, + "require-dev": { + "symfony/console": "^5.4|^6.0" + }, + "suggest": { + "symfony/console": "For validating YAML files using the lint command" }, "bin": [ "Resources/bin/yaml-lint" @@ -4909,6 +5217,85 @@ ], "time": "2022-10-07T08:04:03+00:00" }, + { + "name": "twig/extra-bundle", + "version": "v3.4.0", + "source": { + "type": "git", + "url": "https://github.com/twigphp/twig-extra-bundle.git", + "reference": "2e58256b0e9fe52f30149347c0547e4633304765" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/twigphp/twig-extra-bundle/zipball/2e58256b0e9fe52f30149347c0547e4633304765", + "reference": "2e58256b0e9fe52f30149347c0547e4633304765", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/framework-bundle": "^4.4|^5.0|^6.0", + "symfony/twig-bundle": "^4.4|^5.0|^6.0", + "twig/twig": "^2.7|^3.0" + }, + "require-dev": { + "league/commonmark": "^1.0|^2.0", + "symfony/phpunit-bridge": "^4.4.9|^5.0.9|^6.0", + "twig/cache-extra": "^3.0", + "twig/cssinliner-extra": "^2.12|^3.0", + "twig/html-extra": "^2.12|^3.0", + "twig/inky-extra": "^2.12|^3.0", + "twig/intl-extra": "^2.12|^3.0", + "twig/markdown-extra": "^2.12|^3.0", + "twig/string-extra": "^2.12|^3.0" + }, + "type": "symfony-bundle", + "extra": { + "branch-alias": { + "dev-master": "3.2-dev" + } + }, + "autoload": { + "psr-4": { + "Twig\\Extra\\TwigExtraBundle\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + } + ], + "description": "A Symfony bundle for extra Twig extensions", + "homepage": "https://twig.symfony.com", + "keywords": [ + "bundle", + "extra", + "twig" + ], + "support": { + "source": "https://github.com/twigphp/twig-extra-bundle/tree/v3.4.0" + }, + "funding": [ + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/twig/twig", + "type": "tidelift" + } + ], + "time": "2022-01-04T13:58:53+00:00" + }, { "name": "twig/twig", "version": "v3.4.3", @@ -5043,78 +5430,6 @@ }, "time": "2022-11-12T15:38:23+00:00" }, - { - "name": "symfony/asset", - "version": "v6.1.5", - "source": { - "type": "git", - "url": "https://github.com/symfony/asset.git", - "reference": "6065b5edc36442cb1ba98dc40f7c7f6b9e154729" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/asset/zipball/6065b5edc36442cb1ba98dc40f7c7f6b9e154729", - "reference": "6065b5edc36442cb1ba98dc40f7c7f6b9e154729", - "shasum": "" - }, - "require": { - "php": ">=8.1" - }, - "conflict": { - "symfony/http-foundation": "<5.4" - }, - "require-dev": { - "symfony/http-client": "^5.4|^6.0", - "symfony/http-foundation": "^5.4|^6.0", - "symfony/http-kernel": "^5.4|^6.0" - }, - "suggest": { - "symfony/http-foundation": "" - }, - "type": "library", - "autoload": { - "psr-4": { - "Symfony\\Component\\Asset\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Manages URL generation and versioning of web assets such as CSS stylesheets, JavaScript files and image files", - "homepage": "https://symfony.com", - "support": { - "source": "https://github.com/symfony/asset/tree/v6.1.5" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2022-08-31T08:17:45+00:00" - }, { "name": "symfony/maker-bundle", "version": "v1.48.0", @@ -5208,92 +5523,6 @@ ], "time": "2022-11-14T10:48:46+00:00" }, - { - "name": "symfony/twig-bundle", - "version": "v6.1.1", - "source": { - "type": "git", - "url": "https://github.com/symfony/twig-bundle.git", - "reference": "a2abab10068525a7f5a879e40e411d369d688545" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/twig-bundle/zipball/a2abab10068525a7f5a879e40e411d369d688545", - "reference": "a2abab10068525a7f5a879e40e411d369d688545", - "shasum": "" - }, - "require": { - "composer-runtime-api": ">=2.1", - "php": ">=8.1", - "symfony/config": "^5.4|^6.0", - "symfony/dependency-injection": "^5.4|^6.0", - "symfony/http-foundation": "^5.4|^6.0", - "symfony/http-kernel": "^5.4|^6.0", - "symfony/polyfill-ctype": "~1.8", - "symfony/twig-bridge": "^5.4|^6.0", - "twig/twig": "^2.13|^3.0.4" - }, - "conflict": { - "symfony/framework-bundle": "<5.4", - "symfony/translation": "<5.4" - }, - "require-dev": { - "doctrine/annotations": "^1.10.4", - "symfony/asset": "^5.4|^6.0", - "symfony/expression-language": "^5.4|^6.0", - "symfony/finder": "^5.4|^6.0", - "symfony/form": "^5.4|^6.0", - "symfony/framework-bundle": "^5.4|^6.0", - "symfony/routing": "^5.4|^6.0", - "symfony/stopwatch": "^5.4|^6.0", - "symfony/translation": "^5.4|^6.0", - "symfony/web-link": "^5.4|^6.0", - "symfony/yaml": "^5.4|^6.0" - }, - "type": "symfony-bundle", - "autoload": { - "psr-4": { - "Symfony\\Bundle\\TwigBundle\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Provides a tight integration of Twig into the Symfony full-stack framework", - "homepage": "https://symfony.com", - "support": { - "source": "https://github.com/symfony/twig-bundle/tree/v6.1.1" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2022-05-27T16:55:36+00:00" - }, { "name": "symfony/web-profiler-bundle", "version": "v6.1.6", @@ -5371,158 +5600,6 @@ } ], "time": "2022-10-02T08:30:52+00:00" - }, - { - "name": "symfony/webpack-encore-bundle", - "version": "v1.16.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/webpack-encore-bundle.git", - "reference": "bb399930c0299866258b616a74a27b50b94c5d45" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/webpack-encore-bundle/zipball/bb399930c0299866258b616a74a27b50b94c5d45", - "reference": "bb399930c0299866258b616a74a27b50b94c5d45", - "shasum": "" - }, - "require": { - "php": ">=7.1.3", - "symfony/asset": "^4.4 || ^5.0 || ^6.0", - "symfony/config": "^4.4 || ^5.0 || ^6.0", - "symfony/dependency-injection": "^4.4 || ^5.0 || ^6.0", - "symfony/deprecation-contracts": "^2.1 || ^3.0", - "symfony/http-kernel": "^4.4 || ^5.0 || ^6.0", - "symfony/polyfill-php80": "^1.25.0", - "symfony/service-contracts": "^1.0 || ^2.0 || ^3.0" - }, - "require-dev": { - "symfony/framework-bundle": "^4.4 || ^5.0 || ^6.0", - "symfony/phpunit-bridge": "^5.3 || ^6.0", - "symfony/twig-bundle": "^4.4 || ^5.0 || ^6.0", - "symfony/web-link": "^4.4 || ^5.0 || ^6.0" - }, - "type": "symfony-bundle", - "extra": { - "thanks": { - "name": "symfony/webpack-encore", - "url": "https://github.com/symfony/webpack-encore" - } - }, - "autoload": { - "psr-4": { - "Symfony\\WebpackEncoreBundle\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Integration with your Symfony app & Webpack Encore!", - "support": { - "issues": "https://github.com/symfony/webpack-encore-bundle/issues", - "source": "https://github.com/symfony/webpack-encore-bundle/tree/v1.16.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2022-10-18T15:21:06+00:00" - }, - { - "name": "twig/extra-bundle", - "version": "v3.4.0", - "source": { - "type": "git", - "url": "https://github.com/twigphp/twig-extra-bundle.git", - "reference": "2e58256b0e9fe52f30149347c0547e4633304765" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/twigphp/twig-extra-bundle/zipball/2e58256b0e9fe52f30149347c0547e4633304765", - "reference": "2e58256b0e9fe52f30149347c0547e4633304765", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "symfony/framework-bundle": "^4.4|^5.0|^6.0", - "symfony/twig-bundle": "^4.4|^5.0|^6.0", - "twig/twig": "^2.7|^3.0" - }, - "require-dev": { - "league/commonmark": "^1.0|^2.0", - "symfony/phpunit-bridge": "^4.4.9|^5.0.9|^6.0", - "twig/cache-extra": "^3.0", - "twig/cssinliner-extra": "^2.12|^3.0", - "twig/html-extra": "^2.12|^3.0", - "twig/inky-extra": "^2.12|^3.0", - "twig/intl-extra": "^2.12|^3.0", - "twig/markdown-extra": "^2.12|^3.0", - "twig/string-extra": "^2.12|^3.0" - }, - "type": "symfony-bundle", - "extra": { - "branch-alias": { - "dev-master": "3.2-dev" - } - }, - "autoload": { - "psr-4": { - "Twig\\Extra\\TwigExtraBundle\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": "http://fabien.potencier.org", - "role": "Lead Developer" - } - ], - "description": "A Symfony bundle for extra Twig extensions", - "homepage": "https://twig.symfony.com", - "keywords": [ - "bundle", - "extra", - "twig" - ], - "support": { - "source": "https://github.com/twigphp/twig-extra-bundle/tree/v3.4.0" - }, - "funding": [ - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/twig/twig", - "type": "tidelift" - } - ], - "time": "2022-01-04T13:58:53+00:00" } ], "aliases": [], diff --git a/config/bundles.php b/config/bundles.php index 1b67b39..3bdd1cd 100644 --- a/config/bundles.php +++ b/config/bundles.php @@ -10,4 +10,5 @@ return [ Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true], Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true], Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true], + Symfony\UX\TwigComponent\TwigComponentBundle::class => ['all' => true], ]; diff --git a/src/Twig/Components/NavItemComponent.php b/src/Twig/Components/NavItemComponent.php new file mode 100644 index 0000000..3f909d3 --- /dev/null +++ b/src/Twig/Components/NavItemComponent.php @@ -0,0 +1,12 @@ +<?php + +namespace App\Twig\Components; + +use Symfony\UX\TwigComponent\Attribute\AsTwigComponent; + +#[AsTwigComponent('nav_item')] +final class NavItemComponent +{ + public string $page; + public string $title; +} diff --git a/symfony.lock b/symfony.lock index 0751cf1..cbbfeb0 100644 --- a/symfony.lock +++ b/symfony.lock @@ -125,6 +125,9 @@ "templates/base.html.twig" ] }, + "symfony/ux-twig-component": { + "version": "v2.5.0" + }, "symfony/web-profiler-bundle": { "version": "6.1", "recipe": { diff --git a/templates/components/header.html.twig b/templates/components/header.html.twig index ea33f25..4fc802c 100644 --- a/templates/components/header.html.twig +++ b/templates/components/header.html.twig @@ -1,13 +1,13 @@ -<header class="p-3 navbar-dark bg-dark"> +<header class="p-3 navbar-dark bg-primary navbar-expand-lg"> <div class="container"> <div class="d-flex flex-wrap align-items-center justify-content-center justify-content-lg-start"> <a href="/" class="d-flex align-items-center mb-2 mb-lg-0 text-white text-decoration-none"> <svg class="bi me-2" width="40" height="32" role="img" aria-label="Bootstrap"><use xlink:href="#bootstrap"/></svg> </a> - <ul class="nav col-12 col-lg-auto me-lg-auto mb-2 justify-content-center mb-md-0"> - <li><a href="{{ path("dashboard") }}" class="nav-link px-2 text-secondary">Home</a></li> - <li><a href="{{ path("app_profile") }}" class="nav-link px-2 text-white">Profile</a></li> + <ul class="navbar-nav col-12 col-lg-auto me-lg-auto mb-2 justify-content-center mb-md-0"> + {{ component('nav_item', {page: 'dashboard', title: 'Home'}) }} + {{ component('nav_item', {page: 'app_profile', title: 'Profile'}) }} {% if is_granted('ROLE_ADMIN') %} <li><a href="#" class="nav-link px-2 text-white">Admin Area</a></li> {% endif %} diff --git a/templates/components/nav_item.html.twig b/templates/components/nav_item.html.twig new file mode 100644 index 0000000..f79834f --- /dev/null +++ b/templates/components/nav_item.html.twig @@ -0,0 +1,10 @@ +<li class="nav-item"> + <a + href="{{ path(page) }}" + class=" + nav-link + px-2 + {% if app.request.attributes.get('_route') == page %}active{% endif %} + " + >{{ title }}</a> +</li> \ No newline at end of file -- GitLab