This commit is contained in:
Andras Schmelczer 2026-09-11 22:14:24 +01:00
commit 0c0f08b350
45 changed files with 1565 additions and 1579 deletions

View file

@ -11,8 +11,7 @@ Use a supported Node.js release (22.12+ or 24+). Open the local URL printed by V
The home page introduces the planner, a short DIY laminate fitting guide, and the difference The home page introduces the planner, a short DIY laminate fitting guide, and the difference
between scotia and skirting boards. **Plan my floor** opens the app at `?planner`, resuming the between scotia and skirting boards. **Plan my floor** opens the app at `?planner`, resuming the
last locally saved project when available. Existing project queries and legacy `#plan=` links last locally saved project when available. Current project queries open the planner directly. Both pages work on
still open the planner directly. Both pages work on
static hosting without server-side routing. The planner loads only when opened. static hosting without server-side routing. The planner loads only when opened.
```sh ```sh
@ -21,17 +20,21 @@ npx playwright install chromium
npm run test:e2e # Desktop Chromium and mobile-sized Chromium npm run test:e2e # Desktop Chromium and mobile-sized Chromium
npm run build # Strict TypeScript check and production build npm run build # Strict TypeScript check and production build
npm run check # Build, unit tests and browser tests npm run check # Build, unit tests and browser tests
npm run benchmark # Compare cut-first optimisation with the fixed 84-case baseline
npm run benchmark -- --random # Compare appearance-first optimisation with the same baseline
``` ```
## Planning workflow ## Planning workflow
New plans start with a random laying pattern. Click the numbered room, materials and cut-plan headings to expand or collapse each panel. Click **Custom** to build an outline wall by wall; guidance below the shape choices explains how to begin. Advanced flooring and skirting settings expand separately when needed. Saved plans keep their chosen laying pattern.
1. Start with a rectangle, fireplace recess, or custom outline. Enter wall lengths in order. The first wall runs east; the turn **after** each wall is positive for right and negative for left. For example, a clockwise rectangle has 90° turns. The final corner is derived from the closed outline. Insert a wall after any existing wall, drag its handle to reorder it, or use the up/down buttons on a phone or keyboard. Doors stay attached to their wall. Numeric fields allow empty values and a minus sign while typing; unfinished entries revert to the last valid value when you leave the field. 1. Start with a rectangle, fireplace recess, or custom outline. Enter wall lengths in order. The first wall runs east; the turn **after** each wall is positive for right and negative for left. For example, a clockwise rectangle has 90° turns. The final corner is derived from the closed outline. Insert a wall after any existing wall, drag its handle to reorder it, or use the up/down buttons on a phone or keyboard. Doors stay attached to their wall. Numeric fields allow empty values and a minus sign while typing; unfinished entries revert to the last valid value when you leave the field.
2. Add door openings with a width and a distance from the named starting corner. Each doorway shows the neighbouring wall names and an arrow in the measurement direction. Include architrave/trim in the width where skirting must be omitted. Doors terminate skirting; laminate ends at the room outline with a transition and expansion gap. Rooms are planned independently. 2. Add door openings with a width and a distance from the named starting corner. Each doorway shows the neighbouring wall names and an arrow in the measurement direction. Include architrave/trim in the width where skirting must be omitted. Doors terminate skirting; laminate ends at the room outline with a transition and expansion gap. Rooms are planned independently.
3. For a custom outline, the closing-wall suggestion gives the required length and turn. Add it, then replace the suggested length with the actual measured length. An outline must close within the chosen tolerance and have no intersections or invalid doors before a cut plan can be produced. 3. For a custom outline, the closing-wall suggestion gives the required length and turn. Add it, then replace the suggested length with the actual measured length. An outline must close within the chosen tolerance and have no intersections or invalid doors before a cut plan can be produced.
4. Set material dimensions, spacer, kerf and minimum piece sizes alongside the measurements. Kerf means material removed by the blade: a 3 mm cut leaves 600 mm + 397 mm from a 1,000 mm board. Both kerf fields have keyboard and touch tooltips. Set one purchased skirting board length for the whole project. Materials are shared across rooms; direction is per room. 4. Set material dimensions, spacer, kerf and minimum piece sizes alongside the measurements. Kerf means material removed by the blade: a 3 mm cut leaves 600 mm + 397 mm from a 1,000 mm board. Both kerf fields have keyboard and touch tooltips. Set one purchased skirting board length for the whole project. Materials are shared across rooms; direction is per room.
5. Room measurements, materials and cut plans open and close independently on the same page. The drawing stays pinned on the right while you scroll the panels; on phones a compact drawing stays above them. Flooring and skirting are visible together, with the whole drawing fitting without an internal scrollbar. Warnings follow their room, even when rooms share a name. Every installed board is drawn, including full lengths without labels. Cut codes sit above the wall and skirting drawing; short pieces use nearby labels with pointers so their names remain visible. The compact drawing header shows only the room, area and material legend. Only cuts and reusable offcuts receive sequential codes starting at F1 for flooring and A1 for the first room’s skirting. Flooring and skirting cuts are grouped by the purchased board they come from, including offcuts reused across rooms. Group headings use the cut codes; internal stock IDs stay out of the interface. Pieces wrap side by side when space allows. Each piece has a small preview that opens dimensions directly on its shape. Skirting previews use equal scales on both axes, with close-ups of each end to show the actual mitre angle. Numbered skirting pieces and their labels open cut details; uncut lengths use a neutral fill. Print all room drawings followed by flooring and skirting cut sheets grouped by purchased board. Every cut is included once, with its room and row or wall. 5. Room measurements, materials and cut plans open and close independently on the same page. The drawing stays pinned on the right while you scroll the panels; on phones a compact drawing stays above them. The **Floorboards / Skirting** switch above the drawing shows one material at a time, with the whole drawing fitting without an internal scrollbar. The choice is saved as `view=flooring` or `view=skirting`. Locating or searching for a cut switches to its material automatically; printing includes both materials. Warnings follow their room, even when rooms share a name. Every installed board is drawn, including full lengths without labels. Cut codes sit above the wall and skirting drawing; short pieces use nearby labels with pointers so their names remain visible. The compact drawing header shows only the room, area and material legend. Only cuts and reusable offcuts receive sequential codes starting at F1 for flooring and A1 for the first room’s skirting. Flooring and skirting cuts are grouped by the purchased board they come from, including offcuts reused across rooms. Group headings use the cut codes; internal stock IDs stay out of the interface. Pieces wrap side by side when space allows. Each piece has a small preview that opens dimensions directly on its shape. Skirting previews use equal scales on both axes, with close-ups of each end to show the actual mitre angle. Numbered skirting pieces and their labels open cut details; uncut lengths use a neutral fill. Print all room drawings followed by flooring and skirting cut sheets grouped by purchased board. Every cut is included once, with its room and row or wall.
6. Find a cut by its code, or search by room name. Searching several cut codes together, such as `F27 + F28`, finds their pieces together. **Show on plan** highlights the source board’s pieces or an individual cut, with room buttons when a source is reused across rooms. A visible **Search active** banner stays above the pinned drawing; **Show all pieces** clears the search there. Source boards have **Mark done** checkboxes; completion marks appear on their list entries, installed pieces and printed sheets. Room search results also let you locate and mark uncut boards without adding cut labels to them. Measurements, wall order, flooring direction or material changes clear completion because the allocation changes; renaming rooms keeps it. 6. Find a cut by its code, or search by room name. Searching several cut codes together, such as `F27 + F28`, finds their pieces together. **Show on plan** highlights the source board’s pieces or an individual cut, with room buttons when a source is reused across rooms. A visible **Search active** banner stays above the pinned drawing; **Show all pieces** clears the search there. Source boards have **Mark done** checkboxes; completion marks appear on their list entries, installed pieces and printed sheets. Room search results also let you locate and mark uncut boards without adding cut labels to them. Measurements, wall order, flooring direction or material changes clear completion because the allocation changes; renaming rooms keeps it.
7. Copy the link to save or share the complete project. Measurements, materials and view choices live in readable query parameters such as `flooring.length=1200`, `skirting.length=2400`, `room.1.wall.1.length=4800` and `selectedCut=F1`. Older stock-list links retain their first length; their completion marks are cleared because coping blanks and rounded stock allocation have changed, including for single-size links. Progress uses repeated `done=floor:B4` or `done=skirting:S6` parameters; `search=F1` and repeated `collapsed=materials` parameters preserve the search and closed panels. You can edit values directly in the URL. Older compressed fragment links still load and migrate automatically; obsolete step, layer and zoom choices are ignored. Reloading or opening that link reproduces the plan. Browser back/forward restores room changes. The same parameters are saved automatically in localStorage under `floor-planner.project`. Opening the app without URL parameters restores the last saved plan; explicit query or legacy fragment links take precedence and become the saved plan. If localStorage is unavailable or full, URL saving still works. There is no account, API, database or analytics. Fonts are system fonts; the app makes no external font requests. 7. Copy the link to save or share the complete project. Measurements, materials and view choices live in readable version 2 query parameters such as `flooring.length=1200`, `skirting.length=2400`, `room.1.wall.1.length=4800` and `selectedCut=F1`. Progress uses repeated `done=floor:B4` or `done=skirting:S6` parameters; `search=F1` and repeated `collapsed=materials` parameters preserve the search and closed panels. You can edit values directly in the URL. Reloading or opening that link reproduces the plan. Browser back/forward restores room changes. The same parameters are saved automatically in localStorage under `floor-planner.project`. Opening the app without URL parameters restores the last saved plan; an explicit project query takes precedence and becomes the saved plan. If localStorage is unavailable or full, URL saving still works. There is no account, API or database. Fonts are system fonts; the app makes no external font requests.
## Calculation rules and practical limits ## Calculation rules and practical limits
@ -43,7 +46,8 @@ npm run check # Build, unit tests and browser tests
- Offcut reuse preserves the needed left/right factory ends. Only full-width end remnants are available for reuse; ripped side strips and shaped scraps are conservatively waste. Crosscuts include kerf. The stock count is actual allocated boards, not an area-only estimate. Waste includes kerf and unused material, including still-usable stock remainders. - Offcut reuse preserves the needed left/right factory ends. Only full-width end remnants are available for reuse; ripped side strips and shaped scraps are conservatively waste. Crosscuts include kerf. The stock count is actual allocated boards, not an area-only estimate. Waste includes kerf and unused material, including still-usable stock remainders.
- Skirting internal corners use coped joints. The blank keeps the wall-corner long point instead of subtracting the receiving board’s thickness; the cope preparation is half the measured turn. Earlier walls receive adjoining later walls, so installation order has no cycle. At square corners, a 4,000 mm wall keeps a 4,000 mm blank; with 18 mm skirting at both corners its exposed front length is 3,964 mm. Non-square receiving ends have a wall-fitting bevel. External corners use equal mitres. Minimum sizes check the exposed face and installed body after corner and door allowances. Preparation previews and dashed body edges guide marking; the actual moulding profile must be scribed and back-cut, since thickness alone does not define it. This follows [Gary Katz’s coping and long-point measurement guidance](https://www.finehomebuilding.com/pdf/021174063.pdf); the general-angle allowances are derived from intersecting wall faces. - Skirting internal corners use coped joints. The blank keeps the wall-corner long point instead of subtracting the receiving board’s thickness; the cope preparation is half the measured turn. Earlier walls receive adjoining later walls, so installation order has no cycle. At square corners, a 4,000 mm wall keeps a 4,000 mm blank; with 18 mm skirting at both corners its exposed front length is 3,964 mm. Non-square receiving ends have a wall-fitting bevel. External corners use equal mitres. Minimum sizes check the exposed face and installed body after corner and door allowances. Preparation previews and dashed body edges guide marking; the actual moulding profile must be scribed and back-cut, since thickness alone does not define it. This follows [Gary Katz’s coping and long-point measurement guidance](https://www.finehomebuilding.com/pdf/021174063.pdf); the general-angle allowances are derived from intersecting wall faces.
- Skirting cut lengths are the longest-point envelope. Cut square blanks first, then prepare the mitres and cope the indicated internal ends; this keeps reusable stock remainders square. Back lengths and diagram positions locate the wall-facing edge. The stock allocation includes crosscut kerf and counts additional bevel and coping operations. - Skirting cut lengths are the longest-point envelope. Cut square blanks first, then prepare the mitres and cope the indicated internal ends; this keeps reusable stock remainders square. Back lengths and diagram positions locate the wall-facing edge. The stock allocation includes crosscut kerf and counts additional bevel and coping operations.
- Flooring uses a bounded beam search, minimizing purchased boards first. Random layouts then prefer less visual repetition before fewer saw passes; brick layouts prioritize fewer saw passes. This can add cuts to break a staircase without increasing the selected board count. Skirting compares full-stock, balanced and offcut-aware splits and packs them into the single purchased length, preferring less waste, then fewer cuts. Available offcuts can move the next wall’s joints. Minimum lengths are reserved on the exposed face and full-thickness body of angled and coped pieces. These are deterministic, auditable heuristics rather than guarantees of a global minimum. Room order is an input and can affect shared-offcut allocation. - Random flooring offers **Minimise cuts** and **Maximise randomness**, with the actual cut count and waste percentage beside each choice. Minimise cuts ranks saw passes first, then simpler cuts (fewer shaping passes, then fewer rips), visual repetition and finally purchased boards. Maximise randomness ranks visual repetition first, then the same cutting and waste priorities. The choice is saved as `flooring.optimisation=cuts` or `flooring.optimisation=random`; changing it clears completion marks because stock allocation can change. Brick prioritises cutting effort and then waste.
- Flooring uses a bounded beam search that preserves factory-ended offcuts for later exact fits. Completed candidates are repacked, and interchangeable full-width rectangular rows can be reordered without adding cuts. Both options share clipping results, and the best completed candidates are compared before displaying totals. Skirting compares full-stock, balanced and offcut-aware splits, including exact three-piece stock combinations, preferring fewer cuts and then less waste. Available offcuts can move the next wall’s joints. Minimum lengths are reserved on the exposed face and full-thickness body of angled and coped pieces. These are deterministic, auditable heuristics rather than guarantees of a global minimum. Room order remains an input. See [the benchmark definitions and iteration results](benchmarks/README.md).
- Board counts exclude an extra allowance for damage or mistakes. Spacer, minimum size and staggering defaults are editable starting values; follow the exact product's installation instructions. For example, [Quick-Step's installation guidance](https://www.quick-step.co.uk/en-gb/laminate/installation) provides product-specific manuals, and its [room-transition guidance](https://www.quick-step.co.uk/en-gb/frequently-asked-questions/laminate/preparation-and-installation/do-i-really-need-expansion-gaps-between-every-room) explains separate expansion joints. - Board counts exclude an extra allowance for damage or mistakes. Spacer, minimum size and staggering defaults are editable starting values; follow the exact product's installation instructions. For example, [Quick-Step's installation guidance](https://www.quick-step.co.uk/en-gb/laminate/installation) provides product-specific manuals, and its [room-transition guidance](https://www.quick-step.co.uk/en-gb/frequently-asked-questions/laminate/preparation-and-installation/do-i-really-need-expansion-gaps-between-every-room) explains separate expansion joints.
- Links are bounded to 20 rooms, 100 walls per room and 30 doors per wall. Flooring calculations are bounded to 2,000 purchased boards and 500 rows per room. Large plans may take longer; very large projects should be split into separate links. Long links may exceed the limits of a messaging service. - Links are bounded to 20 rooms, 100 walls per room and 30 doors per wall. Flooring calculations are bounded to 2,000 purchased boards and 500 rows per room. Large plans may take longer; very large projects should be split into separate links. Long links may exceed the limits of a messaging service.
@ -56,7 +60,8 @@ npm run check # Build, unit tests and browser tests
| `src/lib/geometry.ts` | Vector tracing, closure, validation and polygon offsets | | `src/lib/geometry.ts` | Vector tracing, closure, validation and polygon offsets |
| `src/lib/flooring.ts` | Row search, clipping, factory-end-aware stock allocation | | `src/lib/flooring.ts` | Row search, clipping, factory-end-aware stock allocation |
| `src/lib/skirting.ts` | Corner allowances, run splitting and stock allocation | | `src/lib/skirting.ts` | Corner allowances, run splitting and stock allocation |
| `src/lib/url-state.ts` | Readable query schema, legacy links and input validation | | `src/lib/url-state.ts` | Readable query schema and input validation |
| `src/lib/limits.ts` | Shared project, persistence and calculation bounds |
| `src/lib/piece-labels.ts` | Collision-free cut-code placement and pointers for small pieces | | `src/lib/piece-labels.ts` | Collision-free cut-code placement and pointers for small pieces |
| `src/lib/board-tracking.ts` | Exact board/cut matching and room-name search | | `src/lib/board-tracking.ts` | Exact board/cut matching and room-name search |
| `src/lib/wall-editing.ts` | Wall insertion and reordering with stable IDs | | `src/lib/wall-editing.ts` | Wall insertion and reordering with stable IDs |

94
benchmarks/README.md Normal file
View file

@ -0,0 +1,94 @@
# Optimiser measurements
Run `npm run benchmark` for **Minimise cuts**, or `npm run benchmark -- --random` for
**Maximise randomness**. Both are compared with the original stock-first optimiser's
frozen results in `baseline.json`. The 84 inputs in `cases.ts` cover rectangular
remainders, fireplaces in both directions, room-order permutations, tight and exact
stagger limits, fractional stock, large floors, and both supplied angled rooms.
`--output=/tmp/results.json` saves a run; `--compare=/tmp/results.json` compares
against a previous iteration. Do not overwrite the baseline to hide regressions.
## Fixed metrics
- **Saw passes:** crosscuts actually required by the allocation, long-edge rips,
and additional shaping edges. Skirting includes bevel and coping operations.
- **Cut difficulty:** shaping passes, then rip passes, used to break equal saw-count
ties. This is an explicit proxy, not an estimate of minutes or tool-specific effort.
- **Random appearance:** the existing repetition penalty, evaluated independently
from the output rows. It penalises nearby repeating joints, similar consecutive
steps and staircases, including steps that wrap across a board length. Raw repeat,
similar-step and staircase counts are also reported. A lower score is better.
- **Waste:** purchased stock minus installed material, including kerf. The report
gives board counts and waste percentages weighted by purchased stock.
- **Validity and runtime:** errors, elapsed time, p95 and maximum case time. Tests
separately verify coverage, non-overlapping row bands, minimum sizes, stagger,
factory ends, rounded stock consumption, cut accounting, references and input purity.
Minimise cuts orders `(passes, shaping, rips, pattern penalty, boards)`.
Maximise randomness orders `(pattern penalty, passes, shaping, rips, boards)`.
Validity precedes either objective. Skirting orders `(passes, waste)`.
## Measured results
Totals across the same 84 cases, September 2026:
| Metric | Original | Minimise cuts | Maximise randomness |
| ------------------- | -------: | ------------: | ------------------: |
| Flooring saw passes | 2,177 | **1,741** | **1,994** |
| Shaping passes | 192 | 184 | 185 |
| Rip passes | 414 | 402 | 405 |
| Pattern penalty | 265 | 1,349 | **113** |
| Flooring boards | 3,561 | 3,537 | 3,579 |
| Flooring waste | 8.20% | 7.57% | 8.66% |
| Invalid cases | 0 | 0 | 0 |
Minimise cuts saves **20.0%** of saw passes. Maximise randomness reduces the pattern
penalty **57.4%**, while also saving **8.4%** of saw passes. For random flooring in the
default 4,800 × 3,600 mm room, 38 passes become **24** or **30**, respectively; both options use 76
boards and have approximately 1.2% waste.
Skirting drops from **1,447 to 1,436 passes**. It uses 521 boards instead of 513:
cutting effort now takes precedence over waste, which rises from 9.28% to 10.68%.
Eight cases improve and 76 tie.
For flooring, 78 cut-priority cases improve and six tie. Appearance priority improves
72, ties 11, and uses one extra cut in `rectangle-38` despite the same zero pattern
penalty. The bounded search does not establish global optimality.
## Iterations retained
1. Correct the objective order; measuring stock first contradicted the requested priorities.
2. Deduplicate the complete relevant state, including recent joint history. Stop
computing keys once the beam is full; share immutable exhausted stocks and avoid
searching offcuts for pieces requiring both factory ends.
3. Repack completed boundary blanks, reserving exact complementary factory ends
first. Preserve the original placement and cutting order within each source board.
4. Try bounded swaps of interchangeable rectangular rows. Accept only a lower
pattern penalty with unchanged cuts, stock and geometry coverage.
5. Polish all surviving completed candidates, retaining the best result.
6. Preserve end remnants during search instead of trimming them immediately.
This alone improves 56 cut-priority cases and saves another 99 passes after the
earlier improvements. Final packing can still combine non-exact blanks.
7. When repetition remains, compare an immediate-reuse search as well. This improves
five appearance-priority cases. All searches share their clipping cache, and the
two UI choices select from the completed results. Selection itself does not rerun
the optimiser.
8. Compare exact three-piece skirting fills with the original packing. This improves
two cases for a small additional calculation cost.
## Experiments rejected
Increasing beam widths from 5/2 to 12/4 roughly tripled search time, with regressions
in both modes. Carrying two room results into the next room worsened two appearance
cases for a single waste improvement. Expanding the offcut candidate pool with
distinct remnants had no cut-priority benefit and regressed a large-room result,
including after the end-preservation change. These variants were removed.
The original single-result benchmark took about 1.5 seconds for the corpus. Producing
both choices, including the conditional extra appearance search, takes about 3 seconds
on the same machine; p95 is around 110 ms and the most complex case around 0.7 seconds.
These are indicative timings, not CI thresholds. Ordinary option changes reuse the
already calculated plans. A separate 500-row, 2,000-board boundary check completes
without an error; temporary stock is repacked before enforcing the board limit.
Tests enforce the retained aggregate improvements as well as physical invariants.
Metric definitions and input cases stay fixed while search strategies change.

View file

@ -54,8 +54,22 @@ export function plannerCases(): PlannerCase[] {
add('large-rectangle', [room(14020, 8020)]); add('large-rectangle', [room(14020, 8020)]);
add('long-room', [room(30020, 1820)]); add('long-room', [room(30020, 1820)]);
cases.push( cases.push(
{ name: 'angled', project: angled.project as Project }, {
{ name: 'angled-f8', project: angledF8.project as Project }, name: 'angled',
project: {
...angled.project,
version: defaultProject().version,
flooring: { ...defaultProject().flooring, ...angled.project.flooring },
} as Project,
},
{
name: 'angled-f8',
project: {
...angledF8.project,
version: defaultProject().version,
flooring: { ...defaultProject().flooring, ...angledF8.project.flooring },
} as Project,
},
); );
return cases; return cases;
} }

