Problem/Motivation

Currently the SVG iconsʼ markup (see sourcecode) is filled with Adobe's own proprietary-purpose metadata, which is useless for web browsers:
Screenshot

Also, their viewbox has an incorrect size which makes proper CSS alignment difficult:
Screenshot

Steps to reproduce

Inspect the DOM of a page and check the SVG markup.

Proposed resolution

  • Use only dynmically sizing measurements (eg. em) not pixels
  • Set only one dimensions to make the other one automatically calculated when resizing
  • Clean up the CSS, use "currentColor"
  • Remove padding within the SVG

Initially proposed resolution

Use Inkscape to set their viewbox properly and SVGO online converter to cleanup the unnecessary code while maintaining the exactly same visual appearance.

Remaining tasks

User interface changes

More nicely sized icons to display beside the link texts.

Issue fork extlink-3186584

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Balu Ertl created an issue. See original summary.

baluertl’s picture

Issue summary: View changes
StatusFileSize
new54.36 KB
new63.68 KB
baluertl’s picture

Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new3.11 KB
baluertl’s picture

Issue summary: View changes
baluertl’s picture

StatusFileSize
new3.5 KB

Also updating module's CSS to the new sizes.

neslee canil pinto’s picture

Status: Needs review » Needs work

@Balu Ertl I think 8px for the icon looks very small.

baluertl’s picture

@Neslee thanks for your time taking a look on my proposal. Could you please elaborate your suggestion to use instead?

bskibinski’s picture

Just a heads up, I want to add a patch later, i'm reviewing this module in our project as we speak.

We shouldn't use pixels at all, it should be set in EM's, so it dynamically will take the appropriate size.

The viewbox in the latest patch is also incorrect (the icon itself is a perfect square), and we should add the width/height attributes to the SVG itself, that way, you only have to define one dimension and the other attribute can be "auto" (height, .5em; width: auto;)

Also some other improvements, but these could be well out of scope of this ticket:
could be to clean up the CSS a bit more, use "currentColor" instead of a hardcoded fill/stroke color, and set them all on the class "ext" themselves, instead of introducing extra specificity with the `.ext path {stroke}` styles.

Lastly the padding inside the SVG is also strange and should be removed or at least replaced by margin, and should be dependent on the setting that defines if the icon is in front or after the link.

I'm reviewing this module now, and I'll try to get a patch ready as soon as possible, probably tomorrow.

bskibinski’s picture

StatusFileSize
new15.27 KB
new12.54 KB

When trying to fix the SVG viewbox and cleanup, i've noticed a lot of legacy code, and inability to really fix some stylingproblems. This might be a bit out of scope of the ticket, but I think this will improve the theming for everybody, and usability of the module, and bring it into 2020 with modern styling standards (For SVG). And also improve the accessibility.

JS

  • Adjusted the 2 SVG's (mail/link) to have a default size (width/height) and viewport (14px high), This fixes having gigantic icons when CSS fails loading.
  • Replaced `aria-label` with `aria-labelledby` that points to the unique ID of the title of the SVG. This makes it able for (google) translate to also translate those labels.
  • Add mail/link classes for SVG that are now available in the admin form so people can set their own classes. (just like font awesome)
  • Add "placement" classes, so we know if the icon is prepended or appended
  • Add "fill=currentcolor" so the icons gets the same color is the link itself, and not a hardcoded unaccessible gray.

Admin settings

  • NEW: Added a "generic class" setting for both SVG and font-awesome, set to "extlink" and replaced the hardcoded class in font-awesome with the adjustable one.
  • NEW: just like font-awesome, you can now set classes for the SVG icons
  • Improved the Admin form, so you can only see the relevant checkboxes if you are using icons:
    • "icon for image links" only shows if "use icons for external links" is checked
    • "prepend/append" only shows if mail OR link icons are checked
    • "use font-awesome" only shows if mail OR link icons are checked
    • And you can set Classes for SVG or font-awesome, depending on what you have chosen to use.

CSS:
Complete rewrite, because a lot was really old fashioned.

  • Used the generic class to add "placement" classes, so we can prepend/append spacing between the icon, and link text in a proper way.
  • Remove "fill" colors, icons get the same color as the link now.
  • Removed the CSS stroke because of two reasons:
    • Because the viewbox is just as big as the icon, the stroke gets "cut off" because SVG have a default "overflow: hidden" in browsers
    • IMHO, the stroke made the icons really unreadable and not "crisp", if we want a "stroke" we should just replace it with better icons.
  • Removed broken and deprecated/legacy "extlink i" style (it was missing the "dot"), but the <i> element also isn't used anymore for font-awesome
  • Changed the hardcoded pixels height to EM's so the icon scales with the font text.
  • Set width's to "auto" so they are responsive, and you only have to change the height of the icon.
  • Now SVG & font-awesome icons aren't printed.

Created an update hook, to set the newly create classes textfields.

In a nutshell
- Font-awesome should stay the same (no class changes), but the "generic" class isn't hardcoded anymore (extlink).
- SVG has better classes, and more modern styling, with better separation of concerns, and less specificity.
- Improved Admin form expierience.
- Clean SVG's with modern accessibility standards, that don't "blow up" when CSS fails.

Here's an example how the SVG icons look without any custom styling, just the module itself:

bskibinski’s picture

Status: Needs work » Needs review

Changed to need review

Status: Needs review » Needs work

The last submitted patch, 9: 3186584-cleanup-svg-icon-markup-9.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

bskibinski’s picture

Status: Needs work » Needs review
StatusFileSize
new8.07 KB
new15.4 KB

