-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Overview and single page of icons library
- Loading branch information
Showing
8 changed files
with
148 additions
and
50 deletions.
There are no files selected for viewing
70 changes: 70 additions & 0 deletions
70
modules/ui_icons_library/src/Controller/IconsetsController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
|
||
|
||
namespace Drupal\ui_icons_library\Controller; | ||
|
||
use Drupal\Core\Controller\ControllerBase; | ||
use Drupal\Core\Url; | ||
|
||
/** | ||
* Class IconDisplayController. | ||
*/ | ||
class IconsetsController extends ControllerBase | ||
{ | ||
|
||
const OVERVIEW_SLICE = 20; | ||
|
||
/** | ||
* Display icons. | ||
* | ||
* @return array | ||
* Return render array. | ||
*/ | ||
public function overview() | ||
{ | ||
$build = []; | ||
$iconsets = \Drupal::service('strategy.manager.iconset')->getIconsets(); | ||
foreach ($iconsets as $iconset_id => $label) { | ||
$iconset = \Drupal::service('strategy.manager.iconset')->getInstance($iconset_id); | ||
$icons = $iconset->getIcons(); | ||
$icons = array_slice($icons, 0, static::OVERVIEW_SLICE); | ||
$build[] = [ | ||
'#type' => 'html_tag', | ||
'#tag' => 'h2', | ||
'#value' => $label, | ||
]; | ||
foreach ($icons as $icon_id => $icon) { | ||
$build[] = $iconset->build($icon_id); | ||
} | ||
$build[] = [ | ||
'#type' => 'html_tag', | ||
'#tag' => 'p', | ||
0 => [ | ||
'#type' => 'link', | ||
'#title' => $this->t("View more"), | ||
'#url' => Url::fromRoute('ui_icons.single', ["iconset_id" => $iconset_id]), | ||
] | ||
]; | ||
} | ||
return $build; | ||
} | ||
|
||
|
||
/** | ||
* Display icons. | ||
* | ||
* @return array | ||
* Return render array. | ||
*/ | ||
public function single(string $iconset_id) | ||
{ | ||
$build = []; | ||
$iconset = \Drupal::service('strategy.manager.iconset')->getInstance($iconset_id); | ||
$icons = $iconset->getIcons(); | ||
foreach ($icons as $icon_id => $icon) { | ||
$build[] = $iconset->build($icon_id); | ||
} | ||
return $build; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
name: Iconset Library | ||
type: module | ||
description: 'A sous module of UI Icons to display icons library' | ||
core_version_requirement: ^9 || ^10 | ||
package: Custom | ||
dependencies: | ||
- iconset:iconset | ||
- ui_icons:ui_icons |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#ui_suite.index: | ||
# path: '/admin/appearance/ui-libraries' | ||
# defaults: | ||
# _controller: '\Drupal\system\Controller\SystemController::systemAdminMenuBlockPage' | ||
# _title: 'UI libraries' | ||
# requirements: | ||
# _permission: 'access content' | ||
|
||
ui_icons.overview: | ||
path: '/icons' | ||
defaults: | ||
_controller: '\Drupal\ui_icons_library\Controller\IconsetsController::overview' | ||
_title: 'Iconsets library' | ||
requirements: | ||
_permission: 'access content' | ||
|
||
ui_icons.single: | ||
path: '/icons/{iconset_id}' | ||
defaults: | ||
_controller: '\Drupal\ui_icons_library\Controller\IconsetsController::single' | ||
_title: 'Iconset details' | ||
requirements: | ||
_permission: 'access content' | ||
|
This file was deleted.
Oops, something went wrong.
Empty file.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,11 +2,30 @@ bootstrap_icons: | |
label: 'Bootstrap Icons' | ||
plugin: 'svg' | ||
assets: | ||
- '/libraries/bootstrap-icons/house.svg' | ||
- '/libraries/bootstrap-icons/people.svg' | ||
remix_icons: | ||
label: 'Remix Icons' | ||
- '/libraries/bootstrap-icons/icons' | ||
|
||
dsfr_remixicons: | ||
label: 'DSFR Remix Icons' | ||
plugin: 'svg' | ||
assets: | ||
- '/libraries/remixicon/arrow-left-up-line.svg' | ||
- '/libraries/remixicon/mail-line.svg' | ||
- '/libraries/remixicons/icons' | ||
- '/libraries/remixicons/fonts/remixicon.symbol.svg' | ||
- 'https://cdn.jsdelivr.net/npm/[email protected]/fonts/remixicon.symbol.svg' | ||
|
||
tailwind: | ||
label: 'Tailwind' | ||
plugin: 'svg' | ||
assets: | ||
- '/libraries/heroicons/optimized/24/outline' | ||
- '/libraries/heroicons/src/24/solid' | ||
|
||
uswsd: | ||
label: 'US Web Design System' | ||
plugin: 'svg' | ||
assets: | ||
- '/libraries/uswds/packages/usa-icon/src/img/usa-icons-bg' | ||
- '/libraries/uswds/packages/usa-icon/src/img/uswds-icons' | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,24 @@ | ||
ui_icons_display.display: | ||
path: '/admin/config/media/iconset/icon-display' | ||
ui_suite.index: | ||
path: '/admin/appearance/ui-libraries' | ||
defaults: | ||
_controller: '\Drupal\ui_icons\Controller\IconDisplayController::display' | ||
_title: 'Bootstrap Icon Display' | ||
_controller: '\Drupal\system\Controller\SystemController::systemAdminMenuBlockPage' | ||
_title: 'UI libraries' | ||
requirements: | ||
_permission: 'access patterns page+access_ui_styles_library+access_ui_examples_library' | ||
|
||
ui_icons.overview: | ||
path: '/icons' | ||
defaults: | ||
_controller: '\Drupal\ui_icons\Controller\IconsetsController::overview' | ||
_title: 'Iconsets library' | ||
requirements: | ||
_permission: 'access content' | ||
|
||
ui_icons.single: | ||
path: '/icons/{iconset_id}' | ||
defaults: | ||
_controller: '\Drupal\ui_icons\Controller\IconsetsController::single' | ||
_title: 'Iconset details' | ||
requirements: | ||
_permission: 'access content' | ||
|