Olivero: Remove svg from block--system-powered-by-block.html.twig file

The block--system-powered-by-block.html.twig file have raw svg file in code. We should move this file to images folder then include this file.

Why? So that we can use this icon on other places as well. If we have this icon in Images directory, we can use this icon on different places by just including the icon in twig or adding as background-image.

By the current scenario we need to duplicate the icon on different places.

Issue fork drupal-3226047

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

Gauravmahlawat created an issue. See original summary.

gauravvvv’s picture

Status: Active » Needs review
StatusFileSize
new2.92 KB

I have provided a patch. Please review.

kostyashupenko’s picture

StatusFileSize
new3.66 KB
new3.39 KB

Fixed / optimized some things

indrajithkb’s picture

Status: Needs review » Reviewed & tested by the community

Hi @Gauravmahlawat, @kostyashupenko nice catch and work, I have checked the file, now we can see the raw svg is removed from block--system-powered-by-block.html.twig.
Moving to RTBC

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 3: 3226047-3.patch, failed testing. View results

gauravvvv’s picture

Status: Needs work » Reviewed & tested by the community

Random failure.

alexpott’s picture

Category: Support request » Task
Status: Reviewed & tested by the community » Needs review

The issue summary says:

The block--system-powered-by-block.html.twig file have raw svg file in code. We should move this file to images folder then include this file.

Why should we do that? Also as we're including the svg via an @include I'm not sure of the difference.

vikashsoni’s picture

@Gauravmahlawat I have checked the patch after patch svg has been removed
Thanks for the patch

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

Status: Needs review » Postponed (maintainer needs more info)
Issue tags: +Needs Review Queue Initiative, +Needs issue summary update

This issue is being reviewed by the kind folks in Slack, #need-reveiw-queue. We are working to keep the size of Needs Review queue [2700+ issues] to around 200, following Review a patch or merge require as a guide.

As mentioned in #8 what is the "why" if you can update the issue summary with that please.

gauravvvv’s picture

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

Why should we do that? Also as we're including the svg via an @include I'm not sure of the difference.

So that we can use this icon on other places as well. If we have this icon in Images directory, we can use this icon on different places by just including the icon in twig or adding as background-image.

By the current scenario we need to duplicate the icon on different places. Hope this answers.

markconroy’s picture

I'm not fully sure about moving this to an /images or /assets folder.

If we do that, then we can't import it via @import in twig because it will be outside of the templates folder (so not accessible without the use of something like components module).

If we add it via <img src="path/to/images/drupal-logo.svg" /> then you can't do anything with it in CSS such as change path fill colours, etc.

Where it currently is may not be the best solution, but given we are working with only Drupal core and no contrib modules, it might be okay for now.

gauravvvv’s picture

If we do that, then we can't import it via @import in twig because it will be outside of the templates folder

We can use include to add the SVG image. We're already doing it in different places in the Olivero theme. {% include "@olivero/../images/site-under-maintenance-icon.svg" %}

Check Olivero maintenance page template here

markconroy’s picture

Issue summary: View changes

Whaaaaat? I never realised you could use .. to go back up a level and get out of the templates directory for include in Twig. That's opening up a who new set of possibilities. Sorry, that's an aside!

Also, I've updated the issue summary with the reasoning behind this change request.

markconroy’s picture

Status: Needs review » Needs work

@Gauravmahlawat

This patch looks good to me, and the reasoning for using it looks sound. However, the patch is not currently applying for me. Can you check if it it needs a small re-roll please?

╰─ git apply -v ../_patches/3226047-3.patch
Checking patch core/themes/olivero/css/components/powered-by-block.css...
error: while searching for:
.block-system-powered-by-block svg {
    width: 0.875rem; /* 14 */
    height: 1.1875rem; /* 19 */
    vertical-align: top
  }

.block-system-powered-by-block svg path {
      fill: currentColor;
    }

.site-footer .block-system-powered-by-block a {
    color: #fff;
  }

error: patch failed: core/themes/olivero/css/components/powered-by-block.css:41
error: core/themes/olivero/css/components/powered-by-block.css: patch does not apply

I think it's the spaces just before the closing brackets that might be the issue.

gauravvvv’s picture

Status: Needs work » Needs review
StatusFileSize
new3.83 KB

I have re-rolled the patch for 10.1.x, Please review.

markconroy’s picture

Status: Needs review » Reviewed & tested by the community

Thanks @Gauravmahlawat

This looks good to me, and a nice pattern for others to follow. Marking RTBC.

longwave’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/themes/olivero/images/drupal.svg
@@ -0,0 +1,3 @@
+<svg width="14" height="19" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 42.15 55.08" fill="none" aria-label="{{ 'Drupal Logo'|t }}" role="img">

We can't use Twig syntax in the aria-label in an SVG file, if it is to be used as a raw SVG?

gauravvvv’s picture

Status: Needs work » Needs review
StatusFileSize
new1.32 KB
new3.78 KB

Removed TWIG syntax. Please review

longwave’s picture

This means we lose translations of the accessibility label. @markconroy can you think of a way around this? We could name the file .svg.twig, but that reduces reusability. Is there another way?

gauravvvv’s picture

This means we lose translations of the accessibility label. @markconroy can you think of a way around this? We could name the file .svg.twig, but that reduces reusability. Is there another way?

No other SVG image file has aria-label in the Olivero theme. Parent element of this SVG image has aria-label. <span class="drupal-logo" aria-label="Logo Drupal">

markconroy’s picture

I think #22 looks good enough now. As @Gauravmahlawat says, no other SVG in using an aria-label in it in this theme, and we have a wrapper with an aria-label to announce what the SVG is.

I'd propose moving this back to RTBC. @longwave do you have any disagreement?

longwave’s picture

Status: Needs review » Reviewed & tested by the community

OK, as the parent has aria-label I think that should be sufficient for accessibility (and in fact perhaps better, as we don't repeat the label on the span and the svg itself).

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed c1437df and pushed to 10.1.x. Thanks!

The reasoning and the considerations of aria labels are good to have on the issue. Nice work.

  • alexpott committed c1437df0 on 10.1.x
    Issue #3226047 by Gauravvv, IndrajithKB, kostyashupenko, markconroy,...

Status: Fixed » Closed (fixed)

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