feat(nav): reach the package where it is published, not only on npm
The site linked to GitHub and npm and said nothing about JSR, which core has published to since 26.8.0-beta.1. A reader on Deno had no way in from here. The three become marks rather than words. In a header row of five items, three logos are read faster than three nouns, and the words were carrying no information a logo does not — nobody needs to be told what "GitHub" is. The footer keeps both, because a footer is scanned and a column of bare glyphs makes the reader stop and decode where they were skimming. Each mark is inline SVG in one component. Three icons did not justify an icon library: the resolver and the set weigh more than the paths, and every one of them ends up inlining the same paths anyway. The paths are the official ones from simple-icons. Hand-drawn approximations were tried first and rendered as illegible shapes — verified in a screenshot, not in the markup, because the generated HTML was correct in both cases. A third-party mark is either theirs or it is noise. JSR carries an optical multiplier: its wordmark is wide and short and covers about half the viewBox height, so at an equal size it read as the small one of the three. Icon-only links take the label as `aria-label`. Inside the collapsed mobile menu the label comes back beside the mark, where the row is vertical and three unlabelled logos read as decoration. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
This commit is contained in:
4 files changed
+126
-11
No files matched your search
@@ -1,4 +1,6 @@
|
|||||||
---
|
---
|
||||||
|
import Icon from './Icon.astro';
|
||||||
|
|
||||||
const linkColumns = [
|
const linkColumns = [
|
||||||
{
|
{
|
||||||
heading: 'Learn',
|
heading: 'Learn',
|
||||||
@@ -10,8 +12,9 @@ const linkColumns = [
|
|||||||
{
|
{
|
||||||
heading: 'Code',
|
heading: 'Code',
|
||||||
links: [
|
links: [
|
||||||
{ label: 'GitHub', href: 'https://github.com/Expressive-Tea/green-tea', external: true },
|
{ label: 'GitHub', href: 'https://github.com/Expressive-Tea/green-tea', external: true, icon: 'github' as const },
|
||||||
{ label: 'npm', href: 'https://www.npmjs.com/package/@green-tea/core', external: true },
|
{ label: 'npm', href: 'https://www.npmjs.com/package/@green-tea/core', external: true, icon: 'npm' as const },
|
||||||
|
{ label: 'JSR', href: 'https://jsr.io/@green-tea/core', external: true, icon: 'jsr' as const },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
@@ -35,7 +38,13 @@ const year = new Date().getFullYear();
|
|||||||
<ul>
|
<ul>
|
||||||
{column.links.map((link) => (
|
{column.links.map((link) => (
|
||||||
<li>
|
<li>
|
||||||
<a href={link.href} target={link.external ? '_blank' : undefined} rel={link.external ? 'noopener noreferrer' : undefined}>
|
<a
|
||||||
|
class={link.icon ? 'site-footer__link--mark' : undefined}
|
||||||
|
href={link.href}
|
||||||
|
target={link.external ? '_blank' : undefined}
|
||||||
|
rel={link.external ? 'noopener noreferrer' : undefined}
|
||||||
|
>
|
||||||
|
{link.icon && <Icon name={link.icon} size={15} />}
|
||||||
{link.label}
|
{link.label}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
@@ -141,4 +150,12 @@ const year = new Date().getFullYear();
|
|||||||
gap: 2rem;
|
gap: 2rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Icon beside the word, never instead of it. A footer is scanned, and a column of bare
|
||||||
|
glyphs makes the reader stop and decode where they were skimming. */
|
||||||
|
.site-footer__link--mark {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.45rem;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -1,11 +1,15 @@
|
|||||||
---
|
---
|
||||||
import logoUrl from '../assets/logo.svg?url';
|
import logoUrl from '../assets/logo.svg?url';
|
||||||
|
import Icon from './Icon.astro';
|
||||||
|
|
||||||
|
// `icon` marks the links that become a mark on desktop. Their `label` is still the accessible
|
||||||
|
// name — an icon-only link without one is a link a screen reader announces as its href.
|
||||||
const navLinks = [
|
const navLinks = [
|
||||||
{ label: 'Docs', href: 'https://green-tea.expressive-tea.io/docs', external: true },
|
{ label: 'Docs', href: 'https://green-tea.expressive-tea.io/docs', external: true },
|
||||||
{ label: 'Blog', href: '/blog', external: false },
|
{ label: 'Blog', href: '/blog', external: false },
|
||||||
{ label: 'GitHub', href: 'https://github.com/Expressive-Tea/green-tea', external: true },
|
{ label: 'GitHub', href: 'https://github.com/Expressive-Tea/green-tea', external: true, icon: 'github' as const },
|
||||||
{ label: 'npm', href: 'https://www.npmjs.com/package/@green-tea/core', external: true },
|
{ label: 'npm', href: 'https://www.npmjs.com/package/@green-tea/core', external: true, icon: 'npm' as const },
|
||||||
|
{ label: 'JSR', href: 'https://jsr.io/@green-tea/core', external: true, icon: 'jsr' as const },
|
||||||
];
|
];
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -28,8 +32,15 @@ const navLinks = [
|
|||||||
{
|
{
|
||||||
navLinks.map((link) => (
|
navLinks.map((link) => (
|
||||||
<li>
|
<li>
|
||||||
<a href={link.href} target={link.external ? '_blank' : undefined} rel={link.external ? 'noopener noreferrer' : undefined}>
|
<a
|
||||||
{link.label}
|
href={link.href}
|
||||||
|
target={link.external ? '_blank' : undefined}
|
||||||
|
rel={link.external ? 'noopener noreferrer' : undefined}
|
||||||
|
aria-label={link.icon ? link.label : undefined}
|
||||||
|
class={link.icon ? 'site-nav__mark' : undefined}
|
||||||
|
>
|
||||||
|
{link.icon && <Icon name={link.icon} />}
|
||||||
|
<span class={link.icon ? 'site-nav__mark-text' : undefined}>{link.label}</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
))
|
))
|
||||||
@@ -109,6 +120,23 @@ const navLinks = [
|
|||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.site-nav__mark {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The mark carries the meaning on desktop, where the row is short and the three logos read
|
||||||
|
faster than three words. The label is not removed from the DOM: it is the accessible name
|
||||||
|
the collapsed menu shows back. */
|
||||||
|
.site-nav__mark-text {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.site-nav ul {
|
||||||
|
gap: 1.75rem;
|
||||||
|
}
|
||||||
|
|
||||||
.nav-toggle {
|
.nav-toggle {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
@@ -148,6 +176,12 @@ const navLinks = [
|
|||||||
padding-block: 1rem;
|
padding-block: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Inside the drawer the row is vertical and there is room, so the mark stops standing in
|
||||||
|
for the word and stands next to it. Three unlabelled logos stacked read as decoration. */
|
||||||
|
.site-nav__mark-text {
|
||||||
|
display: inline;
|
||||||
|
}
|
||||||
|
|
||||||
.nav-toggle:checked ~ .site-nav {
|
.nav-toggle:checked ~ .site-nav {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
---
|
||||||
|
// Inline marks for the three places a package of ours can be reached. Three icons did not
|
||||||
|
// justify an icon library: `astro-icon` and friends pull a resolver and a set to ship what
|
||||||
|
// fits in this file, and every one of them ends up inlining the same paths anyway.
|
||||||
|
//
|
||||||
|
// `currentColor` rather than a fixed fill, so a mark takes the colour of the link it sits in
|
||||||
|
// and needs no separate rule per surface — the header, the hero's ghost buttons and the
|
||||||
|
// footer all tint it differently today.
|
||||||
|
//
|
||||||
|
// The SVG is `aria-hidden`: the accessible name belongs to the anchor, which knows where it
|
||||||
|
// goes. A `<title>` here would announce "GitHub" twice on a link already labelled GitHub.
|
||||||
|
interface Props {
|
||||||
|
name: 'github' | 'npm' | 'jsr';
|
||||||
|
size?: number;
|
||||||
|
class?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { name, size = 18, class: className } = Astro.props;
|
||||||
|
|
||||||
|
// Optical sizing, not geometric. GitHub and npm fill their 24×24 box; JSR's wordmark is wide
|
||||||
|
// and short and covers about half its height, so at an equal `size` it reads as the small one
|
||||||
|
// of the three. The multiplier matches apparent weight, which is what a row of marks is judged
|
||||||
|
// on — nobody measures them, they just notice one looks wrong.
|
||||||
|
const scale: Record<Props['name'], number> = { github: 1, npm: 1, jsr: 1.4 };
|
||||||
|
const box = Math.round(size * scale[name]);
|
||||||
|
|
||||||
|
// The marks are the official ones, taken from simple-icons rather than redrawn. Hand-drawn
|
||||||
|
// approximations of npm and JSR were tried first and rendered as illegible shapes: a
|
||||||
|
// third-party mark is either theirs or it is noise.
|
||||||
|
const paths: Record<Props['name'], string> = {
|
||||||
|
github:
|
||||||
|
'M12 .5C5.37.5 0 5.87 0 12.5c0 5.3 3.44 9.8 8.21 11.39.6.11.82-.26.82-.58 0-.29-.01-1.24-.02-2.25-3.34.73-4.04-1.42-4.04-1.42-.55-1.39-1.34-1.76-1.34-1.76-1.09-.75.08-.73.08-.73 1.2.08 1.84 1.24 1.84 1.24 1.07 1.83 2.81 1.3 3.5.99.11-.78.42-1.3.76-1.6-2.67-.3-5.47-1.33-5.47-5.93 0-1.31.47-2.38 1.24-3.22-.13-.3-.54-1.52.11-3.18 0 0 1.01-.32 3.3 1.23a11.5 11.5 0 0 1 6.01 0c2.29-1.55 3.3-1.23 3.3-1.23.65 1.66.24 2.88.12 3.18.77.84 1.23 1.91 1.23 3.22 0 4.61-2.8 5.62-5.48 5.92.43.37.81 1.1.81 2.22 0 1.6-.01 2.9-.01 3.29 0 .32.21.7.82.58A12 12 0 0 0 24 12.5C24 5.87 18.63.5 12 .5Z',
|
||||||
|
npm: 'M1.763 0C.786 0 0 .786 0 1.763v20.474C0 23.214.786 24 1.763 24h20.474c.977 0 1.763-.786 1.763-1.763V1.763C24 .786 23.214 0 22.237 0zM5.13 5.323l13.837.019-.009 13.836h-3.464l.01-10.382h-3.456L12.04 19.17H5.113z',
|
||||||
|
// the others rather than carrying its own viewBox.
|
||||||
|
jsr: 'M3.692 5.538v3.693H0v7.384h7.385v1.847h12.923v-3.693H24V7.385h-7.385V5.538Zm1.846 1.847h1.847v7.384H1.846v-3.692h1.846v1.846h1.846zm3.693 0h5.538V9.23h-3.692v1.846h3.692v5.538H9.231V14.77h3.692v-1.846H9.231Zm7.384 1.846h5.539v3.692h-1.846v-1.846h-1.846v5.538h-1.847z',
|
||||||
|
};
|
||||||
|
---
|
||||||
|
|
||||||
|
<svg
|
||||||
|
class={className}
|
||||||
|
width={box}
|
||||||
|
height={box}
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
fill="currentColor"
|
||||||
|
aria-hidden="true"
|
||||||
|
focusable="false"
|
||||||
|
>
|
||||||
|
<path d={paths[name]} />
|
||||||
|
</svg>
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
---
|
---
|
||||||
import logoUrl from '../../assets/logo.svg?url';
|
import logoUrl from '../../assets/logo.svg?url';
|
||||||
|
import Icon from '../Icon.astro';
|
||||||
import GraphMotif from '../GraphMotif.astro';
|
import GraphMotif from '../GraphMotif.astro';
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -25,11 +26,14 @@ import GraphMotif from '../GraphMotif.astro';
|
|||||||
<a class="btn btn--primary" href="https://green-tea.expressive-tea.io/docs" target="_blank" rel="noopener noreferrer">
|
<a class="btn btn--primary" href="https://green-tea.expressive-tea.io/docs" target="_blank" rel="noopener noreferrer">
|
||||||
Get started
|
Get started
|
||||||
</a>
|
</a>
|
||||||
<a class="btn btn--ghost" href="https://github.com/Expressive-Tea/green-tea" target="_blank" rel="noopener noreferrer">
|
<a class="btn btn--ghost btn--mark" href="https://github.com/Expressive-Tea/green-tea" target="_blank" rel="noopener noreferrer" aria-label="GitHub">
|
||||||
GitHub
|
<Icon name="github" size={20} />
|
||||||
</a>
|
</a>
|
||||||
<a class="btn btn--ghost" href="https://www.npmjs.com/package/@green-tea/core" target="_blank" rel="noopener noreferrer">
|
<a class="btn btn--ghost btn--mark" href="https://www.npmjs.com/package/@green-tea/core" target="_blank" rel="noopener noreferrer" aria-label="npm">
|
||||||
npm
|
<Icon name="npm" size={20} />
|
||||||
|
</a>
|
||||||
|
<a class="btn btn--ghost btn--mark" href="https://jsr.io/@green-tea/core" target="_blank" rel="noopener noreferrer" aria-label="JSR">
|
||||||
|
<Icon name="jsr" size={20} />
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -101,6 +105,17 @@ import GraphMotif from '../GraphMotif.astro';
|
|||||||
color: var(--ink);
|
color: var(--ink);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Square rather than pill: with the text gone the ghost button's horizontal padding left a
|
||||||
|
wide box around a small mark. Equal padding keeps the three the same size whatever the
|
||||||
|
glyph's width. */
|
||||||
|
.btn--mark {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 0.65rem;
|
||||||
|
aspect-ratio: 1;
|
||||||
|
}
|
||||||
|
|
||||||
.hero__ctas {
|
.hero__ctas {
|
||||||
margin-bottom: 1.4rem;
|
margin-bottom: 1.4rem;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user