diff --git a/bun.lock b/bun.lock index fa8fcb56..56f3b24c 100644 --- a/bun.lock +++ b/bun.lock @@ -130,6 +130,7 @@ "@astrojs/check": "^0.9.10", "@types/mdast": "^4.0.4", "starlight-links-validator": "^0.26.0", + "vue-tsc": "^3.3.14", }, }, "packages/format": { @@ -1049,7 +1050,7 @@ "@volar/source-map": ["@volar/source-map@2.4.28", "", {}, "sha512-yX2BDBqJkRXfKw8my8VarTyjv48QwxdJtvRgUpNE5erCsgEUdI2DsLbpa+rOQVAJYshY99szEcRDmyHbF10ggQ=="], - "@volar/typescript": ["@volar/typescript@2.4.28", "", { "dependencies": { "@volar/language-core": "2.4.28", "path-browserify": "^1.0.1", "vscode-uri": "^3.0.8" } }, "sha512-Ja6yvWrbis2QtN4ClAKreeUZPVYMARDYZl9LMEv1iQ1QdepB6wn0jTRxA9MftYmYa4DQ4k/DaSZpFPUfxl8giw=="], + "@volar/typescript": ["@volar/typescript@2.4.30", "", { "dependencies": { "@volar/language-core": "2.4.30", "@volar/language-service": "2.4.30", "path-browserify": "^1.0.1", "vscode-uri": "^3.0.8" }, "peerDependencies": { "typescript": "<7" }, "optionalPeers": ["typescript"] }, "sha512-/DgA5tgYFPfrLFuSjIMXMGHk1LQv2+P8eny6+BhGNzFJELWIW7UZlc56ZLIRFhLsPpMfIFxM8/HvOPBggrjTZg=="], "@vscode/emmet-helper": ["@vscode/emmet-helper@2.11.0", "", { "dependencies": { "emmet": "^2.4.3", "jsonc-parser": "^2.3.0", "vscode-languageserver-textdocument": "^1.0.1", "vscode-languageserver-types": "^3.15.1", "vscode-uri": "^3.0.8" } }, "sha512-QLxjQR3imPZPQltfbWRnHU6JecWTF1QSWhx3GAKQpslx7y3Dp6sIIXhKjiUJ/BR9FX8PVthjr9PD6pNwOJfAzw=="], @@ -1097,6 +1098,8 @@ "@vue/devtools-shared": ["@vue/devtools-shared@8.2.1", "", {}, "sha512-Fkac7lUdGReh6pVOi3AYPRGe82LQqRmAfThW7RRligOAP0ZA/Z1z9XLHDM9dv34pV2HRc79DK8uKPeG2fLnA/g=="], + "@vue/language-core": ["@vue/language-core@3.3.14", "", { "dependencies": { "@volar/language-core": "2.4.30", "@vue/compiler-dom": "^3.5.0", "@vue/shared": "^3.5.0", "alien-signals": "^3.2.1", "muggle-string": "^0.4.1", "path-browserify": "^1.0.1", "picomatch": "^4.0.4" } }, "sha512-kRB+3hHg0c+BdD1XLAvwjVMQd5pC05zijSlPDRI3ERvC/s04JlRs5upy2KjeMg/9m9oD5zuMVh9yVvkKfZqoJg=="], + "@vue/reactivity": ["@vue/reactivity@3.5.39", "", { "dependencies": { "@vue/shared": "3.5.39" } }, "sha512-TpsuBJ9gGlZa5d23XcM2y8EXanz9dZeVDQBXRwzy46ItgvM+rWpzs+UVM0wcRLxGvcav0HE5jz2gNL53xlRAog=="], "@vue/runtime-core": ["@vue/runtime-core@3.5.39", "", { "dependencies": { "@vue/reactivity": "3.5.39", "@vue/shared": "3.5.39" } }, "sha512-9GLtNyRvPAUMbX+7ono0RC2j0guo2LXVi8LvcmAooImACUKm0oFf0jjwbX8/H0AE/t1nxhAkn8RSl9PMCzzxZw=="], @@ -2301,6 +2304,8 @@ "vue": ["vue@3.5.39", "", { "dependencies": { "@vue/compiler-dom": "3.5.39", "@vue/compiler-sfc": "3.5.39", "@vue/runtime-dom": "3.5.39", "@vue/server-renderer": "3.5.39", "@vue/shared": "3.5.39" }, "peerDependencies": { "typescript": "*" }, "optionalPeers": ["typescript"] }, "sha512-xmZCYabFGcirU8r0fTuvl/LICc1OU620rnqepaJDL/a141ZigkG7AyaxQLdqJ02ZRYzWe6YPaDHeQx7MfknQfA=="], + "vue-tsc": ["vue-tsc@3.3.14", "", { "dependencies": { "@volar/typescript": "2.4.30", "@vue/language-core": "3.3.14" }, "peerDependencies": { "typescript": ">=5.0.0" }, "bin": { "vue-tsc": "./bin/vue-tsc.js" } }, "sha512-URAu2H9AuMZMg9GCgnqbaHHHd8pBZRAwNV2e2yYS8VDsoTVXHiOSo663OS6DkEvauQ2yixn5TPFJ9WV9QIspkA=="], + "w3c-keyname": ["w3c-keyname@2.2.8", "", {}, "sha512-dpojBhNsCNN7T82Tm7k26A6G9ML3NkhDsnw9n/eoxSRlVBB4CEtIQ/KTCLI2Fwf3ataSXRhYFkQi3SlnFwPvPQ=="], "web-namespaces": ["web-namespaces@2.0.1", "", {}, "sha512-bKr1DkiNa2krS7qxNtdrtHAmzuYGFQLiQ13TsorsdT6ULTkPLKuu5+GsFpDlg6JFjUTwX2DyhMPG2be8uPrqsQ=="], @@ -2357,8 +2362,16 @@ "@img/sharp-wasm32/@emnapi/runtime": ["@emnapi/runtime@1.11.3", "", { "dependencies": { "tslib": "^2.4.0" } }, "sha512-Xz4Tpyki7XyrpbUK1jR1AhdAdaXyhhY4lZ3neLodmhpuWfy2PAQN5B46sAiU4liOXGLkHypn/qU+jvfWSCYYLA=="], + "@volar/kit/@volar/typescript": ["@volar/typescript@2.4.28", "", { "dependencies": { "@volar/language-core": "2.4.28", "path-browserify": "^1.0.1", "vscode-uri": "^3.0.8" } }, "sha512-Ja6yvWrbis2QtN4ClAKreeUZPVYMARDYZl9LMEv1iQ1QdepB6wn0jTRxA9MftYmYa4DQ4k/DaSZpFPUfxl8giw=="], + + "@volar/language-server/@volar/typescript": ["@volar/typescript@2.4.28", "", { "dependencies": { "@volar/language-core": "2.4.28", "path-browserify": "^1.0.1", "vscode-uri": "^3.0.8" } }, "sha512-Ja6yvWrbis2QtN4ClAKreeUZPVYMARDYZl9LMEv1iQ1QdepB6wn0jTRxA9MftYmYa4DQ4k/DaSZpFPUfxl8giw=="], + "@volar/language-server/vscode-languageserver": ["vscode-languageserver@9.0.1", "", { "dependencies": { "vscode-languageserver-protocol": "3.17.5" }, "bin": { "installServerIntoExtension": "bin/installServerIntoExtension" } }, "sha512-woByF3PDpkHFUreUa7Hos7+pUWdeWMXRd26+ZX2A8cFx6v/JPTtd4/uN0/jB6XQHYaOlHbio03NTHCqrgG5n7g=="], + "@volar/typescript/@volar/language-core": ["@volar/language-core@2.4.30", "", { "dependencies": { "@volar/source-map": "2.4.30" } }, "sha512-73fjwEV8wat6aOZ6U/y/hqtE30ocrIWECg67b0txGczOMNw+MffLmvJ5fnFfN9drVUEYZzLdaNo6VAy6G6avMw=="], + + "@volar/typescript/@volar/language-service": ["@volar/language-service@2.4.30", "", { "dependencies": { "@volar/language-core": "2.4.30", "vscode-languageserver-protocol": "^3.17.5", "vscode-languageserver-textdocument": "^1.0.11", "vscode-uri": "^3.0.8" }, "peerDependencies": { "typescript": "<7" }, "optionalPeers": ["typescript"] }, "sha512-w/xDsASiqC71ggCOm7sTDXDNk/l72XEptodeRC68tgZ0e5QM4hM3zAqBGC7mBctvhrpYwKfMG+t9xcUo2hEFtA=="], + "@vscode/emmet-helper/jsonc-parser": ["jsonc-parser@2.3.1", "", {}, "sha512-H8jvkz1O50L3dMZCsLqiuB2tA7muqbSg1AtGEkN0leAqGjsUzDJir3Zwr02BhqdcITPg3ei3mZ+HjMocAknhhg=="], "@vscode/vsce/marked": ["marked@18.0.14", "", { "bin": { "marked": "bin/marked.js" } }, "sha512-mBHK6FBHuBAlhgRe88w9F0O1AbwwXJUcQibUbC/QcdTbVGAD7aWza+xt3N6oT/jCZx3/OMeS+8rnuiHZcQ9s7A=="], @@ -2371,6 +2384,8 @@ "@vue/compiler-sfc/magic-string": ["magic-string@0.30.21", "", { "dependencies": { "@jridgewell/sourcemap-codec": "^1.5.5" } }, "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ=="], + "@vue/language-core/@volar/language-core": ["@volar/language-core@2.4.30", "", { "dependencies": { "@volar/source-map": "2.4.30" } }, "sha512-73fjwEV8wat6aOZ6U/y/hqtE30ocrIWECg67b0txGczOMNw+MffLmvJ5fnFfN9drVUEYZzLdaNo6VAy6G6avMw=="], + "anymatch/picomatch": ["picomatch@2.3.2", "", {}, "sha512-V7+vQEJ06Z+c5tSye8S+nHUfI51xoXIXjHQ99cQtKUkQqqO1kO/KCJUfZXuB47h/YBlDhah2H3hdUGXn8ie0oA=="], "cliui/string-width": ["string-width@7.2.0", "", { "dependencies": { "emoji-regex": "^10.3.0", "get-east-asian-width": "^1.0.0", "strip-ansi": "^7.1.0" } }, "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ=="], @@ -2447,6 +2462,10 @@ "@volar/language-server/vscode-languageserver/vscode-languageserver-protocol": ["vscode-languageserver-protocol@3.17.5", "", { "dependencies": { "vscode-jsonrpc": "8.2.0", "vscode-languageserver-types": "3.17.5" } }, "sha512-mb1bvRJN8SVznADSGWM9u/b07H7Ecg0I3OgXDuLdn307rl/J3A9YD6/eYOssqhecL27hK1IPZAsaqh00i/Jljg=="], + "@volar/typescript/@volar/language-core/@volar/source-map": ["@volar/source-map@2.4.30", "", {}, "sha512-zym1ob/KwDDyN+0jGVtxwbxJSRRnUvv5HspCtz3yEfVVdCG4/dzxJktMGPAgemqRuVs81O0o/y0q3qOUErR8kg=="], + + "@vue/language-core/@volar/language-core/@volar/source-map": ["@volar/source-map@2.4.30", "", {}, "sha512-zym1ob/KwDDyN+0jGVtxwbxJSRRnUvv5HspCtz3yEfVVdCG4/dzxJktMGPAgemqRuVs81O0o/y0q3qOUErR8kg=="], + "csso/css-tree/mdn-data": ["mdn-data@2.0.28", "", {}, "sha512-aylIc7Z9y4yzHYAJNuESG3hfhC+0Ibp/MAMiaOZgNv4pmEdFyfZhhhny4MNiAfWdBQ1RQ2mfDWmM1x8SvGyp8g=="], "cytoscape-fcose/cose-base/layout-base": ["layout-base@2.0.1", "", {}, "sha512-dp3s92+uNI1hWIpPGH3jK2kxE2lMjdXdr+DH8ynZHpd6PUlH6x6cbuXnoMmiNumznqaNO31xu9e79F0uuZ0JFg=="], diff --git a/packages/docs/package.json b/packages/docs/package.json index d90e7005..2a1ebb97 100644 --- a/packages/docs/package.json +++ b/packages/docs/package.json @@ -12,7 +12,7 @@ "build": "astro build && node scripts/check-bundle-size.mjs", "preview": "astro preview", "astro": "astro", - "typecheck": "astro check" + "typecheck": "astro check && vue-tsc --noEmit" }, "dependencies": { "@astrojs/markdown-remark": "^7.3.0", @@ -43,6 +43,7 @@ "devDependencies": { "@astrojs/check": "^0.9.10", "@types/mdast": "^4.0.4", - "starlight-links-validator": "^0.26.0" + "starlight-links-validator": "^0.26.0", + "vue-tsc": "^3.3.14" } } diff --git a/packages/docs/src/components/FeaturePanel.astro b/packages/docs/src/components/FeaturePanel.astro index 22296e4b..5e164338 100644 --- a/packages/docs/src/components/FeaturePanel.astro +++ b/packages/docs/src/components/FeaturePanel.astro @@ -25,14 +25,20 @@ const { gramLang, codeThemes, } = Astro.props; + +// The last word and the link stay together (a link alone on a line reads as +// orphaned): the link is an inline-block, before which a browser may break +// even after a no-break space, so both go in one nowrap span. +const lastSpace = desc.lastIndexOf(" "); +const descHead = lastSpace === -1 ? "" : desc.slice(0, lastSpace + 1); +const descTail = lastSpace === -1 ? desc : desc.slice(lastSpace + 1); ---

