From 9cdaca9570655eb8ceb8ec30053d4f5952dd46ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Owsiak?= Date: Fri, 2 Feb 2024 21:14:51 +0200 Subject: [PATCH] Added stimulus & controllers to a landing page (#954) * Added stimulus & controllers to a landing page * removed tab controller & packages json --- src/web/landing/assets/app.js | 3 + src/web/landing/assets/bootstrap.js | 6 ++ src/web/landing/assets/controllers.json | 4 ++ .../syntax_highlight_controller.js | 16 +++++ src/web/landing/assets/styles/app.css | 4 ++ src/web/landing/composer.json | 3 +- src/web/landing/composer.lock | 71 ++++++++++++++++++- src/web/landing/config/bundles.php | 1 + src/web/landing/importmap.php | 28 ++++++++ src/web/landing/templates/base.html.twig | 8 +-- .../landing/templates/main/index.html.twig | 12 ++-- 11 files changed, 145 insertions(+), 11 deletions(-) create mode 100644 src/web/landing/assets/app.js create mode 100644 src/web/landing/assets/bootstrap.js create mode 100644 src/web/landing/assets/controllers.json create mode 100644 src/web/landing/assets/controllers/syntax_highlight_controller.js create mode 100644 src/web/landing/importmap.php diff --git a/src/web/landing/assets/app.js b/src/web/landing/assets/app.js new file mode 100644 index 000000000..c7a06e81f --- /dev/null +++ b/src/web/landing/assets/app.js @@ -0,0 +1,3 @@ +import '@fontsource-variable/cabin/index.min.css'; +import 'highlight.js/styles/github-dark.min.css'; +import './bootstrap.js'; diff --git a/src/web/landing/assets/bootstrap.js b/src/web/landing/assets/bootstrap.js new file mode 100644 index 000000000..c7a3f599c --- /dev/null +++ b/src/web/landing/assets/bootstrap.js @@ -0,0 +1,6 @@ +import { startStimulusApp } from '@symfony/stimulus-bundle'; + +const app = startStimulusApp(); + +// register any custom, 3rd party controllers here +// app.register('some_controller_name', SomeImportedController); \ No newline at end of file diff --git a/src/web/landing/assets/controllers.json b/src/web/landing/assets/controllers.json new file mode 100644 index 000000000..29d2f3464 --- /dev/null +++ b/src/web/landing/assets/controllers.json @@ -0,0 +1,4 @@ +{ + "controllers": [], + "entrypoints": [] +} \ No newline at end of file diff --git a/src/web/landing/assets/controllers/syntax_highlight_controller.js b/src/web/landing/assets/controllers/syntax_highlight_controller.js new file mode 100644 index 000000000..ff536a238 --- /dev/null +++ b/src/web/landing/assets/controllers/syntax_highlight_controller.js @@ -0,0 +1,16 @@ +import {Controller} from '@hotwired/stimulus'; +import hljs from 'highlight.js/lib/core'; +import php from 'highlight.js/lib/languages/php'; + +export default class extends Controller +{ + static afterLoad(identifier, application) + { + hljs.registerLanguage('php', php); + } + + connect() + { + hljs.highlightElement(this.element); + } +} \ No newline at end of file diff --git a/src/web/landing/assets/styles/app.css b/src/web/landing/assets/styles/app.css index c7842b1a7..e09db6850 100644 --- a/src/web/landing/assets/styles/app.css +++ b/src/web/landing/assets/styles/app.css @@ -2,6 +2,10 @@ @tailwind components; @tailwind utilities; +body { + font-family: "Cabin Variable", sans-serif; +} + .unset { inset: unset; } \ No newline at end of file diff --git a/src/web/landing/composer.json b/src/web/landing/composer.json index 4b57b48f0..b12e7669f 100644 --- a/src/web/landing/composer.json +++ b/src/web/landing/composer.json @@ -18,7 +18,8 @@ "symfony/runtime": "^6.4", "symfony/console": "^6.4", "symfony/yaml": "^6.4", - "symfony/dotenv": "^6.4" + "symfony/dotenv": "^6.4", + "symfony/stimulus-bundle": "^2.14" }, "require-dev": { "symfony/web-profiler-bundle": "^6.4", diff --git a/src/web/landing/composer.lock b/src/web/landing/composer.lock index 5abb10b40..3fab2bfab 100644 --- a/src/web/landing/composer.lock +++ b/src/web/landing/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": "7b4a530af5f9e27500c6f385ae3ac6f6", + "content-hash": "f85c35fb43f55d1686c928bb1b0ee927", "packages": [ { "name": "clue/stream-filter", @@ -3513,6 +3513,75 @@ ], "time": "2023-12-26T14:02:43+00:00" }, + { + "name": "symfony/stimulus-bundle", + "version": "v2.14.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/stimulus-bundle.git", + "reference": "a7c30d95ff109f3b9c357d38d9aaf50ee512b8d4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/stimulus-bundle/zipball/a7c30d95ff109f3b9c357d38d9aaf50ee512b8d4", + "reference": "a7c30d95ff109f3b9c357d38d9aaf50ee512b8d4", + "shasum": "" + }, + "require": { + "php": ">=8.1", + "symfony/config": "^5.4|^6.0|^7.0", + "symfony/dependency-injection": "^5.4|^6.0|^7.0", + "symfony/deprecation-contracts": "^2.0|^3.0", + "symfony/finder": "^5.4|^6.0|^7.0", + "symfony/http-kernel": "^5.4|^6.0|^7.0", + "twig/twig": "^2.15.3|^3.4.3" + }, + "require-dev": { + "symfony/asset-mapper": "^6.3|^7.0", + "symfony/framework-bundle": "^5.4|^6.0|^7.0", + "symfony/phpunit-bridge": "^5.4|^6.0|^7.0", + "symfony/twig-bundle": "^5.4|^6.0|^7.0", + "zenstruck/browser": "^1.4" + }, + "type": "symfony-bundle", + "autoload": { + "psr-4": { + "Symfony\\UX\\StimulusBundle\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Integration with your Symfony app & Stimulus!", + "keywords": [ + "symfony-ux" + ], + "support": { + "source": "https://github.com/symfony/stimulus-bundle/tree/v2.14.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": "2024-01-30T15:40:36+00:00" + }, { "name": "symfony/string", "version": "v6.4.3", diff --git a/src/web/landing/config/bundles.php b/src/web/landing/config/bundles.php index 7cbfb27dc..b0d39dad6 100644 --- a/src/web/landing/config/bundles.php +++ b/src/web/landing/config/bundles.php @@ -6,4 +6,5 @@ Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true], Symfonycasts\TailwindBundle\SymfonycastsTailwindBundle::class => ['dev' => true, 'test' => true], NorbertTech\StaticContentGeneratorBundle\StaticContentGeneratorBundle::class => ['dev' => true, 'test' => true], + Symfony\UX\StimulusBundle\StimulusBundle::class => ['all' => true], ]; diff --git a/src/web/landing/importmap.php b/src/web/landing/importmap.php new file mode 100644 index 000000000..d0aeb4525 --- /dev/null +++ b/src/web/landing/importmap.php @@ -0,0 +1,28 @@ + [ + 'path' => 'app.js', + 'entrypoint' => true, + ], + '@symfony/stimulus-bundle' => [ + 'path' => '@symfony/stimulus-bundle/loader.js', + ], + '@hotwired/stimulus' => [ + 'version' => '3.2.1', + ], + 'highlight.js/lib/core' => [ + 'version' => '11.9.0', + ], + 'highlight.js/lib/languages/php' => [ + 'version' => '11.9.0', + ], + 'highlight.js/styles/github-dark.min.css' => [ + 'version' => '11.9.0', + 'type' => 'css', + ], + '@fontsource-variable/cabin/index.min.css' => [ + 'version' => '5.0.17', + 'type' => 'css', + ], +]; diff --git a/src/web/landing/templates/base.html.twig b/src/web/landing/templates/base.html.twig index 3d7d5a061..cf0285b4a 100644 --- a/src/web/landing/templates/base.html.twig +++ b/src/web/landing/templates/base.html.twig @@ -1,3 +1,4 @@ + @@ -9,18 +10,15 @@ - - - {% block stylesheets %} {% endblock %} {% block javascripts %} - {{ importmap([]) }} + {{ importmap() }} {% endblock %} - +
@@ -97,7 +101,7 @@