question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Move icons in footer to CSS background images

See original GitHub issue
* The `ui/organisms/footer/index.tsx` is probably so big because it loads in all the SVGs. But why aren't

@schalkneethling Would it be feasible to move the SVG from the JS code into external images? I know it becomes hard to control styling then but it would be a win since, as images, they’re technically lazy loaded and the footer is way below the fold.

_Originally posted by @peterbe in https://github.com/mdn/yari/issues/2877#issuecomment-777788131_

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:15 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
sohamsshahcommented, Apr 19, 2021

Thank you! Yes, Will ask if I any questions, Tho Consider it done 😉

1reaction
schalkneethlingcommented, Apr 19, 2021

@sohamsshah Ok, here we go 😄

The file to make the first couple changes will be: client/src/ui/organisms/footer/index.tsx

I would recommend changing the links from:

<a
  href="https://twitter.com/mozilla"
  target="_blank"
  rel="noopener noreferrer"
  aria-label="Twitter"
>
  <TwitterIcon />
</a>

to:

<a
  href="https://twitter.com/mozilla"
  target="_blank"
  rel="noopener noreferrer"
>
  <span className="visuall-hidden">Mozilla on Twitter</span>
</a>

We are adding those span elements for accessibility reasons. The icons you are going to need in SASS will be these:

@mdn/dinocons/brands/github-mark-small.svg
@mdn/dinocons/social/twitter.svg
@mdn/dinocons/social/instagram.svg

Now, because we previously added the appropriate icon directly to the HTML we did not need to identify the anchors, but now we do. That means for the anchor elements you want to add the appropriate class, for example:

<a
  className="social-icon twitter"
  href="https://twitter.com/mozilla"
  target="_blank"
  rel="noopener noreferrer"
>
  <span className="visuall-hidden">Mozilla on Twitter</span>
</a>

Then the SASS will be added here: client/src/ui/organisms/footer/index.scss

Between .social and .footer-license you can add the new SASS:

.social-icon::before {
  background-size: 18px;
  content: "";
  display: inline-block;
  /* because the SVG is not in the HTML we cannot set its fill so we have to use this workaround */
  filter: invert(1);
  height: 18px;
  vertical-align: sub;
  width: 18px;
}

.twitter::before {
  background: transparent url("~@mdn/dinocons/social/twitter.svg") 0 0
    no-repeat;
}

.github::before {
  background: transparent url("~@mdn/dinocons/brands/github-mark-small.svg") 0
    0 no-repeat;
}

You can then also delete the following:

svg {
  height: 18px;
  vertical-align: sub;
  width: 18px;

  path {
    fill: #fff;
  }
}

Hope this helps, please let me know should you have any questions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Icons on top of footer background-image
I have a footer done with the background-image in css, made into a link. Used text-indent: -9999px; to get rid of the H1...
Read more >
CSS background-position property
The background-position property sets the starting position of a background image. Tip: By default, a background-image is placed at the top-left corner of ......
Read more >
Changing the footer image - Power Platform Community
Hi, I'm looking to customize the footer on my web pages in my portal ... to contain in the aforementioned CSS and use...
Read more >
How to specify a fixed background-image in CSS
In this article, we are going to see how to specify a fixed background image in CSS. To keep your background fixed, scroll,...
Read more >
Bootstrap 5 Background Image - examples & tutorial
Learn how to create a responsive background image with the newest Bootstrap 5. Many examples and ready-to-use solutions.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found