From b74c1fc6779f65a06cdc06f1f82f293e546bc089 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Raphael=20Vall=C3=A9e?= <72668371+Tranzitron@users.noreply.github.com> Date: Fri, 2 Oct 2026 18:37:08 -0400 Subject: [PATCH 1/3] Redesign the frontend UI as a dark reference tool Rebuilds all five pages of the brand to model to generation to trim drill-down, and fixes several data-handling bugs found while reviewing it. Design: cool graphite surfaces separated by lightness rather than by borders and shadows, with a single amber signal reserved for "active" and "in production". Archivo for prose, JetBrains Mono only for measured values, where decimal alignment is the point. Each level gets the list treatment its data actually calls for: a dense index for marques, image rows for models, a table for generations, a photo grid for trims, and a spec sheet for a trim's 70-odd measurements. Navigation: the header now shows the whole drill-down path, so a page four levels deep is one click from any ancestor. The old build had no way back up at all. On narrow screens the path keeps its last two levels. The brands index drops its logo cards. At index size a marque badge is too small to identify and duplicates the name beside it, and 398 of them in 100px tiles needed an enormous scroll. The logo stays on the brand page, where it is rendered large enough to do a job. Bug fixes: - power never holds horsepower. The backend matches labels containing "power" before "power per litre", so the field is named for one and carries the other. The UI labels it from the value. - In-production models store an invalid end date, which the API sends as null. The old @if (item.endYear) treated that as truthy, so current cars rendered NaN years under a red "discontinued" badge. - Header path links resolved relative to the current route, so the brand crumb pointed at /alfa_romeo-11 instead of /browse/alfa_romeo-11. - Item anchors had no href, making them unreachable by keyboard and unannounced as links. They are real router links now. - Reusing the global .row rule on a
{{ item.name }}
- + + {{ item.name }} + \ No newline at end of file diff --git a/frontend/src/app/browse/all-brands/all-brands-item/all-brands-item.component.ts b/frontend/src/app/browse/all-brands/all-brands-item/all-brands-item.component.ts index 5457b1b..9ae3bac 100644 --- a/frontend/src/app/browse/all-brands/all-brands-item/all-brands-item.component.ts +++ b/frontend/src/app/browse/all-brands/all-brands-item/all-brands-item.component.ts @@ -1,39 +1,21 @@ -import {Component, Input} from '@angular/core'; -import {ActivatedRoute, Router} from '@angular/router'; +import {ChangeDetectionStrategy, Component, Input, computed} from '@angular/core'; +import {RouterLink} from '@angular/router'; import {Brand} from "../../../../../../library/src/models"; -import {SlugifyPipe} from '../../../slugify-pipe'; +import {entitySlug} from '../../../format'; @Component({ selector: 'app-allbrands-item', - imports: [], + imports: [RouterLink], templateUrl: './all-brands-item.component.html', styleUrl: './all-brands-item.component.css', - providers: [SlugifyPipe] + changeDetection: ChangeDetectionStrategy.OnPush, }) export class AllBrandsItemComponent { @Input({required: true}) item!: Brand; - /** Shown when the marque has no logo, or its logo fails to load. */ - readonly placeholder = 'https://placehold.co/100x100?text=No+logo'; - - constructor(public router: Router, private route: ActivatedRoute, private pipe: SlugifyPipe) { - } - /** - * A stored imageUrl is a URL to another origin, so it can fail even though it - * is well-formed: a logo the site has since renamed or dropped 404s. Without - * this the browser shows its own broken-image icon, which reads as a bug in - * the app rather than missing artwork. + * A real router link, not a click handler on a bare anchor: that keeps the + * entry focusable, reachable by keyboard, and openable in a new tab. */ - onImageError(event: Event): void { - const img = event.target as HTMLImageElement; - if (img.src === this.placeholder) return; - img.src = this.placeholder; - } - - public async clicked() { - let brandName = this.pipe.transform(this.item.name); - let brandUrl = brandName + "-" + this.item.id; - await this.router.navigate([brandUrl], {relativeTo: this.route}); - } -} + protected readonly slug = computed(() => entitySlug(this.item?.name ?? '', this.item?.id ?? 0)); +} \ No newline at end of file diff --git a/frontend/src/app/browse/all-brands/all-brands.component.css b/frontend/src/app/browse/all-brands/all-brands.component.css index 18ebaa9..9a304e5 100644 --- a/frontend/src/app/browse/all-brands/all-brands.component.css +++ b/frontend/src/app/browse/all-brands/all-brands.component.css @@ -1,76 +1,156 @@ -.navigation-bar { - display: flex; - flex-wrap: wrap; - gap: 0.5rem; - padding: 1rem; - background-color: #f8f9fa; - z-index: 100; - border-bottom: 1px solid #dee2e6; - margin-bottom: 1rem; - transition: all 0.3s ease; +.index { + display: grid; + /* The rail is intrinsic: one narrow column of letters. Everything else goes + to the body, which is where the 398 brands live. */ + grid-template-columns: auto minmax(0, 1fr); + gap: 0 clamp(1.25rem, 0.4rem + 2vw, 3rem); + max-width: 1320px; + margin: 0 auto; + padding: 1.75rem var(--gutter) 6rem; + align-items: start; } -.navigation-bar.floating { - position: fixed; - right: 1rem; - top: 50%; - transform: translateY(-50%) translateX(150%); - flex-direction: column; - align-items: center; - background-color: rgba(248, 249, 250, 0.9); - box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); - border-radius: 8px; - border: 1px solid #dee2e6; - padding: 0.5rem; - max-height: 90vh; - overflow-y: auto; - opacity: 0; - transition: transform 0.25s ease-out, opacity 0.25s ease-out, visibility 0s linear 0.25s; - visibility: hidden; -} +/* ------------------------------------------------------------- the rail --- */ -.navigation-bar.floating.visible { - transform: translateY(-50%) translateX(0); - opacity: 1; - visibility: visible; - transition-delay: 0s; +.rail { + position: sticky; + /* Clears the fixed page header. */ + top: calc(var(--bar-h) + 1.75rem); + align-self: start; } -.navigation-bar.floating .nav-letter { - font-size: 0.8rem; - padding: 0.15rem 0.3rem; +.rail__list { + list-style: none; + margin: 0; + padding: 0; + display: flex; + flex-direction: column; + gap: 0.0625rem; } -.nav-letter { - text-decoration: none; - color: #007bff; - font-weight: bold; - padding: 0.25rem 0.5rem; +.rail__letter { + display: grid; + place-items: center; + width: 26px; + height: 22px; + font-family: var(--mono); + font-size: 0.75rem; + /* Navigation, so it carries real text contrast rather than the faint tone + used for supporting meta. */ + color: var(--dim); border-radius: 4px; + transition: color 0.15s var(--ease), background 0.15s var(--ease); } -.nav-letter:hover { - background-color: #e9ecef; +.rail__letter:hover { + color: var(--text); + background: var(--panel); } -.brands-container { - padding: 1rem; +/* The active letter is amber with a filled box: position within a 398-item + list, readable without scrolling the list itself. */ +.rail__letter--active { + color: var(--signal); + background: var(--signal-wash); + font-weight: 500; } -.letter-section { - margin-bottom: 2rem; - scroll-margin-top: 2rem; +/* ---------------------------------------------------------- the sections -- */ + +.index__body { + min-width: 0; } -.letter-header { - border-bottom: 2px solid #343a40; - padding-bottom: 0.5rem; - margin-bottom: 1rem; +.letter-section { + margin-bottom: 2.25rem; + /* Anchor jumps must land below the sticky header and the sticky heading. */ + scroll-margin-top: calc(var(--bar-h) + 3rem); } -.letter-brands { +.letter-head { + position: sticky; + top: var(--bar-h); + z-index: 10; display: flex; - flex-wrap: wrap; - gap: 1.5rem; - justify-content: flex-start; + align-items: center; + gap: 0.75rem; + padding: 0.625rem 0 0.5rem; + margin-bottom: 0.75rem; + background: linear-gradient(var(--bg) 72%, rgba(15, 20, 27, 0)); + font-size: 1.25rem; + font-weight: 600; + letter-spacing: -0.02em; } + +.letter-head__key { + color: var(--text); +} + +.letter-head__count { + font-size: 0.75rem; + font-weight: 400; + color: var(--faint); + margin-left: auto; + order: 3; +} + +.letter-head::after { + content: ''; + flex: 1; + height: 1px; + background: var(--line); + order: 2; +} + +/* The index reads as one dense mass of flush cells, not a grid of cards: the + lattice is drawn by borders, so the short final row of each letter group + leaves empty background rather than a filled block. */ +.entries { + display: grid; + grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); + border-top: 1px solid var(--line-soft); + border-left: 1px solid var(--line-soft); + border-radius: var(--radius); + overflow: hidden; +} + +/* ------------------------------------------------------------ responsive -- */ + +/* Under the two-column threshold the rail becomes a horizontal strip that stays + reachable while the long list scrolls. */ +@media (max-width: 60rem) { + .index { + grid-template-columns: minmax(0, 1fr); + padding-top: 0.75rem; + } + + .rail { + top: var(--bar-h); + z-index: 20; + /* Full-bleed so the strip can scroll to the last letter without the page + scrolling under it. */ + margin: 0 calc(var(--gutter) * -1); + padding: 0.5rem var(--gutter); + background: var(--bg); + border-bottom: 1px solid var(--line); + } + + .rail__list { + flex-direction: row; + gap: 0.125rem; + overflow-x: auto; + scrollbar-width: none; + } + + .rail__list::-webkit-scrollbar { + display: none; + } + + .letter-head { + top: calc(var(--bar-h) + 2.25rem); + } + + .entries { + grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); + } +} \ No newline at end of file diff --git a/frontend/src/app/browse/all-brands/all-brands.component.html b/frontend/src/app/browse/all-brands/all-brands.component.html index 1650c05..b17ba31 100644 --- a/frontend/src/app/browse/all-brands/all-brands.component.html +++ b/frontend/src/app/browse/all-brands/all-brands.component.html @@ -1,32 +1,58 @@ -{{ total() }} marques
+ } +Fetching brands...
- } @else if (groupedBrands.length === 0) { -No brands found.
- } @else { - @for (group of groupedBrands; track group.letter) { -+ No brands yet + The database has no marques in it. Add some, then reload. +
+ } @else { + @for (group of groupedBrands(); track group.letter) { +{{ item.name }}
-- {{ item.startYear | date:'yyyy' }} - - @if (item.endYear) { - {{ item.endYear | date:'yyyy' }} - } @else { - Present - } -
-brand works!
- -@if (brand?.name) { -Showing models for {{ brand.name }}
-} @else { -Showing models for ...
-} +Fetching models...
- } @else if (models.length === 0) { -No models found.
+ @if (loading()) { ++ We could not load that brand + The database has no marque matching this address. It may have been removed. +
+ } @else if (models().length === 0) { ++ No models recorded + Nothing has been added under {{ brand()?.name }} yet. +
} @else { - @for (item of models; track item) { -{{ item.name }}
- diff --git a/frontend/src/app/browse/generation/generation-item/generation-item.component.ts b/frontend/src/app/browse/generation/generation-item/generation-item.component.ts deleted file mode 100644 index 58d4a8e..0000000 --- a/frontend/src/app/browse/generation/generation-item/generation-item.component.ts +++ /dev/null @@ -1,24 +0,0 @@ -import {Component, Input} from '@angular/core'; -import {ActivatedRoute, Router} from '@angular/router'; -import {Trim} from "../../../../../../library/src/models"; -import {SlugifyPipe} from '../../../slugify-pipe'; - -@Component({ - selector: 'app-generation-item', - imports: [], - templateUrl: './generation-item.component.html', - styleUrl: './generation-item.component.css', - providers: [SlugifyPipe] -}) -export class GenerationItemComponent { - @Input({required: true}) item!: Trim; - - constructor(public router: Router, private route: ActivatedRoute, private pipe: SlugifyPipe) { - } - - public async clicked() { - let trimName = this.pipe.transform(this.item.name); - let trimUrl = trimName + "-" + this.item.id; - await this.router.navigate([trimUrl], {relativeTo: this.route}); - } -} diff --git a/frontend/src/app/browse/generation/generation.component.css b/frontend/src/app/browse/generation/generation.component.css index e69de29..a069e5e 100644 --- a/frontend/src/app/browse/generation/generation.component.css +++ b/frontend/src/app/browse/generation/generation.component.css @@ -0,0 +1,3 @@ +.page { + max-width: 1180px; +} \ No newline at end of file diff --git a/frontend/src/app/browse/generation/generation.component.html b/frontend/src/app/browse/generation/generation.component.html index b69a225..ab6bade 100644 --- a/frontend/src/app/browse/generation/generation.component.html +++ b/frontend/src/app/browse/generation/generation.component.html @@ -1,18 +1,54 @@ -generation works!
+Showing trims for {{ generation.name }}
-} @else { -Showing trims for ...
-} - - -@if (loading) { -Fetching trims...
-} @else if (trims.length === 0) { -No trims found.
-} @else { - @for (item of trims; track item) { -+ We could not load that generation + Nothing in the database matches this address. +
+ } @else if (trims().length === 0) { ++ No trims recorded + The source page listed no variants for this generation. +
+ } @else { + +