fix(docs-infra): do not underline link icons on hover (#41051)

The external links in the docs content and the download links in the
"Press kit" page have icons next to their text (an external link icon
and a download icon respectively).

Previously, when hovering over one of those links, the icons used to get
underlined along with the link text, which was not desirable.

This commit fixes it by changing the mechanics of how these icons are
positioned inside the anchor elements so that only the link text is
underlined on hover.

Before: ![external links on hover before][1]
Before: ![presskit links on hover before][2]
After: ![external links on hover after][3]
After: ![presskit links on hover after][4]

[1]: https://user-images.githubusercontent.com/8604205/109340455-b64bf180-7871-11eb-923b-3113a237b8d8.png
[2]: https://user-images.githubusercontent.com/8604205/109340461-b815b500-7871-11eb-9c9d-91b6ffb17346.png
[3]: https://user-images.githubusercontent.com/8604205/109340458-b77d1e80-7871-11eb-884c-c1093ec83e66.png
[4]: https://user-images.githubusercontent.com/8604205/109340462-b815b500-7871-11eb-8f00-702b2b61f6ac.png

PR Close #41051
This commit is contained in:
George Kalpakas 2021-03-09 14:15:14 +02:00 committed by Andrew Kushnir
parent fa3689f432
commit 7944ee2c30
2 changed files with 25 additions and 24 deletions

View File

@ -204,25 +204,24 @@ code {
// We add the icon to all external links which are identified as absolute links (those that start with `http:` or https:`).
// For more info see PR #36601.
@include docs-pages {
aio-doc-viewer{
a {
&[href^="http:"]::after,
&[href^="https:"]::after {
font-family: "Material Icons";
content: "open_in_new";
margin-left: 2px;
position: relative;
@include line-height(24);
vertical-align: middle;
}
}
aio-doc-viewer {
// The docs-viewer also contain links to GitHub (e.g. the "edit this page" icon) identified with
// the `.github-links` class. We don't want to add the external link icon to these links.
:not(.github-links) {
> a {
&[href^="http:"],
&[href^="https:"] {
display: inline-flex;
padding-right: calc(1em + 0.25rem);
position: relative;
// The docs-viewer also contain links to GitHub (e.g. the edit this page icon) identified with `.github-links` class.
// We don't want to add the external link icon to these links, so we hide them.
.github-links a {
&[href^="http:"]::after,
&[href^="https:"]::after {
display: none;
&::after {
content: "open_in_new";
font-family: "Material Icons";
position: absolute;
right: 0;
}
}
}
}
}

View File

@ -50,14 +50,16 @@
padding: 0;
a {
display: flex;
align-items: center;
display: inline-flex;
padding-right: 3rem;
position: relative;
&:after {
font-family: 'Material Icons';
content: 'cloud_download';
&::after {
content: "cloud_download";
font-family: "Material Icons";
@include font-size(24);
margin-left: 0.5rem;
position: absolute;
right: 0;
}
}
}