IE support:
Almost identical patch as #9, except i've added an @support rule so the "width: auto" is ignored by IE11.
This prevents IE11 breaking the images (they become full width with "auto") if people want different sizes, they will have to add width & heights. But it looks good in IE11 now too out of the box:

Status: Needs review » Needs work

The last submitted patch, 12: 3186584-cleanup-svg-icon-markup-11.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

bskibinski’s picture

Status: Needs work » Needs review
StatusFileSize
new14.85 KB
new15.01 KB

I removed some "conditional" code in the admin form because I think the tests fail on it. And updated the schema's/install's to match. And fixed a typo, should work now.

This patch is made for the latest DEV branch.
https://www.drupal.org/files/issues/2021-02-12/3186584-cleanup-svg-icon-...

I've also made the patch to apply to the 8.x.1.5 branch, so you can use/test it straight away
https://www.drupal.org/files/issues/2021-02-12/3186584-cleanup-svg-icon-...

The last submitted patch, 14: 3186584-cleanup-svg-icon-markup-14.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

neslee canil pinto’s picture

Status: Needs review » Needs work

@bskibinski I think tests are failing and patch in #14 is not able to apply, so i will be moving this back to needs work.

ralphvdhoudt made their first commit to this issue’s fork.

ralphvdhoudt’s picture

Re-applied patch because it didn't apply against 1.6

ralphvdhoudt’s picture

ralphvdhoudt’s picture

StatusFileSize
new15.15 KB

Forgot some code

sander.bras’s picture

Status: Needs work » Needs review
StatusFileSize
new14.96 KB

Because of a recent accessibility audit, we had to change the way the text "this link/mail is external" is set.
aria-labelledby on the svg tag is not supported by all screenreaders.
We went for the most reliable way, of just including a 'visually-hidden' next to the icon, that is supported by all screenreaders.
The SVG icon still has it's own title, so visual users can hover over the icon, and get a popup with the text.
But we've also added aria-hidden=true to the SVG itself, so that screenreaders won't pronounce the text twice.
We do see further improvements to accessibility for the placement of the text (it should always be after the link, despite of the position settings), but that is out of scope for this ticket, and we'll make a new one for that.

kopeboy’s picture

Very good, thank you!

The patch was not applying to latest dev version, so this is the new one.

kopeboy’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new17.42 KB

Actually there was an error at extlink.install: the update was re-declared but I think it should replace the previous extlink_update_8103

I'm noob but after this my updb worked.

I consider this reviewed as I only re-applied @sander.bras work from #23 and tested that it worked.

kopeboy’s picture

StatusFileSize
new17.09 KB
anybody’s picture

Status: Reviewed & tested by the community » Needs work

@kopeboy thank you, but please provide it as MR.

immaculatexavier made their first commit to this issue’s fork.

immaculatexavier changed the visibility of the branch 3186584- to hidden.

smustgrave’s picture

Version: 8.x-1.x-dev » 2.0.x-dev
Issue tags: +Needs issue summary update

This will need an issue summary update as not super clear what's being proposed. Seems to be adding new settings.

smustgrave’s picture

Status: Needs work » Postponed (maintainer needs more info)

smustgrave’s picture

Can the IS be updated, else going to close this one out.

baluertl’s picture

Status: Postponed (maintainer needs more info) » Active

It would be a pity to lose the results of such many people's efforts so I rather put my other tasks aside to jump in here.

Unfortunately, the default 1.x branch of the issue repository got spoiled in comments #21 or #22 which caused extra work to upgrade the repo. Now the issue branch is up-to-date with 8.x-1.x. As the latest patch from #26 did not apply automatically, I had to manually copy over all its changes. Perhaps I made some mistakes as it doesn't seem to work for me for some reason:

Only local images are allowed.

I would kindly request the original patch author @bskibinski to take a look and provide us directions what needs to be set on a site to have the icons appear beside the links.

baluertl’s picture

Some further comments:

  1. Although I had to set @kopeboy as the commit author because actually he was who uploaded the patch file I applied, but I think everyone agrees that all credits should go to @bskibinski who actually took the development time to improve the module. Dear module maintainers, please make sure that he will receive his well-earned credits when the ticket gets Fixed finally.
  2. The MR targets the then-default 8.x-1.x branch intentionally because that was closer to these old patches uploaded here (thus lower chance of conflicts). Once a working solution gets accepted, then we will need to port that to the current default 2.x branch too.
  3. Issue summary has been update also based on the code changes suggested, relevant issue tag removed.
  4. Also hiding all the patches as we use merge requests on GitLab from now on.
baluertl’s picture

Issue summary: View changes
smustgrave’s picture

Current solution should land in 2.0.x first as there have been a ton of changes there. Will be very different

And the user bskibinski is already checked at the bottom

edurenye made their first commit to this issue’s fork.

edurenye’s picture

I created a PR for 2.0.x, but it still needs some work on the SVGs, I think.

edurenye’s picture

StatusFileSize
new18.72 KB

Here is the PR as a patch.

smustgrave’s picture

Category: Bug report » Feature request
Issue tags: +Needs issue summary update

Seems more like a feature request looking at the patch. Am tagging for issue summary as the proposed solution doesn't match.

  • smustgrave committed 43b531d0 on 2.0.x
    Issue #3186584 by baluertl, bskibinski, ralphvdhoudt, edurenye, kopeboy...
smustgrave’s picture

So I removed the adobe stuff per the title.

Not sure why the additional stuff was needed so will leave the ticket open but think it can be closed.

smustgrave’s picture

Status: Needs work » Postponed (maintainer needs more info)
smustgrave’s picture

Status: Postponed (maintainer needs more info) » Closed (outdated)
smustgrave’s picture

Status: Closed (outdated) » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.