/* ── The floor-plan editor (`/building/{pand}`) ────────────────────────────── */ /* * The chrome is the library's; this file lays it out and draws the plan. The * page gets the full-width frame, so on a wide screen the plan and the * properties panel sit side by side, and below 900 px they stack. */ .designer { display: flex; flex-direction: column; gap: var(--m-space-3); min-width: 0; } .designer__head { align-items: baseline; display: flex; flex-wrap: wrap; gap: var(--m-space-2) var(--m-space-3); } .designer__title { margin: 0; } .designer__pand { color: var(--m-text-dim); font-family: var(--m-font-mono); font-size: var(--m-font-size-sm); overflow-wrap: anywhere; } .designer__spacer { flex: 1; } .designer__hint { color: var(--m-text-dim); font-size: var(--m-font-size-sm); margin: 0; } .designer__splash { align-items: center; color: var(--m-text-dim); display: flex; gap: var(--m-space-3); justify-content: center; padding: 20vh 0; } /* * The storey and tool pickers are segmented controls, which the library draws * on one line. A building can have more storeys than a phone has width, and * five tools are about 360 px, so here they wrap instead of running off the * edge. */ .designer__storeys, .designer__toolbar { align-items: center; display: flex; flex-wrap: wrap; gap: var(--m-space-2); .m-field { margin: 0; min-width: 0; } .m-segmented { flex-wrap: wrap; max-width: 100%; } } /* Undo and redo at the far end of the tools, or under them on a phone. */ .designer__toolbar > .m-button-group { margin-inline-start: auto; } .designer__tool-hint { margin-top: calc(-1 * var(--m-space-1)); } .designer__body { display: grid; gap: var(--m-space-4); grid-template-columns: minmax(0, 1fr); @media (min-width: 900px) { align-items: start; grid-template-columns: minmax(0, 1fr) minmax(16rem, 22rem); } } /* * The plan keeps its 4:3 box at any width — `building.tsx` takes metres per * pixel from the element's width alone, so a box whose height were capped * independently would letterbox the drawing and every tap would land off by * the margin. On a tall desktop the wrap's width is capped instead, which * caps the height with it. */ .designer__plan-wrap { max-width: calc(78svh * 4 / 3); position: relative; width: 100%; } .designer__zoom { flex-direction: column; gap: var(--m-space-1); position: absolute; right: var(--m-space-2); top: var(--m-space-2); .m-button { box-shadow: var(--m-shadow-sm); min-width: 2.5rem; } } .designer__side { display: flex; flex-direction: column; gap: var(--m-space-3); min-width: 0; .m-card__body { display: flex; flex-direction: column; gap: var(--m-space-3); } .m-card__foot { display: flex; flex-wrap: wrap; gap: var(--m-space-2); } } .designer__fields { display: grid; gap: var(--m-space-3); grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); .m-field { margin: 0; } } /* Two to a row on a phone left a stepper field room for "3." of "3.00 m". */ @media (max-width: 600px) { .designer__fields { grid-template-columns: 1fr; } } .designer__issue { margin: 0; & + & { margin-top: var(--m-space-1); } } /* * Save stays on screen: on a phone the plan alone is most of a screen, and * the panel under it more, so a save bar at the end of the page would be a * scroll away from every edit. */ .designer__save { align-items: center; background: var(--m-bg); border-top: 1px solid var(--m-border); bottom: 0; display: flex; flex-wrap: wrap; gap: var(--m-space-2) var(--m-space-3); padding: var(--m-space-2) 0; position: sticky; z-index: 1; } /* * The plan is drawn in metres (`building.tsx` puts one SVG unit at one metre, * north up), so every stroke width is set there, scaled to stay a pixel or two * wide at any zoom; only colours live here. Every one is a token, so the plan * follows the light and the dark theme: walls in the strongest text colour on * the sunken ground of an empty floor, the accent for what is selected and * what is being drawn. */ .designer__plan { aspect-ratio: 4 / 3; background: var(--m-surface-sunken); border: 1px solid var(--m-border); border-radius: var(--m-radius); display: block; height: auto; /* A drag on the plan pans it; the page must not scroll or zoom instead. */ touch-action: none; user-select: none; width: 100%; &.tool-select { cursor: grab; } &:not(.tool-select) { cursor: crosshair; } .grid .g1 { stroke: var(--m-border); stroke-opacity: 0.5; } .grid .g5 { stroke: var(--m-border-strong); stroke-opacity: 0.6; } .neighbour { fill: var(--m-surface); stroke: var(--m-border); } .outline { fill: none; stroke: var(--m-text-dim); } .floor { fill: var(--m-surface-raised); } .room polygon { fill: color-mix(in srgb, var(--m-accent) 7%, transparent); stroke: color-mix(in srgb, var(--m-accent) 35%, transparent); } .room.is-selected polygon { fill: var(--m-accent-soft); stroke: var(--m-accent); } .room text { fill: var(--m-text-strong); text-anchor: middle; } .room text.area { fill: var(--m-text-dim); } /* A room nobody has named yet: just its area, quietly, until it is tapped. */ .room.unnamed text { fill: var(--m-text-dim); opacity: 0.7; } .wall { stroke: var(--m-text-strong); stroke-linecap: square; } .wall.outer { stroke: var(--m-text); } /* The gap is painted in the floor's colour, cutting the opening out of the wall. */ .opening .gap { stroke: var(--m-surface-raised); } .opening line, .opening path { stroke: var(--m-warning); } .opening.window line:not(.gap) { stroke: var(--m-info); } .wall.is-selected, .opening.is-selected line, .opening.is-selected path { stroke: var(--m-accent); } .stair polygon { fill: color-mix(in srgb, var(--m-text-strong) 8%, transparent); stroke: var(--m-text-strong); } .stair line { stroke: var(--m-text-dim); } .stair .arrow { stroke: var(--m-text-strong); } #arrow path { fill: var(--m-text-strong); } .stair.is-selected polygon { stroke: var(--m-accent); } /* The hole a flight from below comes up through: the bare ground showing. */ .well { fill: var(--m-surface-sunken); stroke: var(--m-text-dim); stroke-dasharray: 0.2 0.1; } .below, .faint { opacity: 0.25; } .preview line { stroke: var(--m-accent); } .preview text { fill: var(--m-accent-text); text-anchor: middle; } .cursor { fill: var(--m-accent); } .north { fill: var(--m-text-dim); } }