Skip to content

Commit

Permalink
Use brighness for links, opacity for monochrome icons.
Browse files Browse the repository at this point in the history
  • Loading branch information
isoos committed Feb 5, 2025
1 parent f66a38b commit f894ed2
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ d.Node versionRowNode(
rel: 'nofollow',
title: 'Download $package ${version.version} archive',
child: d.img(
classes: ['version-table-icon', 'filter-invert-on-dark'],
classes: ['pub-monochrome-icon', 'filter-invert-on-dark'],
image: d.Image(
src: staticUrls.downloadIcon,
alt: 'Download $package ${version.version} archive',
Expand Down Expand Up @@ -91,7 +91,7 @@ d.Node _documentationCell(
rel: 'nofollow',
title: 'Go to the documentation of $package ${version.version}',
child: d.img(
classes: ['version-table-icon', 'filter-invert-on-dark'],
classes: ['pub-monochrome-icon', 'filter-invert-on-dark'],
image: d.Image(
src: staticUrls.documentationIcon,
alt: 'Go to the documentation of $package ${version.version}',
Expand All @@ -106,7 +106,7 @@ d.Node _documentationCell(
rel: 'nofollow',
title: 'Check the analysis logs for $package ${version.version}',
child: d.img(
classes: ['version-table-icon', 'filter-invert-on-dark'],
classes: ['pub-monochrome-icon', 'filter-invert-on-dark'],
image: d.Image(
src: staticUrls.documentationFailedIcon,
alt: 'Check the analysis logs for $package ${version.version}',
Expand Down
12 changes: 6 additions & 6 deletions app/test/frontend/golden/pkg_versions_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -249,12 +249,12 @@ <h2 id="stable">Stable versions of oxygen</h2>
</td>
<td class="documentation">
<a href="/documentation/oxygen/1.2.0/" rel="nofollow" title="Go to the documentation of oxygen 1.2.0">
<img class="version-table-icon filter-invert-on-dark" src="/static/hash-%%etag%%/img/description-24px.svg" alt="Go to the documentation of oxygen 1.2.0" width="24" height="24"/>
<img class="pub-monochrome-icon filter-invert-on-dark" src="/static/hash-%%etag%%/img/description-24px.svg" alt="Go to the documentation of oxygen 1.2.0" width="24" height="24"/>
</a>
</td>
<td class="archive">
<a href="/api/archives/oxygen-1.2.0.tar.gz" rel="nofollow" title="Download oxygen 1.2.0 archive">
<img class="version-table-icon filter-invert-on-dark" src="/static/hash-%%etag%%/img/vertical_align_bottom-24px.svg" alt="Download oxygen 1.2.0 archive" width="24" height="24"/>
<img class="pub-monochrome-icon filter-invert-on-dark" src="/static/hash-%%etag%%/img/vertical_align_bottom-24px.svg" alt="Download oxygen 1.2.0 archive" width="24" height="24"/>
</a>
</td>
</tr>
Expand All @@ -271,12 +271,12 @@ <h2 id="stable">Stable versions of oxygen</h2>
</td>
<td class="documentation">
<a href="/documentation/oxygen/1.0.0/" rel="nofollow" title="Go to the documentation of oxygen 1.0.0">
<img class="version-table-icon filter-invert-on-dark" src="/static/hash-%%etag%%/img/description-24px.svg" alt="Go to the documentation of oxygen 1.0.0" width="24" height="24"/>
<img class="pub-monochrome-icon filter-invert-on-dark" src="/static/hash-%%etag%%/img/description-24px.svg" alt="Go to the documentation of oxygen 1.0.0" width="24" height="24"/>
</a>
</td>
<td class="archive">
<a href="/api/archives/oxygen-1.0.0.tar.gz" rel="nofollow" title="Download oxygen 1.0.0 archive">
<img class="version-table-icon filter-invert-on-dark" src="/static/hash-%%etag%%/img/vertical_align_bottom-24px.svg" alt="Download oxygen 1.0.0 archive" width="24" height="24"/>
<img class="pub-monochrome-icon filter-invert-on-dark" src="/static/hash-%%etag%%/img/vertical_align_bottom-24px.svg" alt="Download oxygen 1.0.0 archive" width="24" height="24"/>
</a>
</td>
</tr>
Expand Down Expand Up @@ -316,12 +316,12 @@ <h2 id="prerelease">Prerelease versions of oxygen</h2>
</td>
<td class="documentation">
<a href="/documentation/oxygen/2.0.0-dev/" rel="nofollow" title="Go to the documentation of oxygen 2.0.0-dev">
<img class="version-table-icon filter-invert-on-dark" src="/static/hash-%%etag%%/img/description-24px.svg" alt="Go to the documentation of oxygen 2.0.0-dev" width="24" height="24"/>
<img class="pub-monochrome-icon filter-invert-on-dark" src="/static/hash-%%etag%%/img/description-24px.svg" alt="Go to the documentation of oxygen 2.0.0-dev" width="24" height="24"/>
</a>
</td>
<td class="archive">
<a href="/api/archives/oxygen-2.0.0-dev.tar.gz" rel="nofollow" title="Download oxygen 2.0.0-dev archive">
<img class="version-table-icon filter-invert-on-dark" src="/static/hash-%%etag%%/img/vertical_align_bottom-24px.svg" alt="Download oxygen 2.0.0-dev archive" width="24" height="24"/>
<img class="pub-monochrome-icon filter-invert-on-dark" src="/static/hash-%%etag%%/img/vertical_align_bottom-24px.svg" alt="Download oxygen 2.0.0-dev archive" width="24" height="24"/>
</a>
</td>
</tr>
Expand Down
8 changes: 4 additions & 4 deletions app/test/task/testdata/goldens/packages/oxygen/versions.html
Original file line number Diff line number Diff line change
Expand Up @@ -235,12 +235,12 @@ <h2 id="stable">Stable versions of oxygen</h2>
</td>
<td class="documentation">
<a href="/documentation/oxygen/2.0.0/" rel="nofollow" title="Go to the documentation of oxygen 2.0.0">
<img class="version-table-icon filter-invert-on-dark" src="/static/hash-%%etag%%/img/description-24px.svg" alt="Go to the documentation of oxygen 2.0.0" width="24" height="24"/>
<img class="pub-monochrome-icon filter-invert-on-dark" src="/static/hash-%%etag%%/img/description-24px.svg" alt="Go to the documentation of oxygen 2.0.0" width="24" height="24"/>
</a>
</td>
<td class="archive">
<a href="/api/archives/oxygen-2.0.0.tar.gz" rel="nofollow" title="Download oxygen 2.0.0 archive">
<img class="version-table-icon filter-invert-on-dark" src="/static/hash-%%etag%%/img/vertical_align_bottom-24px.svg" alt="Download oxygen 2.0.0 archive" width="24" height="24"/>
<img class="pub-monochrome-icon filter-invert-on-dark" src="/static/hash-%%etag%%/img/vertical_align_bottom-24px.svg" alt="Download oxygen 2.0.0 archive" width="24" height="24"/>
</a>
</td>
</tr>
Expand All @@ -257,12 +257,12 @@ <h2 id="stable">Stable versions of oxygen</h2>
</td>
<td class="documentation">
<a href="/documentation/oxygen/1.0.0/" rel="nofollow" title="Go to the documentation of oxygen 1.0.0">
<img class="version-table-icon filter-invert-on-dark" src="/static/hash-%%etag%%/img/description-24px.svg" alt="Go to the documentation of oxygen 1.0.0" width="24" height="24"/>
<img class="pub-monochrome-icon filter-invert-on-dark" src="/static/hash-%%etag%%/img/description-24px.svg" alt="Go to the documentation of oxygen 1.0.0" width="24" height="24"/>
</a>
</td>
<td class="archive">
<a href="/api/archives/oxygen-1.0.0.tar.gz" rel="nofollow" title="Download oxygen 1.0.0 archive">
<img class="version-table-icon filter-invert-on-dark" src="/static/hash-%%etag%%/img/vertical_align_bottom-24px.svg" alt="Download oxygen 1.0.0 archive" width="24" height="24"/>
<img class="pub-monochrome-icon filter-invert-on-dark" src="/static/hash-%%etag%%/img/vertical_align_bottom-24px.svg" alt="Download oxygen 1.0.0 archive" width="24" height="24"/>
</a>
</td>
</tr>
Expand Down
20 changes: 17 additions & 3 deletions pkg/web_css/lib/src/_base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,22 @@ button {
}
}

// The class annotates an image icon with either black or white pixels on
// a transparent base layer.
// The default display with the muted opacity will move the icon's color
// towards the gray spectrum, and on hovering it will show high contrast.
//
// Note: The `filter: brightness()` used below with the `a` element does
// not work with monochrome images, as the linear transformation
// will keep the pixels with rgb(0,0,0) the same.
.pub-monochrome-icon {
opacity: 0.6;

a:hover & {
opacity: 1;
}
}

a {
text-decoration: none;
color: var(--pub-link-text-color);
Expand All @@ -103,10 +119,8 @@ a {
}

.light-theme & {
opacity: 1;

&:hover {
opacity: 0.8;
filter: brightness(80%);
}
}

Expand Down
4 changes: 0 additions & 4 deletions pkg/web_css/lib/src/_pkg.scss
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,6 @@
font-size: 24px;
}
}

.version-table-icon {
opacity: 0.7;
}
}

.changelog-entry {
Expand Down

0 comments on commit f894ed2

Please sign in to comment.