- {desc} - + {descHead}{descTail}  {learnMoreText}{title && : {title}} - +

@@ -189,6 +195,10 @@ const { height: 100%; } + .desc-tail { + white-space: nowrap; + } + .learn-more-link { display: inline-block; font-weight: 600; diff --git a/packages/docs/src/components/Homepage.astro b/packages/docs/src/components/Homepage.astro index 1d84a3be..df233db2 100644 --- a/packages/docs/src/components/Homepage.astro +++ b/packages/docs/src/components/Homepage.astro @@ -6,7 +6,7 @@ import gramGrammar from "@gram-lang/parser/textmate"; import FeaturePanel from "./FeaturePanel.astro"; import { GRAM_VERSION } from "../lib/gram-version"; import { NUTRIENTS, type NutrientKey } from "@gram-lang/analyzer"; -import { nutritionGroups } from "@gram-lang/renderer"; +import { nutritionRows } from "@gram-lang/renderer"; import { getDictionary } from "@gram-lang/i18n"; const { lang, t } = Astro.props; @@ -21,28 +21,42 @@ const codeThemes: Record = { // grouping from `nutritionGroups()` keeps the two from drifting apart. const nutritionDict = getDictionary(lang); -// Per-portion figures for the Chantilly mockup: one quarter of a 269 g batch -// (240 g cream + 25 g powdered sugar + 4 g vanilla), the recipe shown in +// Per-portion figures for the Chantilly mockup: one quarter of a 259 g batch +// (240 g cream + 15 g powdered sugar + 4 g vanilla), the recipe shown in // `nutritionInput`. Values match the renderer's own output. +const MOCK_PORTION_GRAMS = 259 / 4; const MOCK_NUTRITION_VALUES: Partial> = { - calories: 231, - fat: 22, - carbs: 6.5, - sugar: 6.3, + calories: 220, + fat: 21.6, + carbs: 5.5, + sugar: 5.5, fiber: 0, - protein: 1.5, + protein: 1.4, sodium: 11, }; +const per100Values = Object.fromEntries( + Object.entries(MOCK_NUTRITION_VALUES).map(([k, v]) => [ + k, + (v as number) * (100 / MOCK_PORTION_GRAMS), + ]), +); -const mockNutrientGroups = nutritionGroups(MOCK_NUTRITION_VALUES as any, lang); - -// The recipe declares `portions: 4`, so the real panel offers all three bases -// and opens on per-portion. -const mockBases = [ - { label: nutritionDict.renderer.nutritionPerPortion, active: true }, - { label: nutritionDict.renderer.nutritionPer100g, active: false }, - { label: nutritionDict.renderer.nutritionWholeRecipe, active: false }, -]; +// The rows come from the renderer, so the labels and their order follow the +// real table; the mockup is only its simplified picture (two columns, no %RI). +const round1 = (n: number) => Math.round(n * 10) / 10; +const portionRows = nutritionRows(MOCK_NUTRITION_VALUES as any, lang); +const per100Rows = nutritionRows(per100Values as any, lang); +const kcalPortion = Math.round(MOCK_NUTRITION_VALUES.calories ?? 0); +const kcal100 = Math.round(per100Values.calories ?? 0); +const kj = (kcal: number) => Math.round(kcal * 4.184); +const mockNutrientRows = portionRows + .filter((r) => r.key !== "calories") + .map((r) => ({ + label: r.label, + nested: r.nested, + portion: `${round1(r.value)} ${r.unit}`, + per100: `${round1(per100Rows.find((x) => x.key === r.key)?.value ?? 0)} ${r.unit}`, + })); --- @@ -156,90 +170,51 @@ const mockBases = [ gramLang={gramLang} codeThemes={codeThemes} > -
-
-
    -
  1. - {lang === "fr" ? "Fouetter" : "Whisk"} - {lang === "fr" ? "La " : ""}{ - lang === "fr" ? "crème liquide" : "Heavy cream" - } (240g) - {lang === "fr" ? " et le " : " and "} - { - lang === "fr" ? "sucre glace" : "powdered sugar" - } (25g) - { - lang === "fr" - ? " jusqu'à obtenir des pics souples." - : " until soft peaks form." - } -
  2. -
  3. - {lang === "fr" ? "Incorporer" : "Fold"} - { - lang === "fr" - ? "Ajouter délicatement l'" - : "Gently incorporate " - }{ - lang === "fr" - ? "extrait de vanille" - : "vanilla extract" - } (4g). -
  4. -
-
-
+
+
    +
  • + {lang === "fr" ? "crème liquide" : "heavy cream"} + {lang === "fr" ? "1 tasse" : "1 cup"}240 g +
  • +
  • + {lang === "fr" ? "sucre glace" : "powdered sugar"} + {lang === "fr" ? "2 c.à.s" : "2 tbsp"}15 g +
  • +
  • + {lang === "fr" ? "extrait de vanille" : "vanilla extract"} + {lang === "fr" ? "1 c.à.c" : "1 tsp"}4 g +
  • +
+
- {nutritionDict.renderer.nutrition} + {nutritionDict.renderer.nutritionTableTitle} {nutritionDict.renderer.estimateTooltip}
-
- { - mockBases.map((basis) => ( - - {basis.label} - - )) - } -
-
- { - mockNutrientGroups.map((group) => ( -
- {group.label} - - {group.value}{" "} - {group.unit} - - {group.children.length > 0 && ( -
    - {group.children.map((child) => ( -
  • - {child.label} - - {child.value} {child.unit} - -
  • - ))} -
- )} -
- )) - } -
+ + + + + + + + + + + + + + + { + mockNutrientRows.map((row) => ( + + + + + + )) + } + +
{nutritionDict.renderer.nutritionNutrient}{nutritionDict.renderer.nutritionPerPortion}{nutritionDict.renderer.nutritionPer100g}
{nutritionDict.renderer.nutrients.calories}{kcalPortion} kcal{kj(kcalPortion)} kJ{kcal100} kcal{kj(kcal100)} kJ
{row.label}{row.portion}{row.per100}
@@ -264,45 +239,46 @@ const mockBases = [
{lang === "fr" - ? "Plan de marche pour le samedi 17 octobre à 20 h : un passage en cuisine de 19 h 40 à 20 h. À sortir : pâtes, tomates cerises, ail, huile d'olive, basilic. Au programme : cuire 10 minutes, sauter 5 minutes, mélanger." - : "Run sheet for Saturday, October 17 at 8 p.m.: one visit to the kitchen from 7:40 to 8 p.m. To take out: pasta, cherry tomatoes, garlic, olive oil, basil. To do: boil 10 minutes, sauté 5 minutes, toss."} + ? "Plan de marche de la tarte au citron servie le samedi 21 novembre à 20 h. Vendredi : un passage en cuisine à 19 h 50 pour la pâte, qui repose au frais. Samedi : un passage à 19 h 40 pour la tarte, puis service à 20 h." + : "Run sheet for the lemon tart served Saturday, November 21 at 8 p.m. Friday: a visit to the kitchen at 7:50 p.m. for the dough, which rests in the fridge. Saturday: a visit at 7:40 p.m. for the tart, then serving at 8 p.m."}