Files
CatoandClaude a1223d801e fix(chrome): own box model, nav links elsewhere, trailingSlash, footer year (#51)
What a consumer gets:
- styles.css gives sitekit's own elements in the masthead, footer, tab bar
  and skip link box-sizing: border-box at zero specificity (:where), so the
  chrome measures the same without a host reset (the row was 422px wide at
  390 and the controls about 67px tall). A host rule with a type, class or id
  selector still wins; a host '*' rule loaded first does not. Host content
  in a slot (brand, actions, footer extra, tab icon) keeps the host's box
  model. A link straight in actions drops its block padding, so it is
  44-46px in either box model.
- Rendered nav props take SiteNavLink: an in-site path, or an href used
  verbatim, exactly one (siteNavLinkSchema, field-addressed messages; its
  output type is SiteNavLink, so validate-then-render type-checks). An href
  must be http(s), mailto, tel, //host, #fragment or ?query; anything else
  (javascript:, data:, bitcoin:, any other scheme) is refused by the schema
  and never rendered. A nav or group left with no items renders as one given
  none (the document nav: the same empty <nav> as items={[]}).
  href(), siteNavItems(), SiteNavItem, siteNavItemSchema and SiteNavGroup
  are unchanged and stay path-only.
- Links to another origin, as a browser resolves them (also /\host and
  https:/\host), get rel="noopener" in nav and footer (a footer change).
  The footer drops only javascript:, vbscript: and data: links, and a group
  whose every link was dropped; every other footer link renders as in 0.7.0.
- trailingSlash on SiteMasthead, SiteNav, SiteTabBar and href(): the slash
  goes on the path part ('/a/#b'), never after a file name ('/feed.xml')
  unless the path already ended in one ('/a/b.c/'); aria-current then
  ignores slashes. Without it nothing changes.
- SiteFooter year: an integer from 1 to 9999 is printed without reading the
  clock, null prints none, anything else counts as omitted.

How it is checked: test/types/consumer.ts (compiled by typecheck: a 0.7.0
consumer's siteNavItems(...).map(i => i.path.length), and a parsed
siteNavLinkSchema item passed to SiteNav and SiteMasthead),
test/links.test.js (href() against 0.7.0's output for 26 inputs,
trailingSlash, the allow-list, browser-read externality, schema messages and
output, refused hrefs in every renderer, all-refused navs and groups, footer
schemes and groups), test/footer-year.test.js, test/box-model-browser.test.js
(320 and 390px with and without a reset; slotted host elements measure as
outside the chrome). Each fails on the previous source. Masthead, nav and
tab bar markup for path-only items is identical to the 0.7.0 build, except
that a nav path a browser reads as another host (\\host, /\host) keeps its
href and gains rel="noopener"; footer links to another origin gain rel.

Claude-Session: https://claude.ai/code/session_019MDtmsSWTTpVpe4wh3v1sb

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-12 10:05:52 +01:00

573 lines
14 KiB
CSS

/* Shared application chrome. Consumers supply semantic theme variables only. */
/* The chrome's own box model, so it measures the same on a host page with or
without a `box-sizing: border-box` reset. It covers the elements sitekit
renders, not host content passed into its slots (brand, actions, a footer's
extra, a tab icon): those keep whatever box model the host gives them.
Zero specificity (:where), so a host rule with a type, class or id
selector still wins; a host `*` rule loaded before this file does not. Pseudo-elements are
not covered (they cannot sit inside :where()), and sitekit gives none of
them padding or a border, so their box model does not change a size. */
:where(
.sk-skip,
.sk-masthead,
.sk-masthead *,
.sk-footer,
.sk-footer *,
.sk-tabbar,
.sk-tabbar *,
.sk-tabbar-spacer
):not(
:where(
.sk-brand *,
.sk-account-actions *,
.sk-menu-actions *,
.sk-grouped-actions *,
.sk-footer-bottom > :not(:first-child),
.sk-footer-bottom > :not(:first-child) *,
.sk-tab-icon *
)
) {
box-sizing: border-box;
}
:where(.sk-masthead, .sk-footer) {
color: var(--sk-fg, CanvasText);
font-family: var(--sk-font, system-ui, sans-serif);
}
.sk-shell-frame {
width: min(100%, var(--sk-width, 76rem));
margin-inline: auto;
padding-inline: var(--sk-gutter, clamp(1rem, 4vw, 2.5rem));
}
.sk-masthead {
position: sticky;
top: 0;
z-index: 40;
background: var(--sk-bg, Canvas);
border-bottom: 1px solid var(--sk-line, #d6d6d6);
}
.sk-masthead-row {
min-height: var(--sk-header-height, 80px);
display: flex;
align-items: center;
gap: clamp(1rem, 2vw, 2rem);
}
.sk-brand,
.sk-footer-brand {
color: inherit;
text-decoration: none;
font-weight: 650;
letter-spacing: -0.035em;
display: inline-flex;
align-items: center;
gap: 0.75rem;
min-height: 44px;
white-space: nowrap;
font-size: 1.2rem;
}
.sk-brand img,
.sk-brand svg {
width: 38px;
height: 38px;
object-fit: contain;
flex-shrink: 0;
}
.sk-desktop-nav {
margin-inline: auto;
display: flex;
align-items: center;
gap: 0.15rem;
min-width: 0;
}
.sk-desktop-nav a,
.sk-mobile-menu nav a,
.sk-footer nav a {
min-height: 44px;
display: flex;
align-items: center;
color: var(--sk-muted, #555);
text-decoration: none;
font-size: 0.875rem;
line-height: 1.4;
}
.sk-desktop-nav a {
padding: 0.75rem 0.7rem;
border-radius: var(--sk-radius, 0.5rem);
white-space: nowrap;
}
.sk-desktop-nav a[aria-current='page'],
.sk-mobile-menu a[aria-current='page'] {
background: var(--sk-raised, #f0f0f0);
color: var(--sk-fg, CanvasText);
font-weight: 600;
}
.sk-account-actions {
margin-inline-start: auto;
display: flex;
align-items: center;
gap: 0.5rem;
flex-shrink: 0;
}
/* The link is the host's (the `actions` slot), so its box model is too. No
block padding: min-height and centring give it 44px under border-box and
46px (the border) under content-box, where 0.65rem of padding made 67px. */
.sk-account-actions > a {
display: inline-flex;
align-items: center;
justify-content: center;
min-height: 44px;
padding: 0 1rem;
color: var(--sk-fg, CanvasText);
border: 1px solid var(--sk-line, #d6d6d6);
border-radius: var(--sk-radius, 0.5rem);
text-decoration: none;
font-weight: 600;
font-size: 0.875rem;
}
.sk-mobile-menu {
display: none;
}
.sk-mobile-menu summary {
cursor: pointer;
list-style: none;
min-height: 44px;
align-items: center;
justify-content: center;
gap: 0.5rem;
padding: 0.65rem 0.85rem;
border: 1px solid var(--sk-line, #d6d6d6);
border-radius: var(--sk-radius, 0.5rem);
font-size: 0.875rem;
font-weight: 600;
}
.sk-mobile-menu summary::-webkit-details-marker {
display: none;
}
.sk-mobile-menu nav {
position: absolute;
top: 100%;
left: var(--sk-gutter, 1rem);
right: var(--sk-gutter, 1rem);
background: var(--sk-bg, Canvas);
border: 1px solid var(--sk-line, #d6d6d6);
border-radius: var(--sk-radius, 0.5rem);
box-shadow: 0 18px 40px #00000014;
padding: 0.5rem;
max-height: 75dvh;
overflow-y: auto;
}
.sk-mobile-menu nav a {
padding: 0.8rem 1rem;
border-radius: var(--sk-radius, 0.5rem);
}
.sk-footer {
margin-top: var(--sk-footer-gap, clamp(4rem, 8vw, 7rem));
border-top: 1px solid var(--sk-line, #d6d6d6);
background: var(--sk-bg, Canvas);
padding-block: 3rem 1.5rem;
}
.sk-footer-top {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 3rem;
}
.sk-footer-top p {
margin-top: 0.5rem;
color: var(--sk-muted, #555);
max-width: 36ch;
line-height: 1.7;
font-size: 0.875rem;
}
.sk-footer nav {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
column-gap: 1.5rem;
}
.sk-footer nav a {
padding-block: 0.5rem;
}
.sk-footer-bottom {
display: flex;
align-items: center;
justify-content: space-between;
flex-wrap: wrap;
gap: 1rem;
margin-top: 2rem;
padding-top: 1.5rem;
border-top: 1px solid var(--sk-line, #d6d6d6);
color: var(--sk-muted, #555);
font-size: 0.75rem;
}
.sk-footer-bottom a {
color: inherit;
min-height: 44px;
display: inline-flex;
align-items: center;
}
.sk-skip {
position: fixed;
left: 1rem;
top: -10rem;
z-index: 100;
padding: 1rem;
color: var(--sk-bg, Canvas);
background: var(--sk-fg, CanvasText);
border-radius: 0.5rem;
}
.sk-skip:focus {
top: 1rem;
}
:where(.sk-masthead, .sk-footer) :is(a, summary, button):focus-visible,
.sk-skip:focus-visible {
outline: 3px solid var(--sk-focus, Highlight);
outline-offset: 3px;
}
@media (max-width: 1100px) {
.sk-desktop-nav {
display: none;
}
.sk-mobile-menu {
display: block;
order: 3;
}
.sk-mobile-menu summary {
display: flex;
}
.sk-masthead-row {
gap: 0.5rem;
min-height: var(--sk-mobile-header-height, 72px);
}
.sk-brand {
margin-inline-end: auto;
}
}
.sk-menu-actions {
display: none;
}
/* The narrowest phones (up to 380px, which takes in 360px Android): brand, an
account action and the menu button do not fit in one row (AOZ at 320px
needed 369px and scrolled sideways by 49px), so the action moves to the foot
of the menu, and only when there is a menu to hold it. */
@media (max-width: 380px) {
.sk-masthead-row:has(.sk-mobile-menu) > .sk-account-actions {
display: none;
}
.sk-menu-actions {
display: flex;
flex-direction: column;
gap: 0.5rem;
margin-top: 0.5rem;
padding-top: 0.5rem;
border-top: 1px solid var(--sk-line, #d6d6d6);
}
.sk-menu-actions > a {
display: flex;
align-items: center;
justify-content: center;
min-height: 44px;
padding: 0 1rem; /* as .sk-account-actions > a: 44-46px in either box model */
color: var(--sk-fg, CanvasText);
border: 1px solid var(--sk-line, #d6d6d6);
border-radius: var(--sk-radius, 0.5rem);
text-decoration: none;
font-weight: 600;
font-size: 0.875rem;
}
}
@media (max-width: 600px) {
.sk-footer-top {
grid-template-columns: 1fr;
gap: 1.5rem;
}
.sk-brand {
font-size: 1.05rem;
gap: 0.5rem;
}
.sk-account-actions > a {
padding-inline: 0.75rem;
}
}
.sk-hero {
padding-block: var(--sk-hero-space, clamp(3rem, 7vw, 6rem));
}
.sk-eyebrow {
font: 600 0.7rem/1.5 var(--sk-mono, monospace);
text-transform: uppercase;
letter-spacing: 0.13em;
color: var(--sk-muted, #555);
}
.sk-hero-title {
margin-block: 1rem 1.5rem;
font-family: var(--sk-display, Georgia, serif);
font-size: var(--sk-title-size, clamp(3rem, 6vw, 5rem));
font-weight: var(--sk-display-weight, 400);
line-height: var(--sk-display-leading, 1.05);
letter-spacing: var(--sk-display-tracking, -0.045em);
text-wrap: balance;
max-width: var(--sk-title-measure, 20ch);
}
.sk-hero-lead {
max-width: var(--sk-measure, 64ch);
display: grid;
gap: 1rem;
color: var(--sk-muted, #555);
font-size: var(--sk-lead-size, clamp(1.05rem, 2vw, 1.2rem));
line-height: var(--sk-lead-leading, 1.75);
}
.sk-hero-actions {
display: grid;
grid-auto-flow: column;
grid-auto-columns: 1fr;
gap: 0.75rem;
margin-top: 2rem;
max-width: 36rem;
}
.sk-hero-actions a {
display: flex;
align-items: center;
justify-content: center;
min-height: 48px;
padding: 0.8rem 1rem;
font-size: 0.9rem;
font-weight: 600;
border-radius: var(--sk-radius, 0.5rem);
text-decoration: none;
text-align: center;
}
.sk-primary-action {
background: var(--sk-fg, CanvasText);
color: var(--sk-bg, Canvas);
border: 1px solid var(--sk-fg, CanvasText);
}
.sk-secondary-action {
background: transparent;
color: var(--sk-fg, CanvasText);
border: 1px solid var(--sk-line, #d6d6d6);
}
.sk-hero-actions a:focus-visible {
outline: 3px solid var(--sk-focus, Highlight);
outline-offset: 3px;
}
@media (max-width: 420px) {
.sk-hero-actions {
grid-auto-flow: row;
}
}
.sk-footer nav.sk-footer-groups {
grid-template-columns: repeat(var(--sk-footer-columns, 3), minmax(0, 1fr));
gap: 1.5rem;
}
.sk-footer-group h2 {
margin: 0 0 0.75rem;
font: 600 0.75rem/1.5 var(--sk-font, system-ui, sans-serif);
color: var(--sk-fg, CanvasText);
}
.sk-footer-group a {
font-size: 0.8125rem;
}
@media (max-width: 600px) {
.sk-footer nav.sk-footer-groups {
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 1.5rem;
}
}
/* Mobile bottom tab bar (SiteTabBar). Hidden from --sk-tabbar-breakpoint up.
One row of equal cells; the current one carries a short rule above its icon
and the full text colour, so the active state reads without a fill. */
.sk-tabbar {
position: fixed;
inset: auto 0 0 0;
z-index: 45;
display: grid;
grid-auto-flow: column;
grid-auto-columns: minmax(0, 1fr);
padding: 0 4px calc(0px + env(safe-area-inset-bottom));
background: var(--sk-bg, Canvas);
border-top: 1px solid var(--sk-line, #d6d6d6);
font-family: var(--sk-font, system-ui, sans-serif);
}
.sk-tab {
position: relative;
min-width: 0;
min-height: 56px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 3px;
padding: 8px 4px 6px;
color: var(--sk-muted, #555);
font-size: 11px;
font-weight: 600;
letter-spacing: 0.01em;
text-decoration: none;
-webkit-tap-highlight-color: transparent;
}
.sk-tab-icon {
display: inline-flex;
width: 24px;
height: 24px;
align-items: center;
justify-content: center;
font-size: 22px;
line-height: 1;
}
.sk-tab-icon > svg {
width: 24px;
height: 24px;
}
.sk-tab-label {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 100%;
}
.sk-tab[aria-current='page'] {
color: var(--sk-fg, CanvasText);
}
.sk-tab[aria-current='page']::before {
content: '';
position: absolute;
top: -1px;
left: 50%;
width: 28px;
height: 3px;
transform: translateX(-50%);
border-radius: 0 0 3px 3px;
background: var(--sk-tab-active, currentColor);
}
.sk-tab:focus-visible {
outline: 2px solid var(--sk-focus, Highlight);
outline-offset: -4px;
border-radius: 10px;
}
.sk-tabbar-spacer {
height: calc(var(--sk-tabbar-height, 56px) + env(safe-area-inset-bottom));
}
/* Below the tab bar breakpoint the tab bar IS the navigation: a masthead that
says so (`tabBar`) drops its menu button rather than offering the same five
places twice. */
@media (max-width: 47.999rem) {
.sk-masthead--tabbar .sk-mobile-menu {
display: none;
}
.sk-masthead--tabbar .sk-masthead-row:has(.sk-mobile-menu) > .sk-account-actions {
display: flex;
}
}
@media (min-width: 48rem) {
.sk-tabbar,
.sk-tabbar-spacer {
display: none;
}
}
.sk-icon {
display: inline-block;
vertical-align: middle;
flex-shrink: 0;
}
/* One native disclosure and one link tree for grouped application navigation. */
.sk-masthead-row:has(.sk-grouped-menu) {
position: relative;
}
.sk-grouped-menu {
margin-inline-start: auto;
}
.sk-grouped-menu summary {
display: flex;
align-items: center;
justify-content: center;
gap: 0.5rem;
min-height: 44px;
padding: 0.65rem 0.85rem;
list-style: none;
cursor: pointer;
border: 1px solid var(--sk-line, #d6d6d6);
border-radius: var(--sk-radius, 0.5rem);
font-size: 0.875rem;
font-weight: 600;
}
.sk-grouped-menu summary::-webkit-details-marker {
display: none;
}
.sk-grouped-panel {
position: absolute;
inset-block-start: 100%;
inset-inline-end: var(--sk-gutter, 1rem);
width: min(54rem, calc(100% - 2 * var(--sk-gutter, 1rem)));
box-sizing: border-box;
max-height: 75dvh;
overflow-y: auto;
padding: 1rem;
background: var(--sk-bg, Canvas);
border: 1px solid var(--sk-line, #d6d6d6);
border-radius: var(--sk-radius, 0.5rem);
box-shadow: 0 18px 40px #00000014;
}
.sk-nav-groups {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr));
gap: 1rem;
}
.sk-nav-group {
min-width: 0;
}
.sk-nav-group h2 {
margin: 0 0 0.5rem;
font-size: 0.875rem;
color: var(--sk-muted, #555);
}
.sk-grouped-actions > a,
.sk-nav-group a {
display: flex;
flex-direction: column;
justify-content: center;
box-sizing: border-box;
min-height: 44px;
padding: 0.75rem;
border-radius: var(--sk-radius, 0.5rem);
color: var(--sk-fg, CanvasText);
text-decoration: none;
overflow-wrap: anywhere;
}
.sk-nav-group a:hover,
.sk-nav-group a[aria-current='page'] {
background: var(--sk-raised, #f0f0f0);
}
.sk-nav-link-label {
font-weight: 600;
}
.sk-nav-description {
margin-top: 0.25rem;
font-size: 0.875rem;
line-height: 1.5;
color: var(--sk-muted, #555);
}
.sk-grouped-actions {
display: none;
}
@media (max-width: 600px) {
.sk-nav-groups {
grid-template-columns: minmax(0, 1fr);
}
}
@media (max-width: 380px) {
/* Give host account popovers the full narrow viewport, including padding. */
.sk-grouped-panel {
inset-inline: 0;
width: 100%;
}
.sk-masthead-row:has(.sk-grouped-menu) > .sk-account-actions {
display: none;
}
.sk-grouped-actions {
display: flex;
flex-direction: column;
gap: 0.5rem;
border-top: 1px solid var(--sk-line, #d6d6d6);
padding-top: 0.75rem;
margin-top: 0.75rem;
}
}