View file

@ -8,11 +8,16 @@ test('the home page explains the app and its guides fit the screen', async ({ pa
'A great floor starts with a little planning.', 'A great floor starts with a little planning.',
); );
await expect(page.getByRole('heading', { name: 'Scotia or skirting board?' })).toBeVisible(); await expect(page.getByRole('heading', { name: 'Scotia or skirting board?' })).toBeVisible();
await expect(page.getByRole('link', { name: 'Plan my floor' })).toHaveCount(2); await expect(page.getByRole('link', { name: 'Plan my floor' })).toHaveCount(1);
await expect(page.getByRole('link', { name: 'Plan my floor' }).first()).toBeInViewport(); await expect(page.getByRole('link', { name: 'Plan my floor' }).first()).toBeInViewport();
await page.getByRole('link', { name: 'First time fitting a floor?' }).click(); await page.getByRole('link', { name: 'First time fitting a floor?' }).click();
await expect(page).toHaveURL(/#guide$/); await expect(page).toHaveURL(/#guide$/);
await expect(page.getByRole('heading', { name: /Your first floor/ })).toBeInViewport(); await expect(page.getByRole('heading', { name: /Your first floor/ })).toBeInViewport();
await expect(page.getByRole('link', { name: 'Open planner' })).toBeInViewport();
const header = await page.getByRole('banner').boundingBox();
const guide = await page.getByRole('heading', { name: /Your first floor/ }).boundingBox();
expect(header!.y).toBe(0);
expect(guide!.y).toBeGreaterThanOrEqual(header!.height);
await page.reload(); await page.reload();
await expect(page.getByRole('heading', { name: /Your first floor/ })).toBeInViewport(); await expect(page.getByRole('heading', { name: /Your first floor/ })).toBeInViewport();
await page.getByRole('link', { name: 'Back to top' }).click(); await page.getByRole('link', { name: 'Back to top' }).click();
@ -26,16 +31,19 @@ test('the home page explains the app and its guides fit the screen', async ({ pa
for (const [name, selector] of [ for (const [name, selector] of [
['header', '.landing-header'], ['header', '.landing-header'],
['hero', '.landing-hero'], ['hero', '.landing-hero'],
['closing', '.landing-final-cta'],
]) { ]) {
test(`the ${name} CTA opens a working planner and browser history returns home`, async ({ test(`the ${name} CTA opens a working planner and browser history returns home`, async ({
page, page,
}) => { }) => {
await page.goto('/'); await page.goto('/');
if (name === 'header') {
await page.getByRole('contentinfo').scrollIntoViewIfNeeded();
await expect(page.getByRole('link', { name: 'Open planner' })).toBeInViewport();
}
await page.locator(selector).locator('a[href="?planner"]').click(); await page.locator(selector).locator('a[href="?planner"]').click();
await expect(page.getByRole('heading', { name: 'Room measurements' })).toBeVisible(); await expect(page.getByRole('heading', { name: 'Room measurements' })).toBeVisible();
await expect(page.getByLabel('Room width', { exact: true })).toHaveValue('4800'); await expect(page.getByLabel('Room width', { exact: true })).toHaveValue('4800');
await expect(page).toHaveURL(/\?version=1&/); await expect(page).toHaveURL(/\?version=\d+&/);
await page.getByLabel('Room name', { exact: true }).fill('My first floor'); await page.getByLabel('Room name', { exact: true }).fill('My first floor');
const projectUrl = page.url(); const projectUrl = page.url();
await page.reload(); await page.reload();

View file

@ -1,6 +1,5 @@
import { expect, test } from '@playwright/test'; import { expect, test } from '@playwright/test';
import type { Locator, Page } from '@playwright/test'; import type { Locator, Page } from '@playwright/test';
import LZString from 'lz-string';
import { readFile } from 'node:fs/promises'; import { readFile } from 'node:fs/promises';
import { decodeState, encodeState } from '../src/lib/url-state'; import { decodeState, encodeState } from '../src/lib/url-state';
import { PROJECT_STORAGE_KEY } from '../src/lib/use-project'; import { PROJECT_STORAGE_KEY } from '../src/lib/use-project';
@ -9,6 +8,7 @@ import { planFlooring } from '../src/lib/flooring';
import { planSkirting } from '../src/lib/skirting'; import { planSkirting } from '../src/lib/skirting';
import { flooringCuts, skirtingCuts, uncutFlooring } from '../src/lib/cut-list'; import { flooringCuts, skirtingCuts, uncutFlooring } from '../src/lib/cut-list';
import { cutMm } from '../src/lib/format'; import { cutMm } from '../src/lib/format';
import type { UrlState } from '../src/lib/types';
const errors = new WeakMap<Page, string[]>(); const errors = new WeakMap<Page, string[]>();
const panel = (page: Page, section: string) => const panel = (page: Page, section: string) =>
@ -22,7 +22,7 @@ const skirtCodes = (page: Page) =>
skirtEntries(page).getByRole('button', { name: /^Preview skirting cut / }); skirtEntries(page).getByRole('button', { name: /^Preview skirting cut / });
const state = (page: Page) => { const state = (page: Page) => {
const url = new URL(page.url()); const url = new URL(page.url());
return decodeState(url.search || url.hash).state; return decodeState(url.search).state;
}; };
const savedQuery = (page: Page) => const savedQuery = (page: Page) =>
page.evaluate((key) => localStorage.getItem(key), PROJECT_STORAGE_KEY); page.evaluate((key) => localStorage.getItem(key), PROJECT_STORAGE_KEY);
@ -60,6 +60,7 @@ function shortFireplaceFixture() {
length: 1200, length: 1200,
width: 190, width: 190,
pattern: 'random', pattern: 'random',
optimisation: 'cuts',
minOffset: 100, minOffset: 100,
maxOffset: 1000, maxOffset: 1000,
minLength: 10, minLength: 10,
@ -265,7 +266,7 @@ test.beforeEach(async ({ page }) => {
page.on('pageerror', (error) => errors.get(page)!.push(error.message)); page.on('pageerror', (error) => errors.get(page)!.push(error.message));
await page.goto('/?planner'); await page.goto('/?planner');
await expect(page.getByRole('heading', { name: 'Room measurements' })).toBeVisible(); await expect(page.getByRole('heading', { name: 'Room measurements' })).toBeVisible();
await expect(page).toHaveURL(/\?version=1&/); await expect(page).toHaveURL(/\?version=2&/);
}); });
test.afterEach(async ({ page }) => { test.afterEach(async ({ page }) => {
@ -345,10 +346,14 @@ test('source-board groups contain every numbered cut once and leave full boards
} }
await expect(page.locator('.material-cuts table')).toHaveCount(0); await expect(page.locator('.material-cuts table')).toHaveCount(0);
await expect(preview(page).locator('.floor-piece')).toHaveCount(floor.pieces.length); await expect(preview(page).locator('.floor-piece')).toHaveCount(floor.pieces.length);
await expect(preview(page).locator('.skirt-piece')).toHaveCount(skirt.pieces.length);
await expect(preview(page).getByRole('button', { name: /^Select flooring cut / })).toHaveCount( await expect(preview(page).getByRole('button', { name: /^Select flooring cut / })).toHaveCount(
cutFloor.length, cutFloor.length,
); );
await page
.getByRole('group', { name: 'Plan view' })
.getByRole('button', { name: 'Skirting', exact: true })
.click();
await expect(preview(page).locator('.skirt-piece')).toHaveCount(skirt.pieces.length);
await expect(preview(page).getByRole('button', { name: /^Select skirting cut / })).toHaveCount( await expect(preview(page).getByRole('button', { name: /^Select skirting cut / })).toHaveCount(
cutSkirt.length, cutSkirt.length,
); );
@ -539,7 +544,7 @@ test('internal skirting corners retain coping blanks and expose the installed mi
expect( expect(
skirt.pieces.every( skirt.pieces.every(
(piece) => (piece) =>
Math.abs(piece.length - 2400) < 0.001 && Math.abs(piece.visibleLength! - 2364) < 0.001, Math.abs(piece.length - 2400) < 0.001 && Math.abs(piece.visibleLength - 2364) < 0.001,
), ),
).toBe(true); ).toBe(true);
const receiver = skirt.pieces.find((piece) => piece.wallIndex === 0)!; const receiver = skirt.pieces.find((piece) => piece.wallIndex === 0)!;
@ -580,6 +585,7 @@ test('internal skirting corners retain coping blanks and expose the installed mi
expect(piece.leftOverlap).toBeCloseTo(18, 3); expect(piece.leftOverlap).toBeCloseTo(18, 3);
await page.keyboard.press('Escape'); await page.keyboard.press('Escape');
const floorCount = await floorEntries(page).count(); const floorCount = await floorEntries(page).count();
await page.getByText('Advanced skirting settings', { exact: true }).click();
await page.getByLabel('Minimum piece', { exact: true }).fill('2365'); await page.getByLabel('Minimum piece', { exact: true }).fill('2365');
await expect(skirtEntries(page)).toHaveCount(0); await expect(skirtEntries(page)).toHaveCount(0);
await expect(floorEntries(page)).toHaveCount(floorCount); await expect(floorEntries(page)).toHaveCount(floorCount);
@ -666,6 +672,7 @@ test('pattern, direction and spacers persist without steps, layers or stored res
expect(state(page).project.rooms[0].direction).toBe(90); expect(state(page).project.rooms[0].direction).toBe(90);
expect(Object.keys(state(page).view).sort()).toEqual([ expect(Object.keys(state(page).view).sort()).toEqual([
'collapsedSections', 'collapsedSections',
'material',
'roomId', 'roomId',
'search', 'search',
'selectedPiece', 'selectedPiece',
@ -713,6 +720,7 @@ test('localStorage restores all project and view parameters when reopening witho
selectedPiece: 'F1', selectedPiece: 'F1',
search: 'Study', search: 'Study',
collapsedSections: ['cuts', 'materials'], collapsedSections: ['cuts', 'materials'],
material: 'flooring',
}; };
const query = encodeState(fixture); const query = encodeState(fixture);
await page.goto(`/${query}`); await page.goto(`/${query}`);
@ -760,7 +768,7 @@ for (const saved of ['damaged data', '?flooring.length=broken']) {
[PROJECT_STORAGE_KEY, saved], [PROJECT_STORAGE_KEY, saved],
); );
await page.goto('/?planner'); await page.goto('/?planner');
await expect(page).toHaveURL(/\?version=1&/); await expect(page).toHaveURL(/\?version=2&/);
await expect(page.locator('.url-error')).toHaveCount(0); await expect(page.locator('.url-error')).toHaveCount(0);
expect(state(page)).toEqual(defaultState()); expect(state(page)).toEqual(defaultState());
expect(await savedQuery(page)).toBe(encodeState(defaultState())); expect(await savedQuery(page)).toBe(encodeState(defaultState()));
@ -869,6 +877,8 @@ test('shared URLs reopen the selected preview and copying the link preserves the
}); });
test('saw kerf help works with keyboard and touch or mouse', async ({ page, isMobile }) => { test('saw kerf help works with keyboard and touch or mouse', async ({ page, isMobile }) => {
await page.getByText('Advanced flooring settings', { exact: true }).click();
await page.getByText('Advanced skirting settings', { exact: true }).click();
for (const name of ['What is saw kerf?', 'What is skirting saw kerf?']) { for (const name of ['What is saw kerf?', 'What is skirting saw kerf?']) {
const button = page.getByRole('button', { name, exact: true }); const button = page.getByRole('button', { name, exact: true });
await button.focus(); await button.focus();
@ -904,6 +914,10 @@ test('invalid URLs recover when measurements are edited', async ({ page }) => {
}); });
test('clicking the skirting code itself opens its cutting dialog', async ({ page }) => { test('clicking the skirting code itself opens its cutting dialog', async ({ page }) => {
await page
.getByRole('group', { name: 'Plan view' })
.getByRole('button', { name: 'Skirting', exact: true })
.click();
for (const target of ['rect', 'text']) { for (const target of ['rect', 'text']) {
const code = preview(page).locator('.skirting-code').first(); const code = preview(page).locator('.skirting-code').first();
const id = await code.evaluate((element) => const id = await code.evaluate((element) =>
@ -920,18 +934,14 @@ test('clicking the skirting code itself opens its cutting dialog', async ({ page
} }
}); });
test('readable query fields, legacy links and browser history preserve the plan', async ({ test('readable query fields and browser history preserve the plan', async ({ page }) => {
page, const initial = defaultState();
}) => { initial.project.rooms[0].name = 'Current lounge';
const legacy = defaultState(); initial.project.flooring.pattern = 'random';
legacy.project.rooms[0].name = 'Legacy lounge'; await page.goto(`/${encodeState(initial)}`);
legacy.project.flooring.pattern = 'random'; await expect(page).toHaveURL(/\?version=2&/);
const hash = `#plan=${LZString.compressToEncodedURIComponent(JSON.stringify(legacy))}`; expect(state(page)).toEqual(initial);
await page.goto(`/${hash}`); await expect.poll(() => savedQuery(page)).toBe(encodeState(initial));
await expect(page).toHaveURL(/\?version=1&/);
expect(new URL(page.url()).hash).toBe('');
expect(state(page)).toEqual(legacy);
expect(await savedQuery(page)).toBe(encodeState(legacy));
const original = page.url(); const original = page.url();
await page.getByRole('button', { name: 'Add room', exact: true }).click(); await page.getByRole('button', { name: 'Add room', exact: true }).click();
await page.getByLabel('Room name', { exact: true }).fill('Study'); await page.getByLabel('Room name', { exact: true }).fill('Study');
@ -945,7 +955,7 @@ test('readable query fields, legacy links and browser history preserve the plan'
expect([...params.keys()].some((key) => /boardCount|polygon|pieceIds/.test(key))).toBe(false); expect([...params.keys()].some((key) => /boardCount|polygon|pieceIds/.test(key))).toBe(false);
await page.goBack(); await page.goBack();
await expect(page).toHaveURL(original); await expect(page).toHaveURL(original);
await expect(page.getByLabel('Room name', { exact: true })).toHaveValue('Legacy lounge'); await expect(page.getByLabel('Room name', { exact: true })).toHaveValue('Current lounge');
expect(state(page).project.rooms).toHaveLength(1); expect(state(page).project.rooms).toHaveLength(1);
expect(await savedQuery(page)).toBe(new URL(original).search); expect(await savedQuery(page)).toBe(new URL(original).search);
await page.goForward(); await page.goForward();
@ -961,35 +971,6 @@ test('readable query fields, legacy links and browser history preserve the plan'
expect(state(page).project.rooms).toHaveLength(2); expect(state(page).project.rooms).toHaveLength(2);
}); });
test('legacy skirting sizes migrate to one editable length and reset changed allocations', async ({
page,
}) => {
const initial = defaultState();
const legacy = {
...initial,
project: {
...initial.project,
completedBoards: ['skirting:S1'],
skirting: { ...initial.project.skirting, stockLength: undefined, stockLengths: [3600, 2400] },
},
};
await page.goto(`/#plan=${LZString.compressToEncodedURIComponent(JSON.stringify(legacy))}`);
await expect(page.getByLabel('Skirting board length', { exact: true })).toHaveValue('3600');
expect(state(page).project.skirting.stockLength).toBe(3600);
expect(state(page).project.completedBoards).toEqual([]);
const params = new URL(page.url()).searchParams;
expect(params.get('skirting.length')).toBe('3600');
expect(params.has('skirting.stock')).toBe(false);
await page.getByLabel('Skirting board length', { exact: true }).fill('3000');
await page.reload();
await expect(page.getByLabel('Skirting board length', { exact: true })).toHaveValue('3000');
await page.goto('/?skirting.stock=2400&skirting.stock=2400&done=skirting:S1');
await expect(page.getByLabel('Skirting board length', { exact: true })).toHaveValue('2400');
expect(state(page).project.completedBoards).toEqual([]);
expect(new URL(page.url()).searchParams.get('skirting.length')).toBe('2400');
expect(new URL(page.url()).searchParams.has('skirting.stock')).toBe(false);
});
test('printing includes every room and every cut once, grouped by its source board', async ({ test('printing includes every room and every cut once, grouped by its source board', async ({
page, page,
}) => { }) => {
@ -1173,6 +1154,7 @@ test('inserting and reordering walls keeps stable wall IDs and attached doors',
if (!isMobile) { if (!isMobile) {
const source = page.locator(`.wall-row[data-wall-id="${doorWall.id}"] .wall-drag-handle`); const source = page.locator(`.wall-row[data-wall-id="${doorWall.id}"] .wall-drag-handle`);
const target = page.locator(`.wall-row[data-wall-id="${originalIds[0]}"]`); const target = page.locator(`.wall-row[data-wall-id="${originalIds[0]}"]`);
await page.locator('.wall-table').evaluate((table) => table.scrollIntoView({ block: 'start' }));
await source.dragTo(target); await source.dragTo(target);
expect(state(page).project.rooms[0].walls[0]).toEqual(doorWall); expect(state(page).project.rooms[0].walls[0]).toEqual(doorWall);
} }
@ -1201,9 +1183,8 @@ test('the supplied angled room keeps W12 lines and labels inside the drawing', a
new URL('../tests/fixtures/angled-room.json', import.meta.url), new URL('../tests/fixtures/angled-room.json', import.meta.url),
'utf8', 'utf8',
); );
const fixture = decodeState(`#plan=${LZString.compressToEncodedURIComponent(angledRoom)}`); const fixture = JSON.parse(angledRoom) as UrlState;
expect(fixture.error).toBeNull(); await page.goto(`/${encodeState(fixture)}`);
await page.goto(`/${encodeState(fixture.state)}`);
await expect(preview(page).locator('.wall-drawing')).toHaveCount(12); await expect(preview(page).locator('.wall-drawing')).toHaveCount(12);
for (const width of isMobile ? [320, 390] : [1280]) { for (const width of isMobile ? [320, 390] : [1280]) {
await page.setViewportSize({ width, height: 844 }); await page.setViewportSize({ width, height: 844 });
@ -1317,11 +1298,10 @@ test('the supplied F8 room aligns a row seam with its fireplace corner and keeps
new URL('../tests/fixtures/angled-room-f8.json', import.meta.url), new URL('../tests/fixtures/angled-room-f8.json', import.meta.url),
'utf8', 'utf8',
); );
const fixture = decodeState(`#plan=${LZString.compressToEncodedURIComponent(json)}`); const fixture = JSON.parse(json) as UrlState;
expect(fixture.error).toBeNull(); fixture.view.selectedPiece = null;
fixture.state.view.selectedPiece = null; fixture.view.search = '';
fixture.state.view.search = ''; await page.goto(`/${encodeState(fixture)}`);
await page.goto(`/${encodeState(fixture.state)}`);
const { floor, skirt } = plans(page); const { floor, skirt } = plans(page);
const corner = { x: 7607.513, y: 2160.34 }; const corner = { x: 7607.513, y: 2160.34 };
const atCorner = floor.pieces.filter((piece) => const atCorner = floor.pieces.filter((piece) =>
@ -1355,7 +1335,7 @@ test('the supplied F8 room aligns a row seam with its fireplace corner and keeps
dimensions.some(({ actual }) => Math.abs(actual * 2 - Math.round(actual * 2)) > 0.001), dimensions.some(({ actual }) => Math.abs(actual * 2 - Math.round(actual * 2)) > 0.001),
).toBe(true); ).toBe(true);
expectHalfMillimetreCuts(dimensions); expectHalfMillimetreCuts(dimensions);
expect(state(page).project.rooms[0].walls).toEqual(fixture.state.project.rooms[0].walls); expect(state(page).project.rooms[0].walls).toEqual(fixture.project.rooms[0].walls);
await page.keyboard.press('Escape'); await page.keyboard.press('Escape');
const skirtCut = skirtingCuts(skirt).find( const skirtCut = skirtingCuts(skirt).find(
(piece) => (piece) =>
@ -1399,6 +1379,7 @@ test('completed source boards and locate actions follow shared offcuts across ro
const sourcePieces = floor.pieces.filter((piece) => piece.stockId === shared.id); const sourcePieces = floor.pieces.filter((piece) => piece.stockId === shared.id);
const key = `floor:${shared.id}`; const key = `floor:${shared.id}`;
const group = page.locator(`.stock-cut-group[data-board-key="${key}"]`); const group = page.locator(`.stock-cut-group[data-board-key="${key}"]`);
await expect(group).toBeVisible();
const groupCodes = await group const groupCodes = await group
.locator('.board-cut') .locator('.board-cut')
.evaluateAll((cuts) => cuts.map((cut) => cut.getAttribute('data-cut-id')).join(' + ')); .evaluateAll((cuts) => cuts.map((cut) => cut.getAttribute('data-cut-id')).join(' + '));
@ -1464,6 +1445,10 @@ test('completed source boards and locate actions follow shared offcuts across ro
.getByRole('checkbox') .getByRole('checkbox')
.check(); .check();
expect(state(page).project.completedBoards).toEqual([key, skirtKey]); expect(state(page).project.completedBoards).toEqual([key, skirtKey]);
await page
.getByRole('group', { name: 'Plan view' })
.getByRole('button', { name: 'Skirting', exact: true })
.click();
expect(await preview(page).locator('.skirt-piece[data-done="true"]').count()).toBeGreaterThan(0); expect(await preview(page).locator('.skirt-piece[data-done="true"]').count()).toBeGreaterThan(0);
await page.getByLabel('Board width', { exact: true }).fill('201'); await page.getByLabel('Board width', { exact: true }).fill('201');
expect(state(page).project.completedBoards).toEqual([]); expect(state(page).project.completedBoards).toEqual([]);
@ -1508,6 +1493,7 @@ test('cuts from one board share the available width and wrap on a narrow phone',
.filter({ has: page.locator('.board-cut:nth-child(2)') }) .filter({ has: page.locator('.board-cut:nth-child(2)') })
.first(); .first();
const pieces = group.locator('.board-cut'); const pieces = group.locator('.board-cut');
await expect(group).toBeVisible();
expect(await pieces.count()).toBeGreaterThan(1); expect(await pieces.count()).toBeGreaterThan(1);
const first = (await pieces.nth(0).boundingBox())!; const first = (await pieces.nth(0).boundingBox())!;
const second = (await pieces.nth(1).boundingBox())!; const second = (await pieces.nth(1).boundingBox())!;
@ -1558,6 +1544,7 @@ for (const width of [320, 390]) {
}) => { }) => {
await page.setViewportSize({ width, height: 844 }); await page.setViewportSize({ width, height: 844 });
await openWalls(page); await openWalls(page);
await page.getByText('Advanced flooring settings', { exact: true }).click();
await page.getByRole('button', { name: 'What is saw kerf?', exact: true }).click(); await page.getByRole('button', { name: 'What is saw kerf?', exact: true }).click();
await noHorizontalOverflow(page); await noHorizontalOverflow(page);
await expect(page.getByRole('tooltip')).toBeVisible(); await expect(page.getByRole('tooltip')).toBeVisible();

160
e2e/usability.spec.ts Normal file
View file

@ -0,0 +1,160 @@
import { expect, test } from '@playwright/test';
import { defaultState } from '../src/lib/defaults';
import { decodeState, encodeState } from '../src/lib/url-state';
test.beforeEach(async ({ page }) => {
await page.goto('/?planner');
await expect(page.getByRole('heading', { name: 'Room measurements', exact: true })).toBeVisible();
});
test('new plans start random and guide custom measurements through to the cut plan', async ({
page,
}) => {
await expect(page.getByRole('button', { name: 'Random', exact: true })).toHaveAttribute(
'aria-pressed',
'true',
);
await expect(page.locator('#custom-shape-help')).toContainText('Click Custom');
await page.getByRole('button', { name: 'Custom', exact: true }).click();
await expect(page.getByRole('button', { name: 'Custom', exact: true })).toHaveAttribute(
'aria-pressed',
'true',
);
await expect(page.getByLabel('Wall 1 length', { exact: true })).toBeVisible();
await page.getByRole('button', { name: 'Add a wall', exact: true }).click();
await page.getByLabel('Wall 2 length', { exact: true }).fill('3000');
await page.getByRole('button', { name: 'Add a wall', exact: true }).click();
await page.getByLabel('Wall 3 length', { exact: true }).fill('4000');
await page.getByRole('button', { name: 'Add closing wall', exact: true }).click();
await expect(page.getByText('Outline closed', { exact: true })).toBeVisible();
await expect(page.getByLabel('Wall 4 length', { exact: true })).toBeVisible();
await expect(page.getByRole('button', { name: 'Custom', exact: true })).toHaveAttribute(
'aria-pressed',
'true',
);
await page.getByRole('button', { name: 'Materials', exact: true }).click();
await expect(page.getByLabel('Board length', { exact: true })).toBeHidden();
await page.getByRole('button', { name: 'Materials', exact: true }).click();
await expect(page.getByRole('button', { name: 'Materials', exact: true })).toBeFocused();
await expect(page.getByLabel('Board length', { exact: true })).toBeVisible();
await expect(page.getByLabel('Saw kerf', { exact: true })).toBeHidden();
await page.getByText('Advanced flooring settings', { exact: true }).click();
await page.getByLabel('Saw kerf', { exact: true }).fill('4');
expect(decodeState(new URL(page.url()).search).state.project.flooring.kerf).toBe(4);
await page.getByRole('button', { name: 'Cut plan', exact: true }).click();
await page.getByRole('button', { name: 'Cut plan', exact: true }).click();
await expect(page.getByRole('button', { name: 'Cut plan', exact: true })).toBeFocused();
await expect(page.getByLabel('Find a cut or room', { exact: true })).toBeVisible();
});
test('the top switch shows one material and preserves inputs and progress across reloads', async ({
page,
}) => {
const preview = page.getByRole('region', { name: 'Floor plan preview' });
const toggle = page.getByRole('group', { name: 'Plan view', exact: true });
await expect(toggle.getByRole('button', { name: 'Floorboards', exact: true })).toHaveAttribute(
'aria-pressed',
'true',
);
expect(await preview.locator('.floor-piece').count()).toBeGreaterThan(0);
await expect(preview.locator('.skirt-piece')).toHaveCount(0);
await page.locator('.stock-cut-group input[type="checkbox"]').first().check();
const project = decodeState(new URL(page.url()).search).state.project;
await toggle.getByRole('button', { name: 'Skirting', exact: true }).click();
await expect(preview.locator('.floor-piece')).toHaveCount(0);
expect(await preview.locator('.skirt-piece').count()).toBeGreaterThan(0);
await expect(preview.getByText('Flooring cuts', { exact: true })).toHaveCount(0);
expect(decodeState(new URL(page.url()).search).state.project).toEqual(project);
await page.reload();
await expect(toggle.getByRole('button', { name: 'Skirting', exact: true })).toHaveAttribute(
'aria-pressed',
'true',
);
await expect(preview.locator('.floor-piece')).toHaveCount(0);
await page.goto('/?planner');
await expect(toggle.getByRole('button', { name: 'Skirting', exact: true })).toHaveAttribute(
'aria-pressed',
'true',
);
expect(decodeState(new URL(page.url()).search).state.project).toEqual(project);
await toggle.getByRole('button', { name: 'Floorboards', exact: true }).click();
expect(await preview.locator('.floor-piece').count()).toBeGreaterThan(0);
await expect(preview.locator('.skirt-piece')).toHaveCount(0);
});
test('saved brick plans keep their pattern and explicit links restore the selected material', async ({
page,
}) => {
const state = defaultState();
state.project.flooring.pattern = 'brick';
state.view.material = 'skirting';
await page.goto(`/${encodeState(state)}`);
await expect(page.getByRole('button', { name: 'Brick', exact: true })).toHaveAttribute(
'aria-pressed',
'true',
);
await expect(
page
.getByRole('group', { name: 'Plan view' })
.getByRole('button', { name: 'Skirting', exact: true }),
).toHaveAttribute('aria-pressed', 'true');
await page.goto('/?planner');
await expect(page.getByRole('button', { name: 'Brick', exact: true })).toHaveAttribute(
'aria-pressed',
'true',
);
});
test('locating cuts changes material automatically and printing includes both materials', async ({
page,
}) => {
const preview = page.getByRole('region', { name: 'Floor plan preview' });
const toggle = page.getByRole('group', { name: 'Plan view', exact: true });
await page.locator('.skirting-cuts .board-group-actions .board-locate').first().click();
await expect(toggle.getByRole('button', { name: 'Skirting', exact: true })).toHaveAttribute(
'aria-pressed',
'true',
);
expect(await preview.locator('.skirt-piece[data-highlighted="true"]').count()).toBeGreaterThan(0);
await page.getByRole('button', { name: 'Show all pieces', exact: true }).click();
await page.getByLabel('Find a cut or room', { exact: true }).fill('F1');
await expect(toggle.getByRole('button', { name: 'Floorboards', exact: true })).toHaveAttribute(
'aria-pressed',
'true',
);
await expect(preview.locator('.floor-piece[data-piece-id="F1"]')).toHaveAttribute(
'data-highlighted',
'true',
);
await toggle.getByRole('button', { name: 'Skirting', exact: true }).click();
await expect(page.getByRole('button', { name: 'Show all pieces', exact: true })).toHaveCount(0);
await preview
.getByRole('button', { name: /^Select skirting cut / })
.first()
.click();
await expect(page.getByRole('dialog')).toBeVisible();
await page.keyboard.press('Escape');
await page.emulateMedia({ media: 'print' });
expect(await page.locator('.print-plan .floor-piece').count()).toBeGreaterThan(0);
expect(await page.locator('.print-plan .skirt-piece').count()).toBeGreaterThan(0);
});
test('setup and the pinned view switch fit a narrow phone', async ({ page }) => {
await page.setViewportSize({ width: 320, height: 844 });
await page.getByRole('button', { name: 'Materials', exact: true }).scrollIntoViewIfNeeded();
const heading = await page.getByRole('button', { name: 'Materials', exact: true }).boundingBox();
const drawing = await page.getByRole('complementary', { name: 'Room drawing' }).boundingBox();
expect(heading!.y).toBeGreaterThanOrEqual(drawing!.y + drawing!.height);
await page
.getByRole('group', { name: 'Plan view' })
.getByRole('button', { name: 'Skirting', exact: true })
.click();
await page.getByText('Advanced flooring settings', { exact: true }).click();
await page.getByText('Advanced skirting settings', { exact: true }).click();
expect(await page.evaluate(() => document.documentElement.scrollWidth)).toBeLessThanOrEqual(320);
const toggle = await page.getByRole('group', { name: 'Plan view' }).boundingBox();
expect(toggle!.y).toBeGreaterThanOrEqual(0);
expect(toggle!.y + toggle!.height).toBeLessThan(844);
});

10
package-lock.json generated
View file

@ -11,7 +11,6 @@
"@plausible-analytics/tracker": "^0.4.6", "@plausible-analytics/tracker": "^0.4.6",
"clipper-lib": "^6.4.2", "clipper-lib": "^6.4.2",
"lucide-react": "^0.468.0", "lucide-react": "^0.468.0",
"lz-string": "^1.5.0",
"react": "^19.1.1", "react": "^19.1.1",
"react-dom": "^19.1.1" "react-dom": "^19.1.1"
}, },
@ -1757,15 +1756,6 @@
"react": "^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0-rc" "react": "^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0-rc"
} }
}, },
"node_modules/lz-string": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/lz-string/-/lz-string-1.5.0.tgz",
"integrity": "sha512-h5bgJWpxJNswbU7qCrV0tIKQCaS3blPDrqKWx+QxzuzL1zGUzij9XCWLrSLsJPu5t+eWA/ycetzYAO5IOMcWAQ==",
"license": "MIT",
"bin": {
"lz-string": "bin/bin.js"
}
},
"node_modules/magic-string": { "node_modules/magic-string": {
"version": "0.30.21", "version": "0.30.21",
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz", "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz",

View file

@ -19,7 +19,6 @@
"@plausible-analytics/tracker": "^0.4.6", "@plausible-analytics/tracker": "^0.4.6",
"clipper-lib": "^6.4.2", "clipper-lib": "^6.4.2",
"lucide-react": "^0.468.0", "lucide-react": "^0.468.0",
"lz-string": "^1.5.0",
"react": "^19.1.1", "react": "^19.1.1",
"react-dom": "^19.1.1" "react-dom": "^19.1.1"
}, },

View file

@ -1,7 +1,11 @@
import { readFile, writeFile } from 'node:fs/promises'; import { readFile, writeFile } from 'node:fs/promises';
import { createServer } from 'vite'; import { createServer } from 'vite';
const server = await createServer({ server: { middlewareMode: true }, appType: 'custom' }); const server = await createServer({
server: { middlewareMode: true },
appType: 'custom',
optimizeDeps: { noDiscovery: true, include: [] },
});
try { try {
const [{ planFlooring }, { planSkirting }, { plannerCases }, metrics] = await Promise.all([ const [{ planFlooring }, { planSkirting }, { plannerCases }, metrics] = await Promise.all([
server.ssrLoadModule('/src/lib/flooring.ts'), server.ssrLoadModule('/src/lib/flooring.ts'),
@ -65,6 +69,22 @@ try {
if (regressions.length) console.log(`${kind} regressions: ${regressions.join(', ')}`); if (regressions.length) console.log(`${kind} regressions: ${regressions.join(', ')}`);
} }
console.table(summary); console.table(summary);
for (const kind of ['flooring', 'skirting']) {
const wastePercent = (rows) => {
const purchased = rows.reduce((total, row) => {
const { project } = cases.find((c) => c.name === row.name);
const size =
kind === 'flooring'
? project.flooring.length * project.flooring.width
: project.skirting.stockLength;
return total + row[kind].boards * size;
}, 0);
return ((sum(rows, kind, 'waste') / purchased) * 100).toFixed(2);
};
console.log(
`${kind} waste: ${wastePercent(baseline)}% → ${wastePercent(results)}% (weighted by purchased stock)`,
);
}
console.table( console.table(
['shapingCuts', 'ripCuts', 'patternPenalty', 'repeats', 'similarSteps', 'staircases'].map( ['shapingCuts', 'ripCuts', 'patternPenalty', 'repeats', 'similarSteps', 'staircases'].map(
(metric) => ({ (metric) => ({

View file

@ -9,8 +9,9 @@ import { planFlooringOptions } from './lib/flooring';
import { planSkirting } from './lib/skirting'; import { planSkirting } from './lib/skirting';
import { area, mm } from './lib/format'; import { area, mm } from './lib/format';
import { flooringCuts, isSkirtingCut, skirtingCuts } from './lib/cut-list'; import { flooringCuts, isSkirtingCut, skirtingCuts } from './lib/cut-list';
import type { PlannerSection, Project, Room } from './lib/types'; import type { PlanMaterial, PlannerSection, Project, Room } from './lib/types';
import { boardSearchLabel, findBoardMatches } from './lib/board-tracking'; import { boardSearchLabel, findBoardMatches } from './lib/board-tracking';
import { PRECISION, PROJECT_LIMITS } from './lib/limits';
import { OutlineEditor } from './components/OutlineEditor'; import { OutlineEditor } from './components/OutlineEditor';
import { MaterialsEditor } from './components/MaterialsEditor'; import { MaterialsEditor } from './components/MaterialsEditor';
import { FloorPlan } from './components/FloorPlan'; import { FloorPlan } from './components/FloorPlan';
@ -22,12 +23,16 @@ import { Issues } from './components/Fields';
function PlannerPanel({ function PlannerPanel({
section, section,
title, title,
step,
description,
open, open,
toggle, toggle,
children, children,
}: { }: {
section: PlannerSection; section: PlannerSection;
title: string; title: string;
step: number;
description: string;
open: boolean; open: boolean;
toggle: () => void; toggle: () => void;
children: ReactNode; children: ReactNode;
@ -37,15 +42,22 @@ function PlannerPanel({
<h2 className="panel-toggle-heading"> <h2 className="panel-toggle-heading">
<button <button
className="panel-toggle" className="panel-toggle"
id={`${section}-toggle`}
aria-expanded={open} aria-expanded={open}
aria-controls={`${section}-content`} aria-controls={`${section}-content`}
onClick={toggle} onClick={toggle}
> >
<span>{title}</span> <span className="panel-title">
<span className="step-number" aria-hidden="true">
{step}
</span>
{title}
</span>
<span aria-hidden="true">{open ? '−' : '+'}</span> <span aria-hidden="true">{open ? '−' : '+'}</span>
</button> </button>
</h2> </h2>
<div id={`${section}-content`} hidden={!open} className="panel-content"> <div id={`${section}-content`} hidden={!open} className="panel-content">
<p className="helper panel-description">{description}</p>
{children} {children}
</div> </div>
</section> </section>
@ -77,7 +89,7 @@ export default function App() {
() => planFlooringOptions(project.rooms, project.flooring, project.tolerance), () => planFlooringOptions(project.rooms, project.flooring, project.tolerance),
[project.rooms, flooringInputs, project.tolerance], [project.rooms, flooringInputs, project.tolerance],
); );
const flooring = flooringOptions[project.flooring.optimisation ?? 'cuts']; const flooring = flooringOptions[project.flooring.optimisation];
const skirting = useMemo( const skirting = useMemo(
() => planSkirting(project.rooms, project.skirting, project.tolerance), () => planSkirting(project.rooms, project.skirting, project.tolerance),
[project.rooms, project.skirting, project.tolerance], [project.rooms, project.skirting, project.tolerance],
@ -91,8 +103,8 @@ export default function App() {
const wholeBoards = flooring.pieces.filter( const wholeBoards = flooring.pieces.filter(
(p) => (p) =>
!p.cut && !p.cut &&
Math.abs(p.length - project.flooring.length) < 0.01 && Math.abs(p.length - project.flooring.length) < PRECISION.millimetres &&
Math.abs(p.width - project.flooring.width) < 0.01, Math.abs(p.width - project.flooring.width) < PRECISION.millimetres,
).length; ).length;
const wholeSkirting = skirting.pieces.filter((p) => !isSkirtingCut(p, skirting)).length; const wholeSkirting = skirting.pieces.filter((p) => !isSkirtingCut(p, skirting)).length;
@ -111,13 +123,30 @@ export default function App() {
[project, flooring, skirting, view.search], [project, flooring, skirting, view.search],
); );
const searchLabel = boardSearchLabel(project, flooring, skirting, view.search); const searchLabel = boardSearchLabel(project, flooring, skirting, view.search);
const visibleMatchCount = (view.material === 'flooring' ? flooring : skirting).pieces.filter(
(piece) => matches.pieceIds.includes(piece.id),
).length;
const materialForPieces = (ids: string[], current: PlanMaterial): PlanMaterial => {
const hasFloor = flooring.pieces.some((piece) => ids.includes(piece.id));
const hasSkirting = skirting.pieces.some((piece) => ids.includes(piece.id));
return hasFloor && !hasSkirting ? 'flooring' : hasSkirting && !hasFloor ? 'skirting' : current;
};
const setSearch = (search: string) => const setSearch = (search: string) =>
update((s) => { update((s) => {
const found = findBoardMatches(s.project, flooring, skirting, search); const found = findBoardMatches(s.project, flooring, skirting, search);
const roomId = found.roomIds.includes(s.view.roomId) const roomId = found.roomIds.includes(s.view.roomId)
? s.view.roomId ? s.view.roomId
: (found.roomIds[0] ?? s.view.roomId); : (found.roomIds[0] ?? s.view.roomId);
return { ...s, view: { ...s.view, search, roomId, selectedPiece: null } }; return {
...s,
view: {
...s.view,
search,
roomId,
selectedPiece: null,
material: materialForPieces(found.pieceIds, s.view.material),
},
};
}); });
const togglePanel = (section: PlannerSection) => const togglePanel = (section: PlannerSection) =>
update((s) => ({ update((s) => ({
@ -140,13 +169,27 @@ export default function App() {
}, },
})); }));
const locatePiece = (id: string, roomId: string) => const locatePiece = (id: string, roomId: string) =>
update((s) => ({ ...s, view: { ...s.view, search: id, roomId, selectedPiece: null } })); update((s) => ({
...s,
view: {
...s.view,
search: id,
roomId,
selectedPiece: null,
material: materialForPieces([id], s.view.material),
},
}));
const changeRoom = (fn: (r: Room) => Room) => const changeRoom = (fn: (r: Room) => Room) =>
changeProject((p) => ({ ...p, rooms: p.rooms.map((r) => (r.id === room.id ? fn(r) : r)) })); changeProject((p) => ({ ...p, rooms: p.rooms.map((r) => (r.id === room.id ? fn(r) : r)) }));
const select = (id: string | null, roomId?: string) => const select = (id: string | null, roomId?: string) =>
update((s) => ({ update((s) => ({
...s, ...s,
view: { ...s.view, roomId: roomId ?? s.view.roomId, selectedPiece: id }, view: {
...s.view,
roomId: roomId ?? s.view.roomId,
selectedPiece: id,
material: id ? materialForPieces([id], s.view.material) : s.view.material,
},
})); }));
const addRoom = () => { const addRoom = () => {
update((s) => { update((s) => {
@ -252,7 +295,11 @@ export default function App() {
</small> </small>
</button> </button>
))} ))}
<button className="add-room" onClick={addRoom} disabled={project.rooms.length >= 20}> <button
className="add-room"
onClick={addRoom}
disabled={project.rooms.length >= PROJECT_LIMITS.rooms}
>
<Plus size={17} /> <Plus size={17} />
Add room Add room
</button> </button>
@ -261,9 +308,18 @@ export default function App() {
</div> </div>
<div className="workspace"> <div className="workspace">
<div className="planning-panels"> <div className="planning-panels">
<div className="setup-intro">
<h2>Make this plan yours</h2>
<p>
Measure your room, choose your boards, then review the cuts. Your plan updates as
you go.
</p>
</div>
<PlannerPanel <PlannerPanel
section="measurements" section="measurements"
title="Room measurements" title="Room measurements"
step={1}
description="Choose a starting shape, then replace the example dimensions with your measurements. All sizes are in millimetres."
open={!view.collapsedSections.includes('measurements')} open={!view.collapsedSections.includes('measurements')}
toggle={() => togglePanel('measurements')} toggle={() => togglePanel('measurements')}
> >
@ -288,6 +344,8 @@ export default function App() {
<PlannerPanel <PlannerPanel
section="materials" section="materials"
title="Materials" title="Materials"
step={2}
description="Enter the sizes of the boards you will buy. Material settings apply to every room; board direction applies to the selected room."
open={!view.collapsedSections.includes('materials')} open={!view.collapsedSections.includes('materials')}
toggle={() => togglePanel('materials')} toggle={() => togglePanel('materials')}
> >
@ -344,6 +402,8 @@ export default function App() {
<PlannerPanel <PlannerPanel
section="cuts" section="cuts"
title="Cut plan" title="Cut plan"
step={3}
description="Review your boards and cuts. Click a numbered piece in the drawing or below for its cutting dimensions."
open={!view.collapsedSections.includes('cuts')} open={!view.collapsedSections.includes('cuts')}
toggle={() => togglePanel('cuts')} toggle={() => togglePanel('cuts')}
> >
@ -364,6 +424,34 @@ export default function App() {
</PlannerPanel> </PlannerPanel>
</div> </div>
<aside className="drawing-column" id="drawing" aria-label="Room drawing"> <aside className="drawing-column" id="drawing" aria-label="Room drawing">
<div className="plan-view-toolbar">
<span id="plan-view-label">Plan view</span>
<div
className="segmented plan-view-switch"
role="group"
aria-labelledby="plan-view-label"
>
{(['flooring', 'skirting'] as const).map((material) => (
<button
key={material}
className={view.material === material ? 'active' : ''}
aria-pressed={view.material === material}
onClick={() =>
update((s) => ({
...s,
view: { ...s.view, material, selectedPiece: null, search: '' },
}))
}
>
<i
className={`material-key ${material === 'flooring' ? 'floor-key' : 'skirt-key'}`}
aria-hidden="true"
/>
{material === 'flooring' ? 'Floorboards' : 'Skirting'}
</button>
))}
</div>
</div>
{view.search.trim() && ( {view.search.trim() && (
<div className="plan-search-status" role="status"> <div className="plan-search-status" role="status">
<div className="search-mode-heading"> <div className="search-mode-heading">
@ -374,9 +462,9 @@ export default function App() {
</strong> </strong>
<p title={searchLabel}> <p title={searchLabel}>
{searchLabel} ·{' '} {searchLabel} ·{' '}
{matches.pieceIds.length {visibleMatchCount
? `${matches.pieceIds.length} piece${matches.pieceIds.length === 1 ? '' : 's'}` ? `${visibleMatchCount} ${view.material === 'flooring' ? 'floorboard' : 'skirting'} piece${visibleMatchCount === 1 ? '' : 's'}`
: 'No matching pieces'} : 'No matching pieces in this view'}
</p> </p>
</div> </div>
<button className="button clear-plan-search" onClick={() => setSearch('')}> <button className="button clear-plan-search" onClick={() => setSearch('')}>
@ -416,6 +504,7 @@ export default function App() {
completedBoards={project.completedBoards} completedBoards={project.completedBoards}
highlightedPieces={matches.pieceIds} highlightedPieces={matches.pieceIds}
searchActive={!!view.search.trim()} searchActive={!!view.search.trim()}
material={view.material}
/> />
</aside> </aside>
</div> </div>

View file

@ -1,20 +1,18 @@
import { lazy, Suspense, useEffect, useSyncExternalStore } from 'react'; import { lazy, Suspense, useEffect, useSyncExternalStore } from 'react';
import { LandingPage } from './components/LandingPage'; import { LandingPage } from './components/LandingPage';
import { PlannerLoading } from './components/PlannerLoading';
const Planner = lazy(() => import('./App')); const Planner = lazy(() => import('./App'));
function subscribeToLocation(onChange: () => void) { function subscribeToLocation(onChange: () => void) {
window.addEventListener('popstate', onChange); window.addEventListener('popstate', onChange);
window.addEventListener('hashchange', onChange);
return () => { return () => {
window.removeEventListener('popstate', onChange); window.removeEventListener('popstate', onChange);
window.removeEventListener('hashchange', onChange);
}; };
} }
// Query links work on static hosts and keep all existing shared plans accessible. // Query links work on static hosts without server-side routing.
const isPlannerLocation = () => const isPlannerLocation = () => Boolean(window.location.search);
Boolean(window.location.search) || window.location.hash.startsWith('#plan=');
export default function Site() { export default function Site() {
const showPlanner = useSyncExternalStore(subscribeToLocation, isPlannerLocation); const showPlanner = useSyncExternalStore(subscribeToLocation, isPlannerLocation);
@ -24,13 +22,7 @@ export default function Site() {
}, [showPlanner]); }, [showPlanner]);
return showPlanner ? ( return showPlanner ? (
<Suspense <Suspense fallback={<PlannerLoading />}>
fallback={
<p className="planner-loading" role="status">
Opening your planner…
</p>
}
>
<Planner /> <Planner />
</Suspense> </Suspense>
) : ( ) : (

View file

@ -11,6 +11,7 @@ import {
uncutSkirting, uncutSkirting,
} from '../lib/cut-list'; } from '../lib/cut-list';
import { boardSearchLabel, findBoardMatches } from '../lib/board-tracking'; import { boardSearchLabel, findBoardMatches } from '../lib/board-tracking';
import { PERSISTENCE_LIMITS } from '../lib/limits';
import { FlooringPreview, SkirtingPreview } from './CutPreview'; import { FlooringPreview, SkirtingPreview } from './CutPreview';
function BoardHeader({ function BoardHeader({
@ -120,7 +121,7 @@ export function CutList({
id="board-search" id="board-search"
type="search" type="search"
value={boardSearchLabel(project, flooring, skirting, search)} value={boardSearchLabel(project, flooring, skirting, search)}
maxLength={200} maxLength={PERSISTENCE_LIMITS.searchLength}
onChange={(event) => setSearch(event.target.value)} onChange={(event) => setSearch(event.target.value)}
placeholder="F12, A2, or a room name" placeholder="F12, A2, or a room name"
autoComplete="off" autoComplete="off"

View file

@ -2,14 +2,7 @@ import { Fragment } from 'react';
import type { FlooringPiece, SkirtingPiece } from '../lib/types'; import type { FlooringPiece, SkirtingPiece } from '../lib/types';
import { cutMm, degree } from '../lib/format'; import { cutMm, degree } from '../lib/format';
import { skirtingEndLabel } from '../lib/cut-list'; import { skirtingEndLabel } from '../lib/cut-list';
import { import { dimensionedOutline, fullPreviewBox, skirtingEndBoxes, viewBox } from '../lib/cut-preview';
dimensionedOutline,
flooringTemplate,
fullPreviewBox,
skirtingEndBoxes,
skirtingTemplate,
viewBox,
} from '../lib/cut-preview';
import type { EdgeDimension } from '../lib/cut-preview'; import type { EdgeDimension } from '../lib/cut-preview';
function Dimensions({ dimensions, font }: { dimensions: EdgeDimension[]; font: number }) { function Dimensions({ dimensions, font }: { dimensions: EdgeDimension[]; font: number }) {
@ -112,7 +105,7 @@ export function FlooringPreview({
piece: FlooringPiece; piece: FlooringPiece;
compact?: boolean; compact?: boolean;
}) { }) {
const template = flooringTemplate(piece); const template = piece.template;
const dimensions = compact const dimensions = compact
? undefined ? undefined
: dimensionedOutline(template, piece.shaped ? undefined : [0, 1], { : dimensionedOutline(template, piece.shaped ? undefined : [0, 1], {
@ -159,11 +152,10 @@ export function SkirtingPreview({
thickness: number; thickness: number;
compact?: boolean; compact?: boolean;
}) { }) {
const template = skirtingTemplate(piece, thickness); const template = piece.template;
const Wrapper = compact ? 'span' : 'div'; const Wrapper = compact ? 'span' : 'div';
const EndWrapper = compact ? 'span' : 'figure'; const EndWrapper = compact ? 'span' : 'figure';
const Grid = compact ? 'span' : 'div'; const Grid = compact ? 'span' : 'div';
if (template.length !== 4) return <span className="helper">Shape template unavailable</span>;
const boxes = skirtingEndBoxes(template, thickness, piece.installedTemplate); const boxes = skirtingEndBoxes(template, thickness, piece.installedTemplate);
const dimensions = compact const dimensions = compact
? undefined ? undefined
@ -186,8 +178,8 @@ export function SkirtingPreview({
front: template[3], front: template[3],
box: boxes.left, box: boxes.left,
type: piece.leftType, type: piece.leftType,
installedBack: piece.installedTemplate?.[0], installedBack: piece.installedTemplate[0],
installedFront: piece.installedTemplate?.[3], installedFront: piece.installedTemplate[3],
}, },
{ {
side: 'right', side: 'right',
@ -195,8 +187,8 @@ export function SkirtingPreview({
front: template[2], front: template[2],
box: boxes.right, box: boxes.right,
type: piece.rightType, type: piece.rightType,
installedBack: piece.installedTemplate?.[1], installedBack: piece.installedTemplate[1],
installedFront: piece.installedTemplate?.[2], installedFront: piece.installedTemplate[2],
}, },
] as const; ] as const;
return ( return (

View file

@ -1,11 +1,20 @@
import { useId } from 'react'; import { useId } from 'react';
import type { FlooringPlan, Geometry, Point, Room, SkirtingPlan, WallEdge } from '../lib/types'; import type {
FlooringPlan,
Geometry,
PlanMaterial,
Point,
Room,
SkirtingPlan,
WallEdge,
} from '../lib/types';
import { area, cutMm, mm } from '../lib/format'; import { area, cutMm, mm } from '../lib/format';
import { signedArea } from '../lib/geometry'; import { signedArea } from '../lib/geometry';
import { isSkirtingCut } from '../lib/cut-list'; import { isSkirtingCut } from '../lib/cut-list';
import { skirtingPolygon } from '../lib/skirting-polygon'; import { skirtingPolygon } from '../lib/skirting-polygon';
import { dimensionLabels, wallDimensionBox } from '../lib/dimension-labels'; import { dimensionLabels, wallDimensionBox } from '../lib/dimension-labels';
import { floorPieceLabels } from '../lib/piece-labels'; import { floorPieceLabels } from '../lib/piece-labels';
import { PRECISION } from '../lib/limits';
import type { DimensionLabel, LabelBox } from '../lib/dimension-labels'; import type { DimensionLabel, LabelBox } from '../lib/dimension-labels';
const points = (path: Point[]) => path.map((p) => `${p.x},${p.y}`).join(' '); const points = (path: Point[]) => path.map((p) => `${p.x},${p.y}`).join(' ');
@ -61,7 +70,10 @@ function Wall({ edge, span, label }: { edge: WallEdge; span: number; label: Dime
</text> </text>
</g> </g>
{edge.doors {edge.doors
.filter((d) => d.offset >= 0 && d.width > 0 && d.offset + d.width <= edge.length + 0.001) .filter(
(d) =>
d.offset >= 0 && d.width > 0 && d.offset + d.width <= edge.length + PRECISION.clipping,
)
.map((door) => { .map((door) => {
const a = { const a = {
x: edge.start.x + (dx / length) * door.offset, x: edge.start.x + (dx / length) * door.offset,
@ -116,6 +128,7 @@ interface Props {
completedBoards?: string[]; completedBoards?: string[];
highlightedPieces?: string[]; highlightedPieces?: string[];
searchActive?: boolean; searchActive?: boolean;
material?: PlanMaterial;
} }
export function FloorPlan({ export function FloorPlan({
@ -129,6 +142,7 @@ export function FloorPlan({
completedBoards = [], completedBoards = [],
highlightedPieces = [], highlightedPieces = [],
searchActive = false, searchActive = false,
material,
}: Props) { }: Props) {
const hatch = useId().replaceAll(':', ''); const hatch = useId().replaceAll(':', '');
const allPoints = geometry.edges.flatMap((edge) => [edge.start, edge.end]); const allPoints = geometry.edges.flatMap((edge) => [edge.start, edge.end]);
@ -139,8 +153,11 @@ export function FloorPlan({
const span = Math.max(maxX - minX, maxY - minY, 1000), const span = Math.max(maxX - minX, maxY - minY, 1000),
font = span * 0.024; font = span * 0.024;
const orientation = Math.sign(signedArea(geometry.vertices)) || 1; const orientation = Math.sign(signedArea(geometry.vertices)) || 1;
const floorPieces = flooring.pieces.filter((p) => p.roomId === room.id); // Printing includes both materials; the interactive drawing shows the chosen view.
const skirtPieces = skirting.pieces.filter((p) => p.roomId === room.id); const floorPieces =
material === 'skirting' ? [] : flooring.pieces.filter((p) => p.roomId === room.id);
const skirtPieces =
material === 'flooring' ? [] : skirting.pieces.filter((p) => p.roomId === room.id);
const skirtLabels = new Map<string, Point & { width: number; text: string }>(); const skirtLabels = new Map<string, Point & { width: number; text: string }>();
const reserved: LabelBox[] = []; const reserved: LabelBox[] = [];
for (const piece of skirtPieces) { for (const piece of skirtPieces) {
@ -197,20 +214,25 @@ export function FloorPlan({
className="drawing-card" className="drawing-card"
aria-label="Floor plan preview" aria-label="Floor plan preview"
data-search-active={searchActive} data-search-active={searchActive}
data-view={material ?? 'both'}
> >
<div className="drawing-header"> <div className="drawing-header">
<h2> <h2>
{room.name} <small>{area(geometry.area)} m²</small> {room.name} <small>{area(geometry.area)} m²</small>
</h2> </h2>
<div className="drawing-legend"> <div className="drawing-legend">
{material !== 'skirting' && (
<span> <span>
<i className="floor-key" /> <i className="floor-key" />
Flooring cuts Flooring cuts
</span> </span>
)}
{material !== 'flooring' && (
<span> <span>
<i className="skirt-key" /> <i className="skirt-key" />
Skirting cuts Skirting cuts
</span> </span>
)}
<span> <span>
<i className="uncut-key" /> <i className="uncut-key" />
Uncut Uncut
@ -331,8 +353,7 @@ export function FloorPlan({
const done = completedBoards.includes(`skirting:${piece.stockId}`); const done = completedBoards.includes(`skirting:${piece.stockId}`);
const highlighted = highlightedPieces.includes(piece.id); const highlighted = highlightedPieces.includes(piece.id);
// Each template uses its true wall-facing and room-facing edges, including mitres. // Each template uses its true wall-facing and room-facing edges, including mitres.
const thickness = piece.template ? Math.max(...piece.template.map((p) => p.y)) : 0; const polygon = skirtingPolygon(piece, orientation);
const polygon = skirtingPolygon(piece, thickness, orientation);
return ( return (
<g <g
key={piece.id} key={piece.id}

View file

@ -24,12 +24,7 @@ function PlannerLink({ compact = false }: { compact?: boolean }) {
function PlanIllustration() { function PlanIllustration() {
return ( return (
<figure className="landing-plan"> <figure className="landing-plan">
<figcaption className="landing-plan-heading"> <figcaption className="landing-plan-heading">Example floor layout</figcaption>
<span>
<span className="landing-status-dot" /> A little planning goes a long way.
</span>
<span className="landing-plan-index">FIG. 01</span>
</figcaption>
<div className="landing-plan-paper"> <div className="landing-plan-paper">
<div className="landing-plan-room"> <div className="landing-plan-room">
<span>Living room</span> <span>Living room</span>
@ -55,7 +50,7 @@ function PlanIllustration() {
<path d="M80 48V23M460 48V23M80 32H460M75 37L85 27M455 37L465 27" /> <path d="M80 48V23M460 48V23M80 32H460M75 37L85 27M455 37L465 27" />
<path d="M62 57H37M62 343H37M46 57V343M41 62L51 52M41 348L51 338" /> <path d="M62 57H37M62 343H37M46 57V343M41 62L51 52M41 348L51 338" />
</g> </g>
<g fill="#55685d" fontSize="12" fontFamily="monospace" textAnchor="middle"> <g fill="#55685d" textAnchor="middle">
<rect x="224" y="21" width="92" height="22" fill="#f6f7f2" /> <rect x="224" y="21" width="92" height="22" fill="#f6f7f2" />
<text x="270" y="36"> <text x="270" y="36">
4,800 mm 4,800 mm
@ -104,7 +99,7 @@ function PlanIllustration() {
<rect x="91" y="112" width="72" height="22" fill="#c66935" stroke="#a74617" /> <rect x="91" y="112" width="72" height="22" fill="#c66935" stroke="#a74617" />
<rect x="403" y="178" width="46" height="22" fill="#c66935" stroke="#a74617" /> <rect x="403" y="178" width="46" height="22" fill="#c66935" stroke="#a74617" />
</g> </g>
<g fontSize="11" fontFamily="monospace" fill="#fff" textAnchor="middle"> <g fill="#fff" textAnchor="middle">
<text x="127" y="127"> <text x="127" y="127">
F1 F1
</text> </text>
@ -113,11 +108,11 @@ function PlanIllustration() {
</text> </text>
</g> </g>
<rect x="226" y="177" width="114" height="48" rx="2" fill="#fffdf7" stroke="#b49a72" /> <rect x="226" y="177" width="114" height="48" rx="2" fill="#fffdf7" stroke="#b49a72" />
<text x="283" y="198" fontSize="13" fontWeight="600" fill="#17263f" textAnchor="middle"> <text x="283" y="198" fill="#17263f" textAnchor="middle">
Living room Living room
</text> </text>
<text x="283" y="214" fontSize="10" letterSpacing="1" fill="#58655e" textAnchor="middle"> <text x="283" y="214" fill="#58655e" textAnchor="middle">
EXAMPLE LAYOUT Example layout
</text> </text>
<path d="M79 257V317" stroke="#f6f7f2" strokeWidth="15" /> <path d="M79 257V317" stroke="#f6f7f2" strokeWidth="15" />
<path <path
@ -127,8 +122,8 @@ function PlanIllustration() {
strokeWidth="1.2" strokeWidth="1.2"
/> />
<path d="M471 321H496M490 315L496 321L490 327" fill="none" stroke="#748279" /> <path d="M471 321H496M490 315L496 321L490 327" fill="none" stroke="#748279" />
<text x="470" y="307" fontSize="10" fontFamily="monospace" fill="#55685d"> <text x="470" y="307" fill="#55685d">
LAY Lay
</text> </text>
</svg> </svg>
</div> </div>
@ -179,11 +174,11 @@ function TrimIllustration({ scotia }: { scotia: boolean }) {
strokeWidth="1.5" strokeWidth="1.5"
/> />
<path d="M142 143L173 113H225" fill="none" stroke="#a4471c" /> <path d="M142 143L173 113H225" fill="none" stroke="#a4471c" />
<text x="233" y="117" fill="#a4471c" fontSize="13" fontWeight="600"> <text x="233" y="117" fill="#a4471c">
Scotia bead Scotia bead
</text> </text>
<path d="M102 85H225" stroke="#7f8e84" /> <path d="M102 85H225" stroke="#7f8e84" />
<text x="233" y="89" fill="#526156" fontSize="12"> <text x="233" y="89" fill="#526156">
Existing skirting Existing skirting
</text> </text>
</> </>
@ -196,11 +191,11 @@ function TrimIllustration({ scotia }: { scotia: boolean }) {
strokeWidth="1.5" strokeWidth="1.5"
/> />
<path d="M113 85H225" stroke="#a4471c" /> <path d="M113 85H225" stroke="#a4471c" />
<text x="233" y="89" fill="#a4471c" fontSize="13" fontWeight="600"> <text x="233" y="89" fill="#a4471c">
New skirting New skirting
</text> </text>
<path d="M108 154L175 127H225" fill="none" stroke="#7f8e84" /> <path d="M108 154L175 127H225" fill="none" stroke="#7f8e84" />
<text x="233" y="131" fill="#526156" fontSize="12"> <text x="233" y="131" fill="#526156">
Floor tucks under Floor tucks under
</text> </text>
</> </>
@ -211,14 +206,14 @@ function TrimIllustration({ scotia }: { scotia: boolean }) {
stroke="#526156" stroke="#526156"
strokeDasharray="3 3" strokeDasharray="3 3"
/> />
<text x="197" y="210" fill="#526156" fontSize="11"> <text x="197" y="210" fill="#526156">
Expansion gap Expansion gap
</text> </text>
<text x="48" y="15" fill="#526156" fontSize="10" letterSpacing="1"> <text x="48" y="15" fill="#526156">
WALL Wall
</text> </text>
<text x="278" y="151" fill="#526156" fontSize="10" letterSpacing="1"> <text x="278" y="151" fill="#526156">
FLOORING Flooring
</text> </text>
</svg> </svg>
); );
@ -267,38 +262,24 @@ export function LandingPage() {
<a className="landing-skip" href="#main"> <a className="landing-skip" href="#main">
Skip to content Skip to content
</a> </a>
<header className="landing-header landing-container"> <header className="landing-header">
<div className="landing-header-content landing-container">
<a <a
className="landing-brand" className="landing-brand"
href={window.location.pathname} href={window.location.pathname}
aria-label="Floor planner home" aria-label="Floor planner home"
> >
<span className="square-mark" aria-hidden="true" /> <span className="square-mark" aria-hidden="true" />
<span> <span>Floor planner</span>
Floor planner<span className="landing-brand-dot">.</span>
</span>
</a> </a>
<nav className="landing-nav" aria-label="Main navigation">
<a href="#why">Why plan?</a>
<a href="#guide">DIY guide</a>
<a href="#finishing">The finishing touches</a>
</nav>
<PlannerLink compact /> <PlannerLink compact />
</div>
</header> </header>
<main id="main"> <main id="main">
<section className="landing-hero landing-container" aria-labelledby="landing-title"> <section className="landing-hero landing-container" aria-labelledby="landing-title">
<div className="landing-hero-copy"> <div className="landing-hero-copy">
<p className="landing-eyebrow"> <h1 id="landing-title">A great floor starts with a little planning.</h1>
<span /> MEASURE. PLAN. LAY.
</p>
<h1 id="landing-title">
A great floor
<br />
starts with
<br />
<em>a little planning.</em>
</h1>
<p className="landing-intro"> <p className="landing-intro">
From room measurements to the last cut. Plan your floorboards and skirting, make the From room measurements to the last cut. Plan your floorboards and skirting, make the
most of your materials, and start your DIY project with confidence. most of your materials, and start your DIY project with confidence.
@ -309,10 +290,6 @@ export function LandingPage() {
First time fitting a floor? <ArrowDown size={16} aria-hidden="true" /> First time fitting a floor? <ArrowDown size={16} aria-hidden="true" />
</a> </a>
</div> </div>
<p className="landing-reassurance">
<Check size={14} aria-hidden="true" /> Free to use <span>·</span> No sign-up{' '}
<span>·</span> Right in your browser
</p>
</div> </div>
<PlanIllustration /> <PlanIllustration />
</section> </section>
@ -322,16 +299,12 @@ export function LandingPage() {
id="why" id="why"
aria-labelledby="benefits-title" aria-labelledby="benefits-title"
> >
<div className="landing-section-kicker"> <h2 id="benefits-title">Why plan your floor?</h2>
<span className="landing-eyebrow">LESS GUESSWORK. MORE GETTING IT DONE.</span>
<h2 id="benefits-title">Your tape measure’s new best friend.</h2>
</div>
<div className="landing-benefit-grid"> <div className="landing-benefit-grid">
{benefits.map(({ icon: Icon, title, text }, index) => ( {benefits.map(({ icon: Icon, title, text }) => (
<article className="landing-benefit" key={title}> <article className="landing-benefit" key={title}>
<div className="landing-benefit-top"> <div className="landing-benefit-top">
<Icon size={24} strokeWidth={1.5} aria-hidden="true" /> <Icon size={24} strokeWidth={1.5} aria-hidden="true" />
<span>0{index + 1}</span>
</div> </div>
<h3>{title}</h3> <h3>{title}</h3>
<p>{text}</p> <p>{text}</p>
@ -343,12 +316,7 @@ export function LandingPage() {
<section className="landing-guide" id="guide" aria-labelledby="guide-title"> <section className="landing-guide" id="guide" aria-labelledby="guide-title">
<div className="landing-container landing-guide-layout"> <div className="landing-container landing-guide-layout">
<div className="landing-guide-intro"> <div className="landing-guide-intro">
<p className="landing-eyebrow">THE DIY STARTING POINT</p> <h2 id="guide-title">Your first floor? You’ve got this.</h2>
<h2 id="guide-title">
Your first floor?
<br />
You’ve got this.
</h2>
<p> <p>
A little patience, a good plan, and one row at a time. Here’s the journey for a A little patience, a good plan, and one row at a time. Here’s the journey for a
floating click-fit laminate floor. floating click-fit laminate floor.
@ -374,7 +342,7 @@ export function LandingPage() {
<ol className="landing-steps"> <ol className="landing-steps">
{steps.map(({ title, text }, index) => ( {steps.map(({ title, text }, index) => (
<li key={title}> <li key={title}>
<span className="landing-step-number">0{index + 1}</span> <span className="landing-step-number">{index + 1}.</span>
<div> <div>
<h3>{title}</h3> <h3>{title}</h3>
<p>{text}</p> <p>{text}</p>
@ -397,10 +365,7 @@ export function LandingPage() {
aria-labelledby="finishing-title" aria-labelledby="finishing-title"
> >
<div className="landing-finishing-heading"> <div className="landing-finishing-heading">
<div>
<p className="landing-eyebrow">SMALL DETAILS. A PROPER FINISH.</p>
<h2 id="finishing-title">Scotia or skirting board?</h2> <h2 id="finishing-title">Scotia or skirting board?</h2>
</div>
<p> <p>
Both can hide the expansion gap around a floating floor. The difference is what you’re Both can hide the expansion gap around a floating floor. The difference is what you’re
keeping, and the finish you want. keeping, and the finish you want.
@ -408,15 +373,10 @@ export function LandingPage() {
</div> </div>
<div className="landing-trim-grid"> <div className="landing-trim-grid">
<article className="landing-trim-card"> <article className="landing-trim-card">
<div className="landing-trim-label"> <p className="landing-trim-label">Keep your existing skirting</p>
<span>KEEP YOUR EXISTING SKIRTING</span>
<span>01</span>
</div>
<TrimIllustration scotia /> <TrimIllustration scotia />
<div className="landing-trim-copy"> <div className="landing-trim-copy">
<h3> <h3>Scotia</h3>
Scotia <span>the small finishing bead</span>
</h3>
<p> <p>
A narrow, curved moulding fitted at the foot of your existing skirting. It covers A narrow, curved moulding fitted at the foot of your existing skirting. It covers
the flooring’s expansion gap without removing the boards already on your wall. the flooring’s expansion gap without removing the boards already on your wall.
@ -428,18 +388,14 @@ export function LandingPage() {
</div> </div>
</article> </article>
<article className="landing-trim-card"> <article className="landing-trim-card">
<div className="landing-trim-label"> <p className="landing-trim-label">Replace or refit your skirting</p>
<span>REPLACE OR REFIT YOUR SKIRTING</span>
<span>02</span>
</div>
<TrimIllustration scotia={false} /> <TrimIllustration scotia={false} />
<div className="landing-trim-copy"> <div className="landing-trim-copy">
<h3> <h3>Skirting board</h3>
Skirting board <span>also called a baseboard</span>
</h3>
<p> <p>
The taller board along the base of the wall. When fitted after the flooring, it Also called a baseboard, this is the taller board along the base of the wall. When
can cover the expansion gap itself, giving you a clean edge without an extra bead. fitted after the flooring, it can cover the expansion gap itself, giving you a
clean edge without an extra bead.
</p> </p>
<p className="landing-trim-choice"> <p className="landing-trim-choice">
<Check size={16} aria-hidden="true" /> A neat finish when you’re renovating the <Check size={16} aria-hidden="true" /> A neat finish when you’re renovating the
@ -460,30 +416,10 @@ export function LandingPage() {
</a> </a>
</div> </div>
</section> </section>
<section className="landing-final-cta landing-container" aria-labelledby="ready-title">
<div>
<p className="landing-eyebrow">YOUR NEXT PROJECT STARTS HERE</p>
<h2 id="ready-title">
Measure twice.
<br />
<em>Start with a plan.</em>
</h2>
<p>Bring your room measurements. We’ll help with the layout.</p>
</div>
<div className="landing-final-actions">
<PlannerLink />
<span>Open the planner. Make it your room.</span>
</div>
</section>
</main> </main>
<footer className="landing-footer landing-container"> <footer className="landing-footer landing-container">
<a className="landing-brand" href={window.location.pathname}> <span>Floor planner</span>
<span className="square-mark" aria-hidden="true" />
<span>Floor planner.</span>
</a>
<p>A little preparation for a floor you’ll be proud of.</p>
<a href="#main">Back to top ↑</a> <a href="#main">Back to top ↑</a>
</footer> </footer>
</div> </div>

View file

@ -39,6 +39,9 @@ export function MaterialsEditor({
<h3 id="flooring-materials" className="material-heading"> <h3 id="flooring-materials" className="material-heading">
Floorboards Floorboards
</h3> </h3>
<p className="helper material-help">
Use the length and width printed on your flooring pack.
</p>
<div className="field-grid"> <div className="field-grid">
<NumberField <NumberField
label="Board length" label="Board length"
@ -56,13 +59,6 @@ export function MaterialsEditor({
<div className="field"> <div className="field">
<span>Laying pattern</span> <span>Laying pattern</span>
<div className="segmented" role="group" aria-label="Laying pattern"> <div className="segmented" role="group" aria-label="Laying pattern">
<button
className={f.pattern === 'brick' ? 'active' : ''}
aria-pressed={f.pattern === 'brick'}
onClick={() => floor('pattern', 'brick')}
>
Brick
</button>
<button <button
className={f.pattern === 'random' ? 'active' : ''} className={f.pattern === 'random' ? 'active' : ''}
aria-pressed={f.pattern === 'random'} aria-pressed={f.pattern === 'random'}
@ -70,16 +66,28 @@ export function MaterialsEditor({
> >
Random Random
</button> </button>
<button
className={f.pattern === 'brick' ? 'active' : ''}
aria-pressed={f.pattern === 'brick'}
onClick={() => floor('pattern', 'brick')}
>
Brick
</button>
</div> </div>
<p className="helper">
{f.pattern === 'random'
? 'Varied joints for a natural look. Choose fewer cuts or a more varied arrangement below.'
: 'A regular pattern with each row staggered by half a board.'}
</p>
</div> </div>
{f.pattern === 'random' && ( {f.pattern === 'random' && (
<div className="field"> <div className="field">
<span>Optimise random flooring · all rooms</span> <span>What matters most? · all rooms</span>
<div className="optimisation-options" role="group" aria-label="Flooring optimisation"> <div className="optimisation-options" role="group" aria-label="Flooring optimisation">
{(['cuts', 'random'] as const).map((priority) => { {(['cuts', 'random'] as const).map((priority) => {
const plan = flooringOptions[priority]; const plan = flooringOptions[priority];
const valid = !plan.issues.some((issue) => issue.severity === 'error'); const valid = !plan.issues.some((issue) => issue.severity === 'error');
const selected = (f.optimisation ?? 'cuts') === priority; const selected = f.optimisation === priority;
return ( return (
<button <button
key={priority} key={priority}
@ -119,8 +127,18 @@ export function MaterialsEditor({
</button> </button>
</div> </div>
</div> </div>
<NumberField
label="Wall spacer"
value={f.gap}
onChange={(n) => floor('gap', n)}
hint="Expansion gap between the floorboards and walls. Check your flooring instructions."
/>
<details className="advanced-settings">
<summary>Advanced flooring settings</summary>
<p className="helper material-help">
Adjust the saw blade width, joint spacing and smallest pieces to suit your flooring.
</p>
<div className="field-grid"> <div className="field-grid">
<NumberField label="Wall spacer" value={f.gap} onChange={(n) => floor('gap', n)} />
<NumberField <NumberField
label="Saw kerf" label="Saw kerf"
value={f.kerf} value={f.kerf}
@ -150,11 +168,15 @@ export function MaterialsEditor({
onChange={(n) => floor('minWidth', n)} onChange={(n) => floor('minWidth', n)}
/> />
</div> </div>
</details>
</section> </section>
<section className="material-section skirting" aria-labelledby="skirting-materials"> <section className="material-section skirting" aria-labelledby="skirting-materials">
<h3 id="skirting-materials" className="material-heading"> <h3 id="skirting-materials" className="material-heading">
Skirting boards Skirting boards
</h3> </h3>
<p className="helper material-help">
Enter one purchased board length. Door openings are left clear automatically.
</p>
<div className="field-grid"> <div className="field-grid">
<NumberField <NumberField
label="Skirting board length" label="Skirting board length"
@ -167,6 +189,10 @@ export function MaterialsEditor({
value={s.thickness} value={s.thickness}
onChange={(n) => skirt('thickness', n)} onChange={(n) => skirt('thickness', n)}
/> />
</div>
<details className="advanced-settings">
<summary>Advanced skirting settings</summary>
<div className="field-grid">
<NumberField <NumberField
label="Minimum piece" label="Minimum piece"
value={s.minLength} value={s.minLength}
@ -180,6 +206,7 @@ export function MaterialsEditor({
tooltip={kerfHelp} tooltip={kerfHelp}
/> />
</div> </div>
</details>
</section> </section>
</> </>
); );

View file

@ -16,6 +16,7 @@ import { mm } from '../lib/format';
import { NumberField, NumericInput, Issues } from './Fields'; import { NumberField, NumericInput, Issues } from './Fields';
import { DoorPosition } from './DoorPosition'; import { DoorPosition } from './DoorPosition';
import { insertWallAfter, moveWall } from '../lib/wall-editing'; import { insertWallAfter, moveWall } from '../lib/wall-editing';
import { PRECISION, PROJECT_LIMITS } from '../lib/limits';
interface Props { interface Props {
room: Room; room: Room;
geometry: Geometry; geometry: Geometry;
@ -36,6 +37,7 @@ export function OutlineEditor({
}: Props) { }: Props) {
const draggedWall = useRef<string | null>(null); const draggedWall = useRef<string | null>(null);
const [dropTarget, setDropTarget] = useState<string | null>(null); const [dropTarget, setDropTarget] = useState<string | null>(null);
const [customSelected, setCustomSelected] = useState(false);
const changeWall = (id: string, fn: (wall: Wall) => Wall) => const changeWall = (id: string, fn: (wall: Wall) => Wall) =>
changeRoom((r) => ({ ...r, walls: r.walls.map((w) => (w.id === id ? fn(w) : w)) })); changeRoom((r) => ({ ...r, walls: r.walls.map((w) => (w.id === id ? fn(w) : w)) }));
const isRectangle = const isRectangle =
@ -43,6 +45,10 @@ export function OutlineEditor({
room.walls.every((w) => w.turn === 90) && room.walls.every((w) => w.turn === 90) &&
room.walls[0].length === room.walls[2].length && room.walls[0].length === room.walls[2].length &&
room.walls[1].length === room.walls[3].length; room.walls[1].length === room.walls[3].length;
const isFireplace =
room.walls.length === 8 &&
room.walls.every((wall, index) => wall.turn === [90, 90, 90, -90, -90, 90, 90, 90][index]);
const isCustom = customSelected || (!isRectangle && !isFireplace);
const lastEdge = geometry.edges.at(-1); const lastEdge = geometry.edges.at(-1);
const finalExpectedLength = lastEdge ? Math.hypot(lastEdge.start.x, lastEdge.start.y) : 0; const finalExpectedLength = lastEdge ? Math.hypot(lastEdge.start.x, lastEdge.start.y) : 0;
const addWall = () => const addWall = () =>
@ -106,41 +112,72 @@ export function OutlineEditor({
<span>Room name</span> <span>Room name</span>
<input <input
value={room.name} value={room.name}
maxLength={80} maxLength={PROJECT_LIMITS.nameLength}
onChange={(e) => changeRoom((r) => ({ ...r, name: e.target.value }))} onChange={(e) => changeRoom((r) => ({ ...r, name: e.target.value }))}
/> />
</label> </label>
<div className="template-options"> <div className="subheading shape-heading">
<h3>Room shape</h3>
</div>
<div
className="template-options"
role="group"
aria-label="Room shape"
aria-describedby="custom-shape-help"
>
<button <button
className={isRectangle ? 'template active' : 'template'} className={isRectangle && !isCustom ? 'template active' : 'template'}
aria-pressed={isRectangle} aria-pressed={isRectangle && !isCustom}
onClick={() => changeRoom((r) => rectangle(r.id, r.name))} onClick={() => {
setCustomSelected(false);
changeRoom((r) => rectangle(r.id, r.name));
}}
> >
<span className="rectangle-icon" /> <span className="rectangle-icon" />
Rectangle Rectangle
</button> </button>
<button <button
className={room.walls.length === 8 ? 'template active' : 'template'} className={isFireplace && !isCustom ? 'template active' : 'template'}
aria-pressed={room.walls.length === 8} aria-pressed={isFireplace && !isCustom}
onClick={() => changeRoom((r) => fireplace(r.id, r.name))} onClick={() => {
setCustomSelected(false);
changeRoom((r) => fireplace(r.id, r.name));
}}
> >
<span className="fireplace-icon" /> <span className="fireplace-icon" />
With fireplace With fireplace
</button> </button>
<button <button
className="template" className={isCustom ? 'template active' : 'template'}
onClick={() => aria-pressed={isCustom}
onClick={() => {
setCustomSelected(true);
changeRoom((r) => ({ changeRoom((r) => ({
...r, ...r,
walls: [{ id: `${r.id}-w1`, length: 4000, turn: 90, doors: [] }], walls: [{ id: `${r.id}-w1`, length: 4000, turn: 90, doors: [] }],
})) }));
} }}
> >
<MoveUpRight size={19} /> <MoveUpRight size={19} />
Custom Custom
</button> </button>
</div> </div>
{isRectangle && ( <p className="shape-help" id="custom-shape-help">
{isCustom && geometry.closed ? (
<>Your outline is complete. Adjust individual walls, corners or doorways below.</>
) : isCustom ? (
<>
Add your walls in order below, then use <strong>Add closing wall</strong> to complete
the outline.
</>
) : (
<>
Have an irregular room? Click <strong>Custom</strong> to start a new outline and enter
each wall and corner. Choosing a shape replaces the current outline and doorways.
</>
)}
</p>
{isRectangle && !isCustom && (
<div className="field-grid quick-dimensions"> <div className="field-grid quick-dimensions">
<NumberField <NumberField
label="Room width" label="Room width"
@ -166,7 +203,7 @@ export function OutlineEditor({
/> />
</div> </div>
)} )}
<details className="wall-details" open={!isRectangle}> <details className="wall-details" open={isCustom || !isRectangle}>
<summary> <summary>
Walls & corners <span>{room.walls.length} walls</span> Walls & corners <span>{room.walls.length} walls</span>
</summary> </summary>
@ -270,7 +307,7 @@ export function OutlineEditor({
className="icon-button" className="icon-button"
aria-label={`Insert wall after W${i + 1}`} aria-label={`Insert wall after W${i + 1}`}
title={`Insert wall after W${i + 1}`} title={`Insert wall after W${i + 1}`}
disabled={room.walls.length >= 100} disabled={room.walls.length >= PROJECT_LIMITS.wallsPerRoom}
onClick={() => changeRoom((r) => insertWallAfter(r, wall.id))} onClick={() => changeRoom((r) => insertWallAfter(r, wall.id))}
> >
<Plus size={16} /> <Plus size={16} />
@ -289,7 +326,11 @@ export function OutlineEditor({
</div> </div>
))} ))}
</div> </div>
<button className="text-button" onClick={addWall} disabled={room.walls.length >= 100}> <button
className="text-button"
onClick={addWall}
disabled={room.walls.length >= PROJECT_LIMITS.wallsPerRoom}
>
<Plus size={15} /> Add a wall <Plus size={15} /> Add a wall
</button> </button>
</details> </details>
@ -317,7 +358,10 @@ export function OutlineEditor({
<button <button
className="text-button" className="text-button"
onClick={closeOutline} onClick={closeOutline}
disabled={room.walls.length >= 100 || Math.abs(geometry.closingTurn) >= 179.99} disabled={
room.walls.length >= PROJECT_LIMITS.wallsPerRoom ||
Math.abs(geometry.closingTurn) >= PROJECT_LIMITS.maxTurn - PRECISION.millimetres
}
> >
Add closing wall <Plus size={14} /> Add closing wall <Plus size={14} />
</button> </button>
@ -419,7 +463,9 @@ export function OutlineEditor({
<button <button
className="text-button" className="text-button"
onClick={addDoor} onClick={addDoor}
disabled={!room.walls.length || room.walls.at(-1)!.doors.length >= 30} disabled={
!room.walls.length || room.walls.at(-1)!.doors.length >= PROJECT_LIMITS.doorsPerWall
}
> >
<Plus size={15} /> Add a doorway <Plus size={15} /> Add a doorway
</button> </button>
@ -427,7 +473,7 @@ export function OutlineEditor({
<NumberField <NumberField
label="Measurement tolerance" label="Measurement tolerance"
value={tolerance} value={tolerance}
max={50} max={PROJECT_LIMITS.maxTolerance}
onChange={(n) => changeProject((p) => ({ ...p, tolerance: n }))} onChange={(n) => changeProject((p) => ({ ...p, tolerance: n }))}
hint="Largest closing gap accepted for the cut plan." hint="Largest closing gap accepted for the cut plan."
/> />

View file

@ -0,0 +1,66 @@
.planner-loading {
display: grid;
place-items: center;
min-height: 100vh;
min-height: 100dvh;
padding: 32px;
background: #fdfcf7;
}
.planner-loading-content {
display: flex;
flex-direction: column;
align-items: center;
gap: 24px;
color: var(--ink);
font-size: 16px;
font-weight: 600;
text-align: center;
}
.planner-loading-floor {
display: block;
width: 112px;
height: 112px;
}
.planner-loading-outline {
fill: none;
stroke: #d9ddd3;
stroke-width: 2px;
}
.planner-loading-row {
fill: #d7b68a;
opacity: 0.25;
animation: planner-lay-boards 2.4s ease-in-out infinite;
}
.planner-loading-row rect:last-child {
fill: #ead9bc;
}
.planner-loading-row:nth-of-type(2) {
animation-delay: 180ms;
}
.planner-loading-row:nth-of-type(3) {
animation-delay: 360ms;
}
.planner-loading-row:nth-of-type(4) {
animation-delay: 540ms;
}
.planner-loading-row:first-of-type rect:first-child {
fill: #ac451d;
}
@keyframes planner-lay-boards {
0%,
100% {
opacity: 0.25;
transform: translateX(-4px);
}
25%,
65% {
opacity: 1;
transform: translateX(0);
}
}
@media (prefers-reduced-motion: reduce) {
.planner-loading-row {
animation: none;
opacity: 1;
}
}

View file

@ -0,0 +1,35 @@
import './PlannerLoading.css';
export function PlannerLoading() {
return (
<main className="planner-loading">
<div className="planner-loading-content" role="status" aria-live="polite" aria-atomic="true">
<svg
className="planner-loading-floor"
viewBox="0 0 112 112"
aria-hidden="true"
focusable="false"
>
<rect className="planner-loading-outline" x="4" y="4" width="104" height="104" rx="4" />
<g className="planner-loading-row">
<rect x="14" y="14" width="30" height="18" rx="1" />
<rect x="48" y="14" width="50" height="18" rx="1" />
</g>
<g className="planner-loading-row">
<rect x="14" y="36" width="50" height="18" rx="1" />
<rect x="68" y="36" width="30" height="18" rx="1" />
</g>
<g className="planner-loading-row">
<rect x="14" y="58" width="30" height="18" rx="1" />
<rect x="48" y="58" width="50" height="18" rx="1" />
</g>
<g className="planner-loading-row">
<rect x="14" y="80" width="50" height="18" rx="1" />
<rect x="68" y="80" width="30" height="18" rx="1" />
</g>
</svg>
<p>Opening your planner…</p>
</div>
</main>
);
}

View file

@ -2,17 +2,55 @@
--landing-muted: #5e665f; --landing-muted: #5e665f;
--landing-line: #d9ddd3; --landing-line: #d9ddd3;
--landing-accent: #ac451d; --landing-accent: #ac451d;
--landing-header-height: 80px;
--landing-title-size: 48px;
--landing-heading-size: 32px;
--landing-subheading-size: 18px;
--landing-body-size: 16px;
--landing-caption-size: 14px;
padding-top: var(--landing-header-height);
background: #fdfcf7; background: #fdfcf7;
color: var(--ink); color: var(--ink);
font-size: 15px; font-family: Arial, Helvetica, sans-serif;
font-size: var(--landing-body-size);
line-height: 1.65;
-webkit-font-smoothing: antialiased; -webkit-font-smoothing: antialiased;
} }
.landing-page h1,
.landing-page h2,
.landing-page h3 {
font-family: inherit;
font-weight: 600;
letter-spacing: -0.02em;
line-height: 1.2;
text-wrap: balance;
}
.landing-page h1 {
font-size: var(--landing-title-size);
}
.landing-page h2 {
font-size: var(--landing-heading-size);
}
.landing-page h3 {
font-size: var(--landing-subheading-size);
}
.landing-page p {
color: var(--landing-muted);
}
.landing-page strong {
font-weight: 600;
}
.landing-page svg text {
font-family: inherit;
font-size: var(--landing-caption-size);
}
.landing-container { .landing-container {
width: min(1180px, calc(100% - 96px)); width: min(1180px, calc(100% - 96px));
margin-inline: auto; margin-inline: auto;
} }
.landing-page a { .landing-page a {
color: inherit; color: inherit;
scroll-margin-top: calc(var(--landing-header-height) + 24px);
} }
.landing-page a:focus-visible { .landing-page a:focus-visible {
outline: 3px solid var(--blue); outline: 3px solid var(--blue);
@ -20,41 +58,38 @@
} }
.landing-page section[id], .landing-page section[id],
.landing-page main { .landing-page main {
scroll-margin-top: 24px; scroll-margin-top: calc(var(--landing-header-height) + 24px);
} }
.landing-header { .landing-header {
min-height: 100px; position: fixed;
top: 0;
inset-inline: 0;
z-index: 20;
height: var(--landing-header-height);
background: #fdfcf7;
border-bottom: 1px solid var(--landing-line);
}
.landing-header-content {
height: 100%;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
gap: 24px; gap: 24px;
border-bottom: 1px solid var(--landing-line);
} }
.landing-brand { .landing-brand {
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
gap: 12px; gap: 12px;
font-size: 22px; font-size: var(--landing-subheading-size);
font-weight: 750; font-weight: 600;
letter-spacing: -0.9px;
text-decoration: none; text-decoration: none;
white-space: nowrap; white-space: nowrap;
} }
.landing-brand-dot { .landing-footer a {
color: var(--landing-accent);
}
.landing-nav {
display: flex;
gap: 30px;
}
.landing-nav a,
.landing-footer > a:last-child {
padding-block: 12px; padding-block: 12px;
font-size: 13px;
text-decoration: none; text-decoration: none;
} }
.landing-nav a:hover, .landing-footer a:hover {
.landing-footer > a:last-child:hover {
text-decoration: underline; text-decoration: underline;
text-underline-offset: 5px; text-underline-offset: 5px;
} }
@ -69,7 +104,7 @@
border: 1px solid var(--landing-accent); border: 1px solid var(--landing-accent);
color: #fffdf7; color: #fffdf7;
border-radius: 3px; border-radius: 3px;
font-size: 17px; font-size: var(--landing-body-size);
font-weight: 600; font-weight: 600;
text-decoration: none; text-decoration: none;
transition: transition:
@ -83,7 +118,7 @@
.landing-page .landing-cta-small { .landing-page .landing-cta-small {
min-height: 44px; min-height: 44px;
padding: 10px 16px; padding: 10px 16px;
font-size: 13px; font-size: var(--landing-caption-size);
gap: 18px; gap: 18px;
} }
.landing-hero { .landing-hero {
@ -93,46 +128,9 @@
gap: 48px; gap: 48px;
padding-block: 77px 80px; padding-block: 77px 80px;
} }
.landing-eyebrow {
display: flex;
align-items: center;
gap: 10px;
font: 10px var(--mono);
line-height: 1.6;
letter-spacing: 1.5px;
font-weight: 600;
}
.landing-hero .landing-eyebrow > span {
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--landing-accent);
}
.landing-hero h1,
.landing-guide h2,
.landing-finishing h2,
.landing-final-cta h2 {
font-family: Georgia, 'Times New Roman', serif;
font-weight: 400;
letter-spacing: -2.3px;
line-height: 1.07;
text-wrap: balance;
}
.landing-hero h1 {
margin-top: 23px;
font-size: clamp(46px, 4.7vw, 65px);
}
.landing-hero h1 em,
.landing-final-cta h2 em {
color: var(--landing-accent);
font-weight: 400;
}
.landing-intro { .landing-intro {
max-width: 445px; max-width: 445px;
margin-top: 26px; margin-top: 26px;
color: var(--landing-muted);
font-size: 16px;
line-height: 1.8;
} }
.landing-hero-actions { .landing-hero-actions {
display: flex; display: flex;
@ -146,66 +144,32 @@
align-items: center; align-items: center;
gap: 8px; gap: 8px;
min-height: 44px; min-height: 44px;
font-size: 12px; font-size: var(--landing-caption-size);
text-underline-offset: 5px; text-underline-offset: 5px;
text-decoration-color: #a3aca2; text-decoration-color: #a3aca2;
} }
.landing-reassurance {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 8px;
margin-top: 19px;
color: var(--landing-muted);
font-size: 11px;
}
.landing-reassurance svg {
color: #426751;
}
.landing-plan { .landing-plan {
margin: 16px 0 0; margin: 16px 0 0;
border: 1px solid #cbd2c7; border: 1px solid #cbd2c7;
background: #f6f7f2; background: #f6f7f2;
border-radius: 4px; border-radius: 4px;
box-shadow: 9px 9px 0 #eaece4;
transform: rotate(-1.5deg);
} }
.landing-plan-heading { .landing-plan-heading {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
padding: 18px 20px; padding: 18px 20px;
border-bottom: 1px solid #cbd2c7; border-bottom: 1px solid #cbd2c7;
font-size: 11px; font-size: var(--landing-caption-size);
} font-weight: 600;
.landing-plan-heading > span:first-child {
display: inline-flex;
align-items: center;
gap: 8px;
}
.landing-status-dot {
height: 6px;
width: 6px;
border-radius: 50%;
background: #5a7960;
}
.landing-plan-index {
font: 9px var(--mono);
color: #687265;
white-space: nowrap;
} }
.landing-plan-room { .landing-plan-room {
display: flex; display: flex;
flex-wrap: wrap;
justify-content: space-between; justify-content: space-between;
gap: 12px; gap: 4px 12px;
padding: 22px 24px 10px; padding: 22px 24px 10px;
font-size: 12px; font-size: var(--landing-caption-size);
font-weight: 600;
} }
.landing-plan-room > span:last-child { .landing-plan-room > span:last-child {
font: 10px var(--mono); color: var(--landing-muted);
color: #657260;
align-self: center; align-self: center;
} }
.landing-plan-paper > svg { .landing-plan-paper > svg {
@ -219,8 +183,8 @@
gap: 20px; gap: 20px;
padding: 17px 24px; padding: 17px 24px;
border-top: 1px solid #dbe0d5; border-top: 1px solid #dbe0d5;
color: #526156; color: var(--landing-muted);
font-size: 10px; font-size: var(--landing-caption-size);
} }
.landing-plan-legend span { .landing-plan-legend span {
display: inline-flex; display: inline-flex;
@ -246,21 +210,6 @@
padding-bottom: 68px; padding-bottom: 68px;
border-top: 1px solid var(--landing-line); border-top: 1px solid var(--landing-line);
} }
.landing-section-kicker {
display: flex;
justify-content: space-between;
align-items: baseline;
gap: 20px;
}
.landing-section-kicker > .landing-eyebrow {
color: var(--landing-muted);
font-size: 9px;
}
.landing-section-kicker h2 {
font-size: 17px;
letter-spacing: -0.3px;
font-weight: 500;
}
.landing-benefit-grid { .landing-benefit-grid {
display: grid; display: grid;
grid-template-columns: repeat(3, 1fr); grid-template-columns: repeat(3, 1fr);
@ -284,22 +233,9 @@
margin-bottom: 19px; margin-bottom: 19px;
color: var(--landing-accent); color: var(--landing-accent);
} }
.landing-benefit-top span {
color: #667064;
font: 10px var(--mono);
}
.landing-benefit h3 { .landing-benefit h3 {
font-size: 17px;
font-weight: 600;
letter-spacing: -0.3px;
margin-bottom: 10px; margin-bottom: 10px;
} }
.landing-benefit p,
.landing-trim-copy > p {
color: var(--landing-muted);
font-size: 13px;
line-height: 1.8;
}
.landing-guide { .landing-guide {
padding-block: 70px; padding-block: 70px;
background: #eef0e8; background: #eef0e8;
@ -310,24 +246,15 @@
grid-template-columns: 0.8fr 1.2fr; grid-template-columns: 0.8fr 1.2fr;
gap: 110px; gap: 110px;
} }
.landing-guide h2, .landing-guide-intro > p {
.landing-finishing h2 {
font-size: 43px;
letter-spacing: -1.5px;
margin-top: 17px;
}
.landing-guide-intro > p:not(.landing-eyebrow) {
color: var(--landing-muted);
line-height: 1.8;
margin-top: 22px; margin-top: 22px;
font-size: 14px;
} }
.landing-text-link { .landing-text-link {
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
gap: 8px; gap: 8px;
min-height: 44px; min-height: 44px;
font-size: 12px; font-size: var(--landing-caption-size);
text-underline-offset: 4px; text-underline-offset: 4px;
} }
.landing-guide-intro > .landing-text-link { .landing-guide-intro > .landing-text-link {
@ -341,8 +268,7 @@
margin-top: 30px; margin-top: 30px;
border-top: 1px solid #cdd5c5; border-top: 1px solid #cdd5c5;
color: var(--landing-muted); color: var(--landing-muted);
font-size: 12px; font-size: var(--landing-caption-size);
line-height: 1.8;
} }
.landing-tool-note strong { .landing-tool-note strong {
display: block; display: block;
@ -366,25 +292,17 @@
padding-top: 0; padding-top: 0;
} }
.landing-step-number { .landing-step-number {
font: 13px var(--mono); min-width: 18px;
color: var(--landing-accent); font-size: var(--landing-caption-size);
padding-top: 4px; font-weight: 600;
color: var(--landing-muted);
} }
.landing-steps h3 { .landing-steps h3 {
font-size: 17px;
font-weight: 600;
margin-bottom: 8px; margin-bottom: 8px;
} }
.landing-steps p {
font-size: 13px;
color: var(--landing-muted);
line-height: 1.75;
}
.landing-guide-note { .landing-guide-note {
margin: 18px 0 0 39px; margin: 18px 0 0 41px;
font-size: 11px; font-size: var(--landing-caption-size);
color: var(--landing-muted);
line-height: 1.8;
} }
.landing-finishing { .landing-finishing {
padding-block: 73px 65px; padding-block: 73px 65px;
@ -396,11 +314,6 @@
gap: 80px; gap: 80px;
margin-bottom: 35px; margin-bottom: 35px;
} }
.landing-finishing-heading > p {
font-size: 14px;
line-height: 1.8;
color: var(--landing-muted);
}
.landing-trim-grid { .landing-trim-grid {
display: grid; display: grid;
grid-template-columns: 1fr 1fr; grid-template-columns: 1fr 1fr;
@ -412,14 +325,9 @@
overflow: hidden; overflow: hidden;
} }
.landing-trim-label { .landing-trim-label {
display: flex;
justify-content: space-between;
gap: 15px;
padding: 16px 23px; padding: 16px 23px;
background: #f0f1e9; background: #f0f1e9;
font: 9px var(--mono); font-size: var(--landing-caption-size);
letter-spacing: 1px;
color: #586154;
border-bottom: 1px solid var(--landing-line); border-bottom: 1px solid var(--landing-line);
} }
.landing-trim-diagram { .landing-trim-diagram {
@ -435,30 +343,14 @@
border-top: 1px solid var(--landing-line); border-top: 1px solid var(--landing-line);
} }
.landing-trim-copy h3 { .landing-trim-copy h3 {
display: flex;
align-items: baseline;
flex-wrap: wrap;
gap: 7px 12px;
font-size: 22px;
letter-spacing: -0.6px;
font-weight: 600;
margin-bottom: 12px; margin-bottom: 12px;
} }
.landing-trim-copy h3 span {
font-family: Georgia, 'Times New Roman', serif;
font-style: italic;
font-size: 14px;
color: var(--landing-muted);
font-weight: 400;
letter-spacing: 0;
}
.landing-trim-copy .landing-trim-choice { .landing-trim-copy .landing-trim-choice {
display: flex; display: flex;
align-items: flex-start; align-items: flex-start;
gap: 8px; gap: 8px;
margin-top: 18px; margin-top: 18px;
color: var(--ink); font-size: var(--landing-caption-size);
font-size: 11px;
} }
.landing-trim-choice svg { .landing-trim-choice svg {
margin-top: 2px; margin-top: 2px;
@ -470,9 +362,7 @@
justify-content: space-between; justify-content: space-between;
gap: 40px; gap: 40px;
margin-top: 23px; margin-top: 23px;
font-size: 11px; font-size: var(--landing-caption-size);
color: var(--landing-muted);
line-height: 1.8;
} }
.landing-finishing-note p { .landing-finishing-note p {
max-width: 780px; max-width: 780px;
@ -483,69 +373,14 @@
.landing-finishing-note a { .landing-finishing-note a {
flex-shrink: 0; flex-shrink: 0;
} }
.landing-final-cta {
display: flex;
align-items: center;
justify-content: space-between;
gap: 40px;
padding: 47px 55px;
background: #172c25;
color: #faf9ef;
border-radius: 3px;
}
.landing-final-cta .landing-eyebrow {
color: #c0cbb8;
font-size: 9px;
}
.landing-final-cta h2 {
font-size: 48px;
margin-top: 20px;
letter-spacing: -1.7px;
}
.landing-final-cta h2 em {
color: #dfb888;
}
.landing-final-cta p:not(.landing-eyebrow) {
color: #c0cbb8;
font-size: 12px;
margin-top: 17px;
}
.landing-final-actions {
display: grid;
gap: 15px;
text-align: center;
}
.landing-final-cta .landing-cta {
background: #f6ecd9;
border-color: #f6ecd9;
color: #172c25;
min-width: 260px;
}
.landing-final-cta .landing-cta:hover {
background: #e5cfac;
}
.landing-final-actions > span {
color: #c0cbb8;
font-size: 10px;
}
.landing-footer { .landing-footer {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
gap: 24px; gap: 24px;
padding-block: 38px; padding-block: 16px;
} border-top: 1px solid var(--landing-line);
.landing-footer .landing-brand { font-size: var(--landing-caption-size);
font-size: 17px;
}
.landing-footer .square-mark {
transform: scale(0.75);
transform-origin: left center;
margin-right: -6px;
}
.landing-footer p,
.landing-footer > a:last-child {
font-size: 11px;
color: var(--landing-muted); color: var(--landing-muted);
} }
.landing-sr-only { .landing-sr-only {
@ -558,27 +393,21 @@
white-space: nowrap; white-space: nowrap;
} }
.landing-skip { .landing-skip {
position: absolute; position: fixed;
top: 8px; top: 8px;
left: 8px; left: 8px;
padding: 12px; padding: 12px;
background: white; background: white;
z-index: 10; z-index: 30;
transform: translateY(-150%); transform: translateY(-150%);
} }
.landing-skip:focus { .landing-skip:focus {
transform: translateY(0); transform: translateY(0);
} }
.planner-loading {
padding: 32px;
}
@media (max-width: 1100px) { @media (max-width: 1100px) {
.landing-container { .landing-container {
width: calc(100% - 64px); width: calc(100% - 64px);
} }
.landing-nav {
gap: 20px;
}
.landing-hero { .landing-hero {
gap: 32px; gap: 32px;
} }
@ -599,20 +428,14 @@
} }
} }
@media (max-width: 800px) { @media (max-width: 800px) {
.landing-nav { .landing-page {
display: none; --landing-header-height: 72px;
}
.landing-header {
min-height: 82px;
} }
.landing-hero { .landing-hero {
grid-template-columns: 1fr; grid-template-columns: 1fr;
gap: 35px; gap: 35px;
padding-block: 48px 57px; padding-block: 48px 57px;
} }
.landing-hero h1 {
font-size: clamp(48px, 8vw, 65px);
}
.landing-intro { .landing-intro {
max-width: 540px; max-width: 540px;
} }
@ -624,11 +447,6 @@
.landing-plan { .landing-plan {
width: min(100%, 540px); width: min(100%, 540px);
margin: 10px auto 0; margin: 10px auto 0;
transform: rotate(-1deg);
}
.landing-section-kicker {
display: grid;
gap: 10px;
} }
.landing-benefit { .landing-benefit {
padding-inline: 20px; padding-inline: 20px;
@ -656,41 +474,23 @@
} }
.landing-trim-label { .landing-trim-label {
padding-inline: 16px; padding-inline: 16px;
font-size: 8px;
letter-spacing: 0.5px;
} }
.landing-trim-copy { .landing-trim-copy {
margin-inline: 16px; margin-inline: 16px;
} }
.landing-final-cta {
padding: 38px;
gap: 30px;
}
.landing-final-cta h2 {
font-size: 39px;
}
.landing-final-cta .landing-cta {
min-width: 210px;
gap: 25px;
}
.landing-footer {
flex-wrap: wrap;
gap: 10px 24px;
}
.landing-footer p {
order: 3;
width: 100%;
}
} }
@media (max-width: 540px) { @media (max-width: 540px) {
.landing-page {
--landing-title-size: 36px;
--landing-heading-size: 28px;
}
.landing-container { .landing-container {
width: calc(100% - 40px); width: calc(100% - 40px);
} }
.landing-header { .landing-header-content {
gap: 12px; gap: 12px;
} }
.landing-brand { .landing-brand {
font-size: 19px;
gap: 8px; gap: 8px;
} }
.landing-brand .square-mark { .landing-brand .square-mark {
@ -699,16 +499,10 @@
margin-right: -4px; margin-right: -4px;
} }
.landing-page .landing-cta-small { .landing-page .landing-cta-small {
font-size: 12px;
padding-inline: 12px; padding-inline: 12px;
gap: 9px; gap: 9px;
} }
.landing-hero h1 {
font-size: clamp(41px, 11vw, 58px);
letter-spacing: -1.8px;
}
.landing-intro { .landing-intro {
font-size: 15px;
margin-top: 22px; margin-top: 22px;
} }
.landing-hero-actions { .landing-hero-actions {
@ -717,29 +511,15 @@
.landing-hero-actions .landing-cta { .landing-hero-actions .landing-cta {
width: 100%; width: 100%;
} }
.landing-reassurance {
gap: 6px;
font-size: 10px;
margin-top: 10px;
}
.landing-plan-heading { .landing-plan-heading {
font-size: 10px;
padding: 14px 12px; padding: 14px 12px;
} }
.landing-plan-index {
font-size: 8px;
}
.landing-plan-room { .landing-plan-room {
font-size: 11px;
padding: 16px 14px 8px; padding: 16px 14px 8px;
} }
.landing-plan-room > span:last-child {
font-size: 9px;
}
.landing-plan-legend { .landing-plan-legend {
padding: 14px; padding: 14px;
gap: 15px; gap: 8px 16px;
font-size: 9px;
} }
.landing-benefits { .landing-benefits {
padding-bottom: 42px; padding-bottom: 42px;
@ -765,16 +545,11 @@
.landing-guide { .landing-guide {
padding-block: 44px; padding-block: 44px;
} }
.landing-guide h2,
.landing-finishing h2 {
font-size: 35px;
letter-spacing: -1px;
}
.landing-steps li { .landing-steps li {
gap: 18px; gap: 18px;
} }
.landing-guide-note { .landing-guide-note {
margin-left: 34px; margin-left: 36px;
} }
.landing-finishing { .landing-finishing {
padding-block: 46px 36px; padding-block: 46px 36px;
@ -784,7 +559,6 @@
gap: 22px; gap: 22px;
} }
.landing-trim-label { .landing-trim-label {
font-size: 9px;
padding: 15px 20px; padding: 15px 20px;
} }
.landing-trim-copy { .landing-trim-copy {
@ -797,18 +571,6 @@
flex-direction: column; flex-direction: column;
gap: 8px; gap: 8px;
} }
.landing-final-cta {
flex-direction: column;
align-items: stretch;
padding: 32px 25px;
gap: 27px;
}
.landing-final-cta h2 {
font-size: 40px;
}
.landing-footer {
padding-block: 28px;
}
} }
@media (prefers-reduced-motion: reduce) { @media (prefers-reduced-motion: reduce) {
.landing-page .landing-cta { .landing-page .landing-cta {
@ -821,7 +583,6 @@
@media print { @media print {
.landing-header, .landing-header,
.landing-footer, .landing-footer,
.landing-final-cta,
.landing-hero-actions, .landing-hero-actions,
.landing-skip { .landing-skip {
display: none; display: none;
@ -829,9 +590,8 @@
.landing-container { .landing-container {
width: 100%; width: 100%;
} }
.landing-plan { .landing-page {
transform: none; padding-top: 0;
box-shadow: none;
} }
.landing-trim-card, .landing-trim-card,
.landing-steps li { .landing-steps li {

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