Skip to content

Commit fd873c7

Browse files
committed
[Icons] add component
1 parent 2dcfc13 commit fd873c7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+2162
-0
lines changed

src/Icons/.gitattributes

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/.gitattributes export-ignore
2+
/.gitignore export-ignore
3+
/.symfony.bundle.yaml export-ignore
4+
/phpunit.xml.dist export-ignore
5+
/tests export-ignore

src/Icons/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/vendor
2+
/composer.lock
3+
/var
4+
/.phpunit.result.cache

src/Icons/.symfony.bundle.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
branches: ["2.x"]
2+
maintained_branches: ["2.x"]
3+
doc_dir: "doc"

src/Icons/LICENSE

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2024-present Fabien Potencier
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is furnished
8+
to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.

src/Icons/README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# UX Icons
2+
3+
Renders local and remote SVG icons in your Twig templates.
4+
5+
```twig
6+
{{ ux_icon('mdi:symfony', {class: 'w-4 h-4'}) }}
7+
{# or #}
8+
<twig:UX:Icon name="mdi:check" class="w-4 h-4" />
9+
10+
{# renders as: #}
11+
<svg viewBox="0 0 24 24" fill="currentColor" class="w-4 h-4"><path fill="currentColor" d="M21 7L9 19l-5.5-5.5l1.41-1.41L9 16.17L19.59 5.59z"/></svg>
12+
```
13+
14+
Want a demo? Check out https://ux.symfony.com/ux-icons.
15+
16+
**This repository is a READ-ONLY sub-tree split**. See
17+
https://github.com/symfony/ux to create issues or submit pull requests.
18+
19+
## Sponsor
20+
21+
The Symfony UX packages are [backed][1] by [Mercure.rocks][2].
22+
23+
Create real-time experiences in minutes! Mercure.rocks provides a realtime API service
24+
that is tightly integrated with Symfony: create UIs that update in live with UX Turbo,
25+
send notifications with the Notifier component, expose async APIs with API Platform and
26+
create low level stuffs with the Mercure component. We maintain and scale the complex
27+
infrastructure for you!
28+
29+
Help Symfony by [sponsoring][3] its development!
30+
31+
## Resources
32+
33+
- [Documentation](https://symfony.com/bundles/ux-icons/current/index.html)
34+
- [Report issues](https://github.com/symfony/ux/issues) and
35+
[send Pull Requests](https://github.com/symfony/ux/pulls)
36+
in the [main Symfony UX repository](https://github.com/symfony/ux)
37+
38+
[1]: https://symfony.com/backers
39+
[2]: https://mercure.rocks
40+
[3]: https://symfony.com/sponsor

src/Icons/composer.json

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{
2+
"name": "symfony/ux-icons",
3+
"type": "symfony-bundle",
4+
"description": "Renders local and remote SVG icons in your Twig templates.",
5+
"keywords": [
6+
"symfony-ux",
7+
"twig",
8+
"icons",
9+
"svg"
10+
],
11+
"homepage": "https://symfony.com",
12+
"license": "MIT",
13+
"authors": [
14+
{
15+
"name": "Symfony Community",
16+
"homepage": "https://symfony.com/contributors"
17+
}
18+
],
19+
"autoload": {
20+
"psr-4": {
21+
"Symfony\\UX\\Icons\\": "src/"
22+
}
23+
},
24+
"autoload-dev": {
25+
"psr-4": {
26+
"Symfony\\UX\\Icons\\Tests\\": "tests/"
27+
}
28+
},
29+
"require": {
30+
"php": ">=8.1",
31+
"symfony/framework-bundle": "^6.4|^7.0",
32+
"symfony/twig-bundle": "^6.4|^7.0"
33+
},
34+
"require-dev": {
35+
"symfony/asset-mapper": "^6.4|^7.0",
36+
"symfony/console": "^6.4|^7.0",
37+
"symfony/http-client": "6.4|^7.0",
38+
"symfony/phpunit-bridge": "^6.3|^7.0",
39+
"symfony/ux-twig-component": "^2.14",
40+
"zenstruck/console-test": "^1.5"
41+
},
42+
"config": {
43+
"sort-packages": true
44+
},
45+
"conflict": {
46+
"symfony/flex": "<1.13"
47+
},
48+
"extra": {
49+
"thanks": {
50+
"name": "symfony/ux",
51+
"url": "https://github.com/symfony/ux"
52+
}
53+
},
54+
"minimum-stability": "dev"
55+
}

src/Icons/config/asset_mapper.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
13+
14+
use Symfony\Component\AssetMapper\Event\PreAssetsCompileEvent;
15+
use Symfony\UX\Icons\EventListener\WarmIconCacheOnAssetCompileListener;
16+
17+
return static function (ContainerConfigurator $container): void {
18+
$container->services()
19+
->set('.ux_icons.event_listener.warm_icon_cache_on_asset_compile', WarmIconCacheOnAssetCompileListener::class)
20+
->args([
21+
service('.ux_icons.cache_warmer'),
22+
])
23+
->tag('kernel.event_listener', [
24+
'event' => PreAssetsCompileEvent::class,
25+
'method' => '__invoke',
26+
])
27+
;
28+
};

src/Icons/config/iconify.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
13+
14+
use Symfony\UX\Icons\Command\ImportIconCommand;
15+
use Symfony\UX\Icons\Iconify;
16+
use Symfony\UX\Icons\Registry\IconifyOnDemandRegistry;
17+
18+
return static function (ContainerConfigurator $container): void {
19+
$container->services()
20+
->set('.ux_icons.iconify_on_demand_registry', IconifyOnDemandRegistry::class)
21+
->args([
22+
service('.ux_icons.iconify'),
23+
])
24+
->tag('ux_icons.registry')
25+
26+
->set('.ux_icons.iconify', Iconify::class)
27+
->args([
28+
abstract_arg('endpoint'),
29+
service('http_client')->nullOnInvalid(),
30+
])
31+
32+
->set('.ux_icons.command.import', ImportIconCommand::class)
33+
->args([
34+
service('.ux_icons.iconify'),
35+
service('.ux_icons.local_svg_icon_registry'),
36+
])
37+
->tag('console.command')
38+
;
39+
};

src/Icons/config/services.php

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
13+
14+
use Symfony\UX\Icons\Command\WarmCacheCommand;
15+
use Symfony\UX\Icons\IconCacheWarmer;
16+
use Symfony\UX\Icons\IconRenderer;
17+
use Symfony\UX\Icons\Registry\CacheIconRegistry;
18+
use Symfony\UX\Icons\Registry\ChainIconRegistry;
19+
use Symfony\UX\Icons\Registry\LocalSvgIconRegistry;
20+
use Symfony\UX\Icons\Twig\IconFinder;
21+
use Symfony\UX\Icons\Twig\UXIconExtension;
22+
23+
return static function (ContainerConfigurator $container): void {
24+
$container->services()
25+
->set('.ux_icons.cache_icon_registry', CacheIconRegistry::class)
26+
->args([
27+
service('.ux_icons.chain_registry'),
28+
service('cache.system'),
29+
])
30+
31+
->set('.ux_icons.local_svg_icon_registry', LocalSvgIconRegistry::class)
32+
->args([
33+
abstract_arg('icon_dir'),
34+
])
35+
->tag('ux_icons.registry', ['priority' => 10])
36+
37+
->set('.ux_icons.chain_registry', ChainIconRegistry::class)
38+
->args([
39+
tagged_iterator('ux_icons.registry'),
40+
])
41+
42+
->alias('.ux_icons.icon_registry', '.ux_icons.cache_icon_registry')
43+
44+
->set('.ux_icons.twig_icon_extension', UXIconExtension::class)
45+
->tag('twig.extension')
46+
47+
->set('.ux_icons.icon_renderer', IconRenderer::class)
48+
->args([
49+
service('.ux_icons.icon_registry'),
50+
])
51+
->tag('twig.runtime')
52+
53+
->set('.ux_icons.twig_icon_finder', IconFinder::class)
54+
->args([
55+
service('twig'),
56+
])
57+
58+
->set('.ux_icons.cache_warmer', IconCacheWarmer::class)
59+
->args([
60+
service('.ux_icons.cache_icon_registry'),
61+
service('.ux_icons.twig_icon_finder'),
62+
])
63+
64+
->set('.ux_icons.command.warm_cache', WarmCacheCommand::class)
65+
->args([
66+
service('.ux_icons.cache_warmer'),
67+
])
68+
->tag('console.command')
69+
;
70+
};

src/Icons/config/twig_component.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
13+
14+
use Symfony\UX\Icons\Twig\UXIconComponent;
15+
use Symfony\UX\Icons\Twig\UXIconComponentListener;
16+
17+
return static function (ContainerConfigurator $container): void {
18+
$container->services()
19+
->set('.ux_icons.twig_component_listener', UXIconComponentListener::class)
20+
->args([
21+
service('.ux_icons.icon_renderer'),
22+
])
23+
->tag('kernel.event_listener', [
24+
'event' => 'Symfony\UX\TwigComponent\Event\PreCreateForRenderEvent',
25+
'method' => 'onPreCreateForRender',
26+
])
27+
28+
->set('.ux_icons.twig_component.icon', UXIconComponent::class)
29+
->tag('twig.component', ['key' => 'UX:Icon'])
30+
;
31+
};

0 commit comments

Comments
 (0)