From 97b2a50d08c10bc102ba023db61bc53fa3810030 Mon Sep 17 00:00:00 2001 From: Whatsaaaa Date: Fri, 13 Nov 2026 19:54:40 +0100 Subject: [PATCH 1/8] Install the Whatsaaaa design system and Shiki in the React app The design system comes from npm like any other package, and needs Node 22.18 or 24.12, so the app's engines follow it. Shiki highlights code in the design system's code theme. --- react-checkout/package.json | 4 +- react-checkout/pnpm-lock.yaml | 361 +++++++++++++++++++++++++++++ react-checkout/pnpm-workspace.yaml | 1 + 3 files changed, 365 insertions(+), 1 deletion(-) diff --git a/react-checkout/package.json b/react-checkout/package.json index 84c06a0..de71bbf 100644 --- a/react-checkout/package.json +++ b/react-checkout/package.json @@ -17,12 +17,14 @@ "@formisch/react": "^1.2.0", "@hono/node-server": "^2.1.7", "@valibot/i18n": "^1.3.0", + "@whatsaaaa/design-system": "^0.1.1", "@whatsaaaa/form-builder-affects": "0.2.2-rc.0", "@whatsaaaa/form-builder-react": "1.0.0-rc.0", "@whatsaaaa/form-builder-schema": "1.0.0-rc.0", "hono": "^4.13.18", "react": "^19.3.1", "react-dom": "^19.3.1", + "shiki": "^4.6.0", "valibot": "^1.5.0" }, "devDependencies": { @@ -41,6 +43,6 @@ }, "packageManager": "pnpm@11.27.0", "engines": { - "node": ">=20.19" + "node": "^22.18.0 || >=24.12.0" } } diff --git a/react-checkout/pnpm-lock.yaml b/react-checkout/pnpm-lock.yaml index be4f299..70dc7c4 100644 --- a/react-checkout/pnpm-lock.yaml +++ b/react-checkout/pnpm-lock.yaml @@ -17,6 +17,9 @@ importers: '@valibot/i18n': specifier: ^1.3.0 version: 1.3.0(valibot@1.5.0(typescript@7.0.2)) + '@whatsaaaa/design-system': + specifier: ^0.1.1 + version: 0.1.1 '@whatsaaaa/form-builder-affects': specifier: 0.2.2-rc.0 version: 0.2.2-rc.0(@whatsaaaa/form-builder-schema@1.0.0-rc.0(valibot@1.5.0(typescript@7.0.2)))(valibot@1.5.0(typescript@7.0.2)) @@ -35,6 +38,9 @@ importers: react-dom: specifier: ^19.3.1 version: 19.3.1(react@19.3.1) + shiki: + specifier: ^4.6.0 + version: 4.6.0 valibot: specifier: ^1.5.0 version: 1.5.0(typescript@7.0.2) @@ -511,6 +517,40 @@ packages: '@rolldown/pluginutils@1.1.0': resolution: {integrity: sha512-K+NU2HDCEem4sClgHH4ZZXwdJeNFkJo+hRk479DIwdIviAPN2hFJH1KHHwg8CxHQXvi0M5XY4deTXINfIiSG6w==} + '@shikijs/core@4.6.0': + resolution: {integrity: sha512-bfd4OKgvoyXYiYmMRuleA656P4V7M/Du9lcTl38Ngm6KszMj7bq4J1IGZwSYR4c95Tv5UQALtYNWUwaI9UT3xw==} + engines: {node: '>=20'} + + '@shikijs/engine-javascript@4.6.0': + resolution: {integrity: sha512-K0oqxFoL+kEMdz89mHLFO15Tsbv3kFZ6WR1cXZKMvLSc+oqaM00A6pyga1qSeXB22dP0tTiSApRcGBaKWsEccg==} + engines: {node: '>=20'} + + '@shikijs/engine-oniguruma@4.6.0': + resolution: {integrity: sha512-aggd6Q7SuJOXNnsUbfG2XesxBJKBMAw/PDTUo9PyRjMaaJJ2dNrI+q0C+25ARXAK9yLHAlwxc9oRT2u68YKZ7w==} + engines: {node: '>=20'} + + '@shikijs/langs@4.6.0': + resolution: {integrity: sha512-1yMEX3oCVV54LUq/ovfpRkDQoYDkcvjSWFFa/YLUDMiSoRzMi2uxLJYbv41ahT8Lu9lFMaa7hecd3Q39trqUyg==} + engines: {node: '>=20'} + + '@shikijs/primitive@4.6.0': + resolution: {integrity: sha512-c54+TQEo9ToqgfL/AU8FpjnV09+GA9Oa7M5ROkkXteZfp5XzpAJGXjjvZQFQioJOwm/w/6Z3lIzQstAkl8coag==} + engines: {node: '>=20'} + + '@shikijs/themes@4.6.0': + resolution: {integrity: sha512-qHAVAs80RiGD+IRuH9G+JPDOEc9A/kHsng4EzCUCwB9bLzW6Z0y9WETh2YyCcADJBmfrIaJ1Jp7KBNP6FHkgtQ==} + engines: {node: '>=20'} + + '@shikijs/types@4.6.0': + resolution: {integrity: sha512-+ENG1adsKt/X7cRYw1Nl7BEpBmPOjmQ7bR/eGmHuMlT8gtOFf3KEi5l31DJYyAWhW6Y6bjP1plU7FmaxWGENFw==} + engines: {node: '>=20'} + + '@shikijs/vscode-textmate@10.1.0': + resolution: {integrity: sha512-cVBuhDQjBZaNMTwBquYfPydrUP+E3hE6oYGasx8h6ZrODIM7/r+gxLDXdd66oszbrggZHEntdE6j+5gYIVyMWQ==} + + '@terrazzo/token-types@2.10.0': + resolution: {integrity: sha512-93HnrQPUFsZv0k9Z2L0zsxwd2IVLmoI78TwfnHhKPDnGrE+hVyzYRlFi/5ihspNFIbfnXMHW1EmxeiF9m6UPiQ==} + '@tybys/wasm-util@0.10.4': resolution: {integrity: sha512-W3c4gRigFS0T/Ma4qIYF3GDAc5AQdHb1yL5znJT1Zv1YaD9Kitx656wBjvr19qbiosmZT8lWDM5BEMynUqX65A==} @@ -523,6 +563,12 @@ packages: '@types/estree@1.0.10': resolution: {integrity: sha512-lTyOMnOcmRBzdCv6/4zUZCrEhV0xrqQiUZBZtVcbmLHBXKLnN8q89v/wKRF/Q0HbwVsqbIG3o5HDoFl9sduM+g==} + '@types/hast@3.0.5': + resolution: {integrity: sha512-rp/ezSWaD1m44dPKICGhiskI13nVr7qTloFwDa/IYkhhf5nzwP+zIQcIJh3WIFSBOy/H1PzB40jPjMDksN4F+g==} + + '@types/mdast@4.0.4': + resolution: {integrity: sha512-kGaNbPh1k7AFzgpud/gMdvIm5xuECykRR+JnWKQno9TAXVa6WIVCGTPvYGekIDL4uwCZQSYbUxNBSb1aUo79oA==} + '@types/node@24.19.2': resolution: {integrity: sha512-93d49wCWJkCyN87MxLpNN6KXPCwFw7bVUg79mGUV1OS40JGWwVCr8n61DXCSqz7CV6/VfPkb7xec7uP2M+QHWQ==} @@ -534,6 +580,9 @@ packages: '@types/react@19.3.0': resolution: {integrity: sha512-N0rFCuH9YoxG9/m61l9MfpJKfmLOVU0em7ipIz6TRgSSkvReLB9vL85GB+yr8Bs5leqpvg96JSwF4ZS1s4viQg==} + '@types/unist@3.0.3': + resolution: {integrity: sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==} + '@typescript/typescript-aix-ppc64@7.0.2': resolution: {integrity: sha512-MTKKkWB7p/0E9xi1d1tHtZ5PiLkGEMIq88pK2CubZjOsLtYTLqhgIgi6zepFa+9GHZ6h05NMCkQxGKiPXMxXtQ==} engines: {node: '>=16.20.0'} @@ -654,6 +703,9 @@ packages: cpu: [x64] os: [win32] + '@ungap/structured-clone@1.4.0': + resolution: {integrity: sha512-1mEZtMKPM09vDmQt5y7YvmN2+DFTP7Tg0EWXdic8/C6VRnpb33e4ghisCIE3WZjsE2N8mf+QV1Zqh7ZFYLWInQ==} + '@valibot/i18n@1.3.0': resolution: {integrity: sha512-BAhIIBgF1sBVCXXxbUkdza85vA8s4Jr17YsWNMoE6fKU6mjiMvj478d7sk87cuxdxBPI+qRVtjnxkhafZbt2Zg==} peerDependencies: @@ -689,6 +741,18 @@ packages: '@vitest/spy@5.1.0': resolution: {integrity: sha512-2DPO5OMHWKrBngC+fCmTQqemNF0gidRhp3lxbBmRhW+M1XJrfgPpqNqWVevXtn2f2ufD5ZaR1B6B641aAlcX5A==} + '@whatsaaaa/design-system@0.1.1': + resolution: {integrity: sha512-1LWR3jvIYdLxcRUH/FvvCbRxgLfEILU0mP/fMq5S6i3daEYM6jzIt0NtWRHAsvz9bKAhA+UihNenNVZGOyfq4g==} + engines: {node: ^22.18.0 || >=24.12.0} + peerDependencies: + vitepress: ^1.6.4 + vue: ^3.5.0 + peerDependenciesMeta: + vitepress: + optional: true + vue: + optional: true + '@whatsaaaa/form-builder-affects@0.2.2-rc.0': resolution: {integrity: sha512-fnrn8Zo4CS9ErFC3s8+oFC8HA81M5u2mswJRZdezw+b/0vlujl7gh4csMsbh+kjjvqfrMbAuD/PIBl6MJUFeCg==} peerDependencies: @@ -724,6 +788,9 @@ packages: resolution: {integrity: sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==} engines: {node: '>=12'} + ccount@2.0.1: + resolution: {integrity: sha512-eyrF0jiFpY+3drT6383f1qhkbGsLSifNAjA61IUjZjmLCWjItY6LB9ft9YhoDgwfmclB2zhu51Lc7+95b8NRAg==} + chai@6.3.0: resolution: {integrity: sha512-XWAtwJ6OHO+tj0EKCs0Y2UamnyOxseZWltU4x2U2wh8g4AigdjwvtUjvLP2tqkA/avxHEtzxNaqGq/YGNwckKg==} engines: {node: '>=18'} @@ -732,10 +799,19 @@ packages: resolution: {integrity: sha512-7NzBL0rN6fMUW+f7A6Io4h40qQlG+xGmtMxfbnH/K7TAtt8JQWVQK+6g0UXKMeVJoyV5EkkNsErQ8pVD3bLHbA==} engines: {node: ^12.17.0 || ^14.13 || >=16.0.0} + character-entities-html4@2.1.0: + resolution: {integrity: sha512-1v7fgQRj6hnSwFpq1Eu0ynr/CDEw0rXo2B61qXrLNdHZmPKgb7fqS1a2JwF0rISo9q77jDI8VMEHoApn8qDoZA==} + + character-entities-legacy@3.0.0: + resolution: {integrity: sha512-RpPp0asT/6ufRm//AJVwpViZbGM/MkjQFxJccQRHmISF/22NBtsHqAWmL+/pmkPWoIUJdWyeVleTl1wydHATVQ==} + cliui@9.0.1: resolution: {integrity: sha512-k7ndgKhwoQveBL+/1tqGJYNz097I7WOvwbmmU2AR5+magtbjPWQTS1C5vzGkBC8Ym8UWRzfKUzUUqFLypY4Q+w==} engines: {node: '>=20'} + comma-separated-tokens@2.0.3: + resolution: {integrity: sha512-Fu4hJdvzeylCfQPp9SGWidpzrMs7tTrlu6Vb8XGaRGck8QSNZJJp538Wrb60Lax4fPwR64ViY468OIUTbRlGZg==} + concurrently@10.0.7: resolution: {integrity: sha512-zMCeLhawVIj3SLbpg0/BWCdJl1wcBSpcHKbNrhaM01P3xAlEWcH30Lea2q+F4uGZ7YM0scDK0dgpWyn1uCJj6w==} engines: {node: '>=22'} @@ -744,10 +820,17 @@ packages: csstype@3.2.3: resolution: {integrity: sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==} + dequal@2.0.3: + resolution: {integrity: sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==} + engines: {node: '>=6'} + detect-libc@2.1.2: resolution: {integrity: sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==} engines: {node: '>=8'} + devlop@1.1.0: + resolution: {integrity: sha512-RWmIqhcFf1lRYBvNmr7qTNuyCt/7/ns2jbpp1+PalgE/rDQcBT0fioSMUpJ93irlUhC5hrg4cYqe6U+0ImW0rA==} + emoji-regex@10.6.0: resolution: {integrity: sha512-toUI84YS5YmxW219erniWD0CIVOo46xGKColeNQRgOzDorgBi1v4D71/OFzgD9GO2UGKIv1C3Sp8DAn0+j5w7A==} @@ -792,10 +875,19 @@ packages: resolution: {integrity: sha512-XjH1AECxf0giL2V1aU8vKyRR2ppRUb5c0EvT7zuJTokQ74bNo52zOtghqdWIqrhUD79fo3x0WfKZdOqxF6LG1Q==} engines: {node: '>=18'} + hast-util-to-html@9.0.6: + resolution: {integrity: sha512-1SZUxCN3TtJAE7e2BQN2MBHsoZ1gnmi9GoCP5Di59CSWptIezSAW09yDZyVbanb78V9eCwrKqdQsjtfVTxYHWA==} + + hast-util-whitespace@3.0.0: + resolution: {integrity: sha512-88JUN06ipLwsnv+dVn+OIYOvAuvBMy/Qoi6O7mQHxdPXpjy+Cd6xRkWwux7DKO+4sYILtLBRIKgsdpS2gQc7qw==} + hono@4.13.18: resolution: {integrity: sha512-H9q/E1XizaWstJxUW881dmLxEj+t/TrGGnyxINkm4+sK0qUwsMtFdo2BWI9Vs3cIS19MU6b6iCijoUoEf4f3DA==} engines: {node: '>=16.9.0'} + html-void-elements@3.0.0: + resolution: {integrity: sha512-bEqo66MRXsUGxWHV5IP0PUiAWwoEjba4VCzg0LjFJBpchPaTfyfCKTG6bc5F8ucKec3q5y6qOdGyYTSBEvhCrg==} + lightningcss-android-arm64@1.33.0: resolution: {integrity: sha512-gEpRTalKdosp4Bb8qWtc2iOgE5SeIHlpS1up9bFq2wAyYhl1UdTObYiHe98zEM9SQvSoqQZ1IQD0JNpg3Ml5pg==} engines: {node: '>= 12.0.0'} @@ -873,6 +965,24 @@ packages: magic-string@1.4.5: resolution: {integrity: sha512-oLLC2+YvQUfAa+vxoufE/yc1icb87M9iXIRqAoR/2EhE/8cb3SF/+Gi0c2By1B+5Vz2e2vQtUvHiu1+63Znh+w==} + mdast-util-to-hast@13.2.1: + resolution: {integrity: sha512-cctsq2wp5vTsLIcaymblUriiTcZd0CwWtCbLvrOzYCDZoWyMNV8sZ7krj09FSnsiJi3WVsHLM4k6Dq/yaPyCXA==} + + micromark-util-character@2.1.1: + resolution: {integrity: sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q==} + + micromark-util-encode@2.0.1: + resolution: {integrity: sha512-c3cVx2y4KqUnwopcO9b/SCdo2O67LwJJ/UyqGfbigahfegL9myoEFoDYZgkT7f36T0bLrM9hZTAaAyH+PCAXjw==} + + micromark-util-sanitize-uri@2.0.1: + resolution: {integrity: sha512-9N9IomZ/YuGGZZmQec1MbgxtlgougxTodVwDzzEouPKo3qFWvymFHWcnDi2vzV1ff6kas9ucW+o3yzJK9YB1AQ==} + + micromark-util-symbol@2.0.1: + resolution: {integrity: sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==} + + micromark-util-types@2.0.3: + resolution: {integrity: sha512-oxB2Ik03hI0gv+VNn9tnh1t1YEe9MDPptViAEgfdf3YQHsn0pzGTgCdlSCJXcwhqm8phaEuM7zeEu3QQzVBrPg==} + nanoid@3.3.20: resolution: {integrity: sha512-uKdg2G3GNCKQn9byYOpxbGqrT2fGO5KRt5J/8b3pok8rT6qxGWF6hxMyJiEYtAf+FVyYuD9hRaDqX5uPFYJ4ZQ==} engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} @@ -882,6 +992,12 @@ packages: resolution: {integrity: sha512-5vvB5+W7ePv+p3uqxi+RcW1XAzLW0/hxt3/4X4Lc4qHudzOhmBiBwOY6DRob4WnanAEGvNcLjF+KNOufrUoEQw==} engines: {node: '>=12.20.0'} + oniguruma-parser@0.12.2: + resolution: {integrity: sha512-6HVa5oIrgMC6aA6WF6XyyqbhRPJrKR02L20+2+zpDtO5QAzGHAUGw5TKQvwi5vctNnRHkJYmjAhRVQF2EKdTQw==} + + oniguruma-to-es@4.3.6: + resolution: {integrity: sha512-csuQ9x3Yr0cEIs/Zgx/OEt9iBw9vqIunAPQkx19R/fiMq2oGVTgcMqO/V3Ybqefr1TBvosI6jU539ksaBULJyA==} + oxlint@1.93.0: resolution: {integrity: sha512-19JMsQFX+YvEbcUTFQxjTwhvs0Ibg0D6CFneSLgpwnACWcY/6LjhpGpkPodh0T5aIT1pjMTLlYaeBFzaVgugTA==} engines: {node: ^20.19.0 || >=22.12.0} @@ -921,6 +1037,9 @@ packages: engines: {node: '>=14'} hasBin: true + property-information@7.2.0: + resolution: {integrity: sha512-IAtzIB6sUiWaJYrX9smp3V46pBGbBeLFRGdh25kg1334VcBlD8HzhPeNIWQH9zhGmo2itIe25EHt9dQP7G5hmg==} + react-dom@19.3.1: resolution: {integrity: sha512-Y0bARz53lhEC1NMCASs0/j+faB/zqt3R8hpvg1e8+61ZVJ4UL0UdC4cBbXfZMcIuhrfgeILTLe+ZeBCavQPtKQ==} peerDependencies: @@ -930,6 +1049,15 @@ packages: resolution: {integrity: sha512-QNhWdt7nrgVWWQG58QuGsAR3jv3Hbe4mb4vz7w2csnHavciZJgda1CPNaldF6eVxv90ud3jUXpKlHL69gO38yw==} engines: {node: '>=0.10.0'} + regex-recursion@6.0.2: + resolution: {integrity: sha512-0YCaSCq2VRIebiaUviZNs0cBz1kg5kVS2UKUfNIx8YVs1cN3AV7NTctO5FOKBA+UT2BPJIWZauYHPqJODG50cg==} + + regex-utilities@2.3.0: + resolution: {integrity: sha512-8VhliFJAWRaUiVvREIiW2NXXTmHs4vMNnSzuJVhscgmGav3g9VDxLrQndI3dZZVVdp0ZO/5v0xmX516/7M9cng==} + + regex@6.1.0: + resolution: {integrity: sha512-6VwtthbV4o/7+OaAF9I5L5V3llLEsoPyq9P1JVXkedTP33c7MfCG0/5NOPcSJn0TzXcG9YUrR0gQSWioew3LDg==} + rolldown@1.2.19: resolution: {integrity: sha512-QIiV1J9d0pzN4jeeTH4sjPy0AZ6cAy2cG0ExeoE1+U8Rvj+hR3gYkokx0YbeUNGlZqiQJJ2utcETe0oKXwzsuA==} engines: {node: ^20.19.0 || >=22.12.0} @@ -945,10 +1073,17 @@ packages: resolution: {integrity: sha512-PcByqNyT/38F2kDNi006HAMRJaULuBzq/FOsw3qdZvX/GA9W/jamDaRskgHjubHiftXK5sIFxLNkvrXUwcof6Q==} engines: {node: '>= 0.4'} + shiki@4.6.0: + resolution: {integrity: sha512-imjLsVHgPuWhvpU3P+zOekvMYqnel7QmKsFC4Sn0fCuAvaaalBsxwKEsrU8Ko5BdFnZA6Go/8a0RzahS634UgA==} + engines: {node: '>=20'} + source-map-js@1.2.2: resolution: {integrity: sha512-KGj/8Y43x35aZVDtt+J4mK1hoLGHULMYfSkODJNQjNDC3oW1PqPoxMwo0pLUsWM/UEGzON/NxeHywEfNXNP3Vw==} engines: {node: '>=0.10.0'} + space-separated-tokens@2.0.2: + resolution: {integrity: sha512-PEGlAwrG8yXGXRjW32fGbg66JAlOAwbObuqVoJpv/mRgoWDQfgH1wDPvtzWyUSNAXBGSk8h755YDbbcEy3SH2Q==} + std-env@4.3.0: resolution: {integrity: sha512-OtU/EgQ1kIm5KwqQpBC6ZEMXrZRui11w8zgfTWp8cdO9B8OaPsbA8bTHO2P+HNo1VlUTGMVBwPhydu6poeXiag==} @@ -956,6 +1091,9 @@ packages: resolution: {integrity: sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==} engines: {node: '>=18'} + stringify-entities@4.0.4: + resolution: {integrity: sha512-IwfBptatlO+QCJUo19AqvrPNqlVMpW9YEL2LIVY+Rpv2qsjCGxaDLNRgeGsQWJhfItebuJhsGSLjaBbNSQ+ieg==} + strip-ansi@7.2.0: resolution: {integrity: sha512-yDPMNjp4WyfYBkHnjIRLfca1i6KMyGCtsVgoKe/z1+6vukgaENdgGBZt+ZmKPc4gavvEZ5OgHfHdrazhgNyG7w==} engines: {node: '>=12'} @@ -980,6 +1118,9 @@ packages: resolution: {integrity: sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==} hasBin: true + trim-lines@3.0.1: + resolution: {integrity: sha512-kRj8B+YHZCc9kQYdWfJB2/oUl9rA99qbowYYBtr4ui4mZyAQ2JpvVBd/6U2YloATfqBhBTSMhTpgBHtU0Mf3Rg==} + tslib@2.9.1: resolution: {integrity: sha512-a4Ux9VKuIMHsOS7ENbEq6hK2ZGYIT27Rtl0E4eD9KqwxhKiQeMZE/9xb3IdYwWaSOyIBQLExhQgXDTYoiCxnWA==} @@ -996,6 +1137,21 @@ packages: undici-types@7.24.6: resolution: {integrity: sha512-WRNW+sJgj5OBN4/0JpHFqtqzhpbnV0GuB+OozA9gCL7a993SmU+1JBZCzLNxYsbMfIeDL+lTsphD5jN5N+n0zg==} + unist-util-is@6.0.1: + resolution: {integrity: sha512-LsiILbtBETkDz8I9p1dQ0uyRUWuaQzd/cuEeS1hoRSyW5E5XGmTzlwY1OrNzzakGowI9Dr/I8HVaw4hTtnxy8g==} + + unist-util-position@5.0.0: + resolution: {integrity: sha512-fucsC7HjXvkB5R3kTCO7kUjRdrS0BJt3M/FPxmHMBOm8JQi2BsHAHFsy27E0EolP8rp0NzXsJ+jNPyDWvOJZPA==} + + unist-util-stringify-position@4.0.0: + resolution: {integrity: sha512-0ASV06AAoKCDkS2+xw5RXJywruurpbC4JZSm7nr7MOt1ojAzvyyaO+UxZf18j8FCF6kmzCZKcAgN/yu2gm2XgQ==} + + unist-util-visit-parents@6.1.0: + resolution: {integrity: sha512-vKXxz6O38sKDj1mtx/k2cWvkkFBuYGx6uGrlzBkVeWCRF/F8sdI0j3Wbkz/5rVNRRuVc8UrgRdbCxNhmYXgP3w==} + + unist-util-visit@5.2.0: + resolution: {integrity: sha512-fpsYs/VVoZxfGY9/j3FQpZmN8wdLJaV1Pt38AaJNZu9uKIHcFU3halCdBveEq1HGKO1OEfJY65w1zvoFV1b3qQ==} + valibot@1.5.0: resolution: {integrity: sha512-nil6AkP2TChWL43Z5uJ6GTxX01CUA+g8LWUM+N/rB9NBbkUMaUsi9PUNzlUPgoKASgmx9f7eGOYpJ04/fSa6FQ==} peerDependencies: @@ -1004,6 +1160,12 @@ packages: typescript: optional: true + vfile-message@4.0.4: + resolution: {integrity: sha512-66ycRswIkNmHH9PHku7ADtv5RVwgIrOcuv3J8Svz6h4qgGRrKVa+9/neuKyJZUXyOpYwLTvS+whZ4R2urHHgQg==} + + vfile@6.0.3: + resolution: {integrity: sha512-KzIbH/9tXat2u30jf+smMwFCsno4wHVdNmzFyL+T/L3UGqqk6JKfVqOFOZEpZSHADH1k40ab6NUIXZq422ov3Q==} + vite@8.3.8: resolution: {integrity: sha512-LzOn3h9rG/0vhLdXrV4yJ4QFA9eEoqCl+Yx+kGJd7aB9w6nfNgVHKSYwLPZUHrz4ZGa+t+kXjV9itvcHDLQouA==} engines: {node: ^20.19.0 || >=22.12.0} @@ -1109,6 +1271,9 @@ packages: resolution: {integrity: sha512-4UEqdc2RYGHZc7Doyqkrqiln3p9X2DZVxaGbwhn2pi7MrRagKaOcIKe8L3OxYcbhXLgLFUS3zAYuQjKBQgmuNg==} engines: {node: ^20.19.0 || ^22.12.0 || >=23} + zwitch@2.0.4: + resolution: {integrity: sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==} + snapshots: '@emnapi/core@2.0.0-beta.2': @@ -1350,6 +1515,48 @@ snapshots: '@rolldown/pluginutils@1.1.0': {} + '@shikijs/core@4.6.0': + dependencies: + '@shikijs/primitive': 4.6.0 + '@shikijs/types': 4.6.0 + '@shikijs/vscode-textmate': 10.1.0 + '@types/hast': 3.0.5 + hast-util-to-html: 9.0.6 + + '@shikijs/engine-javascript@4.6.0': + dependencies: + '@shikijs/types': 4.6.0 + '@shikijs/vscode-textmate': 10.1.0 + oniguruma-to-es: 4.3.6 + + '@shikijs/engine-oniguruma@4.6.0': + dependencies: + '@shikijs/types': 4.6.0 + '@shikijs/vscode-textmate': 10.1.0 + + '@shikijs/langs@4.6.0': + dependencies: + '@shikijs/types': 4.6.0 + + '@shikijs/primitive@4.6.0': + dependencies: + '@shikijs/types': 4.6.0 + '@shikijs/vscode-textmate': 10.1.0 + '@types/hast': 3.0.5 + + '@shikijs/themes@4.6.0': + dependencies: + '@shikijs/types': 4.6.0 + + '@shikijs/types@4.6.0': + dependencies: + '@shikijs/vscode-textmate': 10.1.0 + '@types/hast': 3.0.5 + + '@shikijs/vscode-textmate@10.1.0': {} + + '@terrazzo/token-types@2.10.0': {} + '@tybys/wasm-util@0.10.4': dependencies: tslib: 2.9.1 @@ -1364,6 +1571,14 @@ snapshots: '@types/estree@1.0.10': {} + '@types/hast@3.0.5': + dependencies: + '@types/unist': 3.0.3 + + '@types/mdast@4.0.4': + dependencies: + '@types/unist': 3.0.3 + '@types/node@24.19.2': dependencies: undici-types: 7.24.6 @@ -1376,6 +1591,8 @@ snapshots: dependencies: csstype: 3.2.3 + '@types/unist@3.0.3': {} + '@typescript/typescript-aix-ppc64@7.0.2': optional: true @@ -1436,6 +1653,8 @@ snapshots: '@typescript/typescript-win32-x64@7.0.2': optional: true + '@ungap/structured-clone@1.4.0': {} + '@valibot/i18n@1.3.0(valibot@1.5.0(typescript@7.0.2))': dependencies: valibot: 1.5.0(typescript@7.0.2) @@ -1456,6 +1675,10 @@ snapshots: '@vitest/spy@5.1.0': {} + '@whatsaaaa/design-system@0.1.1': + dependencies: + '@terrazzo/token-types': 2.10.0 + '@whatsaaaa/form-builder-affects@0.2.2-rc.0(@whatsaaaa/form-builder-schema@1.0.0-rc.0(valibot@1.5.0(typescript@7.0.2)))(valibot@1.5.0(typescript@7.0.2))': dependencies: '@whatsaaaa/form-builder-schema': 1.0.0-rc.0(valibot@1.5.0(typescript@7.0.2)) @@ -1478,16 +1701,24 @@ snapshots: assertion-error@2.0.1: {} + ccount@2.0.1: {} + chai@6.3.0: {} chalk@5.6.2: {} + character-entities-html4@2.1.0: {} + + character-entities-legacy@3.0.0: {} + cliui@9.0.1: dependencies: string-width: 7.2.0 strip-ansi: 7.2.0 wrap-ansi: 9.0.2 + comma-separated-tokens@2.0.3: {} + concurrently@10.0.7: dependencies: chalk: 5.6.2 @@ -1499,8 +1730,14 @@ snapshots: csstype@3.2.3: {} + dequal@2.0.3: {} + detect-libc@2.1.2: {} + devlop@1.1.0: + dependencies: + dequal: 2.0.3 + emoji-regex@10.6.0: {} es-module-lexer@2.3.2: {} @@ -1553,8 +1790,28 @@ snapshots: get-east-asian-width@1.7.0: {} + hast-util-to-html@9.0.6: + dependencies: + '@types/hast': 3.0.5 + '@types/unist': 3.0.3 + ccount: 2.0.1 + comma-separated-tokens: 2.0.3 + hast-util-whitespace: 3.0.0 + html-void-elements: 3.0.0 + mdast-util-to-hast: 13.2.1 + property-information: 7.2.0 + space-separated-tokens: 2.0.2 + stringify-entities: 4.0.4 + zwitch: 2.0.4 + + hast-util-whitespace@3.0.0: + dependencies: + '@types/hast': 3.0.5 + hono@4.13.18: {} + html-void-elements@3.0.0: {} + lightningcss-android-arm64@1.33.0: optional: true @@ -1608,10 +1865,47 @@ snapshots: dependencies: '@jridgewell/sourcemap-codec': 1.6.0 + mdast-util-to-hast@13.2.1: + dependencies: + '@types/hast': 3.0.5 + '@types/mdast': 4.0.4 + '@ungap/structured-clone': 1.4.0 + devlop: 1.1.0 + micromark-util-sanitize-uri: 2.0.1 + trim-lines: 3.0.1 + unist-util-position: 5.0.0 + unist-util-visit: 5.2.0 + vfile: 6.0.3 + + micromark-util-character@2.1.1: + dependencies: + micromark-util-symbol: 2.0.1 + micromark-util-types: 2.0.3 + + micromark-util-encode@2.0.1: {} + + micromark-util-sanitize-uri@2.0.1: + dependencies: + micromark-util-character: 2.1.1 + micromark-util-encode: 2.0.1 + micromark-util-symbol: 2.0.1 + + micromark-util-symbol@2.0.1: {} + + micromark-util-types@2.0.3: {} + nanoid@3.3.20: {} obug@3.0.0: {} + oniguruma-parser@0.12.2: {} + + oniguruma-to-es@4.3.6: + dependencies: + oniguruma-parser: 0.12.2 + regex: 6.1.0 + regex-recursion: 6.0.2 + oxlint@1.93.0: optionalDependencies: '@oxlint/binding-android-arm-eabi': 1.93.0 @@ -1652,6 +1946,8 @@ snapshots: prettier@3.9.10: {} + property-information@7.2.0: {} + react-dom@19.3.1(react@19.3.1): dependencies: react: 19.3.1 @@ -1659,6 +1955,16 @@ snapshots: react@19.3.1: {} + regex-recursion@6.0.2: + dependencies: + regex-utilities: 2.3.0 + + regex-utilities@2.3.0: {} + + regex@6.1.0: + dependencies: + regex-utilities: 2.3.0 + rolldown@1.2.19: dependencies: '@oxc-project/types': 0.156.0 @@ -1689,8 +1995,21 @@ snapshots: shell-quote@1.12.0: {} + shiki@4.6.0: + dependencies: + '@shikijs/core': 4.6.0 + '@shikijs/engine-javascript': 4.6.0 + '@shikijs/engine-oniguruma': 4.6.0 + '@shikijs/langs': 4.6.0 + '@shikijs/themes': 4.6.0 + '@shikijs/types': 4.6.0 + '@shikijs/vscode-textmate': 10.1.0 + '@types/hast': 3.0.5 + source-map-js@1.2.2: {} + space-separated-tokens@2.0.2: {} + std-env@4.3.0: {} string-width@7.2.0: @@ -1699,6 +2018,11 @@ snapshots: get-east-asian-width: 1.7.0 strip-ansi: 7.2.0 + stringify-entities@4.0.4: + dependencies: + character-entities-html4: 2.1.0 + character-entities-legacy: 3.0.0 + strip-ansi@7.2.0: dependencies: ansi-regex: 6.6.0 @@ -1716,6 +2040,8 @@ snapshots: tree-kill@1.2.2: {} + trim-lines@3.0.1: {} + tslib@2.9.1: {} tsx@4.23.15: @@ -1749,10 +2075,43 @@ snapshots: undici-types@7.24.6: {} + unist-util-is@6.0.1: + dependencies: + '@types/unist': 3.0.3 + + unist-util-position@5.0.0: + dependencies: + '@types/unist': 3.0.3 + + unist-util-stringify-position@4.0.0: + dependencies: + '@types/unist': 3.0.3 + + unist-util-visit-parents@6.1.0: + dependencies: + '@types/unist': 3.0.3 + unist-util-is: 6.0.1 + + unist-util-visit@5.2.0: + dependencies: + '@types/unist': 3.0.3 + unist-util-is: 6.0.1 + unist-util-visit-parents: 6.1.0 + valibot@1.5.0(typescript@7.0.2): optionalDependencies: typescript: 7.0.2 + vfile-message@4.0.4: + dependencies: + '@types/unist': 3.0.3 + unist-util-stringify-position: 4.0.0 + + vfile@6.0.3: + dependencies: + '@types/unist': 3.0.3 + vfile-message: 4.0.4 + vite@8.3.8(@types/node@24.19.2)(esbuild@0.28.2)(tsx@4.23.15): dependencies: lightningcss: 1.33.0 @@ -1807,3 +2166,5 @@ snapshots: string-width: 7.2.0 y18n: 5.0.8 yargs-parser: 22.0.0 + + zwitch@2.0.4: {} diff --git a/react-checkout/pnpm-workspace.yaml b/react-checkout/pnpm-workspace.yaml index d67a2c7..754a81c 100644 --- a/react-checkout/pnpm-workspace.yaml +++ b/react-checkout/pnpm-workspace.yaml @@ -4,3 +4,4 @@ minimumReleaseAgeExclude: - '@whatsaaaa/form-builder-schema@1.0.0-rc.0' - '@whatsaaaa/form-builder-react@1.0.0-rc.0' - '@whatsaaaa/form-builder-affects@0.2.2-rc.0' + - '@whatsaaaa/design-system@0.1.1' From 55e966a541b11f0b39c4be4741873454edc308af Mon Sep 17 00:00:00 2001 From: Whatsaaaa Date: Fri, 13 Nov 2026 20:14:03 +0100 Subject: [PATCH 2/8] Restyle the React app on the design system's terminal frame The page is the design system's window, as in the Vue app: a tab bar with form-builder's mark, a link to its docs and the ghost, and a status line with the mode, the theme switch and the switch for the shortcut keys. The fields, buttons, groups, notices and code block are the Vue app's, ported to React. Every color, font, size, space, radius and border comes from a design system token, in both themes. What the Vue app does not have: the checkout's sections are titled parts of the page, side by side on a wide screen and one under the other on a phone; the language switch is a pair of buttons that share an edge; the order summary lists its amounts on the right; a server's rejection is a message over the order button, in the voice of a field's error. The loading line is StatusMessage now, as StatusLine is the window's. On a 320 px screen the status line keeps the mode, the keys switch and the theme's name whole, with the keys on or off: the path shrinks behind its ellipsis and then goes. Shiki is loaded on its own, so the first render does not wait for it and no chunk is over Vite's 500 kB warning. --- react-checkout/index.html | 4 +- react-checkout/public/apple-touch-icon.png | Bin 0 -> 913 bytes react-checkout/public/favicon.ico | Bin 0 -> 15086 bytes react-checkout/public/favicon.svg | 2 +- react-checkout/src/App.tsx | 12 +- react-checkout/src/styles.css | 827 +++++++++++++----- react-checkout/src/ui/CodeBlock.tsx | 88 +- react-checkout/src/ui/LanguageSwitch.tsx | 29 + react-checkout/src/ui/Notice.tsx | 11 +- react-checkout/src/ui/PageShell.tsx | 49 +- react-checkout/src/ui/StatusLine.tsx | 93 +- react-checkout/src/ui/StatusMessage.tsx | 13 + react-checkout/src/ui/TabBar.tsx | 47 + react-checkout/src/ui/assets/mark-on-dark.svg | 1 + .../src/ui/assets/mark-on-light.svg | 1 + react-checkout/src/ui/fields/FieldShell.tsx | 5 +- react-checkout/src/ui/fields/SelectInput.tsx | 43 +- react-checkout/src/ui/fields/TextInput.tsx | 3 - react-checkout/src/ui/highlight.ts | 21 + react-checkout/src/ui/layout/LayoutRow.tsx | 13 +- .../src/ui/layout/LayoutSection.tsx | 13 +- react-checkout/vite.config.ts | 24 +- 22 files changed, 1001 insertions(+), 298 deletions(-) create mode 100644 react-checkout/public/apple-touch-icon.png create mode 100644 react-checkout/public/favicon.ico create mode 100644 react-checkout/src/ui/LanguageSwitch.tsx create mode 100644 react-checkout/src/ui/StatusMessage.tsx create mode 100644 react-checkout/src/ui/TabBar.tsx create mode 100644 react-checkout/src/ui/assets/mark-on-dark.svg create mode 100644 react-checkout/src/ui/assets/mark-on-light.svg create mode 100644 react-checkout/src/ui/highlight.ts diff --git a/react-checkout/index.html b/react-checkout/index.html index e721036..78767bd 100644 --- a/react-checkout/index.html +++ b/react-checkout/index.html @@ -2,9 +2,11 @@ - Checkout - form-builder sample + + +
diff --git a/react-checkout/public/apple-touch-icon.png b/react-checkout/public/apple-touch-icon.png new file mode 100644 index 0000000000000000000000000000000000000000..f4ade4017b17ae3268826231fd401b805c19ad3e GIT binary patch literal 913 zcmeAS@N?(olHy`uVBq!ia0vp^TR@nD4M^IaWiw)6V2uUj5`vTc9CzPkV49{=TT5ikj4@fC3tcD>*t zNOk6v+s$=<|Np9Zc=`1D>Bp<(9Y2ROsdX*rRLWSyF-wCK=IiFRbRpdC16uTL`r>t; z?kC=^)80H+;ETi5#re1MQ@05>$*m~*lKXq@nKGvf%%Oeza`#WY>BmvE;MB$KZ?_xW z=5*u_vHZ2|Z&;eO;)_Nt_xs!KpUP2Zu?=|o;`X=bnQvPbu&FW4NW;F&+S3j3^P6f0l$>|5KYjT1z^9MTuD3Fwr^>3$G)qx=(J!e z$d~4s5uVq0(){E(t{02T<)m0$O^P2j-)ek$?Mh6 zR$SJ%#kc$z-;x$iTfG&R^=vVtUSNOwae(E+*M7 zRWhFC$96Gk`N#B(7t`~7wu?!&OO=dg`LW#~o5z8bzpi>K?_KdN{~>*RVZc#QQI#SGVgIr31(2x2pjdOdcFePaK8vg&KM z;re?6aIpqBU(q%}rh{UwG3Ewi(>?`mk-`n0-hB!*eLTvX(cS^>*=XyzuKhLUU+rt) z9xZYRbNfiLp-{Iqjr|;Z9^u+QcD<$f$f^hFkCE$G8-(|XTdWRc-uspFXj_DJ=zHF+ zb~x&@PCoZi$~Ycq_?}R|3HwvE&qs4)O1=AJThH$&%isBI;=K(`9wP_dxnASVx?}M7 z#$=9~^kU_*)3{o?TpYDH7Dr95;pWn5{48BAj#?axqo&tzbLljGmM#}ZEsn)e(`&f7 zbQ(WPmy4qo$Kt5zHQZb}ji05<#c_xe>^b)7xAlp0vG%*$=w*LR^_RY$aw@*ZUdHv< zOB?CyDNEmdm1W#iOzG<>r{a6;Wn7QFw2{7^vh>|oS;kGpl)j#FD!#{F#`V}s8|gcg zhv(Lz`+)3weJH2aw-1~phk<|mdvTekLzRd8_b~tE`{dbuYTNY2zWhJQ>|<~Eq^_Ch z-7x)^C)KY9_VPOoEPpw \ No newline at end of file +form-builder diff --git a/react-checkout/src/App.tsx b/react-checkout/src/App.tsx index c854a09..c322914 100644 --- a/react-checkout/src/App.tsx +++ b/react-checkout/src/App.tsx @@ -10,7 +10,7 @@ import { Button } from './ui/Button' import { CodeBlock } from './ui/CodeBlock' import { Notice } from './ui/Notice' import { PageShell } from './ui/PageShell' -import { StatusLine } from './ui/StatusLine' +import { StatusMessage } from './ui/StatusMessage' type Loading = | { status: 'loading' } @@ -108,7 +108,7 @@ export function App() { function Status({ messageKey }: { messageKey: string }) { const { t } = useLocale() - return {t(messageKey)} + return {t(messageKey)} } function LoadFailed({ onRetry }: { onRetry: () => void }) { @@ -137,9 +137,11 @@ function OrderPlaced({

{t('done.total')}: {money(order.total)}

- - {JSON.stringify(order.order, null, 2)} - + ) diff --git a/react-checkout/src/styles.css b/react-checkout/src/styles.css index 597210e..17d293a 100644 --- a/react-checkout/src/styles.css +++ b/react-checkout/src/styles.css @@ -1,178 +1,345 @@ /* - * The whole look of the app. It is plain on purpose: the components under src/ui carry the class - * names, and this file gives them a look, so a restyle swaps this file and those components only. + * The whole look of the app, on the Whatsaaaa design system. The design system brings the fonts, + * the tokens and the terminal frame; this file lays the page out in that frame and gives the form + * controls, which the design system leaves to each app, their look from its roles. The components + * under src/ui carry the class names, so a restyle swaps this file and those components only. */ +@import '@whatsaaaa/design-system/index.css'; + :root { - --color-page: #f4f4f2; - --color-surface: #ffffff; - --color-text: #1c1d1f; - --color-muted: #5a5e66; - --color-border: #c9ccd1; - --color-border-strong: #868b94; - --color-accent: #1d4ed8; - --color-accent-strong: #1a3fae; - --color-on-accent: #ffffff; - --color-error: #b42318; - --color-error-surface: #fef3f2; - --color-success: #17663a; - --color-success-surface: #f0f9f3; - - --radius: 6px; - --space-1: 0.25rem; - --space-2: 0.5rem; - --space-3: 0.75rem; - --space-4: 1rem; - --space-5: 1.5rem; - --space-6: 2rem; - - --control-height: 2.75rem; - - font-family: - system-ui, - -apple-system, - 'Segoe UI', - Roboto, - 'Helvetica Neue', - Arial, - sans-serif; - font-size: 100%; - line-height: 1.5; - color: var(--color-text); - background: var(--color-page); -} - -*, -*::before, -*::after { - box-sizing: border-box; + /* + * The space between the window's edge and what is in it: the tab bar's own, so the edges of the + * form line up with the brand on the left and with the links on the right. + */ + --page-gutter: var(--ws-space-20); + /* The height of a one-line field and of a button. */ + --control-height: var(--ws-space-40); + /* A tick, drawn as a mask like the design system's icons: only its shape counts. It fills its box. */ + --icon-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='2 2 12 12' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 8.5 6.5 12 13 4.5'/%3E%3C/svg%3E"); +} + +@media (width < 64rem) { + :root { + --page-gutter: var(--ws-space-16); + } } +.visually-hidden { + position: absolute; + width: 1px; + height: 1px; + margin: -1px; + padding: 0; + overflow: hidden; + clip-path: inset(50%); + white-space: nowrap; + border: 0; +} + +/* The window: as tall as the screen, as wide as the form. Its content scrolls inside it. */ + body { - margin: 0; + padding: var(--ws-space-20); } -h1, -h2, -h3, -p, -dl, -dd, -ol, -ul { - margin: 0; +.page { + max-width: calc( + var(--ws-size-content) + 2 * var(--page-gutter) + 2 * + var(--ws-border-width-thin) + ); + height: calc(100dvh - 2 * var(--ws-space-20)); + margin-inline: auto; } -button, -input, -select, -textarea { - font: inherit; +.page__main { + overflow: auto; +} + +.page__content { + padding: var(--ws-space-40) var(--page-gutter) var(--ws-space-48); +} + +/* On a narrow screen the window grows with the form, and the page scrolls. */ +@media (width < 64rem) { + body { + padding: var(--ws-space-12); + } + + .page { + height: auto; + min-height: calc(100dvh - 2 * var(--ws-space-12)); + } + + .page__main { + overflow: visible; + } + + .page__content { + padding-block: var(--ws-space-24) var(--ws-space-40); + } +} + +/* Tab bar */ + +/* + * The mark at 32 px, two screen pixels to a sprite pixel. Its file keeps two empty sprite columns + * on each side, so it reaches past its box by them: its pixels start where the form does, and + * they stand off the name by the bar's own gap. + */ +.tab-bar__mark { + width: var(--ws-space-32); + height: var(--ws-space-32); + margin-inline: calc(-1 * var(--ws-space-4)); +} + +/* + * The cut of the mark for the page's theme. The same rule as the design system's for the name of + * the theme in the status line: an image has no token to switch. + */ +[data-theme='dark'] .tab-bar__mark--light, +[data-theme='light'] .tab-bar__mark--dark { + display: none; +} + +@media (prefers-color-scheme: light) { + :root:not([data-theme]) .tab-bar__mark--dark { + display: none; + } +} + +@media not (prefers-color-scheme: light) { + :root:not([data-theme]) .tab-bar__mark--light { + display: none; + } +} + +/* The ghost keeps its body in the text color, as everywhere. */ +.ws-tab-bar__end .tab-bar__ghost { + color: var(--ws-color-text); + line-height: 0; +} + +/* Status line */ + +/* + * The path is decoration, so it gives way first, down to a 320 px screen: it shrinks behind its + * ellipsis, and once not even "~/…" fits, it leaves the line with its fill and its padding, which + * would not shrink on the box itself. Its text wraps to a second line of the box that is never + * seen: the empty item before it starts the first line, and the box keeps the status line's + * height. + */ +.ws-status-line__file { + flex-wrap: wrap; + gap: 0; + height: calc(var(--ws-size-status-line) - var(--ws-border-width-thin)); + padding-inline: 0; + overflow: hidden; + background: none; +} + +.ws-status-line__file::before { + height: 100%; + content: ''; +} + +/* + * As wide as "~/…" to start with, so that is where it wraps, and as wide as the path when there is + * room. Its text sits on the middle of the line, where the other items center theirs. + */ +.ws-status-line__file > span { + flex: 1 1 calc(2 * var(--ws-space-14) + 3ch); + max-width: max-content; + padding: calc( + (var(--ws-size-status-line) - var(--ws-border-width-thin) - 1lh) / 2 + ) + var(--ws-space-14); + background: var(--ws-color-raised); +} + +.status-line__theme { + margin: 0; + border-block: 0; + border-right: 0; color: inherit; + font: inherit; + cursor: pointer; + background: none; +} + +.status-line__theme:hover { + color: var(--ws-color-text); } -:focus-visible { - outline: 3px solid var(--color-accent); - outline-offset: 2px; +/* + * The focus ring of a control in the status line goes inside it, as the keys switch's does: the + * line cuts off what reaches past its edges. A key hint gets room for the ring from the gap + * around it, so nothing moves. + */ +.ws-status-line__keys :is(button, a) { + margin-inline: calc(-1 * var(--ws-space-6)); + padding-inline: var(--ws-space-6); } -/* Page */ +.ws-status-line__keys :is(button, a):focus-visible, +.status-line__theme:focus-visible { + outline-offset: calc(-1 * var(--ws-border-width-medium)); +} -.page { - max-width: 64rem; - margin: 0 auto; - padding: var(--space-6) var(--space-4); +/* The theme's name is the last item, in the window's corner: its ring follows that curve. */ +.status-line__theme:focus-visible { + border-radius: var(--ws-radius-sm) var(--ws-radius-sm) + calc(var(--ws-radius-xl) - var(--ws-border-width-thin)) var(--ws-radius-sm); } +/* Page header: the title and its lead, with the switch between languages beside the title. */ + .page__header { - display: flex; - flex-wrap: wrap; - align-items: flex-start; - justify-content: space-between; - gap: var(--space-3) var(--space-5); - margin-bottom: var(--space-5); + display: grid; + grid-template-columns: minmax(0, 1fr) auto; + column-gap: var(--ws-space-24); + margin-bottom: var(--ws-space-32); } .page__title { - font-size: 1.75rem; - line-height: 1.2; + font: var(--ws-text-h1); + letter-spacing: var(--ws-text-h1-letter-spacing); } .page__lead { - margin-top: var(--space-2); - color: var(--color-muted); + margin-top: var(--ws-space-8); + color: var(--ws-color-text-secondary); + font: var(--ws-text-lead); } -.status { - color: var(--color-muted); +.language { + display: flex; + grid-row: 1; + grid-column: 2; + align-self: center; } -/* Language switch */ +@media (width < 64rem) { + .page__title { + font: var(--ws-text-h1-compact); + letter-spacing: var(--ws-text-h1-compact-letter-spacing); + } -.language { - display: inline-flex; - border: 1px solid var(--color-border-strong); - border-radius: var(--radius); + /* A title and two language names do not fit one line of a phone: the switch goes under the lead. */ + .page__header { + grid-template-columns: minmax(0, 1fr); + } + + .language { + grid-row: auto; + grid-column: 1; + justify-self: start; + margin-top: var(--ws-space-16); + } } +/* Language switch: two buttons that share an edge. The pressed one is filled, like a checked radio. */ + .language__button { - min-height: 2.25rem; - padding: var(--space-1) var(--space-3); + min-height: var(--control-height); + margin: 0; + padding: 0 var(--ws-space-16); + border: var(--ws-border-width-thin) solid var(--ws-color-field-border); + color: var(--ws-color-text-secondary); + font: var(--ws-text-label); + font-weight: var(--ws-font-weight-semibold); cursor: pointer; - background: var(--color-surface); - border: 0; + background: none; } .language__button:first-child { - border-radius: var(--radius) 0 0 var(--radius); + border-radius: var(--ws-radius-md) 0 0 var(--ws-radius-md); } .language__button:last-child { - border-radius: 0 var(--radius) var(--radius) 0; + border-radius: 0 var(--ws-radius-md) var(--ws-radius-md) 0; } +/* The shared edge is one line: the pressed or hovered button draws it, on top of the other. */ .language__button + .language__button { - border-left: 1px solid var(--color-border-strong); + margin-left: calc(-1 * var(--ws-border-width-thin)); +} + +.language__button:hover { + position: relative; + border-color: var(--ws-color-text-secondary); + color: var(--ws-color-text); + background: var(--ws-color-raised); } .language__button[aria-pressed='true'] { - font-weight: 600; - color: var(--color-on-accent); - background: var(--color-accent); + position: relative; + border-color: var(--ws-color-interactive); + color: var(--ws-color-on-interactive); + cursor: default; + background: var(--ws-color-interactive); } -/* Form */ +.language__button:focus-visible { + position: relative; + z-index: 1; +} -.stack { +/* The line the page shows while the checkout loads. */ +.status-message { + color: var(--ws-color-text-secondary); + font: var(--ws-text-label); +} + +/* Sections: the parts of the checkout, each with a title, one under the other. */ + +.sections { display: flex; flex-direction: column; - gap: var(--space-5); + gap: var(--ws-space-32); min-width: 0; } -.stack--tight { - gap: var(--space-3); +.sections > * + * { + padding-top: var(--ws-space-32); + border-top: var(--ws-border-width-thin) solid var(--ws-color-border); } -/* Sections */ - -.card { +.section { min-width: 0; - padding: var(--space-5); - background: var(--color-surface); - border: 1px solid var(--color-border); - border-radius: var(--radius); } -.card__title { - margin-bottom: var(--space-4); - font-size: 1.25rem; - line-height: 1.3; +.section__title { + font: var(--ws-text-h2); + letter-spacing: var(--ws-text-h2-letter-spacing); +} + +.section__lead { + margin-top: var(--ws-space-4); + color: var(--ws-color-text-secondary); + font: var(--ws-text-body-sm); } -.card__lead { - margin: calc(-1 * var(--space-3)) 0 var(--space-4); - color: var(--color-muted); +.section > .stack { + margin-top: var(--ws-space-24); +} + +@media (width < 64rem) { + .section__title { + font: var(--ws-text-h2-compact); + letter-spacing: var(--ws-text-h2-compact-letter-spacing); + } +} + +.stack { + display: flex; + flex-direction: column; + gap: var(--ws-space-24); + min-width: 0; +} + +.stack--tight { + gap: var(--ws-space-16); } /* Fields */ @@ -180,7 +347,7 @@ textarea { .field { display: flex; flex-direction: column; - gap: var(--space-1); + gap: var(--ws-space-6); min-width: 0; margin: 0; padding: 0; @@ -189,115 +356,255 @@ textarea { .field__label { padding: 0; - font-weight: 600; + color: var(--ws-color-text); + font: var(--ws-text-label); } .field__required { - color: var(--color-error); + color: var(--ws-color-brand); } .field__hint { - font-size: 0.875rem; - color: var(--color-muted); + color: var(--ws-color-text-secondary); + font: var(--ws-text-body-sm); } +/* An error is a word with the danger icon before it, never a color alone. */ .field__error { - font-size: 0.875rem; - font-weight: 600; - color: var(--color-error); + display: flex; + gap: var(--ws-space-6); + color: var(--ws-color-danger-text); + font: var(--ws-text-body-sm); + font-weight: var(--ws-font-weight-medium); +} + +.field__error::before { + flex: none; + width: var(--ws-space-16); + height: 1lh; + content: ''; + background: var(--ws-color-danger); + mask: var(--ws-icon-danger) center / var(--ws-space-16) no-repeat; } .input { display: block; width: 100%; min-width: 0; - min-height: var(--control-height); - padding: var(--space-2) var(--space-3); - background: var(--color-surface); - border: 1px solid var(--color-border-strong); - border-radius: var(--radius); + height: var(--control-height); + padding: 0 var(--ws-space-12); + border: var(--ws-border-width-thin) solid var(--ws-color-field-border); + border-radius: var(--ws-radius-md); + color: var(--ws-color-text); + font-family: var(--ws-font-family-sans); + font-size: var(--ws-font-size-16); + line-height: var(--ws-font-line-height-normal); + background: var(--ws-color-bg); +} + +.input:hover { + border-color: var(--ws-color-text-secondary); +} + +/* + * A number is typed, and stepped with the arrow keys. The browser's own spin buttons have no look + * of the system's, so they go. + */ +.input[type='number'] { + appearance: textfield; +} + +.input::-webkit-inner-spin-button, +.input::-webkit-outer-spin-button { + margin: 0; + appearance: none; } .input--multiline { + height: auto; + min-height: var(--control-height); + padding-block: var(--ws-space-8); resize: vertical; } -/* A native select indents its text a little more than an input does. */ -select.input { - padding-inline-start: calc(var(--space-3) - 0.25rem); +/* A select draws no arrow of its own here: its box draws one, where the field's text would end. */ +.select { + position: relative; } -.field--invalid .input { - border-color: var(--color-error); - box-shadow: 0 0 0 1px var(--color-error); +/* Room on the right for the arrow, with the field's own padding on both sides of it. */ +.select .input { + padding-right: calc(3 * var(--ws-space-12)); + cursor: pointer; + appearance: none; +} + +.select::after { + position: absolute; + top: 50%; + right: calc(var(--ws-space-12) + var(--ws-border-width-thin)); + width: var(--ws-space-12); + height: var(--ws-space-12); + content: ''; + background: var(--ws-color-text-secondary); + mask: var(--ws-icon-chevron) center / contain no-repeat; + translate: 0 -50%; + rotate: 90deg; + pointer-events: none; +} + +.field--invalid .input, +.field--invalid .input:hover { + border-color: var(--ws-color-danger); + box-shadow: inset 0 0 0 var(--ws-border-width-thin) var(--ws-color-danger); } .choices { display: flex; flex-direction: column; - gap: var(--space-2); - margin-top: var(--space-1); + gap: var(--ws-space-10); + margin-top: var(--ws-space-4); } .choice { display: flex; align-items: flex-start; - gap: var(--space-2); + gap: var(--ws-space-10); + cursor: pointer; } +.choice__label { + min-width: 0; + font-family: var(--ws-font-family-sans); + font-size: var(--ws-font-size-16); + line-height: var(--ws-font-line-height-normal); +} + +/* A box or a dot of the system's colors, on the first line of its label. */ .choice__input { + display: grid; flex: none; - width: 1.125rem; - height: 1.125rem; - margin: 0.1875rem 0 0; - accent-color: var(--color-accent); + place-content: center; + width: var(--ws-space-20); + height: var(--ws-space-20); + margin: var(--ws-space-2) 0 0; + border: var(--ws-border-width-thin) solid var(--ws-color-field-border); + border-radius: var(--ws-radius-xs); + cursor: pointer; + background: var(--ws-color-bg); + appearance: none; } -.choice__label { - min-width: 0; +.choice__input[type='radio'] { + border-radius: var(--ws-radius-full); +} + +.choice__input::before { + width: var(--ws-space-12); + height: var(--ws-space-12); + content: ''; + background: var(--ws-color-on-interactive); + mask: var(--icon-check) center / contain no-repeat; + scale: 0; +} + +.choice__input[type='radio']::before { + width: var(--ws-space-8); + height: var(--ws-space-8); + border-radius: var(--ws-radius-full); + mask: none; +} + +.choice__input:hover { + border-color: var(--ws-color-text-secondary); } -/* Groups and lists */ +.choice__input:checked { + border-color: var(--ws-color-interactive); + background: var(--ws-color-interactive); +} + +.choice__input:checked::before { + scale: 1; +} + +.field--invalid .choice__input:not(:checked) { + border-color: var(--ws-color-danger); +} + +@media (prefers-reduced-motion: no-preference) { + .choice__input::before { + transition: scale var(--ws-motion-duration-fast) + var(--ws-motion-easing-standard); + } +} + +/* A control that can't be used now is faint and says so: the order button while it is sent. */ +.input:disabled, +.choice__input:disabled, +.button:disabled { + border-color: var(--ws-color-text-faint); + color: var(--ws-color-text-faint); + cursor: not-allowed; + background: none; +} + +.choice:has(:disabled) { + color: var(--ws-color-text-faint); + cursor: not-allowed; +} + +/* Groups and lists: a box with its name in the top edge. */ .group { min-width: 0; margin: 0; - padding: var(--space-4); - border: 1px solid var(--color-border); - border-radius: var(--radius); + padding: var(--ws-space-16) var(--ws-space-20) var(--ws-space-20); + border: var(--ws-border-width-thin) solid var(--ws-color-border); + border-radius: var(--ws-radius-lg); } +/* The name sits in the edge with room around it, and its text starts where the fields do. */ .group__label { - padding: 0 var(--space-2); - font-weight: 600; + margin-left: calc(-1 * var(--ws-space-6)); + padding: 0 var(--ws-space-6); + color: var(--ws-color-text-secondary); + font: var(--ws-text-overline); + letter-spacing: var(--ws-text-overline-letter-spacing); + text-transform: uppercase; } .group__hint { - margin-bottom: var(--space-4); - font-size: 0.875rem; - color: var(--color-muted); + margin-bottom: var(--ws-space-16); + color: var(--ws-color-text-secondary); + font: var(--ws-text-body-sm); +} + +@media (width < 64rem) { + .group { + padding: var(--ws-space-12) var(--ws-space-16) var(--ws-space-16); + } } .list__empty { - color: var(--color-muted); + color: var(--ws-color-text-secondary); } .list__item { - padding: var(--space-4); - background: var(--color-page); - border-radius: var(--radius); + padding-top: var(--ws-space-16); + border-top: var(--ws-border-width-thin) dashed var(--ws-color-border); } .list__item-header { display: flex; - align-items: center; + align-items: baseline; justify-content: space-between; - gap: var(--space-3); - margin-bottom: var(--space-3); + gap: var(--ws-space-12); + margin-bottom: var(--ws-space-16); } .list__item-title { - font-size: 1rem; + font: var(--ws-text-h4); } /* Rows: one line of a 12-column grid, stacked on a narrow screen */ @@ -305,96 +612,131 @@ select.input { .row { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); - gap: var(--space-5) var(--space-4); + gap: var(--ws-space-24) var(--ws-space-16); } .row__cell { - grid-column: 1 / -1; + grid-column: span var(--span, 12); min-width: 0; } -@media (min-width: 40rem) { +/* The page's columns stand further apart than fields do. */ +.row--sections { + column-gap: var(--ws-space-40); +} + +@media (width < 64rem) { .row__cell { - grid-column: span var(--span, 12); + grid-column: 1 / -1; + } + + /* + * Stacked, the columns are sections like the others, and are set off from each other the same + * way. Their wide gap goes: twelve tracks still have eleven gaps between them, wider than a phone. + */ + .row--sections { + gap: var(--ws-space-32) 0; + } + + .row--sections > .row__cell + .row__cell { + padding-top: var(--ws-space-32); + border-top: var(--ws-border-width-thin) solid var(--ws-color-border); } } /* Buttons */ .button { + display: inline-flex; + align-items: center; + justify-content: center; min-height: var(--control-height); - padding: var(--space-2) var(--space-4); - font-weight: 600; + margin: 0; + padding: 0 var(--ws-space-20); + border: var(--ws-border-width-thin) solid var(--ws-color-field-border); + border-radius: var(--ws-radius-md); + color: var(--ws-color-text); + font: var(--ws-text-label); + font-weight: var(--ws-font-weight-semibold); cursor: pointer; - background: var(--color-surface); - border: 1px solid var(--color-border-strong); - border-radius: var(--radius); + background: none; } .button:hover { - border-color: var(--color-text); + border-color: var(--ws-color-text-secondary); + background: var(--ws-color-raised); } .button--primary { - color: var(--color-on-accent); - background: var(--color-accent); - border-color: var(--color-accent); + border-color: var(--ws-color-interactive); + color: var(--ws-color-on-interactive); + background: var(--ws-color-interactive); } +/* The system has no hover color for the interactive fill: a touch of the text color lifts it. */ .button--primary:hover { - background: var(--color-accent-strong); - border-color: var(--color-accent-strong); + --hover: color-mix( + in oklab, + var(--ws-color-interactive) 85%, + var(--ws-color-text) + ); + + border-color: var(--hover); + background: var(--hover); } .button--wide { width: 100%; } -.button:disabled { - cursor: progress; - opacity: 0.7; -} - .button--quiet { - min-height: 2rem; - padding: var(--space-1) var(--space-2); - font-weight: 400; + min-height: 0; + padding: 0; + border: 0; + color: var(--ws-color-interactive); + font-weight: var(--ws-font-weight-regular); text-decoration: underline; +} + +.button--quiet:hover { background: none; - border-color: transparent; + text-decoration-thickness: var(--ws-border-width-medium); } -/* Summary */ +/* Summary: what the order costs, a line each, its amounts on the right. */ .summary { - border-top: 1px solid var(--color-border); -} - -.summary__row--empty { - color: var(--color-muted); + border-top: var(--ws-border-width-thin) dashed var(--ws-color-border); } +/* A term in the voice of a label, its amount in the face of a field, on one baseline. */ .summary__row { - display: flex; + display: grid; + grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; - justify-content: space-between; - gap: var(--space-3); - padding: var(--space-2) 0; - border-bottom: 1px solid var(--color-border); + gap: var(--ws-space-16); + padding-block: var(--ws-space-8); + border-bottom: var(--ws-border-width-thin) dashed var(--ws-color-border); } .summary__term { - min-width: 0; + color: var(--ws-color-text-secondary); + font: var(--ws-text-label); overflow-wrap: anywhere; } .summary__value { - flex: none; font-variant-numeric: tabular-nums; + text-align: right; +} + +.summary__row--total .summary__term { + color: var(--ws-color-text); + font-weight: var(--ws-font-weight-semibold); } -.summary__row--total { - font-weight: 600; +.summary__row--total .summary__value { + font-weight: var(--ws-font-weight-semibold); } /* Notices */ @@ -403,36 +745,85 @@ select.input { display: flex; flex-direction: column; align-items: flex-start; - gap: var(--space-3); - padding: var(--space-5); - border: 1px solid; - border-radius: var(--radius); + gap: var(--ws-space-16); } -.notice--success { - background: var(--color-success-surface); - border-color: var(--color-success); +.notice__title { + display: flex; + gap: var(--ws-space-12); + font: var(--ws-text-h2); + letter-spacing: var(--ws-text-h2-letter-spacing); +} + +/* + * A notice without a title is its message alone, like the one over the order button: a sentence + * in the voice of a field's error, its icon before the first line. + */ +.notice__message { + display: flex; + gap: var(--ws-space-6); + font: var(--ws-text-body-sm); + font-weight: var(--ws-font-weight-medium); +} + +/* The title says what happened, and the icon of its status goes before its first line. */ +.notice__title::before, +.notice__message::before { + flex: none; + width: var(--ws-space-16); + height: 1lh; + content: ''; + background: var(--ws-color-tip); + mask: var(--icon-check) center / var(--ws-space-16) no-repeat; } .notice--error { - background: var(--color-error-surface); - border-color: var(--color-error); + padding: var(--ws-space-16) var(--ws-space-20) var(--ws-space-20); + border-left: var(--ws-border-width-thick) solid var(--ws-color-danger); + border-radius: 0 var(--ws-radius-lg) var(--ws-radius-lg) 0; + background: var(--ws-color-danger-tint); } -.notice__title { - font-size: 1.25rem; - line-height: 1.3; +.notice--error .notice__title::before { + width: var(--ws-space-20); + background: var(--ws-color-danger); + mask-image: var(--ws-icon-danger); + mask-size: var(--ws-space-20); } -.notice__code { +/* A message alone has no title's leading above it, so its box is as deep above as below. */ +.notice--error:has(> .notice__message) { + padding-bottom: var(--ws-space-16); +} + +.notice--error .notice__message::before { + background: var(--ws-color-danger); + mask-image: var(--ws-icon-danger); +} + +.notice .ws-code { align-self: stretch; - max-height: 24rem; margin: 0; - padding: var(--space-3); - overflow: auto; - font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; - font-size: 0.875rem; - background: var(--color-surface); - border: 1px solid var(--color-border); - border-radius: var(--radius); +} + +/* + * The order can hold long text a person typed. Its line wraps inside the block, and the rest of + * it starts one level in from the line's own text, so the shape of the JSON still reads. + */ +.code { + white-space: pre-wrap; + overflow-wrap: anywhere; +} + +.code__line { + display: block; + padding-left: calc(var(--hang) * 1ch); + text-indent: calc(var(--hang) * -1ch); +} + +@media (width < 64rem) { + .notice__title { + font: var(--ws-text-h2-compact); + letter-spacing: var(--ws-text-h2-compact-letter-spacing); + } } diff --git a/react-checkout/src/ui/CodeBlock.tsx b/react-checkout/src/ui/CodeBlock.tsx index f4de09b..234e342 100644 --- a/react-checkout/src/ui/CodeBlock.tsx +++ b/react-checkout/src/ui/CodeBlock.tsx @@ -1,6 +1,86 @@ -import type { HTMLAttributes } from 'react' +import { + useEffect, + useMemo, + useState, + type CSSProperties, + type HTMLAttributes, +} from 'react' +import type { highlightJson } from './highlight' -/** Preformatted text, like the order as the server accepted it. */ -export function CodeBlock(props: HTMLAttributes) { - return
+type Highlight = typeof highlightJson
+
+// Shiki is most of the app's weight and is needed only once an order is placed, so it is a file
+// of its own. It starts loading with the app, and the first render does not wait for it.
+let loaded: Highlight | undefined
+const loading = import('./highlight').then(({ highlightJson }) => {
+  loaded = highlightJson
+  return highlightJson
+})
+
+/** Lines of plain text, in the block's own text color, for until Shiki is there. */
+function plain(code: string): ReturnType {
+  return code.split('\n').map((line) => [{ content: line, offset: 0 }])
+}
+
+interface CodeBlockProps extends HTMLAttributes {
+  /** A piece of JSON, like the order as the server accepted it. */
+  code: string
+  /** The name the caption gives it. */
+  file: string
+}
+
+/**
+ * A piece of JSON in the design system's code block, highlighted in its code theme. The other
+ * attributes, like a test id, go to the code, so they are on the text alone.
+ */
+export function CodeBlock({ code, file, ...props }: CodeBlockProps) {
+  const [highlight, setHighlight] = useState(() => loaded)
+  useEffect(() => {
+    if (highlight) return
+    let current = true
+    void loading.then((loadedHighlight) => {
+      if (current) setHighlight(() => loadedHighlight)
+    })
+    return () => {
+      current = false
+    }
+  }, [highlight])
+
+  // Each line with the column its wrapped rest starts at: one level in from its own text, so a
+  // long value wraps inside the block instead of running out of it.
+  const lines = useMemo(
+    () =>
+      (highlight ?? plain)(code).map((tokens) => {
+        const text = tokens.map((token) => token.content).join('')
+        return { tokens, hang: text.length - text.trimStart().length + 2 }
+      }),
+    [code, highlight],
+  )
+  return (
+    
+
+ {file} + json +
+ {/* A line break ends each line but the last: the text of the block is the code as given. */} +
+        
+          {lines.map((line, index) => (
+            
+              {line.tokens.map((token, column) => (
+                
+                  {token.content}
+                
+              ))}
+              {index < lines.length - 1 ? '\n' : ''}
+            
+          ))}
+        
+      
+
+ ) } diff --git a/react-checkout/src/ui/LanguageSwitch.tsx b/react-checkout/src/ui/LanguageSwitch.tsx new file mode 100644 index 0000000..3a99e72 --- /dev/null +++ b/react-checkout/src/ui/LanguageSwitch.tsx @@ -0,0 +1,29 @@ +import { localeNames, locales, type Locale } from '../../shared/i18n' +import { useLocale } from '../locale/context' + +/** The languages of the shop, side by side. The one on show is pressed. */ +export function LanguageSwitch({ + onChange, +}: { + onChange: (locale: Locale) => void +}) { + const { locale, t } = useLocale() + return ( +
+ {locales.map((each) => ( + + ))} +
+ ) +} diff --git a/react-checkout/src/ui/Notice.tsx b/react-checkout/src/ui/Notice.tsx index 25086a8..24023c9 100644 --- a/react-checkout/src/ui/Notice.tsx +++ b/react-checkout/src/ui/Notice.tsx @@ -2,6 +2,7 @@ import type { ReactNode } from 'react' interface NoticeProps { tone: 'success' | 'error' + /** What happened. Without one, the notice is its text alone, like a message under a form. */ title?: string children?: ReactNode } @@ -13,8 +14,14 @@ export function Notice({ tone, title, children }: NoticeProps) { className={`notice notice--${tone}`} role={tone === 'error' ? 'alert' : 'status'} > - {title &&

{title}

} - {children} + {title ? ( + <> +

{title}

+ {children} + + ) : ( +

{children}

+ )} ) } diff --git a/react-checkout/src/ui/PageShell.tsx b/react-checkout/src/ui/PageShell.tsx index 717bf77..fe56548 100644 --- a/react-checkout/src/ui/PageShell.tsx +++ b/react-checkout/src/ui/PageShell.tsx @@ -1,40 +1,35 @@ import type { ReactNode } from 'react' -import { localeNames, locales, type Locale } from '../../shared/i18n' +import type { Locale } from '../../shared/i18n' import { useLocale } from '../locale/context' +import { LanguageSwitch } from './LanguageSwitch' +import { StatusLine } from './StatusLine' +import { TabBar } from './TabBar' interface PageShellProps { onLocaleChange: (locale: Locale) => void children: ReactNode } -/** The page around the checkout: its title, and the switch between languages. */ +/** + * The page around the checkout, in the design system's terminal frame: a window with a tab bar + * on top and a status line, and in it the title and the switch between languages. + */ export function PageShell({ onLocaleChange, children }: PageShellProps) { - const { locale, t } = useLocale() + const { t } = useLocale() return ( -
-
-
-

{t('app.title')}

-

{t('app.lead')}

+
+ +
+
+
+

{t('app.title')}

+

{t('app.lead')}

+ +
+ {children}
-
- {locales.map((each) => ( - - ))} -
-
- {children} -
+ + + ) } diff --git a/react-checkout/src/ui/StatusLine.tsx b/react-checkout/src/ui/StatusLine.tsx index 2c7d89b..5f60488 100644 --- a/react-checkout/src/ui/StatusLine.tsx +++ b/react-checkout/src/ui/StatusLine.tsx @@ -1,10 +1,91 @@ -import type { ReactNode } from 'react' +import { enableShortcuts, isTyping } from '@whatsaaaa/design-system/shortcuts' +import { toggleTheme } from '@whatsaaaa/design-system/theme' +import { useEffect, useState } from 'react' -/** A line about what the page is doing, like loading. */ -export function StatusLine({ children }: { children: ReactNode }) { +type Mode = 'NORMAL' | 'INSERT' + +/** + * NORMAL while single keys are shortcuts, INSERT while they are typed into a field. It says + * whether the key hints next to it work right now. + */ +function currentMode(): Mode { + return isTyping(document.activeElement) ? 'INSERT' : 'NORMAL' +} + +/** + * The bottom of the window, the design system's status line: the mode, the app's path, the + * theme switch and the switch for the shortcut keys. + */ +export function StatusLine() { + const [mode, setMode] = useState('NORMAL') + + useEffect(() => { + const updateMode = () => { + setMode(currentMode()) + } + updateMode() + document.addEventListener('focusin', updateMode) + document.addEventListener('focusout', updateMode) + const disableShortcuts = enableShortcuts() + return () => { + document.removeEventListener('focusin', updateMode) + document.removeEventListener('focusout', updateMode) + disableShortcuts() + } + }, []) + + return ( +
+ {mode} + + ~/react-checkout + + + {/* Each hint is the control it names: the key clicks the button. */} + + + + {/* The shortcuts module gives the switch its state. Until then the styles keep it hidden. */} + + {/* + The name of the theme, which also switches it: the hints above are hidden on a narrow + screen, and this is not. Both names are in the page and the styles show the theme's one. + */} + + +
+ ) +} + +function ThemeName({ theme, name }: { theme: 'dark' | 'light'; name: string }) { return ( -

- {children} -

+ ) } diff --git a/react-checkout/src/ui/StatusMessage.tsx b/react-checkout/src/ui/StatusMessage.tsx new file mode 100644 index 0000000..c229cbc --- /dev/null +++ b/react-checkout/src/ui/StatusMessage.tsx @@ -0,0 +1,13 @@ +import type { ReactNode } from 'react' + +/** + * A line about what the page is doing, like loading. Not the status line of the window: this + * one is in the page, where the form will be. + */ +export function StatusMessage({ children }: { children: ReactNode }) { + return ( +

+ {children} +

+ ) +} diff --git a/react-checkout/src/ui/TabBar.tsx b/react-checkout/src/ui/TabBar.tsx new file mode 100644 index 0000000..5e54360 --- /dev/null +++ b/react-checkout/src/ui/TabBar.tsx @@ -0,0 +1,47 @@ +import { ghostSvg } from '@whatsaaaa/design-system/ghost' +import markOnDark from './assets/mark-on-dark.svg' +import markOnLight from './assets/mark-on-light.svg' + +// The ghost as a picture, for a link: on a project's page it links to the handle's site. +const ghost = { __html: ghostSvg({ px: 2 }) } + +/** The top of the window: form-builder's mark and name, its docs, and the ghost. */ +export function TabBar() { + return ( +
+ + {/* The kit has a cut of the mark for each theme. The stylesheet shows the page's one. */} + + + form-builder + +
+ + docs + + {/* Markup built by the design system's ghost module. */} + +
+
+ ) +} diff --git a/react-checkout/src/ui/assets/mark-on-dark.svg b/react-checkout/src/ui/assets/mark-on-dark.svg new file mode 100644 index 0000000..dd3b4ae --- /dev/null +++ b/react-checkout/src/ui/assets/mark-on-dark.svg @@ -0,0 +1 @@ +form-builder mark diff --git a/react-checkout/src/ui/assets/mark-on-light.svg b/react-checkout/src/ui/assets/mark-on-light.svg new file mode 100644 index 0000000..fee9952 --- /dev/null +++ b/react-checkout/src/ui/assets/mark-on-light.svg @@ -0,0 +1 @@ +form-builder mark diff --git a/react-checkout/src/ui/fields/FieldShell.tsx b/react-checkout/src/ui/fields/FieldShell.tsx index 50d4b3e..0202acf 100644 --- a/react-checkout/src/ui/fields/FieldShell.tsx +++ b/react-checkout/src/ui/fields/FieldShell.tsx @@ -13,7 +13,10 @@ interface FieldShellProps { children: ReactNode } -/** The frame every field shares: its label, hint and error. */ +/** + * The frame every field shares: its label, hint and error. No input has a placeholder: the hint, + * from the definition's `description`, goes under it. + */ export function FieldShell({ id, label, diff --git a/react-checkout/src/ui/fields/SelectInput.tsx b/react-checkout/src/ui/fields/SelectInput.tsx index 5704a76..567e523 100644 --- a/react-checkout/src/ui/fields/SelectInput.tsx +++ b/react-checkout/src/ui/fields/SelectInput.tsx @@ -25,26 +25,29 @@ export function SelectInput({ errors={errors} required={required} > - + {/* The box draws the arrow: a select of its own look has none. */} +
+ +
) } diff --git a/react-checkout/src/ui/fields/TextInput.tsx b/react-checkout/src/ui/fields/TextInput.tsx index 84c402c..f210463 100644 --- a/react-checkout/src/ui/fields/TextInput.tsx +++ b/react-checkout/src/ui/fields/TextInput.tsx @@ -1,6 +1,5 @@ import type { ValueFieldProps } from '@whatsaaaa/form-builder-react' import { useId } from 'react' -import { useLocale } from '../../locale/context' import { FieldShell } from './FieldShell' import { describedBy, uiHint } from './hints' @@ -19,7 +18,6 @@ export function TextInput({ setInput, }: ValueFieldProps) { const id = useId() - const { t } = useLocale() return ( + typeof item === 'object' && 'type' in item && item.type === 'section', + ) return ( -
+
{spans.map((span, index) => (
{children}
+ return
{children}
} return ( -
- {section.label &&

{t(section.label)}

} +
+ {section.label &&

{t(section.label)}

} {section.description && ( -

{t(section.description)}

+

{t(section.description)}

)}
{children}
diff --git a/react-checkout/vite.config.ts b/react-checkout/vite.config.ts index f406def..4a9b504 100644 --- a/react-checkout/vite.config.ts +++ b/react-checkout/vite.config.ts @@ -1,9 +1,31 @@ +import { keysInitScript } from '@whatsaaaa/design-system/shortcuts' +import { themeInitScript } from '@whatsaaaa/design-system/theme' import react from '@vitejs/plugin-react' +import type { Plugin } from 'vite' import { defineConfig } from 'vitest/config' +/** + * The design system's head scripts, inline in the before the stylesheet: a remembered + * theme and a remembered "keys off" apply before the first paint. They come from the installed + * package, so they stay in step with it. + */ +function designSystemHead(): Plugin { + return { + name: 'design-system-head', + transformIndexHtml: { + // before Vite adds the stylesheet and the app's script at the end of the + order: 'pre', + handler: () => [ + { tag: 'script', children: themeInitScript, injectTo: 'head' }, + { tag: 'script', children: keysInitScript, injectTo: 'head' }, + ], + }, + } +} + // https://vite.dev/config/ export default defineConfig({ - plugins: [react()], + plugins: [react(), designSystemHead()], server: { // In development, the API runs on its own port (`pnpm dev` starts both). proxy: { '/api': 'http://localhost:8787' }, From f56b274a5f615331d854447666db54c78a08e5eb Mon Sep 17 00:00:00 2001 From: Whatsaaaa Date: Fri, 13 Nov 2026 20:14:04 +0100 Subject: [PATCH 3/8] Check the React app at 320 and 390 px in both themes, and its switches The window, its bars and its code block hide what is wider than they are, so the check for sideways overflow measures them too, not only the page: without it, a row of the page that was wider than a phone passed. At 320 px the status line keeps its working items whole with the keys on and off, and the theme and keys switches work and are remembered. --- react-checkout/e2e/checkout.spec.ts | 81 ++++++++++++++-- react-checkout/e2e/checks.ts | 64 +++++++++++++ react-checkout/e2e/frame.spec.ts | 142 ++++++++++++++++++++++++++++ 3 files changed, 277 insertions(+), 10 deletions(-) create mode 100644 react-checkout/e2e/checks.ts create mode 100644 react-checkout/e2e/frame.spec.ts diff --git a/react-checkout/e2e/checkout.spec.ts b/react-checkout/e2e/checkout.spec.ts index a7971dc..9bf0f35 100644 --- a/react-checkout/e2e/checkout.spec.ts +++ b/react-checkout/e2e/checkout.spec.ts @@ -1,14 +1,5 @@ import { expect, test, type Page } from '@playwright/test' - -/** Fails when the page scrolls sideways: something is wider than the screen. */ -async function expectNoSidewaysScroll(page: Page) { - const overflow = await page.evaluate( - () => - document.documentElement.scrollWidth - - document.documentElement.clientWidth, - ) - expect(overflow).toBeLessThanOrEqual(0) -} +import { expectNoSidewaysScroll } from './checks' /** Fills in an order that is valid: two mugs, shipped to Belgrade, paid by card. */ async function fillValidOrder(page: Page) { @@ -282,3 +273,73 @@ test('the server rejects invalid data sent straight to its API', async ({ ]), ) }) + +// 320 px is the width a page has to work at without scrolling sideways (WCAG's reflow), 390 px a +// common phone. +for (const [width, colorScheme] of [ + [320, 'dark'], + [320, 'light'], + [390, 'dark'], + [390, 'light'], +] as const) { + test.describe(`on a ${String(width)} px screen, in the ${colorScheme} theme`, () => { + test.use({ viewport: { width, height: 844 }, colorScheme }) + + test('fits the screen in English and in German, with its errors', async ({ + page, + }) => { + // The page follows the system's theme, and names it in the status line. + const name = colorScheme === 'dark' ? 'rose-pine' : 'rose-pine-dawn' + await expect( + page.getByRole('button', { + name: `Switch theme, now ${name}`, + exact: true, + }), + ).toBeVisible() + await expectNoSidewaysScroll(page) + + await page.getByRole('button', { name: 'Place order' }).click() + await expect(page.getByText('Enter your email')).toBeVisible() + await expectNoSidewaysScroll(page) + await fillValidOrder(page) + await page + .getByLabel('Note for the courier') + .fill('Zvonite kod Đorđevića, ulaz iz dvorišta. Čuvar je u prizemlju.') + await expectNoSidewaysScroll(page) + + // German labels, buttons and messages are longer. + await page.getByRole('button', { name: 'Deutsch' }).click() + await expect(page.getByRole('heading', { name: 'Kasse' })).toBeVisible() + await expectNoSidewaysScroll(page) + + // The server's messages on the fields, as in the test of a changed order above. + await page.route('**/api/orders', async (route) => { + const body = route.request().postDataJSON() as { + input: { + lines: { quantity: unknown }[] + shipping: { zip: string } + } + } + const line = body.input.lines[0] + if (line) line.quantity = 99 + body.input.shipping.zip = 'ABC' + await route.continue({ postData: JSON.stringify(body) }) + }) + await page.getByRole('button', { name: 'Bestellung aufgeben' }).click() + await expect( + page.getByText('Bestellen Sie höchstens zehn Stück eines Produkts'), + ).toBeVisible() + await expect( + page.getByText('Verwenden Sie 4 oder 5 Ziffern'), + ).toBeVisible() + await expectNoSidewaysScroll(page) + + await page.unroute('**/api/orders') + await page.getByRole('button', { name: 'Bestellung aufgeben' }).click() + await expect( + page.getByRole('heading', { name: 'Vielen Dank für Ihre Bestellung' }), + ).toBeVisible() + await expectNoSidewaysScroll(page) + }) + }) +} diff --git a/react-checkout/e2e/checks.ts b/react-checkout/e2e/checks.ts new file mode 100644 index 0000000..4152b90 --- /dev/null +++ b/react-checkout/e2e/checks.ts @@ -0,0 +1,64 @@ +import { expect, type Page } from '@playwright/test' + +/** + * Fails when the page scrolls sideways, or when a part of the window cuts something off at its + * side. The window, its bars and its code block hide what is wider than they are, so that would + * not make the page scroll. + */ +export async function expectNoSidewaysScroll(page: Page) { + const overflowing = await page.evaluate(() => + [ + 'html', + '.ws-term', + '.ws-tab-bar', + '.ws-status-line', + '.ws-code', + '.ws-code > pre', + ].filter((selector) => + [...document.querySelectorAll(selector)].some( + (element) => element.scrollWidth > element.clientWidth, + ), + ), + ) + expect(overflowing).toEqual([]) +} + +/** + * Fails unless every working item of the status line is whole and inside it: the mode, the keys + * switch and the name of the theme. The path is decoration: it may shrink or go, but not be cut. + */ +export async function expectWholeStatusLine(page: Page) { + const problems = await page.evaluate(() => { + const line = document.querySelector('.ws-status-line') + if (!line) return ['no status line'] + const edge = line.getBoundingClientRect() + const items = { + mode: '.ws-status-line__mode', + keys: '.ws-status-line__switch', + theme: '.status-line__theme', + } + const found = Object.entries(items).flatMap(([name, selector]) => { + const shown = [...line.querySelectorAll(selector)].filter( + (element) => element.getClientRects().length > 0, + ) + if (shown.length !== 1) return [`${name}: ${String(shown.length)} shown`] + const element = shown[0] as Element + const box = element.getBoundingClientRect() + // Half a pixel for the rounding of fractional layout on a phone. + const inside = + box.left >= edge.left - 0.5 && box.right <= edge.right + 0.5 + const whole = element.scrollWidth <= element.clientWidth + return inside && whole ? [] : [`${name}: cut`] + }) + const path = line.querySelector('.ws-status-line__file') + const text = path?.firstElementChild + if (path && text) { + const box = path.getBoundingClientRect() + const textBox = text.getBoundingClientRect() + const gone = textBox.top >= box.bottom + if (!gone && textBox.right > box.right + 0.5) found.push('path: cut') + } + return found + }) + expect(problems).toEqual([]) +} diff --git a/react-checkout/e2e/frame.spec.ts b/react-checkout/e2e/frame.spec.ts new file mode 100644 index 0000000..f399b07 --- /dev/null +++ b/react-checkout/e2e/frame.spec.ts @@ -0,0 +1,142 @@ +import { expect, test, type Page } from '@playwright/test' +import { expectNoSidewaysScroll, expectWholeStatusLine } from './checks' + +/** The item of the status line that names the theme on show, and switches it. */ +function themeName(page: Page, name: 'rose-pine' | 'rose-pine-dawn') { + return page.getByRole('button', { + name: `Switch theme, now ${name}`, + exact: true, + }) +} + +function keysSwitch(page: Page) { + return page.getByRole('switch', { name: 'Shortcut keys' }) +} + +/** The color of the page behind the window: it changes with the theme. */ +function pageColor(page: Page) { + return page.evaluate(() => getComputedStyle(document.body).backgroundColor) +} + +test.beforeEach(async ({ page }) => { + await page.goto('/') + await expect(page.getByRole('button', { name: 'Place order' })).toBeVisible() +}) + +test.describe('on a light system', () => { + test.use({ colorScheme: 'light' }) + + test('switches the theme, and remembers it', async ({ page }) => { + const html = page.locator('html') + + // Until it is switched, the theme is the system's. + await expect(html).not.toHaveAttribute('data-theme') + await expect(themeName(page, 'rose-pine-dawn')).toBeVisible() + await expect(themeName(page, 'rose-pine')).toBeHidden() + const light = await pageColor(page) + + await themeName(page, 'rose-pine-dawn').click() + await expect(html).toHaveAttribute('data-theme', 'dark') + await expect(themeName(page, 'rose-pine')).toBeVisible() + await expect(themeName(page, 'rose-pine-dawn')).toBeHidden() + const dark = await pageColor(page) + expect(dark).not.toBe(light) + + // The head script applies the choice again before the page is drawn. + await page.reload() + await expect(html).toHaveAttribute('data-theme', 'dark') + expect(await pageColor(page)).toBe(dark) + + await themeName(page, 'rose-pine').click() + await expect(html).toHaveAttribute('data-theme', 'light') + expect(await pageColor(page)).toBe(light) + }) +}) + +test('switches the shortcut keys off and on, and remembers it', async ({ + page, +}) => { + const html = page.locator('html') + await expect(keysSwitch(page)).toBeChecked() + await expect(keysSwitch(page)).toHaveText(/keys\s*on/, { + useInnerText: true, + }) + await expect(html).toHaveAttribute('data-ws-keys', 'on') + + await keysSwitch(page).click() + await expect(keysSwitch(page)).not.toBeChecked() + await expect(keysSwitch(page)).toHaveText(/keys\s*off/, { + useInnerText: true, + }) + await expect(html).toHaveAttribute('data-ws-keys', 'off') + + await page.reload() + await expect(keysSwitch(page)).not.toBeChecked() + await expect(html).toHaveAttribute('data-ws-keys', 'off') + + await keysSwitch(page).click() + await expect(keysSwitch(page)).toBeChecked() + await expect(html).toHaveAttribute('data-ws-keys', 'on') +}) + +test.describe('on a dark system', () => { + test.use({ colorScheme: 'dark' }) + + test('switches the theme with the t key while the keys are on', async ({ + page, + isMobile, + }) => { + test.skip(isMobile, 'Key hints show on a wide screen only') + const html = page.locator('html') + const hint = page.getByRole('button', { name: 'Switch theme', exact: true }) + const mode = page.locator('.ws-status-line__mode') + await expect(hint.locator('kbd')).toBeVisible() + await expect(mode).toHaveText('NORMAL') + + await page.keyboard.press('t') + await expect(html).toHaveAttribute('data-theme', 'light') + await page.keyboard.press('t') + await expect(html).toHaveAttribute('data-theme', 'dark') + + // A key typed into a field is only a letter. + const email = page.getByRole('textbox', { name: 'Email' }) + await email.press('t') + await expect(email).toHaveValue('t') + await expect(mode).toHaveText('INSERT') + await expect(html).toHaveAttribute('data-theme', 'dark') + await email.blur() + await expect(mode).toHaveText('NORMAL') + + // With the keys off, the key rests and its cap goes, but the button still works by hand. + await keysSwitch(page).click() + await expect(hint.locator('kbd')).toBeHidden() + await page.keyboard.press('t') + await expect(html).toHaveAttribute('data-theme', 'dark') + await hint.click() + await expect(html).toHaveAttribute('data-theme', 'light') + }) +}) + +for (const colorScheme of ['dark', 'light'] as const) { + test.describe(`on a 320 px screen, in the ${colorScheme} theme`, () => { + test.use({ viewport: { width: 320, height: 640 }, colorScheme }) + + test('keeps every item of the status line whole, with the keys on and off', async ({ + page, + }) => { + const mode = page.locator('.ws-status-line__mode') + await expect(keysSwitch(page)).toBeChecked() + await expectWholeStatusLine(page) + await expectNoSidewaysScroll(page) + + // "keys off" is longer, and "INSERT" takes the place of "NORMAL" while a field has focus. + await keysSwitch(page).click() + await expect(keysSwitch(page)).not.toBeChecked() + await expectWholeStatusLine(page) + await page.getByRole('textbox', { name: 'Email' }).focus() + await expect(mode).toHaveText('INSERT') + await expectWholeStatusLine(page) + await expectNoSidewaysScroll(page) + }) + }) +} From 25e5e3fe8b1976ec076f0afed986364ea75939c7 Mon Sep 17 00:00:00 2001 From: Whatsaaaa Date: Fri, 13 Nov 2026 20:27:53 +0100 Subject: [PATCH 4/8] Show the status line's path whole or not at all, from 320 to 400 px MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The path's box is a size container that takes the room the mode, the keys switch and the theme's name leave. The path's text, with its fill and padding, shrinks behind its ellipsis in it, and goes, padding and all, once the box has no room for "~…" between the paddings: no glyph is cut through at any width, and there is still no breakpoint but the design system's. The end-to-end check sweeps 320 to 400 px in 2 px steps, in both themes with the keys on and off, and fails on a path without the query. --- react-checkout/e2e/checks.ts | 34 ++++++++++++++++++++---------- react-checkout/e2e/frame.spec.ts | 29 ++++++++++++++----------- react-checkout/src/styles.css | 36 ++++++++++++++++---------------- 3 files changed, 58 insertions(+), 41 deletions(-) diff --git a/react-checkout/e2e/checks.ts b/react-checkout/e2e/checks.ts index 4152b90..90b8267 100644 --- a/react-checkout/e2e/checks.ts +++ b/react-checkout/e2e/checks.ts @@ -5,7 +5,7 @@ import { expect, type Page } from '@playwright/test' * side. The window, its bars and its code block hide what is wider than they are, so that would * not make the page scroll. */ -export async function expectNoSidewaysScroll(page: Page) { +export async function expectNoSidewaysScroll(page: Page, message?: string) { const overflowing = await page.evaluate(() => [ 'html', @@ -20,14 +20,15 @@ export async function expectNoSidewaysScroll(page: Page) { ), ), ) - expect(overflowing).toEqual([]) + expect(overflowing, message).toEqual([]) } /** * Fails unless every working item of the status line is whole and inside it: the mode, the keys - * switch and the name of the theme. The path is decoration: it may shrink or go, but not be cut. + * switch and the name of the theme. The path is decoration: it may shrink or go, but when it shows, + * it is readable, "~…" at the least, and no glyph of it is cut through. */ -export async function expectWholeStatusLine(page: Page) { +export async function expectWholeStatusLine(page: Page, message?: string) { const problems = await page.evaluate(() => { const line = document.querySelector('.ws-status-line') if (!line) return ['no status line'] @@ -50,15 +51,26 @@ export async function expectWholeStatusLine(page: Page) { const whole = element.scrollWidth <= element.clientWidth return inside && whole ? [] : [`${name}: cut`] }) - const path = line.querySelector('.ws-status-line__file') - const text = path?.firstElementChild - if (path && text) { + const path = line.querySelector('.ws-status-line__file > span') + if (path && path.getClientRects().length > 0) { + // The text's own width, cut or not: the path is in a font of one width for every glyph. + const range = document.createRange() + range.selectNodeContents(path) + const text = range.getBoundingClientRect().width + const glyph = text / (path.textContent ?? ' ').length + const style = getComputedStyle(path) + const room = + path.clientWidth - + parseFloat(style.paddingLeft) - + parseFloat(style.paddingRight) const box = path.getBoundingClientRect() - const textBox = text.getBoundingClientRect() - const gone = textBox.top >= box.bottom - if (!gone && textBox.right > box.right + 0.5) found.push('path: cut') + const frame = path.parentElement?.getBoundingClientRect() + // All of it, or as much as its ellipsis leaves: one glyph and the ellipsis at the least. + const readable = room >= text - 0.5 || room >= 2 * glyph - 0.5 + const inside = !frame || box.right <= frame.right + 0.5 + if (!readable || !inside) found.push('path: cut') } return found }) - expect(problems).toEqual([]) + expect(problems, message).toEqual([]) } diff --git a/react-checkout/e2e/frame.spec.ts b/react-checkout/e2e/frame.spec.ts index f399b07..e5cc095 100644 --- a/react-checkout/e2e/frame.spec.ts +++ b/react-checkout/e2e/frame.spec.ts @@ -118,25 +118,30 @@ test.describe('on a dark system', () => { }) for (const colorScheme of ['dark', 'light'] as const) { - test.describe(`on a 320 px screen, in the ${colorScheme} theme`, () => { + test.describe(`from 320 to 400 px, in the ${colorScheme} theme`, () => { test.use({ viewport: { width: 320, height: 640 }, colorScheme }) test('keeps every item of the status line whole, with the keys on and off', async ({ page, }) => { - const mode = page.locator('.ws-status-line__mode') - await expect(keysSwitch(page)).toBeChecked() - await expectWholeStatusLine(page) - await expectNoSidewaysScroll(page) - - // "keys off" is longer, and "INSERT" takes the place of "NORMAL" while a field has focus. - await keysSwitch(page).click() - await expect(keysSwitch(page)).not.toBeChecked() - await expectWholeStatusLine(page) + // The path gives way to the others: it shrinks, and then goes, at no width cut through. + // "keys off" is longer than "keys on". + for (const keys of ['on', 'off']) { + if (keys === 'off') await keysSwitch(page).click() + await expect(page.locator('html')).toHaveAttribute('data-ws-keys', keys) + for (let width = 320; width <= 400; width += 2) { + await page.setViewportSize({ width, height: 640 }) + const at = `at ${String(width)} px with the keys ${keys}` + await expectWholeStatusLine(page, at) + await expectNoSidewaysScroll(page, at) + } + } + + // "INSERT" takes the place of "NORMAL" while a field has focus. + await page.setViewportSize({ width: 320, height: 640 }) await page.getByRole('textbox', { name: 'Email' }).focus() - await expect(mode).toHaveText('INSERT') + await expect(page.locator('.ws-status-line__mode')).toHaveText('INSERT') await expectWholeStatusLine(page) - await expectNoSidewaysScroll(page) }) }) } diff --git a/react-checkout/src/styles.css b/react-checkout/src/styles.css index 17d293a..310d1d3 100644 --- a/react-checkout/src/styles.css +++ b/react-checkout/src/styles.css @@ -123,33 +123,26 @@ body { /* Status line */ /* - * The path is decoration, so it gives way first, down to a 320 px screen: it shrinks behind its - * ellipsis, and once not even "~/…" fits, it leaves the line with its fill and its padding, which - * would not shrink on the box itself. Its text wraps to a second line of the box that is never - * seen: the empty item before it starts the first line, and the box keeps the status line's - * height. + * The path is decoration, so it gives way first, down to a 320 px screen. Its box takes the room + * the working items leave, and its text sits in it at its own width, with the fill and the + * padding, shrinking behind its ellipsis. Where the box has no room for "~…" and that padding, + * the text goes, padding and all, so no glyph is ever cut through: a query on the path's own box, + * not a breakpoint of the page. */ .ws-status-line__file { - flex-wrap: wrap; - gap: 0; - height: calc(var(--ws-size-status-line) - var(--ws-border-width-thin)); + flex: 1 1 0; + container-type: inline-size; padding-inline: 0; - overflow: hidden; background: none; } -.ws-status-line__file::before { - height: 100%; - content: ''; +/* The path's box fills the line, so the spacer has nothing left to push. */ +.ws-status-line__spacer { + flex: none; } -/* - * As wide as "~/…" to start with, so that is where it wraps, and as wide as the path when there is - * room. Its text sits on the middle of the line, where the other items center theirs. - */ +/* Its text sits on the middle of the line, where the other items center theirs. */ .ws-status-line__file > span { - flex: 1 1 calc(2 * var(--ws-space-14) + 3ch); - max-width: max-content; padding: calc( (var(--ws-size-status-line) - var(--ws-border-width-thin) - 1lh) / 2 ) @@ -157,6 +150,13 @@ body { background: var(--ws-color-raised); } +/* "~…" between the paddings: 2 × --ws-space-14 is 1.75rem, as a query can't read a custom property. */ +@container (width < calc(2ch + 1.75rem)) { + .ws-status-line__file > span { + display: none; + } +} + .status-line__theme { margin: 0; border-block: 0; From 58092926504d55bfefa324a4404323b87535bbee Mon Sep 17 00:00:00 2001 From: Whatsaaaa Date: Fri, 13 Nov 2026 20:49:50 +0100 Subject: [PATCH 5/8] Take the Vue app's status line path and forced colors, as reviewed there MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The status line's path is the design system's again, in a box of the app's own that takes the room left in the line and is a size container: the path shrinks to its ellipsis in it, and is hidden as a whole once "~…" and its padding no longer fit. It is the Vue app's rule, so both apps' status lines behave the same, and the end-to-end check is the Vue app's too: from 320 to 400 px, with the keys on and off, the path never shows a cut glyph, never runs into the keys switch, and hides only when it must. In forced colors the browser paints every background in the page's color, so a checked box, the pressed language and the marks drawn as masks take the system's colors instead. A new check fails when the pressed language or a ticked box looks like the others there. --- react-checkout/e2e/checks.ts | 96 +++++++++++++++++++--------- react-checkout/e2e/frame.spec.ts | 56 ++++++++++++---- react-checkout/src/styles.css | 65 +++++++++++-------- react-checkout/src/ui/StatusLine.tsx | 8 ++- 4 files changed, 152 insertions(+), 73 deletions(-) diff --git a/react-checkout/e2e/checks.ts b/react-checkout/e2e/checks.ts index 90b8267..fa43341 100644 --- a/react-checkout/e2e/checks.ts +++ b/react-checkout/e2e/checks.ts @@ -10,6 +10,7 @@ export async function expectNoSidewaysScroll(page: Page, message?: string) { [ 'html', '.ws-term', + '.page__main', '.ws-tab-bar', '.ws-status-line', '.ws-code', @@ -24,23 +25,27 @@ export async function expectNoSidewaysScroll(page: Page, message?: string) { } /** - * Fails unless every working item of the status line is whole and inside it: the mode, the keys - * switch and the name of the theme. The path is decoration: it may shrink or go, but when it shows, - * it is readable, "~…" at the least, and no glyph of it is cut through. + * Fails when the status line cuts what it holds. The mode, the keys switch and the name of the + * theme are whole and inside it, and its path shows whole or not at all: when it shows, "~…" fits + * in its text box, and the text has as much room before the keys switch as after the mode. It is + * gone only when "~…" and its padding have no room there. Says whether the path showed. */ -export async function expectWholeStatusLine(page: Page, message?: string) { - const problems = await page.evaluate(() => { - const line = document.querySelector('.ws-status-line') - if (!line) return ['no status line'] +export async function expectStatusLineWhole(page: Page, message?: string) { + const line = await page.locator('.ws-status-line').evaluate((line) => { + const find = (selector: string) => { + const element = line.querySelector(selector) + if (!element) throw new Error(`The status line has no ${selector}`) + return element + } const edge = line.getBoundingClientRect() const items = { mode: '.ws-status-line__mode', keys: '.ws-status-line__switch', theme: '.status-line__theme', } - const found = Object.entries(items).flatMap(([name, selector]) => { - const shown = [...line.querySelectorAll(selector)].filter( - (element) => element.getClientRects().length > 0, + const cut = Object.entries(items).flatMap(([name, selector]) => { + const shown = [...line.querySelectorAll(selector)].filter((element) => + element.checkVisibility(), ) if (shown.length !== 1) return [`${name}: ${String(shown.length)} shown`] const element = shown[0] as Element @@ -51,26 +56,57 @@ export async function expectWholeStatusLine(page: Page, message?: string) { const whole = element.scrollWidth <= element.clientWidth return inside && whole ? [] : [`${name}: cut`] }) - const path = line.querySelector('.ws-status-line__file > span') - if (path && path.getClientRects().length > 0) { - // The text's own width, cut or not: the path is in a font of one width for every glyph. - const range = document.createRange() - range.selectNodeContents(path) - const text = range.getBoundingClientRect().width - const glyph = text / (path.textContent ?? ' ').length - const style = getComputedStyle(path) - const room = - path.clientWidth - - parseFloat(style.paddingLeft) - - parseFloat(style.paddingRight) - const box = path.getBoundingClientRect() - const frame = path.parentElement?.getBoundingClientRect() - // All of it, or as much as its ellipsis leaves: one glyph and the ellipsis at the least. - const readable = room >= text - 0.5 || room >= 2 * glyph - 0.5 - const inside = !frame || box.right <= frame.right + 0.5 - if (!readable || !inside) found.push('path: cut') + const path = find('.ws-status-line__file') + const text = find('.ws-status-line__file > span') + const pathStyle = getComputedStyle(path) + const textStyle = getComputedStyle(text) + const probe = document.createElement('span') + probe.style.position = 'absolute' + probe.style.font = textStyle.font + probe.textContent = '~…' + document.body.append(probe) + const shortest = probe.getBoundingClientRect().width + probe.remove() + const mode = find('.ws-status-line__mode').getBoundingClientRect().right + const keys = find('.ws-status-line__switch').getBoundingClientRect().left + const box = text.getBoundingClientRect() + const left = box.left + parseFloat(textStyle.paddingLeft) + const right = box.right - parseFloat(textStyle.paddingRight) + return { + cut, + overflow: line.scrollWidth - line.clientWidth, + shown: path.checkVisibility(), + room: keys - mode, + needed: + shortest + + parseFloat(pathStyle.paddingLeft) + + parseFloat(pathStyle.paddingRight) + + parseFloat(textStyle.paddingLeft) + + parseFloat(textStyle.paddingRight), + text: right - left, + shortest, + before: left - mode, + after: keys - right, } - return found }) - expect(problems, message).toEqual([]) + const at = message ? ` ${message}` : '' + expect(line.cut, `a working item is cut${at}`).toEqual([]) + expect( + line.overflow, + `the status line cuts its end${at}`, + ).toBeLessThanOrEqual(0) + if (line.shown) { + expect(line.text, `the path shows a cut glyph${at}`).toBeGreaterThanOrEqual( + line.shortest, + ) + expect( + line.after, + `the path runs into the keys switch${at}`, + ).toBeGreaterThanOrEqual(line.before) + } else { + expect(line.room, `the path is gone with room for "~…"${at}`).toBeLessThan( + line.needed, + ) + } + return line.shown } diff --git a/react-checkout/e2e/frame.spec.ts b/react-checkout/e2e/frame.spec.ts index e5cc095..6e28111 100644 --- a/react-checkout/e2e/frame.spec.ts +++ b/react-checkout/e2e/frame.spec.ts @@ -1,5 +1,5 @@ import { expect, test, type Page } from '@playwright/test' -import { expectNoSidewaysScroll, expectWholeStatusLine } from './checks' +import { expectNoSidewaysScroll, expectStatusLineWhole } from './checks' /** The item of the status line that names the theme on show, and switches it. */ function themeName(page: Page, name: 'rose-pine' | 'rose-pine-dawn') { @@ -118,30 +118,58 @@ test.describe('on a dark system', () => { }) for (const colorScheme of ['dark', 'light'] as const) { - test.describe(`from 320 to 400 px, in the ${colorScheme} theme`, () => { - test.use({ viewport: { width: 320, height: 640 }, colorScheme }) - - test('keeps every item of the status line whole, with the keys on and off', async ({ - page, - }) => { - // The path gives way to the others: it shrinks, and then goes, at no width cut through. - // "keys off" is longer than "keys on". + test.describe(`in the ${colorScheme} theme`, () => { + test.use({ colorScheme }) + + // From the width the content must reflow to (WCAG 1.4.10) up, with each width of the switch. + test('keeps the status line whole on a narrow screen', async ({ page }) => { + let shown = 0 for (const keys of ['on', 'off']) { if (keys === 'off') await keysSwitch(page).click() - await expect(page.locator('html')).toHaveAttribute('data-ws-keys', keys) + await expect(keysSwitch(page)).toHaveText( + new RegExp(`keys\\s*${keys}`), + { useInnerText: true }, + ) for (let width = 320; width <= 400; width += 2) { - await page.setViewportSize({ width, height: 640 }) + await page.setViewportSize({ width, height: 700 }) const at = `at ${String(width)} px with the keys ${keys}` - await expectWholeStatusLine(page, at) + if (await expectStatusLineWhole(page, at)) shown++ await expectNoSidewaysScroll(page, at) } } + // The path showed at some width, so the checks of a shown path ran too. + expect(shown).toBeGreaterThan(0) // "INSERT" takes the place of "NORMAL" while a field has focus. - await page.setViewportSize({ width: 320, height: 640 }) + await page.setViewportSize({ width: 320, height: 700 }) await page.getByRole('textbox', { name: 'Email' }).focus() await expect(page.locator('.ws-status-line__mode')).toHaveText('INSERT') - await expectWholeStatusLine(page) + await expectStatusLineWhole(page, 'at 320 px while typing') }) }) } + +test.describe('in forced colors', () => { + test.use({ forcedColors: 'active' }) + + // The browser paints every background in the page's color, so a fill alone would say nothing. + test('tells the pressed language and a ticked box from the others', async ({ + page, + }) => { + const fill = (name: string, role: 'button' | 'checkbox') => + page + .getByRole(role, { name }) + .evaluate((element) => getComputedStyle(element).backgroundColor) + + expect(await fill('English', 'button')).not.toBe( + await fill('Deutsch', 'button'), + ) + + const terms = page.getByRole('checkbox', { name: /terms of sale/ }) + const unticked = await fill('I accept the terms of sale', 'checkbox') + await terms.check() + expect(await fill('I accept the terms of sale', 'checkbox')).not.toBe( + unticked, + ) + }) +}) diff --git a/react-checkout/src/styles.css b/react-checkout/src/styles.css index 310d1d3..8322a8c 100644 --- a/react-checkout/src/styles.css +++ b/react-checkout/src/styles.css @@ -123,36 +123,19 @@ body { /* Status line */ /* - * The path is decoration, so it gives way first, down to a 320 px screen. Its box takes the room - * the working items leave, and its text sits in it at its own width, with the fill and the - * padding, shrinking behind its ellipsis. Where the box has no room for "~…" and that padding, - * the text goes, padding and all, so no glyph is ever cut through: a query on the path's own box, - * not a breakpoint of the page. + * The path is what gives way on a narrow screen, so the switches after it always fit. Its box + * takes the room left in the line, as the spacer would: the path shrinks to its ellipsis in it, + * and goes as a whole once "~…" no longer fits inside its padding. The padding is the path's own + * --ws-space-14 on each side, as a container query takes no var(). */ -.ws-status-line__file { - flex: 1 1 0; +.status-line__path { + display: flex; + flex: 1; container-type: inline-size; - padding-inline: 0; - background: none; -} - -/* The path's box fills the line, so the spacer has nothing left to push. */ -.ws-status-line__spacer { - flex: none; } -/* Its text sits on the middle of the line, where the other items center theirs. */ -.ws-status-line__file > span { - padding: calc( - (var(--ws-size-status-line) - var(--ws-border-width-thin) - 1lh) / 2 - ) - var(--ws-space-14); - background: var(--ws-color-raised); -} - -/* "~…" between the paddings: 2 × --ws-space-14 is 1.75rem, as a query can't read a custom property. */ -@container (width < calc(2ch + 1.75rem)) { - .ws-status-line__file > span { +@container (width < calc(2ch + 2 * 0.875rem)) { + .ws-status-line__file { display: none; } } @@ -827,3 +810,33 @@ body { letter-spacing: var(--ws-text-h2-compact-letter-spacing); } } + +/* + * In forced colors the browser paints every background in the page's own color, and with it the + * marks drawn as a mask on one. Here they take the system's colors: a checked box and the pressed + * language as a selection, every other mark in the color of the text it stands with. + */ +@media (forced-colors: active) { + .choice__input:checked, + .language__button[aria-pressed='true'] { + border-color: Highlight; + color: HighlightText; + background: Highlight; + } + + .choice__input:checked::before { + background: HighlightText; + } + + .select::after { + background: FieldText; + } + + .field__error::before, + .notice__title::before, + .notice__message::before, + .notice--error .notice__title::before, + .notice--error .notice__message::before { + background: CanvasText; + } +} diff --git a/react-checkout/src/ui/StatusLine.tsx b/react-checkout/src/ui/StatusLine.tsx index 5f60488..31c49c2 100644 --- a/react-checkout/src/ui/StatusLine.tsx +++ b/react-checkout/src/ui/StatusLine.tsx @@ -37,10 +37,12 @@ export function StatusLine() { return (