feat/website-optimisation-accessibility #21

Merged
abiwab merged 8 commits from feat/website-optimisation-accessibility into main 2026-08-25 21:58:21 +02:00
22 changed files with 757 additions and 266 deletions

View file

@ -20,7 +20,7 @@
}, },
"audit": { "audit": {
"name": "@gram-lang/audit", "name": "@gram-lang/audit",
"version": "1.1.1", "version": "1.2.0",
"dependencies": { "dependencies": {
"@gram-lang/analyzer": "workspace:*", "@gram-lang/analyzer": "workspace:*",
"@gram-lang/format": "workspace:*", "@gram-lang/format": "workspace:*",
@ -97,7 +97,7 @@
}, },
"packages/docs": { "packages/docs": {
"name": "@gram-lang/docs", "name": "@gram-lang/docs",
"version": "1.1.1", "version": "1.2.0",
"dependencies": { "dependencies": {
"@astrojs/markdown-remark": "^7.2.2", "@astrojs/markdown-remark": "^7.2.2",
"@astrojs/mdx": "^7.0.5", "@astrojs/mdx": "^7.0.5",
@ -198,7 +198,7 @@
}, },
"packages/vscode-extension": { "packages/vscode-extension": {
"name": "gram-lang", "name": "gram-lang",
"version": "1.1.1", "version": "1.2.0",
"dependencies": { "dependencies": {
"@gram-lang/language-server": "workspace:*", "@gram-lang/language-server": "workspace:*",
"@gram-lang/renderer": "workspace:*", "@gram-lang/renderer": "workspace:*",

View file

@ -116,13 +116,15 @@ const topicHref = `${basePath}/topic/${getTopicSlug(post.data.topic)}`;
} }
.post-content :global(a) { .post-content :global(a) {
color: var(--sl-color-accent); color: var(--sl-color-text);
text-decoration: underline; text-decoration: underline;
text-underline-offset: 4px; text-decoration-color: var(--gram-orange);
text-decoration-thickness: 2px;
text-underline-offset: 3px;
} }
.post-content :global(a:hover) { .post-content :global(a:hover) {
color: var(--sl-color-accent-high); color: var(--sl-color-accent);
} }
.post-content :global(ul), .post-content :global(ul),

View file

@ -4,6 +4,7 @@ import Icon from "./Icon.astro";
interface Props { interface Props {
id: string; id: string;
title?: string;
desc: string; desc: string;
link: string; link: string;
learnMoreText: string; learnMoreText: string;
@ -15,6 +16,7 @@ interface Props {
const { const {
id, id,
title,
desc, desc,
link, link,
learnMoreText, learnMoreText,
@ -29,36 +31,65 @@ const {
<p class="feature-desc"> <p class="feature-desc">
{desc} {desc}
<a href={link} class="learn-more-link" style="margin-left: 0.5rem;"> <a href={link} class="learn-more-link" style="margin-left: 0.5rem;">
{learnMoreText} &rarr; {learnMoreText}{title && <span class="sr-only">: {title}</span>}<span aria-hidden="true"> &rarr;</span>
</a> </a>
</p> </p>
<div class="feature-columns"> <div class="feature-columns">
<div class="col-input"> <div class="col-input">
<div class="code-block"> <div class="code-block" role="region" aria-label="input.gram">
<div class="code-header"> <div class="code-header">
<span class="filename">input.gram</span> <span class="filename">input.gram</span>
</div> </div>
<Code code={inputCode} lang={gramLang} themes={codeThemes} /> <Code code={inputCode} lang={gramLang} themes={codeThemes} />
</div> </div>
</div> </div>
<div class="col-arrow"> <div class="col-arrow" aria-hidden="true">
<Icon name="right-arrow" class="arrow-icon" /> <Icon name="right-arrow" class="arrow-icon" />
</div> </div>
<div class="col-output"> <div class="col-output">
<div class="modern-output-pane"> <div class="modern-output-pane">
<div class="output-header"> <div class="output-header">
<div class="view-toggles pill-toggles"> <div class="view-toggles pill-toggles" role="tablist" aria-label="Output format">
<button class="pill-btn active" data-view="preview" <button
>Preview</button type="button"
> role="tab"
<button class="pill-btn" data-view="json">JSON</button> id={`${id}-tab-preview`}
aria-controls={`${id}-view-preview`}
aria-selected="true"
class="pill-btn active"
data-view="preview"
tabindex="0"
>Preview</button>
<button
type="button"
role="tab"
id={`${id}-tab-json`}
aria-controls={`${id}-view-json`}
aria-selected="false"
class="pill-btn"
data-view="json"
tabindex="-1"
>JSON</button>
</div> </div>
</div> </div>
<div class="view-content preview-view active"> <div
id={`${id}-view-preview`}
role="tabpanel"
aria-labelledby={`${id}-tab-preview`}
class="view-content preview-view active"
tabindex="0"
>
<slot /> <slot />
</div> </div>
<div class="view-content json-view"> <div
<div class="code-block json-block"> id={`${id}-view-json`}
role="tabpanel"
aria-labelledby={`${id}-tab-json`}
class="view-content json-view"
tabindex="0"
hidden
>
<div class="code-block json-block" role="region" aria-label="JSON Output">
<Code <Code
code={outputCode} code={outputCode}
lang="json" lang="json"
@ -159,8 +190,18 @@ const {
.learn-more-link { .learn-more-link {
display: inline-block; display: inline-block;
color: var(--sl-color-text-accent);
font-weight: 600; font-weight: 600;
color: var(--sl-color-text);
text-decoration: underline;
text-decoration-color: var(--gram-orange);
text-decoration-thickness: 2px;
text-underline-offset: 3px;
}
.learn-more-link:focus-visible {
outline: 2px solid var(--sl-color-accent);
outline-offset: 3px;
border-radius: 2px;
} }
/* Output Pane */ /* Output Pane */
@ -203,8 +244,14 @@ const {
color: var(--sl-color-white); color: var(--sl-color-white);
} }
.pill-btn:focus-visible {
outline: 2px solid var(--sl-color-accent);
outline-offset: 3px;
border-radius: 2px;
}
.pill-btn.active { .pill-btn.active {
color: var(--sl-color-text-accent); color: var(--sl-color-text);
border-bottom-color: var(--sl-color-text-accent); border-bottom-color: var(--sl-color-text-accent);
} }
@ -214,7 +261,7 @@ const {
background-color: var(--sl-color-bg); background-color: var(--sl-color-bg);
} }
.view-content.active { .view-content:not([hidden]).active {
display: block; display: block;
} }

View file

@ -19,7 +19,7 @@ const { currentLang = "en" } = Astro.props;
<a <a
href={currentLang === "fr" href={currentLang === "fr"
? "/fr/docs/explanation/philosophy" ? "/fr/docs/explanation/philosophy"
: "/docs/explanation/philosophy"}>Documentation</a : "/docs/explanation/philosophy"}>Docs</a
> >
<a href={currentLang === "fr" ? "/fr/play" : "/play"}>Playground</a> <a href={currentLang === "fr" ? "/fr/play" : "/play"}>Playground</a>
<a href={currentLang === "fr" ? "/fr/blog" : "/blog"}>Blog</a> <a href={currentLang === "fr" ? "/fr/blog" : "/blog"}>Blog</a>
@ -79,7 +79,7 @@ const { currentLang = "en" } = Astro.props;
<a <a
href={currentLang === "fr" href={currentLang === "fr"
? "/fr/docs/explanation/philosophy" ? "/fr/docs/explanation/philosophy"
: "/docs/explanation/philosophy"}>Documentation</a : "/docs/explanation/philosophy"}>Docs</a
> >
<a href={currentLang === "fr" ? "/fr/play" : "/play"}>Playground</a> <a href={currentLang === "fr" ? "/fr/play" : "/play"}>Playground</a>
<a href={currentLang === "fr" ? "/fr/blog" : "/blog"}>Blog</a> <a href={currentLang === "fr" ? "/fr/blog" : "/blog"}>Blog</a>

View file

@ -47,11 +47,11 @@ const mockBases = [
<Layout title="Gram" description={t.metaDescription} currentLang={lang}> <Layout title="Gram" description={t.metaDescription} currentLang={lang}>
<!-- Hero Section --> <!-- Hero Section -->
<section class="section hero"> <section class="section hero" aria-labelledby="hero-heading">
<div class="homepage-container"> <div class="homepage-container">
<div class="hero-layout"> <div class="hero-layout">
<div class="hero-text"> <div class="hero-text">
<h1 class="title">{t.heroTitle}</h1> <h1 class="title" id="hero-heading">{t.heroTitle}</h1>
<p class="subtitle">{t.heroSubtitle}</p> <p class="subtitle">{t.heroSubtitle}</p>
<p class="description"> <p class="description">
{t.heroDescription} {t.heroDescription}
@ -78,7 +78,7 @@ const mockBases = [
</div> </div>
<div class="hero-code"> <div class="hero-code">
<div class="code-block"> <div class="code-block" role="region" aria-label={t.recipeFileName || "recipe.gram"}>
<div class="code-header"> <div class="code-header">
<span class="filename">{t.recipeFileName || "recipe.gram"}</span> <span class="filename">{t.recipeFileName || "recipe.gram"}</span>
</div> </div>
@ -116,7 +116,9 @@ const mockBases = [
<p>{item.details}</p> <p>{item.details}</p>
{item.link && ( {item.link && (
<a href={item.link} class="learn-more-link"> <a href={item.link} class="learn-more-link">
{t.learnMore} &rarr; {t.learnMore}
<span class="sr-only">: {item.title}</span>
<span aria-hidden="true"> &rarr;</span>
</a> </a>
)} )}
</div> </div>
@ -145,6 +147,7 @@ const mockBases = [
</summary> </summary>
<FeaturePanel <FeaturePanel
id="feature-nutrition" id="feature-nutrition"
title={t.tabNutritionTitle}
desc={t.tabNutritionDesc} desc={t.tabNutritionDesc}
link={t.tabNutritionLink} link={t.tabNutritionLink}
learnMoreText={t.learnMore} learnMoreText={t.learnMore}
@ -153,9 +156,9 @@ const mockBases = [
gramLang={gramLang} gramLang={gramLang}
codeThemes={codeThemes} codeThemes={codeThemes}
> >
<div class="modern-mockup-card nut-card-mock"> <div class="modern-mockup-card nut-card-mock" role="region" aria-label={nutritionDict.renderer.nutrition}>
<div class="mockup-steps"> <div class="mockup-steps">
<ol class="gram-steps"> <ol class="gram-steps" aria-label={lang === "fr" ? "Étapes de la recette Chantilly" : "Chantilly recipe steps"}>
<li> <li>
<span class="action" <span class="action"
>{lang === "fr" ? "Fouetter" : "Whisk"}</span >{lang === "fr" ? "Fouetter" : "Whisk"}</span
@ -195,15 +198,18 @@ const mockBases = [
</li> </li>
</ol> </ol>
</div> </div>
<div class="nut-panel-mock"> <div class="nut-panel-mock" role="group" aria-label={nutritionDict.renderer.nutrition}>
<div class="nut-header-mock"> <div class="nut-header-mock">
{nutritionDict.renderer.nutrition} {nutritionDict.renderer.nutrition}
<span>{nutritionDict.renderer.estimateTooltip}</span> <span>{nutritionDict.renderer.estimateTooltip}</span>
</div> </div>
<div class="nut-basis-switch-mock"> <div class="nut-basis-switch-mock" role="group" aria-label={lang === "fr" ? "Base de calcul nutritionnel" : "Nutrition calculation basis"}>
{ {
mockBases.map((basis) => ( mockBases.map((basis) => (
<span class:list={["pill", { active: basis.active }]}> <span
class:list={["pill", { active: basis.active }]}
aria-current={basis.active ? "true" : undefined}
>
{basis.label} {basis.label}
</span> </span>
)) ))
@ -219,7 +225,7 @@ const mockBases = [
<span class="unit">{group.unit}</span> <span class="unit">{group.unit}</span>
</strong> </strong>
{group.children.length > 0 && ( {group.children.length > 0 && (
<ul class="nut-item-children"> <ul class="nut-item-children" aria-label={group.label}>
{group.children.map((child) => ( {group.children.map((child) => (
<li> <li>
<span class="label">{child.label}</span> <span class="label">{child.label}</span>
@ -246,6 +252,7 @@ const mockBases = [
</summary> </summary>
<FeaturePanel <FeaturePanel
id="feature-schedule" id="feature-schedule"
title={t.tabScheduleTitle}
desc={t.tabScheduleDesc} desc={t.tabScheduleDesc}
link={t.tabScheduleLink} link={t.tabScheduleLink}
learnMoreText={t.learnMore} learnMoreText={t.learnMore}
@ -254,78 +261,89 @@ const mockBases = [
gramLang={gramLang} gramLang={gramLang}
codeThemes={codeThemes} codeThemes={codeThemes}
> >
<div class="modern-mockup-card timeline-mockup-card"> <div
<div class="gantt-header-mock"> class="modern-mockup-card timeline-mockup-card"
<span role="region"
>{lang === "fr" ? "Temps Total" : "Total Time"}: <strong aria-label={lang === "fr" ? "Aperçu de la planification et du rétro-planning" : "Schedule and timeline preview"}
>17m</strong >
></span <div class="sr-only">
> {lang === "fr"
<span ? "Rétro-planning : Temps total 17 minutes, temps actif 7 minutes. Déroulé : 0 à 5m : Mise en place ; 5 à 15m : Ébullition ; 10 à 15m : Sauter ; 15 à 17m : Mélanger."
>{lang === "fr" ? " · Actif" : " · Active"}: <strong>7m</strong : "Timeline schedule: Total time 17 minutes, active time 7 minutes. Steps: 0 to 5m: Mise en place; 5 to 15m: Boiling; 10 to 15m: Sauté; 15 to 17m: Toss."}
></span
>
</div> </div>
<div class="gantt-tracks-container"> <div aria-hidden="true">
<div class="gantt-track-mock" style="height: 120px;"> <div class="gantt-header-mock">
<div class="track-label-mock"> <span
{lang === "fr" ? "Actions" : "Actions"} >{lang === "fr" ? "Temps Total" : "Total Time"}: <strong
</div> >17m</strong
<div class="track-content-mock"> ></span
<div >
class="time-block-mock passive-mock" <span
style="width: 26%; left: 0; top: 8px; border: none;" >{lang === "fr" ? " · Actif" : " · Active"}: <strong>7m</strong
> ></span
<span >
style="position: absolute; left: calc(100% + 10px); color: var(--sl-color-white); font-size: 0.85rem; font-weight: 600; white-space: nowrap;"
>Mise en place</span
>
</div>
<div
class="time-block-mock active-mock"
style="width: 26%; left: 52%; top: 44px;"
>
<span
style="position: absolute; left: calc(100% + 10px); color: var(--sl-color-white); font-size: 0.85rem; font-weight: 600; white-space: nowrap;"
>{lang === "fr" ? "Sauter" : "Sauté"}</span
>
</div>
<div
class="time-block-mock active-mock"
style="width: 10%; left: 78%; top: 80px;"
>
<span
style="position: absolute; left: calc(100% + 10px); color: var(--sl-color-white); font-size: 0.85rem; font-weight: 600; white-space: nowrap;"
>↳ {lang === "fr" ? "Mélanger" : "Toss"}</span
>
</div>
</div>
</div> </div>
<div class="gantt-track-mock"> <div class="gantt-tracks-container">
<div class="track-label-mock"> <div class="gantt-track-mock" style="height: 120px;">
{lang === "fr" ? "Ébullition" : "Boiling"} <div class="track-label-mock">
</div> {lang === "fr" ? "Actions" : "Actions"}
<div class="track-content-mock"> </div>
<div <div class="track-content-mock">
class="time-block-mock passive-mock" <div
style="width: 52%; left: 26%;" class="time-block-mock passive-mock"
> style="width: 26%; left: 0; top: 8px; border: none;"
<span class="block-label-mock">10m</span> >
<span
style="position: absolute; left: calc(100% + 10px); color: var(--sl-color-white); font-size: 0.85rem; font-weight: 600; white-space: nowrap;"
>Mise en place</span
>
</div>
<div
class="time-block-mock active-mock"
style="width: 26%; left: 52%; top: 44px;"
>
<span
style="position: absolute; left: calc(100% + 10px); color: var(--sl-color-white); font-size: 0.85rem; font-weight: 600; white-space: nowrap;"
>{lang === "fr" ? "Sauter" : "Sauté"}</span
>
</div>
<div
class="time-block-mock active-mock"
style="width: 10%; left: 78%; top: 80px;"
>
<span
style="position: absolute; left: calc(100% + 10px); color: var(--sl-color-white); font-size: 0.85rem; font-weight: 600; white-space: nowrap;"
>↳ {lang === "fr" ? "Mélanger" : "Toss"}</span
>
</div>
</div> </div>
</div> </div>
</div> <div class="gantt-track-mock">
<div <div class="track-label-mock">
class="gantt-track-mock" {lang === "fr" ? "Ébullition" : "Boiling"}
style="height: 36px; border-bottom: none;" </div>
> <div class="track-content-mock">
<div class="track-label-mock" style="border-right: none;"> <div
class="time-block-mock passive-mock"
style="width: 52%; left: 26%;"
>
<span class="block-label-mock">10m</span>
</div>
</div>
</div> </div>
<div class="track-content-mock" style="position: relative;"> <div
<div class="gantt-tick" style="left: 0%;">0m</div> class="gantt-track-mock"
<div class="gantt-tick" style="left: 26%;">5m</div> style="height: 36px; border-bottom: none;"
<div class="gantt-tick" style="left: 52%;">10m</div> >
<div class="gantt-tick" style="left: 78%;">15m</div> <div class="track-label-mock" style="border-right: none;">
<div class="gantt-tick" style="left: 88%;">17m</div> </div>
<div class="track-content-mock" style="position: relative;">
<div class="gantt-tick" style="left: 0%;">0m</div>
<div class="gantt-tick" style="left: 26%;">5m</div>
<div class="gantt-tick" style="left: 52%;">10m</div>
<div class="gantt-tick" style="left: 78%;">15m</div>
<div class="gantt-tick" style="left: 88%;">17m</div>
</div>
</div> </div>
</div> </div>
</div> </div>
@ -340,6 +358,7 @@ const mockBases = [
</summary> </summary>
<FeaturePanel <FeaturePanel
id="feature-modules" id="feature-modules"
title={t.tabModulesTitle}
desc={t.tabModulesDesc} desc={t.tabModulesDesc}
link={t.tabModulesLink} link={t.tabModulesLink}
learnMoreText={t.learnMore} learnMoreText={t.learnMore}
@ -348,7 +367,7 @@ const mockBases = [
gramLang={gramLang} gramLang={gramLang}
codeThemes={codeThemes} codeThemes={codeThemes}
> >
<div class="modern-mockup-card rendered-recipe-mock"> <div class="modern-mockup-card rendered-recipe-mock" role="region" aria-label={lang === "fr" ? "Recette modulaire assemblée" : "Composed modular recipe"}>
<!-- Section 1 : Base importée (inlinée et mise à l'échelle) --> <!-- Section 1 : Base importée (inlinée et mise à l'échelle) -->
<div class="rendered-section"> <div class="rendered-section">
<div class="rendered-section-header"> <div class="rendered-section-header">
@ -408,6 +427,7 @@ const mockBases = [
</summary> </summary>
<FeaturePanel <FeaturePanel
id="feature-scale" id="feature-scale"
title={t.tabScaleTitle}
desc={t.tabScaleDesc} desc={t.tabScaleDesc}
link={t.tabScaleLink} link={t.tabScaleLink}
learnMoreText={t.learnMore} learnMoreText={t.learnMore}
@ -416,44 +436,55 @@ const mockBases = [
gramLang={gramLang} gramLang={gramLang}
codeThemes={codeThemes} codeThemes={codeThemes}
> >
<div class="modern-mockup-card tabular-mockup"> <table class="modern-mockup-card tabular-mockup">
<div class="tab-row reference-row"> <caption class="sr-only">
<span class="tab-name" {lang === "fr" ? "Pourcentages du boulanger pour la recette" : "Baker's percentages for the recipe"}
><strong </caption>
>{lang === "fr" ? "Farine T65" : "Bread Flour"}</strong <thead>
> - 400g</span <tr class="sr-only">
> <th scope="col">{lang === "fr" ? "Ingrédient et poids" : "Ingredient and weight"}</th>
<span class="tab-val tab-val-ref">100%</span> <th scope="col">{lang === "fr" ? "Pourcentage" : "Percentage"}</th>
</div> </tr>
<div class="tab-row reference-row"> </thead>
<span class="tab-name" <tbody>
><strong <tr class="tab-row reference-row">
>{ <td class="tab-name"
lang === "fr" ? "Farine Complète" : "Whole Wheat" ><strong
}</strong >{lang === "fr" ? "Farine T65" : "Bread Flour"}</strong
> - 100g</span > - 400g</td
> >
<span class="tab-val">25%</span> <td class="tab-val tab-val-ref">100%</td>
</div> </tr>
<div class="tab-row"> <tr class="tab-row reference-row">
<span class="tab-name" <td class="tab-name"
><strong>{lang === "fr" ? "Eau" : "Water"}</strong> - 375g</span ><strong
> >{
<span class="tab-val">75%</span> lang === "fr" ? "Farine Complète" : "Whole Wheat"
</div> }</strong
<div class="tab-row"> > - 100g</td
<span class="tab-name" >
><strong>{lang === "fr" ? "Levain" : "Levain"}</strong> - 100g</span <td class="tab-val">25%</td>
> </tr>
<span class="tab-val">20%</span> <tr class="tab-row">
</div> <td class="tab-name"
<div class="tab-row"> ><strong>{lang === "fr" ? "Eau" : "Water"}</strong> - 375g</td
<span class="tab-name" >
><strong>{lang === "fr" ? "Sel" : "Salt"}</strong> - 10g</span <td class="tab-val">75%</td>
> </tr>
<span class="tab-val">2%</span> <tr class="tab-row">
</div> <td class="tab-name"
</div> ><strong>{lang === "fr" ? "Levain" : "Levain"}</strong> - 100g</td
>
<td class="tab-val">20%</td>
</tr>
<tr class="tab-row">
<td class="tab-name"
><strong>{lang === "fr" ? "Sel" : "Salt"}</strong> - 10g</td
>
<td class="tab-val">2%</td>
</tr>
</tbody>
</table>
</FeaturePanel> </FeaturePanel>
</details> </details>
</div> </div>
@ -484,7 +515,8 @@ const mockBases = [
href={lang === "fr" href={lang === "fr"
? "/fr/docs/explanation/philosophy" ? "/fr/docs/explanation/philosophy"
: "/docs/explanation/philosophy"} : "/docs/explanation/philosophy"}
class="link-btn">{t.readBookLink} &rarr;</a class="link-btn"
>{t.readBookLink}<span class="sr-only">: {t.readBookTitle}</span><span aria-hidden="true"> &rarr;</span></a
> >
</div> </div>
<div class="grid-item card"> <div class="grid-item card">
@ -493,7 +525,7 @@ const mockBases = [
{t.contributeDesc} {t.contributeDesc}
</p> </p>
<a href="https://git.gram-lang.org/gram-lang/gram" class="link-btn" <a href="https://git.gram-lang.org/gram-lang/gram" class="link-btn"
>{t.contributeLink} &rarr;</a >{t.contributeLink}<span class="sr-only">: {t.contributeTitle}</span><span aria-hidden="true"> &rarr;</span></a
> >
</div> </div>
</div> </div>
@ -514,15 +546,19 @@ const mockBases = [
> >
{t.tryDesc} {t.tryDesc}
</p> </p>
<div class="terminal-mini"> <div class="terminal-mini" role="region" aria-label={lang === "fr" ? "Commande d'initialisation CLI" : "CLI initialization command"}>
<code id="cli-init-cmd" <code id="cli-init-cmd"
><span class="prompt">$</span> npx @gram-lang/cli init</code ><span class="prompt" aria-hidden="true">$</span> npx @gram-lang/cli init</code
> >
<button <button
type="button"
class="copy-cmd-btn" class="copy-cmd-btn"
aria-label="Copy command" aria-label={lang === "fr" ? "Copier la commande d'initialisation dans le presse-papiers" : "Copy initialization command to clipboard"}
data-umami-event="copy-cli-init-command">Copy</button data-umami-event="copy-cli-init-command"
> >
<span class="copy-label" aria-hidden="true">Copy</span>
<span class="sr-only" aria-live="polite" id="copy-status"></span>
</button>
</div> </div>
</div> </div>
</section> </section>
@ -533,36 +569,76 @@ const mockBases = [
import { trackEvent } from "../lib/umami"; import { trackEvent } from "../lib/umami";
document.addEventListener("DOMContentLoaded", () => { document.addEventListener("DOMContentLoaded", () => {
// Preview/JSON Toggle Logic // Preview/JSON Toggle Logic with ARIA tabs and keyboard support
const featurePanels = document.querySelectorAll(".feature-panel"); const featurePanels = document.querySelectorAll<HTMLElement>(".feature-panel");
featurePanels.forEach((panel) => { featurePanels.forEach((panel) => {
const toggleBtns = panel.querySelectorAll(".pill-btn"); const toggleBtns = Array.from(panel.querySelectorAll<HTMLButtonElement>(".pill-btn"));
const viewContents = panel.querySelectorAll(".view-content"); const viewContents = Array.from(panel.querySelectorAll<HTMLElement>(".view-content"));
toggleBtns.forEach((btn) => { const switchTab = (btn: HTMLButtonElement) => {
btn.addEventListener("click", () => { const viewType = btn.getAttribute("data-view");
toggleBtns.forEach((b) => b.classList.remove("active")); toggleBtns.forEach((b) => {
viewContents.forEach((vc) => vc.classList.remove("active")); const isActive = b === btn;
b.classList.toggle("active", isActive);
b.setAttribute("aria-selected", isActive ? "true" : "false");
b.setAttribute("tabindex", isActive ? "0" : "-1");
});
btn.classList.add("active"); viewContents.forEach((vc) => {
const viewType = btn.getAttribute("data-view"); const isTarget = vc.classList.contains(`${viewType}-view`);
const targetView = panel.querySelector(`.${viewType}-view`); vc.classList.toggle("active", isTarget);
if (targetView) targetView.classList.add("active"); if (isTarget) {
trackEvent("homepage-feature-view", { feature: panel.id, view: viewType }); vc.removeAttribute("hidden");
} else {
vc.setAttribute("hidden", "");
}
});
trackEvent("homepage-feature-view", { feature: panel.id, view: viewType });
};
toggleBtns.forEach((btn, index) => {
btn.addEventListener("click", () => switchTab(btn));
btn.addEventListener("keydown", (e) => {
let targetIndex = -1;
if (e.key === "ArrowRight") {
targetIndex = (index + 1) % toggleBtns.length;
} else if (e.key === "ArrowLeft") {
targetIndex = (index - 1 + toggleBtns.length) % toggleBtns.length;
} else if (e.key === "Home") {
targetIndex = 0;
} else if (e.key === "End") {
targetIndex = toggleBtns.length - 1;
}
if (targetIndex !== -1) {
e.preventDefault();
toggleBtns[targetIndex].focus();
switchTab(toggleBtns[targetIndex]);
}
}); });
}); });
}); });
// Copy Command Logic // Copy Command Logic with Screen Reader feedback
const copyBtn = document.querySelector(".copy-cmd-btn") as HTMLElement; const copyBtn = document.querySelector<HTMLButtonElement>(".copy-cmd-btn");
if (copyBtn) { const copyLabel = copyBtn?.querySelector<HTMLElement>(".copy-label");
const defaultLabel = copyBtn.textContent; const copyStatus = document.getElementById("copy-status");
if (copyBtn && copyLabel) {
const defaultText = copyLabel.textContent || "Copy";
copyBtn.addEventListener("click", async () => { copyBtn.addEventListener("click", async () => {
try { try {
await navigator.clipboard.writeText("npx @gram-lang/cli init"); await navigator.clipboard.writeText("npx @gram-lang/cli init");
copyBtn.textContent = "Copied"; copyLabel.textContent = "Copied";
if (copyStatus) {
copyStatus.textContent = document.documentElement.lang === "fr"
? "Commande copiée dans le presse-papiers"
: "Command copied to clipboard";
}
setTimeout(() => { setTimeout(() => {
copyBtn.textContent = defaultLabel; copyLabel.textContent = defaultText;
if (copyStatus) copyStatus.textContent = "";
}, 2000); }, 2000);
} catch (err) { } catch (err) {
console.error("Failed to copy!", err); console.error("Failed to copy!", err);
@ -658,7 +734,11 @@ const mockBases = [
.version-badge a { .version-badge a {
font-size: 1.1rem; font-size: 1.1rem;
font-weight: 600; font-weight: 600;
color: var(--sl-color-text-accent); color: var(--sl-color-text);
text-decoration: underline;
text-decoration-color: var(--gram-orange);
text-decoration-thickness: 2px;
text-underline-offset: 3px;
} }
.title { .title {
@ -694,14 +774,17 @@ const mockBases = [
text-decoration: none; text-decoration: none;
font-weight: 600; font-weight: 600;
border: 1px solid transparent; border: 1px solid transparent;
transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
} }
.button.primary { .button.primary {
background-color: var(--sl-color-accent); background-color: var(--sl-color-accent);
color: var(--sl-color-white); color: #1a0d00;
font-weight: 700;
} }
.button.primary:hover { .button.primary:hover {
filter: brightness(1.1); background-color: var(--gram-orange-light, #ff952b);
color: #1a0d00;
} }
.button.secondary { .button.secondary {
@ -709,9 +792,16 @@ const mockBases = [
color: var(--sl-color-white); color: var(--sl-color-white);
border-color: var(--sl-color-border); border-color: var(--sl-color-border);
} }
:root[data-theme="light"] .button.secondary {
color: var(--sl-color-text);
}
.button.secondary:hover { .button.secondary:hover {
border-color: var(--sl-color-text-accent); border-color: var(--sl-color-accent);
background-color: var(--sl-color-bg-nav); background-color: var(--sl-color-bg-nav);
color: var(--sl-color-white);
}
:root[data-theme="light"] .button.secondary:hover {
color: var(--sl-color-text);
} }
/* Code Block Styling */ /* Code Block Styling */
@ -777,9 +867,13 @@ const mockBases = [
} }
.learn-more-link { .learn-more-link {
display: inline-block; display: inline-block;
color: var(--sl-color-text-accent);
font-weight: 600; font-weight: 600;
font-size: 1rem; font-size: 1rem;
color: var(--sl-color-text);
text-decoration: underline;
text-decoration-color: var(--gram-orange);
text-decoration-thickness: 2px;
text-underline-offset: 3px;
} }
.philosophy h3 { .philosophy h3 {
@ -813,14 +907,16 @@ const mockBases = [
} }
.link-btn { .link-btn {
display: inline-block; display: inline-block;
color: var(--sl-color-text-accent);
font-weight: 500; font-weight: 500;
margin-top: 1rem; margin-top: 1rem;
} color: var(--sl-color-text);
.link-btn:hover {
text-decoration: underline; text-decoration: underline;
text-decoration-color: var(--gram-orange);
text-decoration-thickness: 2px;
text-underline-offset: 3px;
} }
/* Mini terminal */ /* Mini terminal */
.terminal-mini { .terminal-mini {
background-color: var(--sl-color-bg); background-color: var(--sl-color-bg);
@ -964,7 +1060,7 @@ const mockBases = [
.nut-header-mock span { .nut-header-mock span {
font-size: 0.6em; font-size: 0.6em;
text-transform: uppercase; text-transform: uppercase;
background-color: var(--sl-color-gray-4); background-color: var(--sl-color-gray-3);
padding: 2px 6px; padding: 2px 6px;
font-weight: 700; font-weight: 700;
color: var(--sl-color-bg); color: var(--sl-color-bg);
@ -1011,7 +1107,7 @@ const mockBases = [
.nut-item-mock .label { .nut-item-mock .label {
font-size: 0.65em; font-size: 0.65em;
text-transform: uppercase; text-transform: uppercase;
color: var(--sl-color-text-accent); color: var(--sl-color-gray-3);
font-weight: 600; font-weight: 600;
} }
.nut-item-mock strong { .nut-item-mock strong {
@ -1139,15 +1235,17 @@ const mockBases = [
/* Tabular Mockup */ /* Tabular Mockup */
.tabular-mockup { .tabular-mockup {
display: flex; width: 100%;
flex-direction: column; border-collapse: collapse;
padding: 0; padding: 0;
text-align: left;
}
.tabular-mockup tbody {
display: table-row-group;
} }
.tab-row { .tab-row {
display: flex;
justify-content: space-between;
padding: 1rem 1.5rem;
border-bottom: 1px solid var(--sl-color-border); border-bottom: 1px solid var(--sl-color-border);
} }
@ -1155,6 +1253,11 @@ const mockBases = [
border-bottom: none; border-bottom: none;
} }
.tabular-mockup td {
padding: 1rem 1.5rem;
vertical-align: middle;
}
.reference-row { .reference-row {
background-color: var(--sl-color-bg); background-color: var(--sl-color-bg);
} }
@ -1167,6 +1270,7 @@ const mockBases = [
color: var(--sl-color-text-accent); color: var(--sl-color-text-accent);
font-family: var(--sl-font-mono); font-family: var(--sl-font-mono);
font-weight: bold; font-weight: bold;
text-align: right;
} }
.tab-val-ref { .tab-val-ref {
@ -1223,4 +1327,32 @@ const mockBases = [
#cli-init-cmd { #cli-init-cmd {
display: block; display: block;
} }
/* Accessibility: Focus visible and reduced motion */
.button:focus-visible,
.copy-cmd-btn:focus-visible,
.learn-more-link:focus-visible,
.link-btn:focus-visible,
.version-badge a:focus-visible {
outline: 2px solid var(--sl-color-accent);
outline-offset: 3px;
border-radius: 2px;
}
.feature-summary:focus-visible {
outline: 2px solid var(--sl-color-accent);
outline-offset: 4px;
border-radius: 4px;
}
@media (prefers-reduced-motion: reduce) {
*,
*::before,
*::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
scroll-behavior: auto !important;
}
}
</style> </style>

View file

@ -10,7 +10,7 @@ const t = {
resources: "Resources", resources: "Resources",
ecosystemTooling: "Ecosystem & Tooling", ecosystemTooling: "Ecosystem & Tooling",
community: "Community", community: "Community",
documentation: "Documentation", documentation: "Docs",
playground: "Playground", playground: "Playground",
blog: "Blog", blog: "Blog",
changelog: "Changelog", changelog: "Changelog",
@ -31,7 +31,7 @@ const t = {
resources: "Ressources", resources: "Ressources",
ecosystemTooling: "Écosystème & Outils", ecosystemTooling: "Écosystème & Outils",
community: "Communauté", community: "Communauté",
documentation: "Documentation", documentation: "Docs",
playground: "Playground", playground: "Playground",
blog: "Blog", blog: "Blog",
changelog: "Changelog", changelog: "Changelog",
@ -58,7 +58,7 @@ const prefix = currentLang === "fr" ? "/fr" : "";
<!-- Column 1: Brand --> <!-- Column 1: Brand -->
<div class="footer-col brand-col"> <div class="footer-col brand-col">
<a href={currentLang === "fr" ? "/fr/" : "/"} class="footer-logo"> <a href={currentLang === "fr" ? "/fr/" : "/"} class="footer-logo">
<img src="/logo.svg" alt="Gram Logo" /> <img src="/logo.svg" alt="Gram Logo" width="32" height="32" />
<span class="site-title">Gram</span> <span class="site-title">Gram</span>
</a> </a>
<p class="tagline">{langText.tagline}</p> <p class="tagline">{langText.tagline}</p>
@ -243,7 +243,8 @@ const prefix = currentLang === "fr" ? "/fr" : "";
} }
.brand-col img { .brand-col img {
height: 2.2rem; width: 32px;
height: 32px;
} }
.brand-col .tagline { .brand-col .tagline {

View file

@ -9,7 +9,7 @@ const changelogHref =
<div class="site-title sl-flex"> <div class="site-title sl-flex">
<a href="/" class="main-site-link">Gram</a> <a href="/" class="main-site-link">Gram</a>
<span class="separator">/</span> <span class="separator">/</span>
<a href={siteTitleHref} class="docs-site-link">Documentation</a> <a href={siteTitleHref} class="docs-site-link">Docs</a>
<a href={changelogHref} class="version-pill">v{GRAM_VERSION}</a> <a href={changelogHref} class="version-pill">v{GRAM_VERSION}</a>
</div> </div>
@ -36,7 +36,7 @@ const changelogHref =
color: var(--sl-color-accent-high); color: var(--sl-color-accent-high);
} }
:root[data-theme='light'] .docs-site-link { :root[data-theme='light'] .docs-site-link {
color: var(--sl-color-accent); color: var(--sl-color-accent-high);
} }
.docs-site-link:hover, .main-site-link:hover { .docs-site-link:hover, .main-site-link:hover {
opacity: 0.7; opacity: 0.7;

View file

@ -23,8 +23,10 @@ import type { HighlighterCore } from "shiki/core";
import { getHighlighter, SHIKI_THEMES } from "./shikiHighlighter"; import { getHighlighter, SHIKI_THEMES } from "./shikiHighlighter";
import { shikiHighlightExtension } from "./codemirror/shikiHighlightExtension"; import { shikiHighlightExtension } from "./codemirror/shikiHighlightExtension";
import { useI18n } from "./useI18n";
const isDark = inject<Ref<boolean>>("isDark")!; const isDark = inject<Ref<boolean>>("isDark")!;
const { t } = useI18n();
const props = defineProps<{ const props = defineProps<{
files: Map<string, string>; files: Map<string, string>;
@ -71,11 +73,19 @@ const editorTheme = EditorView.theme({
}, },
".cm-gutters": { ".cm-gutters": {
backgroundColor: "var(--sl-color-bg)", backgroundColor: "var(--sl-color-bg)",
color: "var(--sl-color-gray-4)", // gray-4 fails WCAG AA (2.65:1 dark / 3.19:1 light) against
// --sl-color-bg; gray-3 clears 4.5:1 in both themes.
color: "var(--sl-color-gray-3)",
border: "none", border: "none",
}, },
"&.cm-focused": { "&.cm-focused": {
// CodeMirror's default focus outline gets clipped by
// .editor-container's overflow: hidden, so it's replaced with an
// inset box-shadow ring to keep focus visible for keyboard users.
// accent-high (not accent) so the ring still clears the 3:1
// non-text contrast minimum in light mode (accent alone is 2.33:1).
outline: "none", outline: "none",
boxShadow: "inset 0 0 0 2px var(--sl-color-accent-high)",
}, },
}); });
@ -84,6 +94,9 @@ function makeExtensions(theme: string) {
lineNumbers(), lineNumbers(),
highlightActiveLine(), highlightActiveLine(),
EditorView.lineWrapping, EditorView.lineWrapping,
EditorView.contentAttributes.of({
"aria-label": t.value.playground.inputTab,
}),
history(), history(),
keymap.of([...defaultKeymap, ...historyKeymap, indentWithTab]), keymap.of([...defaultKeymap, ...historyKeymap, indentWithTab]),
editorTheme, editorTheme,

View file

@ -76,12 +76,14 @@ const primaryError = computed(() => {
text-align: center; text-align: center;
padding: 32px 24px; padding: 32px 24px;
border-radius: 12px; border-radius: 12px;
border: 1px solid rgba(239, 68, 68, 0.25); border: 1px solid var(--sl-color-red);
background-color: rgba(239, 68, 68, 0.03); background-color: var(--sl-color-red-low);
} }
.error-state-icon { .error-state-icon {
color: #ef4444; /* red-high, not the base red: the base red only clears 3:1 against
red-low in dark mode (4.80:1) but drops to 2.61:1 in light mode. */
color: var(--sl-color-red-high);
margin-bottom: 16px; margin-bottom: 16px;
} }
@ -118,8 +120,8 @@ const primaryError = computed(() => {
font-family: var(--sl-font-mono); font-family: var(--sl-font-mono);
font-size: 12px; font-size: 12px;
font-weight: 600; font-weight: 600;
color: #ef4444; color: var(--sl-color-red-high);
background-color: rgba(239, 68, 68, 0.1); background-color: var(--sl-color-bg);
padding: 2px 6px; padding: 2px 6px;
border-radius: 4px; border-radius: 4px;
} }
@ -150,19 +152,21 @@ const primaryError = computed(() => {
justify-content: center; justify-content: center;
gap: 8px; gap: 8px;
padding: 8px 16px; padding: 8px 16px;
background-color: #ef4444; background-color: var(--sl-color-red);
color: #ffffff; /* white text on --sl-color-red only reaches ~3.4:1 in either theme;
a fixed dark brown clears 4.5:1 against red's lightness in both. */
color: #1a1613;
font-size: 13px; font-size: 13px;
font-weight: 600; font-weight: 600;
border: none; border: none;
border-radius: 6px; border-radius: 6px;
cursor: pointer; cursor: pointer;
transition: background-color 0.2s; transition: filter 0.2s;
align-self: center; align-self: center;
margin-top: 4px; margin-top: 4px;
} }
.jump-button:hover { .jump-button:hover {
background-color: #dc2626; filter: brightness(0.9);
} }
</style> </style>

View file

@ -7,6 +7,7 @@ const props = defineProps<{
activeFile: string; activeFile: string;
entryFile: string; entryFile: string;
errorFiles: Set<string>; errorFiles: Set<string>;
editorPanelId?: string;
}>(); }>();
const emit = defineEmits<{ const emit = defineEmits<{
@ -24,17 +25,76 @@ function label(path: string): string {
return path.startsWith("/") ? path.slice(1) : path; return path.startsWith("/") ? path.slice(1) : path;
} }
// biome-ignore lint/correctness/noUnusedVariables: tabId is used in the <template> block below, which Biome's Vue support doesn't see.
function tabId(path: string): string {
return `file-tab-${path.replace(/[^a-zA-Z0-9_-]/g, "_")}`;
}
const renamingPath = ref<string | null>(null); const renamingPath = ref<string | null>(null);
const renameValue = ref(""); const renameValue = ref("");
const renameInput = ref<HTMLInputElement | null>(null); const renameInput = ref<HTMLInputElement | null>(null);
const tabRefs = ref<Map<string, HTMLElement>>(new Map());
// biome-ignore lint/correctness/noUnusedVariables: setRenameInputRef is used in the <template> block below, which Biome's Vue support doesn't see.
function setRenameInputRef(el: any) { function setRenameInputRef(el: any) {
if (el) { if (el) {
renameInput.value = el as HTMLInputElement; renameInput.value = el as HTMLInputElement;
} }
} }
// biome-ignore lint/correctness/noUnusedVariables: startRename is used in the <template> block below, which Biome's Vue support doesn't see. // biome-ignore lint/correctness/noUnusedVariables: setTabRef is used in the <template> block below, which Biome's Vue support doesn't see.
function setTabRef(path: string, el: unknown) {
if (el) tabRefs.value.set(path, el as HTMLElement);
else tabRefs.value.delete(path);
}
function focusAndSelectTab(path: string) {
emit("select", path);
nextTick(() => tabRefs.value.get(path)?.focus());
}
// biome-ignore lint/correctness/noUnusedVariables: onTabKeydown is used in the <template> block below, which Biome's Vue support doesn't see.
function onTabKeydown(e: KeyboardEvent, path: string) {
const idx = props.files.indexOf(path);
switch (e.key) {
case "ArrowRight":
e.preventDefault();
focusAndSelectTab(props.files[(idx + 1) % props.files.length]);
break;
case "ArrowLeft":
e.preventDefault();
focusAndSelectTab(
props.files[(idx - 1 + props.files.length) % props.files.length],
);
break;
case "Home":
e.preventDefault();
focusAndSelectTab(props.files[0]);
break;
case "End":
e.preventDefault();
focusAndSelectTab(props.files[props.files.length - 1]);
break;
case "Enter":
case " ":
e.preventDefault();
emit("select", path);
break;
case "F2":
e.preventDefault();
startRename(path);
break;
case "Delete":
case "Backspace":
if (path !== props.entryFile) {
e.preventDefault();
emit("remove", path);
nextTick(() => tabRefs.value.get(props.entryFile)?.focus());
}
break;
}
}
async function startRename(path: string) { async function startRename(path: string) {
renamingPath.value = path; renamingPath.value = path;
renameValue.value = label(path); renameValue.value = label(path);
@ -86,13 +146,23 @@ defineExpose({
<template> <template>
<div class="gram-file-tabs"> <div class="gram-file-tabs">
<div class="gram-file-tabs-list" role="tablist" :aria-label="t.playground.tabs.openFiles">
<div <div
v-for="path in files" v-for="path in files"
:key="path" :key="path"
:id="tabId(path)"
:ref="(el) => setTabRef(path, el)"
class="file-tab" class="file-tab"
:class="{ active: path === activeFile, 'has-error': errorFiles.has(path) }" :class="{ active: path === activeFile, 'has-error': errorFiles.has(path) }"
role="tab"
:aria-selected="path === activeFile"
:aria-label="errorFiles.has(path) ? `${label(path)} (${t.playground.tabs.hasErrors})` : label(path)"
:aria-controls="path === activeFile ? editorPanelId : undefined"
:aria-keyshortcuts="path === entryFile ? undefined : 'Delete'"
:tabindex="path === activeFile ? 0 : -1"
@click="emit('select', path)" @click="emit('select', path)"
@dblclick="startRename(path)" @dblclick="startRename(path)"
@keydown="onTabKeydown($event, path)"
> >
<input <input
v-if="renamingPath === path" v-if="renamingPath === path"
@ -102,6 +172,7 @@ defineExpose({
:aria-label="t.playground.tabs.newFileName" :aria-label="t.playground.tabs.newFileName"
@click.stop @click.stop
@dblclick.stop @dblclick.stop
@keydown.stop
@keydown.enter="commitRename(true)" @keydown.enter="commitRename(true)"
@keydown.escape="cancelRename(true)" @keydown.escape="cancelRename(true)"
@blur="commitRename(false)" @blur="commitRename(false)"
@ -119,8 +190,9 @@ defineExpose({
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" width="12" height="12" fill="currentColor"><path d="M205.66,194.34a8,8,0,0,1-11.32,11.32L128,139.31,61.66,205.66a8,8,0,0,1-11.32-11.32L116.69,128,50.34,61.66A8,8,0,0,1,61.66,50.34L128,116.69l66.34-66.35a8,8,0,0,1,11.32,11.32L139.31,128Z"></path></svg> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" width="12" height="12" fill="currentColor"><path d="M205.66,194.34a8,8,0,0,1-11.32,11.32L128,139.31,61.66,205.66a8,8,0,0,1-11.32-11.32L116.69,128,50.34,61.66A8,8,0,0,1,61.66,50.34L128,116.69l66.34-66.35a8,8,0,0,1,11.32,11.32L139.31,128Z"></path></svg>
</button> </button>
</div> </div>
</div>
<button class="file-tab-add" :title="t.playground.tabs.addFile" @click="emit('add')"> <button class="file-tab-add" :title="t.playground.tabs.addFile" :aria-label="t.playground.tabs.addFile" @click="emit('add')">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" width="14" height="14" fill="currentColor"><path d="M224,128a8,8,0,0,1-8,8H136v80a8,8,0,0,1-16,0V136H40a8,8,0,0,1,0-16h80V40a8,8,0,0,1,16,0v80h80A8,8,0,0,1,224,128Z"></path></svg> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" width="14" height="14" fill="currentColor"><path d="M224,128a8,8,0,0,1-8,8H136v80a8,8,0,0,1-16,0V136H40a8,8,0,0,1,0-16h80V40a8,8,0,0,1,16,0v80h80A8,8,0,0,1,224,128Z"></path></svg>
</button> </button>
</div> </div>
@ -132,8 +204,15 @@ defineExpose({
align-items: stretch; align-items: stretch;
background-color: var(--sl-color-gray-7); background-color: var(--sl-color-gray-7);
border-bottom: 1px solid var(--sl-color-border); border-bottom: 1px solid var(--sl-color-border);
overflow-x: auto;
flex-shrink: 0; flex-shrink: 0;
min-width: 0;
}
.gram-file-tabs-list {
display: flex;
align-items: stretch;
overflow-x: auto;
min-width: 0;
} }
.file-tab { .file-tab {
@ -159,18 +238,20 @@ defineExpose({
.file-tab.active { .file-tab.active {
color: var(--sl-color-text); color: var(--sl-color-text);
background-color: var(--sl-color-bg); background-color: var(--sl-color-bg);
/* accent-high: plain accent is only 2.33:1 on white, under the 3:1
non-text minimum for a state indicator in light mode. */
box-shadow: inset 0 -2px 0 var(--sl-color-accent); box-shadow: inset 0 -2px 0 var(--sl-color-accent);
} }
.file-tab.has-error .file-tab-label { .file-tab.has-error .file-tab-label {
color: #ef4444; color: var(--sl-color-red-high);
} }
.file-tab-error-dot { .file-tab-error-dot {
width: 6px; width: 6px;
height: 6px; height: 6px;
border-radius: 50%; border-radius: 50%;
background-color: #ef4444; background-color: var(--sl-color-red);
flex-shrink: 0; flex-shrink: 0;
} }
@ -178,7 +259,7 @@ defineExpose({
font: inherit; font: inherit;
color: inherit; color: inherit;
background-color: var(--sl-color-bg); background-color: var(--sl-color-bg);
border: 1px solid var(--sl-color-accent); border: 1px solid var(--sl-color-accent-high);
border-radius: 3px; border-radius: 3px;
padding: 1px 4px; padding: 1px 4px;
width: 16ch; width: 16ch;

View file

@ -410,7 +410,11 @@ function submitScale() {
.scale-apply-btn { .scale-apply-btn {
padding: 6px 12px; padding: 6px 12px;
background-color: var(--sl-color-accent); background-color: var(--sl-color-accent);
color: var(--sl-color-bg); /* --sl-color-bg text (white in light mode) is only 2.33:1 against
accent; a fixed dark brown clears 4.5:1 against accent in both
light and dark mode, where a theme token can't since accent's
lightness doesn't invert the way bg/text tokens do. */
color: #1a1613;
font-size: 13px; font-size: 13px;
font-weight: 600; font-weight: 600;
cursor: pointer; cursor: pointer;
@ -447,7 +451,9 @@ function submitScale() {
} }
.option-item:hover .option-name { .option-item:hover .option-name {
color: var(--sl-color-accent); /* orange-high, not accent: plain accent is 2.33:1 on white, well
under the 4.5:1 text minimum in light mode. */
color: var(--sl-color-orange-high);
} }
.child-option { .child-option {

View file

@ -1,5 +1,13 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref, computed, watch, nextTick, inject, type Ref } from "vue"; import {
ref,
computed,
watch,
nextTick,
inject,
defineAsyncComponent,
type Ref,
} from "vue";
import { useI18n } from "./useI18n"; import { useI18n } from "./useI18n";
import { getHighlighter, SHIKI_THEMES } from "./shikiHighlighter"; import { getHighlighter, SHIKI_THEMES } from "./shikiHighlighter";
@ -8,10 +16,13 @@ import type { PlaygroundDiagnostic } from "./diagnostics";
// biome-ignore lint/correctness/noUnusedImports: used as a component in the <template> block below // biome-ignore lint/correctness/noUnusedImports: used as a component in the <template> block below
import JsonNode from "./JsonNode.vue"; import JsonNode from "./JsonNode.vue";
// biome-ignore lint/correctness/noUnusedImports: used as a component in the <template> block below // biome-ignore lint/correctness/noUnusedImports: used as a component in the <template> block below
import GramGantt from "./GramGantt.vue";
// biome-ignore lint/correctness/noUnusedImports: used as a component in the <template> block below
import GramErrorState from "./GramErrorState.vue"; import GramErrorState from "./GramErrorState.vue";
// Only rendered when the user switches to the Gantt tab: load it on demand
// so its code doesn't inflate the initial GramPlayground bundle.
// biome-ignore lint/correctness/noUnusedVariables: used as a component in the <template> block below
const GramGantt = defineAsyncComponent(() => import("./GramGantt.vue"));
const props = defineProps<{ const props = defineProps<{
viewMode: "json" | "ast" | "markdown" | "json-tree" | "preview" | "gantt"; viewMode: "json" | "ast" | "markdown" | "json-tree" | "preview" | "gantt";
content: string; // JSON string, AST string, or Markdown string content: string; // JSON string, AST string, or Markdown string
@ -327,7 +338,8 @@ function handlePreviewClick(e: MouseEvent) {
align-items: center; align-items: center;
justify-content: center; justify-content: center;
height: 100%; height: 100%;
color: var(--sl-color-gray-4); /* gray-4 fails 4.5:1 in both themes against --sl-color-bg; gray-3 clears it. */
color: var(--sl-color-gray-3);
font-size: 14px; font-size: 14px;
} }

View file

@ -94,6 +94,12 @@ const entryFile = ref<string>(DEFAULT_ENTRY_URI);
const files = ref<Map<string, string>>(new Map([[DEFAULT_ENTRY_URI, ""]])); const files = ref<Map<string, string>>(new Map([[DEFAULT_ENTRY_URI, ""]]));
const activeFile = ref<string>(DEFAULT_ENTRY_URI); const activeFile = ref<string>(DEFAULT_ENTRY_URI);
const EDITOR_PANEL_ID = "editor-panel";
function tabId(path: string): string {
return `file-tab-${path.replace(/[^a-zA-Z0-9_-]/g, "_")}`;
}
const activeTabId = computed(() => tabId(activeFile.value));
const mobileTab = ref<"editor" | "preview">("editor"); const mobileTab = ref<"editor" | "preview">("editor");
const diagnostics = ref<PlaygroundDiagnostic[]>([]); const diagnostics = ref<PlaygroundDiagnostic[]>([]);
@ -685,6 +691,7 @@ onUnmounted(() => {
v-model="selectedExample" v-model="selectedExample"
:options="examples" :options="examples"
:placeholder="t.playground.loadExample" :placeholder="t.playground.loadExample"
:aria-label="t.playground.loadExample"
@change="loadExample" @change="loadExample"
/> />
</div> </div>
@ -757,13 +764,20 @@ onUnmounted(() => {
:active-file="activeFile" :active-file="activeFile"
:entry-file="entryFile" :entry-file="entryFile"
:error-files="errorFiles" :error-files="errorFiles"
:editor-panel-id="EDITOR_PANEL_ID"
@select="selectFile" @select="selectFile"
@add="addFile" @add="addFile"
@rename="renameFile" @rename="renameFile"
@remove="removeFile" @remove="removeFile"
@done-rename="handleDoneRename" @done-rename="handleDoneRename"
/> />
<div class="editor-wrapper"> <div
class="editor-wrapper"
:id="EDITOR_PANEL_ID"
role="tabpanel"
:aria-labelledby="activeTabId"
tabindex="-1"
>
<GramEditor <GramEditor
ref="editorRef" ref="editorRef"
:files="files" :files="files"
@ -799,6 +813,7 @@ onUnmounted(() => {
<PlaygroundDropdown <PlaygroundDropdown
v-model="viewMode" v-model="viewMode"
:options="viewModeOptions" :options="viewModeOptions"
:aria-label="t.playground.viewLabel"
class="header-view-selector" class="header-view-selector"
/> />
</div> </div>
@ -886,16 +901,22 @@ onUnmounted(() => {
background-color: var(--sl-color-gray-7); background-color: var(--sl-color-gray-7);
} }
/*
* The -high variants (not the flat hex values used previously) are the
* only reliable way to clear 4.5:1 text contrast against --sl-color-bg
* *and* the is-clickable:hover --sl-color-gray-7 background in both
* light and dark mode.
*/
.status-badge.valid { .status-badge.valid {
color: #008829; color: var(--sl-color-green-high);
} }
.status-badge.warning { .status-badge.warning {
color: #d97706; color: var(--sl-color-orange-high);
} }
.status-badge.invalid { .status-badge.invalid {
color: #ef4444; color: var(--sl-color-red-high);
} }
.toolbar-item { .toolbar-item {
@ -1028,11 +1049,11 @@ onUnmounted(() => {
} }
.mobile-tab-dot.dot-error { .mobile-tab-dot.dot-error {
background-color: #ef4444; background-color: var(--sl-color-red);
} }
.mobile-tab-dot.dot-warning { .mobile-tab-dot.dot-warning {
background-color: #f59e0b; background-color: var(--sl-color-orange);
} }
} }

View file

@ -281,37 +281,44 @@ const overallSeverity = computed<WarningSeverity>(() => {
height: 6px; height: 6px;
} }
/*
* Pills use the same -low/base/-high triad as the severity badges below:
* base for the dot (3:1 non-text minimum), -high for the label text
* (4.5:1), -low for the hover/active fill (verified to keep -high text
* at 4.5:1+ on top of it in both light and dark mode). The flat hex
* values previously here dropped as low as 3.19:1 in light mode.
*/
.pill-error { .pill-error {
color: #ef4444; color: var(--sl-color-red-high);
} }
.pill-error .pill-dot { .pill-error .pill-dot {
background-color: #ef4444; background-color: var(--sl-color-red);
} }
.pill-error:hover, .pill-error.active { .pill-error:hover, .pill-error.active {
background-color: rgba(239, 68, 68, 0.15); background-color: var(--sl-color-red-low);
border-color: rgba(239, 68, 68, 0.3); border-color: var(--sl-color-red);
} }
.pill-warning { .pill-warning {
color: #d97706; color: var(--sl-color-orange-high);
} }
.pill-warning .pill-dot { .pill-warning .pill-dot {
background-color: #f59e0b; background-color: var(--sl-color-orange);
} }
.pill-warning:hover, .pill-warning.active { .pill-warning:hover, .pill-warning.active {
background-color: rgba(245, 158, 11, 0.15); background-color: var(--sl-color-orange-low);
border-color: rgba(245, 158, 11, 0.3); border-color: var(--sl-color-orange);
} }
.pill-info { .pill-info {
color: #2563eb; color: var(--sl-color-blue-high);
} }
.pill-info .pill-dot { .pill-info .pill-dot {
background-color: #3b82f6; background-color: var(--sl-color-blue);
} }
.pill-info:hover, .pill-info.active { .pill-info:hover, .pill-info.active {
background-color: rgba(59, 130, 246, 0.15); background-color: var(--sl-color-blue-low);
border-color: rgba(59, 130, 246, 0.3); border-color: var(--sl-color-blue);
} }
.console-header-right { .console-header-right {
@ -377,13 +384,13 @@ const overallSeverity = computed<WarningSeverity>(() => {
} }
.diagnostic-item.item-error .diagnostic-icon { .diagnostic-item.item-error .diagnostic-icon {
color: #ef4444; color: var(--sl-color-red);
} }
.diagnostic-item.item-warning .diagnostic-icon { .diagnostic-item.item-warning .diagnostic-icon {
color: #f59e0b; color: var(--sl-color-orange);
} }
.diagnostic-item.item-info .diagnostic-icon { .diagnostic-item.item-info .diagnostic-icon {
color: #3b82f6; color: var(--sl-color-blue);
} }
.diagnostic-icon { .diagnostic-icon {
@ -414,16 +421,16 @@ const overallSeverity = computed<WarningSeverity>(() => {
} }
.severity-badge.badge-error { .severity-badge.badge-error {
background-color: rgba(239, 68, 68, 0.15); background-color: var(--sl-color-red-low);
color: #ef4444; color: var(--sl-color-red-high);
} }
.severity-badge.badge-warning { .severity-badge.badge-warning {
background-color: rgba(245, 158, 11, 0.15); background-color: var(--sl-color-orange-low);
color: #d97706; color: var(--sl-color-orange-high);
} }
.severity-badge.badge-info { .severity-badge.badge-info {
background-color: rgba(59, 130, 246, 0.15); background-color: var(--sl-color-blue-low);
color: #2563eb; color: var(--sl-color-blue-high);
} }
.diagnostic-code { .diagnostic-code {
@ -438,7 +445,8 @@ const overallSeverity = computed<WarningSeverity>(() => {
.diagnostic-uri { .diagnostic-uri {
font-size: 11px; font-size: 11px;
font-family: var(--sl-font-mono); font-family: var(--sl-font-mono);
color: var(--sl-color-gray-3); /* gray-3 on --sl-color-bg-inline-code is only 3.62:1 in dark mode; gray-2 clears 4.5:1 in both. */
color: var(--sl-color-gray-2);
background-color: var(--sl-color-bg-inline-code); background-color: var(--sl-color-bg-inline-code);
padding: 3px 5px; padding: 3px 5px;
} }

View file

@ -63,8 +63,16 @@ const count = computed(() => keys.value.length);
<!-- Objects and Arrays --> <!-- Objects and Arrays -->
<template v-else> <template v-else>
<div class="json-line json-header" @click.stop="toggle"> <div
<span class="json-toggle">{{ isExpanded ? '▼' : '▶' }}</span> class="json-line json-header"
role="button"
tabindex="0"
:aria-expanded="isExpanded"
@click.stop="toggle"
@keydown.enter.prevent="toggle"
@keydown.space.prevent="toggle"
>
<span class="json-toggle" aria-hidden="true">{{ isExpanded ? '▼' : '▶' }}</span>
<span v-if="name" class="json-key">"{{ name }}"</span> <span v-if="name" class="json-key">"{{ name }}"</span>
<span v-if="name" class="json-colon">: </span> <span v-if="name" class="json-colon">: </span>
<span :class="type === 'array' ? 'json-bracket' : 'json-brace'"> <span :class="type === 'array' ? 'json-bracket' : 'json-brace'">
@ -141,7 +149,8 @@ const count = computed(() => keys.value.length);
width: 14px; width: 14px;
text-align: center; text-align: center;
font-size: 10px; font-size: 10px;
color: var(--sl-color-gray-4); /* gray-4 fails 4.5:1 in both themes against --sl-color-bg; gray-3 clears it. */
color: var(--sl-color-gray-3);
margin-right: 4px; margin-right: 4px;
} }
@ -160,5 +169,5 @@ const count = computed(() => keys.value.length);
.json-brace { .json-brace {
color: var(--json-punct-color); color: var(--json-punct-color);
} }
.json-count { color: var(--sl-color-gray-4); font-style: italic; margin: 0 4px; } .json-count { color: var(--sl-color-gray-3); font-style: italic; margin: 0 4px; }
</style> </style>

View file

@ -1,10 +1,11 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref, onMounted, onUnmounted } from "vue"; import { ref, computed, onMounted, onUnmounted, useId } from "vue";
const _props = defineProps<{ const props = defineProps<{
modelValue: string; modelValue: string;
options: { label: string; value: string }[]; options: { label: string; value: string }[];
placeholder?: string; placeholder?: string;
ariaLabel: string;
}>(); }>();
const emit = defineEmits<{ const emit = defineEmits<{
@ -13,52 +14,148 @@ const emit = defineEmits<{
}>(); }>();
const isOpen = ref(false); const isOpen = ref(false);
const highlightedIndex = ref(-1);
const dropdownRef = ref<HTMLElement | null>(null); const dropdownRef = ref<HTMLElement | null>(null);
const triggerRef = ref<HTMLElement | null>(null);
const listboxId = useId();
function optionId(index: number): string {
return `${listboxId}-option-${index}`;
}
// biome-ignore lint/correctness/noUnusedVariables: activeDescendant is used in the <template> block below, which Biome's Vue support doesn't see.
const activeDescendant = computed(() =>
isOpen.value && highlightedIndex.value >= 0
? optionId(highlightedIndex.value)
: undefined,
);
function selectedIndex(): number {
return props.options.findIndex((o) => o.value === props.modelValue);
}
function openDropdown() {
isOpen.value = true;
const idx = selectedIndex();
highlightedIndex.value = idx >= 0 ? idx : 0;
}
function closeDropdown(focusTrigger = false) {
isOpen.value = false;
if (focusTrigger) triggerRef.value?.focus();
}
// biome-ignore lint/correctness/noUnusedVariables: toggle is used in the <template> block below, which Biome's Vue support doesn't see. // biome-ignore lint/correctness/noUnusedVariables: toggle is used in the <template> block below, which Biome's Vue support doesn't see.
function toggle() { function toggle() {
isOpen.value = !isOpen.value; if (isOpen.value) closeDropdown();
else openDropdown();
} }
// biome-ignore lint/correctness/noUnusedVariables: selectOption is used in the <template> block below, which Biome's Vue support doesn't see.
function selectOption(value: string) { function selectOption(value: string) {
emit("update:modelValue", value); emit("update:modelValue", value);
emit("change", value); emit("change", value);
isOpen.value = false; closeDropdown(true);
} }
function closeDropdown(e: MouseEvent) { // biome-ignore lint/correctness/noUnusedVariables: onTriggerKeydown is used in the <template> block below, which Biome's Vue support doesn't see.
function onTriggerKeydown(e: KeyboardEvent) {
switch (e.key) {
case "ArrowDown":
e.preventDefault();
if (!isOpen.value) openDropdown();
else
highlightedIndex.value = Math.min(
highlightedIndex.value + 1,
props.options.length - 1,
);
break;
case "ArrowUp":
e.preventDefault();
if (!isOpen.value) openDropdown();
else highlightedIndex.value = Math.max(highlightedIndex.value - 1, 0);
break;
case "Home":
if (isOpen.value) {
e.preventDefault();
highlightedIndex.value = 0;
}
break;
case "End":
if (isOpen.value) {
e.preventDefault();
highlightedIndex.value = props.options.length - 1;
}
break;
case "Enter":
case " ":
e.preventDefault();
if (isOpen.value && highlightedIndex.value >= 0) {
selectOption(props.options[highlightedIndex.value].value);
} else if (!isOpen.value) {
openDropdown();
}
break;
case "Escape":
if (isOpen.value) {
e.preventDefault();
closeDropdown();
}
break;
case "Tab":
isOpen.value = false;
break;
}
}
function onOutsideClick(e: MouseEvent) {
if (dropdownRef.value && !dropdownRef.value.contains(e.target as Node)) { if (dropdownRef.value && !dropdownRef.value.contains(e.target as Node)) {
isOpen.value = false; isOpen.value = false;
} }
} }
onMounted(() => { onMounted(() => {
document.addEventListener("click", closeDropdown); document.addEventListener("click", onOutsideClick);
}); });
onUnmounted(() => { onUnmounted(() => {
document.removeEventListener("click", closeDropdown); document.removeEventListener("click", onOutsideClick);
}); });
</script> </script>
<template> <template>
<div class="custom-dropdown" ref="dropdownRef"> <div class="custom-dropdown" ref="dropdownRef">
<div class="dropdown-header" @click="toggle" :class="{ 'is-open': isOpen }"> <div
class="dropdown-header"
ref="triggerRef"
role="combobox"
tabindex="0"
:aria-label="ariaLabel"
aria-haspopup="listbox"
:aria-expanded="isOpen"
:aria-controls="listboxId"
:aria-activedescendant="activeDescendant"
:class="{ 'is-open': isOpen }"
@click="toggle"
@keydown="onTriggerKeydown"
>
<span class="dropdown-label"> <span class="dropdown-label">
{{ options.find(o => o.value === modelValue)?.label || placeholder }} {{ options.find(o => o.value === modelValue)?.label || placeholder }}
</span> </span>
<svg class="dropdown-icon" xmlns="http://www.w3.org/2000/svg" width="26" height="26" fill="currentColor" viewBox="0 0 24 24"> <svg class="dropdown-icon" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="26" height="26" fill="currentColor" viewBox="0 0 24 24">
<path d="M12 15.0006L7.75732 10.758L9.17154 9.34375L12 12.1722L14.8284 9.34375L16.2426 10.758L12 15.0006Z"></path> <path d="M12 15.0006L7.75732 10.758L9.17154 9.34375L12 12.1722L14.8284 9.34375L16.2426 10.758L12 15.0006Z"></path>
</svg> </svg>
</div> </div>
<div v-show="isOpen" class="dropdown-menu"> <div v-show="isOpen" class="dropdown-menu" role="listbox" :id="listboxId">
<div <div
v-for="opt in options" v-for="(opt, index) in options"
:key="opt.value" :key="opt.value"
:id="optionId(index)"
class="dropdown-item" class="dropdown-item"
:class="{ active: opt.value === modelValue }" role="option"
:aria-selected="opt.value === modelValue"
:class="{ active: opt.value === modelValue, highlighted: index === highlightedIndex }"
@mousemove="highlightedIndex = index"
@click="selectOption(opt.value)" @click="selectOption(opt.value)"
> >
{{ opt.label }} {{ opt.label }}
@ -144,7 +241,8 @@ onUnmounted(() => {
white-space: nowrap; white-space: nowrap;
} }
.dropdown-item:hover { .dropdown-item:hover,
.dropdown-item.highlighted {
background-color: var(--sl-color-gray-7); background-color: var(--sl-color-gray-7);
} }

View file

@ -8,6 +8,30 @@ export const SHIKI_THEMES = {
dark: "github-dark", dark: "github-dark",
} as const; } as const;
// github-dark's comment token (#6a737d) only clears ~3:1 against our dark
// background, under the 4.5:1 text minimum. Swapping to the high-contrast
// theme variant fixed that but also recolors `entity.name` (ingredients)
// from purple to orange, breaking the purple used to match the HTML
// preview — so instead this patches just the comment rule's foreground,
// reusing github-dark-high-contrast's own comment color (AAA on our bg),
// and leaves every other scope from github-dark untouched.
const DARK_COMMENT_COLOR = "#bdc4cc";
async function accessibleGithubDark() {
const { default: theme } = await import("shiki/themes/github-dark.mjs");
return {
...theme,
tokenColors: theme.tokenColors?.map((rule) =>
Array.isArray(rule.scope) && rule.scope.includes("comment")
? {
...rule,
settings: { ...rule.settings, foreground: DARK_COMMENT_COLOR },
}
: rule,
),
};
}
let highlighterPromise: Promise<HighlighterCore> | undefined; let highlighterPromise: Promise<HighlighterCore> | undefined;
// Shared singleton: the same highlighter instance backs both the // Shared singleton: the same highlighter instance backs both the
@ -16,10 +40,7 @@ let highlighterPromise: Promise<HighlighterCore> | undefined;
export function getHighlighter(): Promise<HighlighterCore> { export function getHighlighter(): Promise<HighlighterCore> {
if (!highlighterPromise) { if (!highlighterPromise) {
highlighterPromise = createHighlighterCore({ highlighterPromise = createHighlighterCore({
themes: [ themes: [import("shiki/themes/github-light.mjs"), accessibleGithubDark()],
import("shiki/themes/github-light.mjs"),
import("shiki/themes/github-dark.mjs"),
],
langs: [ langs: [
{ ...gramGrammar, name: "gram" } as any, { ...gramGrammar, name: "gram" } as any,
import("shiki/langs/json.mjs"), import("shiki/langs/json.mjs"),

View file

@ -24,5 +24,15 @@ import GramPlayground from "../../components/playground/GramPlayground.vue";
flex: 1; flex: 1;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
/* Reserve the space GramPlayground.vue's .playground-workspace takes once
hydrated, so the client:only island doesn't collapse to 0 height and
shift the footer down when it mounts. */
min-height: calc(100vh - 60px);
}
@media (max-width: 767px) {
.playground-wrapper {
min-height: calc(100dvh + 30px);
}
} }
</style> </style>

View file

@ -24,5 +24,15 @@ import GramPlayground from "../components/playground/GramPlayground.vue";
flex: 1; flex: 1;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
/* Reserve the space GramPlayground.vue's .playground-workspace takes once
hydrated, so the client:only island doesn't collapse to 0 height and
shift the footer down when it mounts. */
min-height: calc(100vh - 60px);
}
@media (max-width: 767px) {
.playground-wrapper {
min-height: calc(100dvh + 30px);
}
} }
</style> </style>

View file

@ -436,3 +436,15 @@ div[data-nova-code-container] > div:first-child:not(pre) {
letter-spacing: 0.02em !important; letter-spacing: 0.02em !important;
background-color: transparent !important; background-color: transparent !important;
} }
.sl-markdown-content a:not(:where(.not-content *)) {
color: var(--sl-color-text);
text-decoration: underline;
text-decoration-color: var(--gram-orange);
text-decoration-thickness: 2px;
text-underline-offset: 3px;
}
.sl-markdown-content a:not(:where(.not-content *)):hover {
color: var(--sl-color-accent);
}

Some files were not shown because too many files have changed in this diff Show more