Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
smnandre committed Aug 12, 2024
1 parent 30a433b commit 4d9f4f7
Show file tree
Hide file tree
Showing 9 changed files with 567 additions and 362 deletions.
6 changes: 6 additions & 0 deletions ux.symfony.com/.env
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,9 @@ DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"
###> symfony/mercure-notifier ###
MERCURE_DSN=mercure://default
###< symfony/mercure-notifier ###

###> symfony/ux-leaflet-map ###
# Options available at https://github.com/symfony/symfony-ux/blob/2.x/src/Map/src/Bridge/Leaflet/README.md
#
UX_MAP_DSN=leaflet://default
###< symfony/ux-leaflet-map ###
2 changes: 2 additions & 0 deletions ux.symfony.com/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@
"symfony/ux-dropzone": "2.x-dev",
"symfony/ux-icons": "2.x-dev",
"symfony/ux-lazy-image": "2.x-dev",
"symfony/ux-leaflet-map": "2.x-dev",
"symfony/ux-live-component": "2.x-dev",
"symfony/ux-map": "2.x-dev",
"symfony/ux-notify": "2.x-dev",
"symfony/ux-react": "2.x-dev",
"symfony/ux-svelte": "2.x-dev",
Expand Down
832 changes: 493 additions & 339 deletions ux.symfony.com/composer.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions ux.symfony.com/config/packages/ux_map.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
ux_map:
# The directory where the JavaScript translations are dumped
renderer: '%env(UX_MAP_DSN)%'
# https://symfony.com/bundles/ux-map/current/index.html#available-renderers
renderer: '%env(resolve:default::UX_MAP_DSN)%'
27 changes: 17 additions & 10 deletions ux.symfony.com/importmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@
'@symfony/ux-live-component' => [
'path' => './vendor/symfony/ux-live-component/assets/dist/live_controller.js',
],
'@symfony/ux-map/abstract-map-controller' => [
'path' => './vendor/symfony/ux-map/assets/dist/abstract_map_controller.js',
],
'bootstrap' => [
'version' => '5.3.3',
],
Expand All @@ -78,14 +81,14 @@
'version' => '18.3.1',
],
'vue' => [
'version' => '3.4.31',
'version' => '3.4.37',
'package_specifier' => 'vue/dist/vue.esm-bundler.js',
],
'swup' => [
'version' => '3.1.1',
],
'delegate-it' => [
'version' => '6.1.0',
'version' => '6.0.1',
],
'@swup/debug-plugin' => [
'version' => '3.0.0',
Expand All @@ -103,7 +106,7 @@
'version' => '2.0.3',
],
'@hotwired/turbo' => [
'version' => '8.0.4',
'version' => '8.0.5',
],
'typed.js' => [
'version' => '2.1.0',
Expand All @@ -127,22 +130,22 @@
'version' => '10.5.14',
],
'@vue/runtime-dom' => [
'version' => '3.4.31',
'version' => '3.4.37',
],
'@vue/runtime-core' => [
'version' => '3.4.31',
'version' => '3.4.37',
],
'@vue/shared' => [
'version' => '3.4.31',
'version' => '3.4.37',
],
'@vue/reactivity' => [
'version' => '3.4.31',
'version' => '3.4.37',
],
'@vue/compiler-dom' => [
'version' => '3.4.31',
'version' => '3.4.37',
],
'@vue/compiler-core' => [
'version' => '3.4.31',
'version' => '3.4.37',
],
'tslib' => [
'version' => '2.6.3',
Expand Down Expand Up @@ -179,7 +182,7 @@
'type' => 'css',
],
'path-to-regexp' => [
'version' => '6.2.1',
'version' => '7.1.0',
],
'@swup/theme' => [
'version' => '2.1.0',
Expand All @@ -190,4 +193,8 @@
'chart.js' => [
'version' => '4.4.3',
],
'bootstrap/dist/css/bootstrap.min.css' => [
'version' => '5.3.3',
'type' => 'css',
],
];
25 changes: 24 additions & 1 deletion ux.symfony.com/src/Controller/UxPackage/MapController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,43 @@

use App\Service\UxPackageRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\DependencyInjection\Attribute\Autowire;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\UX\Chartjs\Builder\ChartBuilderInterface;
use Symfony\UX\Chartjs\Model\Chart;
use Symfony\UX\Map\Bridge\Leaflet\LeafletOptions;
use Symfony\UX\Map\Bridge\Leaflet\Option\TileLayer;
use Symfony\UX\Map\Map;
use Symfony\UX\Map\Marker;
use Symfony\UX\Map\Point;

class MapController extends AbstractController
{
#[Route('/map', name: 'app_map')]
public function __invoke(UxPackageRepository $packageRepository): Response
public function __invoke(UxPackageRepository $packageRepository,
): Response
{
$package = $packageRepository->find('map');

$map = (new Map())
->center(new Point(48.8566, 2.3522))
->zoom(6);

$map->options((new LeafletOptions())
->tileLayer(new TileLayer(
url: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>',
options: [
'minZoom' => 5,
'maxZoom' => 10,
]
))
);

return $this->render('ux_packages/map.html.twig', [
'package' => $package,
'map' => $map,
]);
}
}
21 changes: 21 additions & 0 deletions ux.symfony.com/symfony.lock
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,15 @@
"symfony/ux-lazy-image": {
"version": "v2.1.1"
},
"symfony/ux-leaflet-map": {
"version": "2.19",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "2.19",
"ref": "e696e4124071004125072f3b582a2b7e43ad58c1"
}
},
"symfony/ux-live-component": {
"version": "2.9999999",
"recipe": {
Expand All @@ -575,6 +584,18 @@
"config/routes/ux_live_component.yaml"
]
},
"symfony/ux-map": {
"version": "2.19",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "2.19",
"ref": "04de870967555f00bd82f542e9e2d29683c3d39e"
},
"files": [
"config/packages/ux_map.yaml"
]
},
"symfony/ux-notify": {
"version": "2.x-dev"
},
Expand Down
8 changes: 0 additions & 8 deletions ux.symfony.com/templates/base.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,6 @@
document.documentElement.setAttribute('data-bs-theme', theme === 'light' ? 'light' : 'dark');
</script>
{% block importmap %}
<script>
if (!(HTMLScriptElement && HTMLScriptElement.supports?.('importmap'))) {
document.head.appendChild(Object.assign(document.createElement("script"),{
src:"https://cdn.jsdelivr.net/npm/[email protected]/dist/es-module-shims.min.js",
async:true,
}));
}
</script>
{{ importmap('app') }}
{% endblock %}
{% endblock %}
Expand Down
4 changes: 2 additions & 2 deletions ux.symfony.com/templates/ux_packages/map.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
eyebrowText: 'React Component Rendering'
} %}
{% block title_header %}
Build Interactive Maps <em>from PHP</em>
Interactive Maps <em>from PHP</em>
{% endblock %}

{% block sub_content %}
Expand All @@ -30,6 +30,6 @@

{% block demo_content %}
<div>
{{ render_map(map) }}
{{ render_map(map,{ style: 'height: 300px' }) }}
</div>
{% endblock %}

0 comments on commit 4d9f4f7

Please sign in to comment.