feat/website-optimisation-accessibility #21
22 changed files with 757 additions and 266 deletions
6
bun.lock
6
bun.lock
|
|
@ -20,7 +20,7 @@
|
|||
},
|
||||
"audit": {
|
||||
"name": "@gram-lang/audit",
|
||||
"version": "1.1.1",
|
||||
"version": "1.2.0",
|
||||
"dependencies": {
|
||||
"@gram-lang/analyzer": "workspace:*",
|
||||
"@gram-lang/format": "workspace:*",
|
||||
|
|
@ -97,7 +97,7 @@
|
|||
},
|
||||
"packages/docs": {
|
||||
"name": "@gram-lang/docs",
|
||||
"version": "1.1.1",
|
||||
"version": "1.2.0",
|
||||
"dependencies": {
|
||||
"@astrojs/markdown-remark": "^7.2.2",
|
||||
"@astrojs/mdx": "^7.0.5",
|
||||
|
|
@ -198,7 +198,7 @@
|
|||
},
|
||||
"packages/vscode-extension": {
|
||||
"name": "gram-lang",
|
||||
"version": "1.1.1",
|
||||
"version": "1.2.0",
|
||||
"dependencies": {
|
||||
"@gram-lang/language-server": "workspace:*",
|
||||
"@gram-lang/renderer": "workspace:*",
|
||||
|
|
|
|||
|
|
@ -116,13 +116,15 @@ const topicHref = `${basePath}/topic/${getTopicSlug(post.data.topic)}`;
|
|||
}
|
||||
|
||||
.post-content :global(a) {
|
||||
color: var(--sl-color-accent);
|
||||
color: var(--sl-color-text);
|
||||
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) {
|
||||
color: var(--sl-color-accent-high);
|
||||
color: var(--sl-color-accent);
|
||||
}
|
||||
|
||||
.post-content :global(ul),
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import Icon from "./Icon.astro";
|
|||
|
||||
interface Props {
|
||||
id: string;
|
||||
title?: string;
|
||||
desc: string;
|
||||
link: string;
|
||||
learnMoreText: string;
|
||||
|
|
@ -15,6 +16,7 @@ interface Props {
|
|||
|
||||
const {
|
||||
id,
|
||||
title,
|
||||
desc,
|
||||
link,
|
||||
learnMoreText,
|
||||
|
|
@ -29,36 +31,65 @@ const {
|
|||
<p class="feature-desc">
|
||||
{desc}
|
||||
<a href={link} class="learn-more-link" style="margin-left: 0.5rem;">
|
||||
{learnMoreText} →
|
||||
{learnMoreText}{title && <span class="sr-only">: {title}</span>}<span aria-hidden="true"> →</span>
|
||||
</a>
|
||||
</p>
|
||||
<div class="feature-columns">
|
||||
<div class="col-input">
|
||||
<div class="code-block">
|
||||
<div class="code-block" role="region" aria-label="input.gram">
|
||||
<div class="code-header">
|
||||
<span class="filename">input.gram</span>
|
||||
</div>
|
||||
<Code code={inputCode} lang={gramLang} themes={codeThemes} />
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-arrow">
|
||||
<div class="col-arrow" aria-hidden="true">
|
||||
<Icon name="right-arrow" class="arrow-icon" />
|
||||
</div>
|
||||
<div class="col-output">
|
||||
<div class="modern-output-pane">
|
||||
<div class="output-header">
|
||||
<div class="view-toggles pill-toggles">
|
||||
<button class="pill-btn active" data-view="preview"
|
||||
>Preview</button
|
||||
>
|
||||
<button class="pill-btn" data-view="json">JSON</button>
|
||||
<div class="view-toggles pill-toggles" role="tablist" aria-label="Output format">
|
||||
<button
|
||||
type="button"
|
||||
role="tab"
|
||||
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 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 />
|
||||
</div>
|
||||
<div class="view-content json-view">
|
||||
<div class="code-block json-block">
|
||||
<div
|
||||
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={outputCode}
|
||||
lang="json"
|
||||
|
|
@ -159,8 +190,18 @@ const {
|
|||
|
||||
.learn-more-link {
|
||||
display: inline-block;
|
||||
color: var(--sl-color-text-accent);
|
||||
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 */
|
||||
|
|
@ -203,8 +244,14 @@ const {
|
|||
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 {
|
||||
color: var(--sl-color-text-accent);
|
||||
color: var(--sl-color-text);
|
||||
border-bottom-color: var(--sl-color-text-accent);
|
||||
}
|
||||
|
||||
|
|
@ -214,7 +261,7 @@ const {
|
|||
background-color: var(--sl-color-bg);
|
||||
}
|
||||
|
||||
.view-content.active {
|
||||
.view-content:not([hidden]).active {
|
||||
display: block;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ const { currentLang = "en" } = Astro.props;
|
|||
<a
|
||||
href={currentLang === "fr"
|
||||
? "/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/blog" : "/blog"}>Blog</a>
|
||||
|
|
@ -79,7 +79,7 @@ const { currentLang = "en" } = Astro.props;
|
|||
<a
|
||||
href={currentLang === "fr"
|
||||
? "/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/blog" : "/blog"}>Blog</a>
|
||||
|
|
|
|||
|
|
@ -47,11 +47,11 @@ const mockBases = [
|
|||
|
||||
<Layout title="Gram" description={t.metaDescription} currentLang={lang}>
|
||||
<!-- Hero Section -->
|
||||
<section class="section hero">
|
||||
<section class="section hero" aria-labelledby="hero-heading">
|
||||
<div class="homepage-container">
|
||||
<div class="hero-layout">
|
||||
<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="description">
|
||||
{t.heroDescription}
|
||||
|
|
@ -78,7 +78,7 @@ const mockBases = [
|
|||
</div>
|
||||
|
||||
<div class="hero-code">
|
||||
<div class="code-block">
|
||||
<div class="code-block" role="region" aria-label={t.recipeFileName || "recipe.gram"}>
|
||||
<div class="code-header">
|
||||
<span class="filename">{t.recipeFileName || "recipe.gram"}</span>
|
||||
</div>
|
||||
|
|
@ -116,7 +116,9 @@ const mockBases = [
|
|||
<p>{item.details}</p>
|
||||
{item.link && (
|
||||
<a href={item.link} class="learn-more-link">
|
||||
{t.learnMore} →
|
||||
{t.learnMore}
|
||||
<span class="sr-only">: {item.title}</span>
|
||||
<span aria-hidden="true"> →</span>
|
||||
</a>
|
||||
)}
|
||||
</div>
|
||||
|
|
@ -145,6 +147,7 @@ const mockBases = [
|
|||
</summary>
|
||||
<FeaturePanel
|
||||
id="feature-nutrition"
|
||||
title={t.tabNutritionTitle}
|
||||
desc={t.tabNutritionDesc}
|
||||
link={t.tabNutritionLink}
|
||||
learnMoreText={t.learnMore}
|
||||
|
|
@ -153,9 +156,9 @@ const mockBases = [
|
|||
gramLang={gramLang}
|
||||
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">
|
||||
<ol class="gram-steps">
|
||||
<ol class="gram-steps" aria-label={lang === "fr" ? "Étapes de la recette Chantilly" : "Chantilly recipe steps"}>
|
||||
<li>
|
||||
<span class="action"
|
||||
>{lang === "fr" ? "Fouetter" : "Whisk"}</span
|
||||
|
|
@ -195,15 +198,18 @@ const mockBases = [
|
|||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
<div class="nut-panel-mock">
|
||||
<div class="nut-panel-mock" role="group" aria-label={nutritionDict.renderer.nutrition}>
|
||||
<div class="nut-header-mock">
|
||||
{nutritionDict.renderer.nutrition}
|
||||
<span>{nutritionDict.renderer.estimateTooltip}</span>
|
||||
</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) => (
|
||||
<span class:list={["pill", { active: basis.active }]}>
|
||||
<span
|
||||
class:list={["pill", { active: basis.active }]}
|
||||
aria-current={basis.active ? "true" : undefined}
|
||||
>
|
||||
{basis.label}
|
||||
</span>
|
||||
))
|
||||
|
|
@ -219,7 +225,7 @@ const mockBases = [
|
|||
<span class="unit">{group.unit}</span>
|
||||
</strong>
|
||||
{group.children.length > 0 && (
|
||||
<ul class="nut-item-children">
|
||||
<ul class="nut-item-children" aria-label={group.label}>
|
||||
{group.children.map((child) => (
|
||||
<li>
|
||||
<span class="label">{child.label}</span>
|
||||
|
|
@ -246,6 +252,7 @@ const mockBases = [
|
|||
</summary>
|
||||
<FeaturePanel
|
||||
id="feature-schedule"
|
||||
title={t.tabScheduleTitle}
|
||||
desc={t.tabScheduleDesc}
|
||||
link={t.tabScheduleLink}
|
||||
learnMoreText={t.learnMore}
|
||||
|
|
@ -254,78 +261,89 @@ const mockBases = [
|
|||
gramLang={gramLang}
|
||||
codeThemes={codeThemes}
|
||||
>
|
||||
<div class="modern-mockup-card timeline-mockup-card">
|
||||
<div class="gantt-header-mock">
|
||||
<span
|
||||
>{lang === "fr" ? "Temps Total" : "Total Time"}: <strong
|
||||
>17m</strong
|
||||
></span
|
||||
>
|
||||
<span
|
||||
>{lang === "fr" ? " · Actif" : " · Active"}: <strong>7m</strong
|
||||
></span
|
||||
>
|
||||
<div
|
||||
class="modern-mockup-card timeline-mockup-card"
|
||||
role="region"
|
||||
aria-label={lang === "fr" ? "Aperçu de la planification et du rétro-planning" : "Schedule and timeline preview"}
|
||||
>
|
||||
<div class="sr-only">
|
||||
{lang === "fr"
|
||||
? "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."
|
||||
: "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."}
|
||||
</div>
|
||||
<div class="gantt-tracks-container">
|
||||
<div class="gantt-track-mock" style="height: 120px;">
|
||||
<div class="track-label-mock">
|
||||
{lang === "fr" ? "Actions" : "Actions"}
|
||||
</div>
|
||||
<div class="track-content-mock">
|
||||
<div
|
||||
class="time-block-mock passive-mock"
|
||||
style="width: 26%; left: 0; top: 8px; border: none;"
|
||||
>
|
||||
<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 aria-hidden="true">
|
||||
<div class="gantt-header-mock">
|
||||
<span
|
||||
>{lang === "fr" ? "Temps Total" : "Total Time"}: <strong
|
||||
>17m</strong
|
||||
></span
|
||||
>
|
||||
<span
|
||||
>{lang === "fr" ? " · Actif" : " · Active"}: <strong>7m</strong
|
||||
></span
|
||||
>
|
||||
</div>
|
||||
<div class="gantt-track-mock">
|
||||
<div class="track-label-mock">
|
||||
{lang === "fr" ? "Ébullition" : "Boiling"}
|
||||
</div>
|
||||
<div class="track-content-mock">
|
||||
<div
|
||||
class="time-block-mock passive-mock"
|
||||
style="width: 52%; left: 26%;"
|
||||
>
|
||||
<span class="block-label-mock">10m</span>
|
||||
<div class="gantt-tracks-container">
|
||||
<div class="gantt-track-mock" style="height: 120px;">
|
||||
<div class="track-label-mock">
|
||||
{lang === "fr" ? "Actions" : "Actions"}
|
||||
</div>
|
||||
<div class="track-content-mock">
|
||||
<div
|
||||
class="time-block-mock passive-mock"
|
||||
style="width: 26%; left: 0; top: 8px; border: none;"
|
||||
>
|
||||
<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"
|
||||
style="height: 36px; border-bottom: none;"
|
||||
>
|
||||
<div class="track-label-mock" style="border-right: none;">
|
||||
<div class="gantt-track-mock">
|
||||
<div class="track-label-mock">
|
||||
{lang === "fr" ? "Ébullition" : "Boiling"}
|
||||
</div>
|
||||
<div class="track-content-mock">
|
||||
<div
|
||||
class="time-block-mock passive-mock"
|
||||
style="width: 52%; left: 26%;"
|
||||
>
|
||||
<span class="block-label-mock">10m</span>
|
||||
</div>
|
||||
</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
|
||||
class="gantt-track-mock"
|
||||
style="height: 36px; border-bottom: none;"
|
||||
>
|
||||
<div class="track-label-mock" style="border-right: none;">
|
||||
</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>
|
||||
|
|
@ -340,6 +358,7 @@ const mockBases = [
|
|||
</summary>
|
||||
<FeaturePanel
|
||||
id="feature-modules"
|
||||
title={t.tabModulesTitle}
|
||||
desc={t.tabModulesDesc}
|
||||
link={t.tabModulesLink}
|
||||
learnMoreText={t.learnMore}
|
||||
|
|
@ -348,7 +367,7 @@ const mockBases = [
|
|||
gramLang={gramLang}
|
||||
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) -->
|
||||
<div class="rendered-section">
|
||||
<div class="rendered-section-header">
|
||||
|
|
@ -408,6 +427,7 @@ const mockBases = [
|
|||
</summary>
|
||||
<FeaturePanel
|
||||
id="feature-scale"
|
||||
title={t.tabScaleTitle}
|
||||
desc={t.tabScaleDesc}
|
||||
link={t.tabScaleLink}
|
||||
learnMoreText={t.learnMore}
|
||||
|
|
@ -416,44 +436,55 @@ const mockBases = [
|
|||
gramLang={gramLang}
|
||||
codeThemes={codeThemes}
|
||||
>
|
||||
<div class="modern-mockup-card tabular-mockup">
|
||||
<div class="tab-row reference-row">
|
||||
<span class="tab-name"
|
||||
><strong
|
||||
>{lang === "fr" ? "Farine T65" : "Bread Flour"}</strong
|
||||
> - 400g</span
|
||||
>
|
||||
<span class="tab-val tab-val-ref">100%</span>
|
||||
</div>
|
||||
<div class="tab-row reference-row">
|
||||
<span class="tab-name"
|
||||
><strong
|
||||
>{
|
||||
lang === "fr" ? "Farine Complète" : "Whole Wheat"
|
||||
}</strong
|
||||
> - 100g</span
|
||||
>
|
||||
<span class="tab-val">25%</span>
|
||||
</div>
|
||||
<div class="tab-row">
|
||||
<span class="tab-name"
|
||||
><strong>{lang === "fr" ? "Eau" : "Water"}</strong> - 375g</span
|
||||
>
|
||||
<span class="tab-val">75%</span>
|
||||
</div>
|
||||
<div class="tab-row">
|
||||
<span class="tab-name"
|
||||
><strong>{lang === "fr" ? "Levain" : "Levain"}</strong> - 100g</span
|
||||
>
|
||||
<span class="tab-val">20%</span>
|
||||
</div>
|
||||
<div class="tab-row">
|
||||
<span class="tab-name"
|
||||
><strong>{lang === "fr" ? "Sel" : "Salt"}</strong> - 10g</span
|
||||
>
|
||||
<span class="tab-val">2%</span>
|
||||
</div>
|
||||
</div>
|
||||
<table class="modern-mockup-card tabular-mockup">
|
||||
<caption class="sr-only">
|
||||
{lang === "fr" ? "Pourcentages du boulanger pour la recette" : "Baker's percentages for the recipe"}
|
||||
</caption>
|
||||
<thead>
|
||||
<tr class="sr-only">
|
||||
<th scope="col">{lang === "fr" ? "Ingrédient et poids" : "Ingredient and weight"}</th>
|
||||
<th scope="col">{lang === "fr" ? "Pourcentage" : "Percentage"}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr class="tab-row reference-row">
|
||||
<td class="tab-name"
|
||||
><strong
|
||||
>{lang === "fr" ? "Farine T65" : "Bread Flour"}</strong
|
||||
> - 400g</td
|
||||
>
|
||||
<td class="tab-val tab-val-ref">100%</td>
|
||||
</tr>
|
||||
<tr class="tab-row reference-row">
|
||||
<td class="tab-name"
|
||||
><strong
|
||||
>{
|
||||
lang === "fr" ? "Farine Complète" : "Whole Wheat"
|
||||
}</strong
|
||||
> - 100g</td
|
||||
>
|
||||
<td class="tab-val">25%</td>
|
||||
</tr>
|
||||
<tr class="tab-row">
|
||||
<td class="tab-name"
|
||||
><strong>{lang === "fr" ? "Eau" : "Water"}</strong> - 375g</td
|
||||
>
|
||||
<td class="tab-val">75%</td>
|
||||
</tr>
|
||||
<tr class="tab-row">
|
||||
<td class="tab-name"
|
||||
><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>
|
||||
</details>
|
||||
</div>
|
||||
|
|
@ -484,7 +515,8 @@ const mockBases = [
|
|||
href={lang === "fr"
|
||||
? "/fr/docs/explanation/philosophy"
|
||||
: "/docs/explanation/philosophy"}
|
||||
class="link-btn">{t.readBookLink} →</a
|
||||
class="link-btn"
|
||||
>{t.readBookLink}<span class="sr-only">: {t.readBookTitle}</span><span aria-hidden="true"> →</span></a
|
||||
>
|
||||
</div>
|
||||
<div class="grid-item card">
|
||||
|
|
@ -493,7 +525,7 @@ const mockBases = [
|
|||
{t.contributeDesc}
|
||||
</p>
|
||||
<a href="https://git.gram-lang.org/gram-lang/gram" class="link-btn"
|
||||
>{t.contributeLink} →</a
|
||||
>{t.contributeLink}<span class="sr-only">: {t.contributeTitle}</span><span aria-hidden="true"> →</span></a
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -514,15 +546,19 @@ const mockBases = [
|
|||
>
|
||||
{t.tryDesc}
|
||||
</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"
|
||||
><span class="prompt">$</span> npx @gram-lang/cli init</code
|
||||
><span class="prompt" aria-hidden="true">$</span> npx @gram-lang/cli init</code
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
class="copy-cmd-btn"
|
||||
aria-label="Copy command"
|
||||
data-umami-event="copy-cli-init-command">Copy</button
|
||||
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"
|
||||
>
|
||||
<span class="copy-label" aria-hidden="true">Copy</span>
|
||||
<span class="sr-only" aria-live="polite" id="copy-status"></span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
|
@ -533,36 +569,76 @@ const mockBases = [
|
|||
import { trackEvent } from "../lib/umami";
|
||||
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
// Preview/JSON Toggle Logic
|
||||
const featurePanels = document.querySelectorAll(".feature-panel");
|
||||
// Preview/JSON Toggle Logic with ARIA tabs and keyboard support
|
||||
const featurePanels = document.querySelectorAll<HTMLElement>(".feature-panel");
|
||||
featurePanels.forEach((panel) => {
|
||||
const toggleBtns = panel.querySelectorAll(".pill-btn");
|
||||
const viewContents = panel.querySelectorAll(".view-content");
|
||||
const toggleBtns = Array.from(panel.querySelectorAll<HTMLButtonElement>(".pill-btn"));
|
||||
const viewContents = Array.from(panel.querySelectorAll<HTMLElement>(".view-content"));
|
||||
|
||||
toggleBtns.forEach((btn) => {
|
||||
btn.addEventListener("click", () => {
|
||||
toggleBtns.forEach((b) => b.classList.remove("active"));
|
||||
viewContents.forEach((vc) => vc.classList.remove("active"));
|
||||
const switchTab = (btn: HTMLButtonElement) => {
|
||||
const viewType = btn.getAttribute("data-view");
|
||||
toggleBtns.forEach((b) => {
|
||||
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");
|
||||
const viewType = btn.getAttribute("data-view");
|
||||
const targetView = panel.querySelector(`.${viewType}-view`);
|
||||
if (targetView) targetView.classList.add("active");
|
||||
trackEvent("homepage-feature-view", { feature: panel.id, view: viewType });
|
||||
viewContents.forEach((vc) => {
|
||||
const isTarget = vc.classList.contains(`${viewType}-view`);
|
||||
vc.classList.toggle("active", isTarget);
|
||||
if (isTarget) {
|
||||
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
|
||||
const copyBtn = document.querySelector(".copy-cmd-btn") as HTMLElement;
|
||||
if (copyBtn) {
|
||||
const defaultLabel = copyBtn.textContent;
|
||||
// Copy Command Logic with Screen Reader feedback
|
||||
const copyBtn = document.querySelector<HTMLButtonElement>(".copy-cmd-btn");
|
||||
const copyLabel = copyBtn?.querySelector<HTMLElement>(".copy-label");
|
||||
const copyStatus = document.getElementById("copy-status");
|
||||
if (copyBtn && copyLabel) {
|
||||
const defaultText = copyLabel.textContent || "Copy";
|
||||
copyBtn.addEventListener("click", async () => {
|
||||
try {
|
||||
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(() => {
|
||||
copyBtn.textContent = defaultLabel;
|
||||
copyLabel.textContent = defaultText;
|
||||
if (copyStatus) copyStatus.textContent = "";
|
||||
}, 2000);
|
||||
} catch (err) {
|
||||
console.error("Failed to copy!", err);
|
||||
|
|
@ -658,7 +734,11 @@ const mockBases = [
|
|||
.version-badge a {
|
||||
font-size: 1.1rem;
|
||||
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 {
|
||||
|
|
@ -694,14 +774,17 @@ const mockBases = [
|
|||
text-decoration: none;
|
||||
font-weight: 600;
|
||||
border: 1px solid transparent;
|
||||
transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
|
||||
}
|
||||
|
||||
.button.primary {
|
||||
background-color: var(--sl-color-accent);
|
||||
color: var(--sl-color-white);
|
||||
color: #1a0d00;
|
||||
font-weight: 700;
|
||||
}
|
||||
.button.primary:hover {
|
||||
filter: brightness(1.1);
|
||||
background-color: var(--gram-orange-light, #ff952b);
|
||||
color: #1a0d00;
|
||||
}
|
||||
|
||||
.button.secondary {
|
||||
|
|
@ -709,9 +792,16 @@ const mockBases = [
|
|||
color: var(--sl-color-white);
|
||||
border-color: var(--sl-color-border);
|
||||
}
|
||||
:root[data-theme="light"] .button.secondary {
|
||||
color: var(--sl-color-text);
|
||||
}
|
||||
.button.secondary:hover {
|
||||
border-color: var(--sl-color-text-accent);
|
||||
border-color: var(--sl-color-accent);
|
||||
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 */
|
||||
|
|
@ -777,9 +867,13 @@ const mockBases = [
|
|||
}
|
||||
.learn-more-link {
|
||||
display: inline-block;
|
||||
color: var(--sl-color-text-accent);
|
||||
font-weight: 600;
|
||||
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 {
|
||||
|
|
@ -813,14 +907,16 @@ const mockBases = [
|
|||
}
|
||||
.link-btn {
|
||||
display: inline-block;
|
||||
color: var(--sl-color-text-accent);
|
||||
font-weight: 500;
|
||||
margin-top: 1rem;
|
||||
}
|
||||
.link-btn:hover {
|
||||
color: var(--sl-color-text);
|
||||
text-decoration: underline;
|
||||
text-decoration-color: var(--gram-orange);
|
||||
text-decoration-thickness: 2px;
|
||||
text-underline-offset: 3px;
|
||||
}
|
||||
|
||||
|
||||
/* Mini terminal */
|
||||
.terminal-mini {
|
||||
background-color: var(--sl-color-bg);
|
||||
|
|
@ -964,7 +1060,7 @@ const mockBases = [
|
|||
.nut-header-mock span {
|
||||
font-size: 0.6em;
|
||||
text-transform: uppercase;
|
||||
background-color: var(--sl-color-gray-4);
|
||||
background-color: var(--sl-color-gray-3);
|
||||
padding: 2px 6px;
|
||||
font-weight: 700;
|
||||
color: var(--sl-color-bg);
|
||||
|
|
@ -1011,7 +1107,7 @@ const mockBases = [
|
|||
.nut-item-mock .label {
|
||||
font-size: 0.65em;
|
||||
text-transform: uppercase;
|
||||
color: var(--sl-color-text-accent);
|
||||
color: var(--sl-color-gray-3);
|
||||
font-weight: 600;
|
||||
}
|
||||
.nut-item-mock strong {
|
||||
|
|
@ -1139,15 +1235,17 @@ const mockBases = [
|
|||
|
||||
/* Tabular Mockup */
|
||||
.tabular-mockup {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
padding: 0;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.tabular-mockup tbody {
|
||||
display: table-row-group;
|
||||
}
|
||||
|
||||
.tab-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
padding: 1rem 1.5rem;
|
||||
border-bottom: 1px solid var(--sl-color-border);
|
||||
}
|
||||
|
||||
|
|
@ -1155,6 +1253,11 @@ const mockBases = [
|
|||
border-bottom: none;
|
||||
}
|
||||
|
||||
.tabular-mockup td {
|
||||
padding: 1rem 1.5rem;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.reference-row {
|
||||
background-color: var(--sl-color-bg);
|
||||
}
|
||||
|
|
@ -1167,6 +1270,7 @@ const mockBases = [
|
|||
color: var(--sl-color-text-accent);
|
||||
font-family: var(--sl-font-mono);
|
||||
font-weight: bold;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.tab-val-ref {
|
||||
|
|
@ -1223,4 +1327,32 @@ const mockBases = [
|
|||
#cli-init-cmd {
|
||||
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>
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ const t = {
|
|||
resources: "Resources",
|
||||
ecosystemTooling: "Ecosystem & Tooling",
|
||||
community: "Community",
|
||||
documentation: "Documentation",
|
||||
documentation: "Docs",
|
||||
playground: "Playground",
|
||||
blog: "Blog",
|
||||
changelog: "Changelog",
|
||||
|
|
@ -31,7 +31,7 @@ const t = {
|
|||
resources: "Ressources",
|
||||
ecosystemTooling: "Écosystème & Outils",
|
||||
community: "Communauté",
|
||||
documentation: "Documentation",
|
||||
documentation: "Docs",
|
||||
playground: "Playground",
|
||||
blog: "Blog",
|
||||
changelog: "Changelog",
|
||||
|
|
@ -58,7 +58,7 @@ const prefix = currentLang === "fr" ? "/fr" : "";
|
|||
<!-- Column 1: Brand -->
|
||||
<div class="footer-col brand-col">
|
||||
<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>
|
||||
</a>
|
||||
<p class="tagline">{langText.tagline}</p>
|
||||
|
|
@ -243,7 +243,8 @@ const prefix = currentLang === "fr" ? "/fr" : "";
|
|||
}
|
||||
|
||||
.brand-col img {
|
||||
height: 2.2rem;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
}
|
||||
|
||||
.brand-col .tagline {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ const changelogHref =
|
|||
<div class="site-title sl-flex">
|
||||
<a href="/" class="main-site-link">Gram</a>
|
||||
<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>
|
||||
</div>
|
||||
|
||||
|
|
@ -36,7 +36,7 @@ const changelogHref =
|
|||
color: var(--sl-color-accent-high);
|
||||
}
|
||||
: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 {
|
||||
opacity: 0.7;
|
||||
|
|
|
|||
|
|
@ -23,8 +23,10 @@ import type { HighlighterCore } from "shiki/core";
|
|||
|
||||
import { getHighlighter, SHIKI_THEMES } from "./shikiHighlighter";
|
||||
import { shikiHighlightExtension } from "./codemirror/shikiHighlightExtension";
|
||||
import { useI18n } from "./useI18n";
|
||||
|
||||
const isDark = inject<Ref<boolean>>("isDark")!;
|
||||
const { t } = useI18n();
|
||||
|
||||
const props = defineProps<{
|
||||
files: Map<string, string>;
|
||||
|
|
@ -71,11 +73,19 @@ const editorTheme = EditorView.theme({
|
|||
},
|
||||
".cm-gutters": {
|
||||
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",
|
||||
},
|
||||
"&.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",
|
||||
boxShadow: "inset 0 0 0 2px var(--sl-color-accent-high)",
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -84,6 +94,9 @@ function makeExtensions(theme: string) {
|
|||
lineNumbers(),
|
||||
highlightActiveLine(),
|
||||
EditorView.lineWrapping,
|
||||
EditorView.contentAttributes.of({
|
||||
"aria-label": t.value.playground.inputTab,
|
||||
}),
|
||||
history(),
|
||||
keymap.of([...defaultKeymap, ...historyKeymap, indentWithTab]),
|
||||
editorTheme,
|
||||
|
|
|
|||
|
|
@ -76,12 +76,14 @@ const primaryError = computed(() => {
|
|||
text-align: center;
|
||||
padding: 32px 24px;
|
||||
border-radius: 12px;
|
||||
border: 1px solid rgba(239, 68, 68, 0.25);
|
||||
background-color: rgba(239, 68, 68, 0.03);
|
||||
border: 1px solid var(--sl-color-red);
|
||||
background-color: var(--sl-color-red-low);
|
||||
}
|
||||
|
||||
.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;
|
||||
}
|
||||
|
||||
|
|
@ -118,8 +120,8 @@ const primaryError = computed(() => {
|
|||
font-family: var(--sl-font-mono);
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
color: #ef4444;
|
||||
background-color: rgba(239, 68, 68, 0.1);
|
||||
color: var(--sl-color-red-high);
|
||||
background-color: var(--sl-color-bg);
|
||||
padding: 2px 6px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
|
@ -150,19 +152,21 @@ const primaryError = computed(() => {
|
|||
justify-content: center;
|
||||
gap: 8px;
|
||||
padding: 8px 16px;
|
||||
background-color: #ef4444;
|
||||
color: #ffffff;
|
||||
background-color: var(--sl-color-red);
|
||||
/* 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-weight: 600;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.2s;
|
||||
transition: filter 0.2s;
|
||||
align-self: center;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.jump-button:hover {
|
||||
background-color: #dc2626;
|
||||
filter: brightness(0.9);
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ const props = defineProps<{
|
|||
activeFile: string;
|
||||
entryFile: string;
|
||||
errorFiles: Set<string>;
|
||||
editorPanelId?: string;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
|
|
@ -24,17 +25,76 @@ function label(path: string): string {
|
|||
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 renameValue = ref("");
|
||||
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) {
|
||||
if (el) {
|
||||
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) {
|
||||
renamingPath.value = path;
|
||||
renameValue.value = label(path);
|
||||
|
|
@ -86,13 +146,23 @@ defineExpose({
|
|||
|
||||
<template>
|
||||
<div class="gram-file-tabs">
|
||||
<div class="gram-file-tabs-list" role="tablist" :aria-label="t.playground.tabs.openFiles">
|
||||
<div
|
||||
v-for="path in files"
|
||||
:key="path"
|
||||
:id="tabId(path)"
|
||||
:ref="(el) => setTabRef(path, el)"
|
||||
class="file-tab"
|
||||
: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)"
|
||||
@dblclick="startRename(path)"
|
||||
@keydown="onTabKeydown($event, path)"
|
||||
>
|
||||
<input
|
||||
v-if="renamingPath === path"
|
||||
|
|
@ -102,6 +172,7 @@ defineExpose({
|
|||
:aria-label="t.playground.tabs.newFileName"
|
||||
@click.stop
|
||||
@dblclick.stop
|
||||
@keydown.stop
|
||||
@keydown.enter="commitRename(true)"
|
||||
@keydown.escape="cancelRename(true)"
|
||||
@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>
|
||||
</button>
|
||||
</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>
|
||||
</button>
|
||||
</div>
|
||||
|
|
@ -132,8 +204,15 @@ defineExpose({
|
|||
align-items: stretch;
|
||||
background-color: var(--sl-color-gray-7);
|
||||
border-bottom: 1px solid var(--sl-color-border);
|
||||
overflow-x: auto;
|
||||
flex-shrink: 0;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.gram-file-tabs-list {
|
||||
display: flex;
|
||||
align-items: stretch;
|
||||
overflow-x: auto;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.file-tab {
|
||||
|
|
@ -159,18 +238,20 @@ defineExpose({
|
|||
.file-tab.active {
|
||||
color: var(--sl-color-text);
|
||||
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);
|
||||
}
|
||||
|
||||
.file-tab.has-error .file-tab-label {
|
||||
color: #ef4444;
|
||||
color: var(--sl-color-red-high);
|
||||
}
|
||||
|
||||
.file-tab-error-dot {
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
border-radius: 50%;
|
||||
background-color: #ef4444;
|
||||
background-color: var(--sl-color-red);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
|
|
@ -178,7 +259,7 @@ defineExpose({
|
|||
font: inherit;
|
||||
color: inherit;
|
||||
background-color: var(--sl-color-bg);
|
||||
border: 1px solid var(--sl-color-accent);
|
||||
border: 1px solid var(--sl-color-accent-high);
|
||||
border-radius: 3px;
|
||||
padding: 1px 4px;
|
||||
width: 16ch;
|
||||
|
|
|
|||
|
|
@ -410,7 +410,11 @@ function submitScale() {
|
|||
.scale-apply-btn {
|
||||
padding: 6px 12px;
|
||||
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-weight: 600;
|
||||
cursor: pointer;
|
||||
|
|
@ -447,7 +451,9 @@ function submitScale() {
|
|||
}
|
||||
|
||||
.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 {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,13 @@
|
|||
<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 { 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
|
||||
import JsonNode from "./JsonNode.vue";
|
||||
// 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";
|
||||
|
||||
// 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<{
|
||||
viewMode: "json" | "ast" | "markdown" | "json-tree" | "preview" | "gantt";
|
||||
content: string; // JSON string, AST string, or Markdown string
|
||||
|
|
@ -327,7 +338,8 @@ function handlePreviewClick(e: MouseEvent) {
|
|||
align-items: center;
|
||||
justify-content: center;
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -94,6 +94,12 @@ const entryFile = ref<string>(DEFAULT_ENTRY_URI);
|
|||
const files = ref<Map<string, string>>(new Map([[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 diagnostics = ref<PlaygroundDiagnostic[]>([]);
|
||||
|
|
@ -681,11 +687,12 @@ onUnmounted(() => {
|
|||
<div class="toolbar-right">
|
||||
<div class="toolbar-item" v-if="examples.length > 0">
|
||||
<span class="toolbar-label">{{ t.playground.recipe }}</span>
|
||||
<PlaygroundDropdown
|
||||
v-model="selectedExample"
|
||||
:options="examples"
|
||||
<PlaygroundDropdown
|
||||
v-model="selectedExample"
|
||||
:options="examples"
|
||||
:placeholder="t.playground.loadExample"
|
||||
@change="loadExample"
|
||||
:aria-label="t.playground.loadExample"
|
||||
@change="loadExample"
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
|
@ -757,13 +764,20 @@ onUnmounted(() => {
|
|||
:active-file="activeFile"
|
||||
:entry-file="entryFile"
|
||||
:error-files="errorFiles"
|
||||
:editor-panel-id="EDITOR_PANEL_ID"
|
||||
@select="selectFile"
|
||||
@add="addFile"
|
||||
@rename="renameFile"
|
||||
@remove="removeFile"
|
||||
@done-rename="handleDoneRename"
|
||||
/>
|
||||
<div class="editor-wrapper">
|
||||
<div
|
||||
class="editor-wrapper"
|
||||
:id="EDITOR_PANEL_ID"
|
||||
role="tabpanel"
|
||||
:aria-labelledby="activeTabId"
|
||||
tabindex="-1"
|
||||
>
|
||||
<GramEditor
|
||||
ref="editorRef"
|
||||
:files="files"
|
||||
|
|
@ -796,9 +810,10 @@ onUnmounted(() => {
|
|||
<template #view-selector>
|
||||
<div class="header-view-wrapper">
|
||||
<span class="toolbar-label">{{ t.playground.viewLabel }}</span>
|
||||
<PlaygroundDropdown
|
||||
v-model="viewMode"
|
||||
:options="viewModeOptions"
|
||||
<PlaygroundDropdown
|
||||
v-model="viewMode"
|
||||
:options="viewModeOptions"
|
||||
:aria-label="t.playground.viewLabel"
|
||||
class="header-view-selector"
|
||||
/>
|
||||
</div>
|
||||
|
|
@ -886,16 +901,22 @@ onUnmounted(() => {
|
|||
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 {
|
||||
color: #008829;
|
||||
color: var(--sl-color-green-high);
|
||||
}
|
||||
|
||||
.status-badge.warning {
|
||||
color: #d97706;
|
||||
color: var(--sl-color-orange-high);
|
||||
}
|
||||
|
||||
.status-badge.invalid {
|
||||
color: #ef4444;
|
||||
color: var(--sl-color-red-high);
|
||||
}
|
||||
|
||||
.toolbar-item {
|
||||
|
|
@ -1028,11 +1049,11 @@ onUnmounted(() => {
|
|||
}
|
||||
|
||||
.mobile-tab-dot.dot-error {
|
||||
background-color: #ef4444;
|
||||
background-color: var(--sl-color-red);
|
||||
}
|
||||
|
||||
.mobile-tab-dot.dot-warning {
|
||||
background-color: #f59e0b;
|
||||
background-color: var(--sl-color-orange);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -281,37 +281,44 @@ const overallSeverity = computed<WarningSeverity>(() => {
|
|||
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 {
|
||||
color: #ef4444;
|
||||
color: var(--sl-color-red-high);
|
||||
}
|
||||
.pill-error .pill-dot {
|
||||
background-color: #ef4444;
|
||||
background-color: var(--sl-color-red);
|
||||
}
|
||||
.pill-error:hover, .pill-error.active {
|
||||
background-color: rgba(239, 68, 68, 0.15);
|
||||
border-color: rgba(239, 68, 68, 0.3);
|
||||
background-color: var(--sl-color-red-low);
|
||||
border-color: var(--sl-color-red);
|
||||
}
|
||||
|
||||
.pill-warning {
|
||||
color: #d97706;
|
||||
color: var(--sl-color-orange-high);
|
||||
}
|
||||
.pill-warning .pill-dot {
|
||||
background-color: #f59e0b;
|
||||
background-color: var(--sl-color-orange);
|
||||
}
|
||||
.pill-warning:hover, .pill-warning.active {
|
||||
background-color: rgba(245, 158, 11, 0.15);
|
||||
border-color: rgba(245, 158, 11, 0.3);
|
||||
background-color: var(--sl-color-orange-low);
|
||||
border-color: var(--sl-color-orange);
|
||||
}
|
||||
|
||||
.pill-info {
|
||||
color: #2563eb;
|
||||
color: var(--sl-color-blue-high);
|
||||
}
|
||||
.pill-info .pill-dot {
|
||||
background-color: #3b82f6;
|
||||
background-color: var(--sl-color-blue);
|
||||
}
|
||||
.pill-info:hover, .pill-info.active {
|
||||
background-color: rgba(59, 130, 246, 0.15);
|
||||
border-color: rgba(59, 130, 246, 0.3);
|
||||
background-color: var(--sl-color-blue-low);
|
||||
border-color: var(--sl-color-blue);
|
||||
}
|
||||
|
||||
.console-header-right {
|
||||
|
|
@ -377,13 +384,13 @@ const overallSeverity = computed<WarningSeverity>(() => {
|
|||
}
|
||||
|
||||
.diagnostic-item.item-error .diagnostic-icon {
|
||||
color: #ef4444;
|
||||
color: var(--sl-color-red);
|
||||
}
|
||||
.diagnostic-item.item-warning .diagnostic-icon {
|
||||
color: #f59e0b;
|
||||
color: var(--sl-color-orange);
|
||||
}
|
||||
.diagnostic-item.item-info .diagnostic-icon {
|
||||
color: #3b82f6;
|
||||
color: var(--sl-color-blue);
|
||||
}
|
||||
|
||||
.diagnostic-icon {
|
||||
|
|
@ -414,16 +421,16 @@ const overallSeverity = computed<WarningSeverity>(() => {
|
|||
}
|
||||
|
||||
.severity-badge.badge-error {
|
||||
background-color: rgba(239, 68, 68, 0.15);
|
||||
color: #ef4444;
|
||||
background-color: var(--sl-color-red-low);
|
||||
color: var(--sl-color-red-high);
|
||||
}
|
||||
.severity-badge.badge-warning {
|
||||
background-color: rgba(245, 158, 11, 0.15);
|
||||
color: #d97706;
|
||||
background-color: var(--sl-color-orange-low);
|
||||
color: var(--sl-color-orange-high);
|
||||
}
|
||||
.severity-badge.badge-info {
|
||||
background-color: rgba(59, 130, 246, 0.15);
|
||||
color: #2563eb;
|
||||
background-color: var(--sl-color-blue-low);
|
||||
color: var(--sl-color-blue-high);
|
||||
}
|
||||
|
||||
.diagnostic-code {
|
||||
|
|
@ -438,7 +445,8 @@ const overallSeverity = computed<WarningSeverity>(() => {
|
|||
.diagnostic-uri {
|
||||
font-size: 11px;
|
||||
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);
|
||||
padding: 3px 5px;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,8 +63,16 @@ const count = computed(() => keys.value.length);
|
|||
|
||||
<!-- Objects and Arrays -->
|
||||
<template v-else>
|
||||
<div class="json-line json-header" @click.stop="toggle">
|
||||
<span class="json-toggle">{{ isExpanded ? '▼' : '▶' }}</span>
|
||||
<div
|
||||
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-colon">: </span>
|
||||
<span :class="type === 'array' ? 'json-bracket' : 'json-brace'">
|
||||
|
|
@ -141,7 +149,8 @@ const count = computed(() => keys.value.length);
|
|||
width: 14px;
|
||||
text-align: center;
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
@ -160,5 +169,5 @@ const count = computed(() => keys.value.length);
|
|||
.json-brace {
|
||||
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>
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
<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;
|
||||
options: { label: string; value: string }[];
|
||||
placeholder?: string;
|
||||
ariaLabel: string;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
|
|
@ -13,52 +14,148 @@ const emit = defineEmits<{
|
|||
}>();
|
||||
|
||||
const isOpen = ref(false);
|
||||
const highlightedIndex = ref(-1);
|
||||
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.
|
||||
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) {
|
||||
emit("update:modelValue", 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)) {
|
||||
isOpen.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
document.addEventListener("click", closeDropdown);
|
||||
document.addEventListener("click", onOutsideClick);
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
document.removeEventListener("click", closeDropdown);
|
||||
document.removeEventListener("click", onOutsideClick);
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<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">
|
||||
{{ options.find(o => o.value === modelValue)?.label || placeholder }}
|
||||
</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>
|
||||
</svg>
|
||||
</div>
|
||||
|
||||
<div v-show="isOpen" class="dropdown-menu">
|
||||
<div
|
||||
v-for="opt in options"
|
||||
:key="opt.value"
|
||||
class="dropdown-item"
|
||||
:class="{ active: opt.value === modelValue }"
|
||||
|
||||
<div v-show="isOpen" class="dropdown-menu" role="listbox" :id="listboxId">
|
||||
<div
|
||||
v-for="(opt, index) in options"
|
||||
:key="opt.value"
|
||||
:id="optionId(index)"
|
||||
class="dropdown-item"
|
||||
role="option"
|
||||
:aria-selected="opt.value === modelValue"
|
||||
:class="{ active: opt.value === modelValue, highlighted: index === highlightedIndex }"
|
||||
@mousemove="highlightedIndex = index"
|
||||
@click="selectOption(opt.value)"
|
||||
>
|
||||
{{ opt.label }}
|
||||
|
|
@ -144,7 +241,8 @@ onUnmounted(() => {
|
|||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.dropdown-item:hover {
|
||||
.dropdown-item:hover,
|
||||
.dropdown-item.highlighted {
|
||||
background-color: var(--sl-color-gray-7);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,30 @@ export const SHIKI_THEMES = {
|
|||
dark: "github-dark",
|
||||
} 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;
|
||||
|
||||
// Shared singleton: the same highlighter instance backs both the
|
||||
|
|
@ -16,10 +40,7 @@ let highlighterPromise: Promise<HighlighterCore> | undefined;
|
|||
export function getHighlighter(): Promise<HighlighterCore> {
|
||||
if (!highlighterPromise) {
|
||||
highlighterPromise = createHighlighterCore({
|
||||
themes: [
|
||||
import("shiki/themes/github-light.mjs"),
|
||||
import("shiki/themes/github-dark.mjs"),
|
||||
],
|
||||
themes: [import("shiki/themes/github-light.mjs"), accessibleGithubDark()],
|
||||
langs: [
|
||||
{ ...gramGrammar, name: "gram" } as any,
|
||||
import("shiki/langs/json.mjs"),
|
||||
|
|
|
|||
|
|
@ -24,5 +24,15 @@ import GramPlayground from "../../components/playground/GramPlayground.vue";
|
|||
flex: 1;
|
||||
display: flex;
|
||||
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>
|
||||
|
|
|
|||
|
|
@ -24,5 +24,15 @@ import GramPlayground from "../components/playground/GramPlayground.vue";
|
|||
flex: 1;
|
||||
display: flex;
|
||||
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>
|
||||
|
|
|
|||
|
|
@ -436,3 +436,15 @@ div[data-nova-code-container] > div:first-child:not(pre) {
|
|||
letter-spacing: 0.02em !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
Loading…
Reference in a new issue