-
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.
Create UI Icons module and display bootstrap icons
- Loading branch information
0 parents
commit af5ba75
Showing
5 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
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,39 @@ | ||
<?php | ||
|
||
|
||
namespace Drupal\ui_icons\Controller; | ||
|
||
use Drupal\Core\Controller\ControllerBase; | ||
|
||
/** | ||
* Class IconDisplayController. | ||
*/ | ||
class IconDisplayController extends ControllerBase | ||
{ | ||
|
||
/** | ||
* Display icons. | ||
* | ||
* @return array | ||
* Return render array. | ||
*/ | ||
public function display() | ||
{ | ||
$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(); | ||
$build[] = [ | ||
'#type' => 'html_tag', | ||
'#tag' => 'h2', | ||
'#value' => $label, | ||
]; | ||
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 @@ | ||
<?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,6 @@ | ||
bootstrap_icons: | ||
label: 'Bootstrap Icons' | ||
plugin: 'svg' | ||
assets: | ||
- '/libraries/bootstrap-icons/house.svg' | ||
- '/libraries/bootstrap-icons/people.svg' |
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: 'UI Icons' | ||
type: module | ||
description: 'A custom module to display icons using Iconset' | ||
core_version_requirement: ^9 || ^10 | ||
package: Custom | ||
dependencies: | ||
- iconset:iconset | ||
|
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,7 @@ | ||
ui_icons_display.display: | ||
path: '/admin/config/media/iconset/icon-display' | ||
defaults: | ||
_controller: '\Drupal\ui_icons\Controller\IconDisplayController::display' | ||
_title: 'Bootstrap Icon Display' | ||
requirements: | ||
_permission: 'access content' |