Simple Icons provides a field type, widget, and formatter as well as a Twig function to output one of 789+ brand icons from the Simple Icons project, an open-source collection of brand icons/logos in SVG format.

The icon is output as raw SVG markup so it can be easily styled with CSS, but the markup is sanitized before being output for security (just in case!)

Each icon is monochrome so fits easily into most designs and has been optimised for performance.

Why use it? (Usage)

This module allows your CMS users to use almost any major brand icon that they like, without you having to source, optimize, and upload these logos yourself.

If your client has a list of social media profiles in their footer then you could build it as a Drupal menu, install the Menu Item Extras module, and then add a Simple Icons icon field to the menu. Or use Config Pages and a Paragraph type to do a similar thing (outputting the Config Pages entity as a block, just like a menu).

Then, if a client wanted to add a new social media profile they could do it all themselves, including supplying an icon. No more support tickets to 'Add a link to X in the footer'!

Improvements I know I could make

  • I should be using dependency injection in the TwigExtension
  • I could add automated tests
  • I need to update the TwigExtension to extend from Twig\Extension\AbstractExtension rather than the deprecated method of extending from \Twig_Extension. Once I have done this I will update the requirements to core_version_requirement: ^8.8 || ^9 and tag a new major release (I plan to switch to semver once I have been vetted).

Project link

https://www.drupal.org/project/simple_icons

Git instructions

git clone --branch '8.x-1.x' https://git.drupalcode.org/project/simple_icons.git

PAreview checklist

http://pareview.net/r/89

Comments

Phil Wolstenholme created an issue. See original summary.

Phil Wolstenholme’s picture

Issue summary: View changes
Phil Wolstenholme’s picture

Issue summary: View changes
Phil Wolstenholme’s picture

Issue summary: View changes
avpaderno’s picture

Issue summary: View changes
avpaderno’s picture

Title: [D8/D9] Simple Icons » [D8] Simple Icons
manish34jain’s picture

Hello Phil,

Checked below point.

DrupalPractice: has found some issues with your code, but could be false positives.
FILE: ...areview_temp/smbbtyrd/src/TwigExtension/SimpleIconsTwigExtension.php
--------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------
39 | WARNING | \Drupal calls should be avoided in classes, use
| | dependency injection instead
--------------------------------------------------------------------------

avpaderno’s picture

Status: Needs review » Needs work
Phil Wolstenholme’s picture

Hi manish34jain, thanks for your comment.

I had mentioned that I should be using dependency injection in the TwigExtension in the 'Improvements I know I could make' section of my original application, and it's also included in the PAReview link that I included with my submission.

My understanding is that DI is best practice but I wouldn't consider it vital, as the module does not have any automated tests so the benefits of DI are less obvious in this case. However, I might be wrong!

I can see that kiamlaluno (an active reviewer in this issue queue) has changed the status of the application to 'needs work', so I'll take that as approval of the 'use dependency injection instead' suggestion and I will update the module to use DI when I have some spare time. It's the right thing to do anyway :)

avpaderno’s picture

Since a Twig extension in Drupal is a service, the correct way is defining the service arguments. In Drupal, the class implementing a Twig extension extends the AbstractExtension class too.

avpaderno’s picture

Priority: Normal » Minor
avpaderno’s picture

Status: Needs work » Closed (won't fix)

I am closing this application since there have been replies in the past 5 months.