From bb118dba8d7851ca394c81901796027ce7edcb25 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 18 Nov 2026 16:08:04 -0500 Subject: [PATCH] Tires tab: tire size and cold pressures up top, the sheet's own tire section below The tab shows the car sheet's Tires and wheels section alone (same wording, write-in blanks and correction form), under three figures from the closest NHTSA test vehicle. A mismatch (other model year or version) is stated and marked; the door placard governs. No values are shown when none were tested. Co-Authored-By: Claude Fable 5.2 --- public/app.js | 1 + public/index.html | 7 +++++-- public/market.css | 28 ++++++++++++++++++++++++---- public/report-tabs.js | 4 ++-- public/tires-tab.js | 43 +++++++++++++++++++++++++++++++++++++++++++ tests/market.test.mjs | 29 +++++++++++++++++++++++++---- 6 files changed, 100 insertions(+), 12 deletions(-) create mode 100644 public/tires-tab.js diff --git a/public/app.js b/public/app.js index 2d79076..bae44cc 100644 --- a/public/app.js +++ b/public/app.js @@ -148,6 +148,7 @@ function renderResults(report) { if (typeof window !== 'undefined') window.VinWorkspace?.reportUpdated(report); window.ReportTabs?.reportUpdated(report); // tab bar over the report (public/report-tabs.js) window.Market?.render(report); // Price tab: local asking prices and cars for sale (public/market.js) + window.TiresTab?.render(report); // Tires tab: size and pressures up top (public/tires-tab.js) } // ── Hero ── diff --git a/public/index.html b/public/index.html index d5731a4..3b7848e 100644 --- a/public/index.html +++ b/public/index.html @@ -97,7 +97,7 @@ - + @@ -129,11 +129,14 @@
+
+ +
@@ -456,4 +459,4 @@ -
+
diff --git a/public/market.css b/public/market.css index 5d96fb6..2bb6b14 100644 --- a/public/market.css +++ b/public/market.css @@ -14,9 +14,15 @@ .market{margin:20px 0 36px} @media screen{ #results[data-tab=sheet] .report-nav-title{display:none} - #results:not([data-tab=sheet]) #car-sheet{display:none} + #results:not([data-tab=sheet],[data-tab=tires]) #car-sheet{display:none} + /* Tires tab: the sheet's own tire section alone, under the figures (public/tires-tab.js) */ + #results:not([data-tab=tires]) #tires-quick{display:none} + #results[data-tab=tires] #car-sheet>.sheet-head,#results[data-tab=tires] #car-sheet>.sheet-foot,#results[data-tab=tires] .sheet-body>.sheet-section:not(.sheet-tires){display:none} + #results[data-tab=tires] .sheet-body{display:block} + #results[data-tab=tires] .sheet-tires>h3{display:none} + #results[data-tab=tires] .car-sheet{margin-top:16px} #results:not([data-tab=price]) #market-panel{display:none} - #results[data-tab=sheet] .cards-grid,#results[data-tab=price] .cards-grid{display:none} + #results[data-tab=sheet] .cards-grid,#results[data-tab=price] .cards-grid,#results[data-tab=tires] .cards-grid{display:none} #results .car-sheet{margin-top:20px} #results .cards-grid{margin-top:20px} #results[data-tab=safety] .cards-grid>.card:not(#card-recalls,#card-safety-ratings,#card-complaints,#card-safety-equip){display:none} @@ -24,7 +30,18 @@ #results[data-tab=safety] #card-recalls{order:-1} #results[data-tab=specs] .cards-grid>.card:is(#card-recalls,#card-safety-ratings,#card-complaints,#card-safety-equip,#card-raw){display:none} } -@media print{.report-nav,#market-panel{display:none!important}} +@media print{.report-nav,#market-panel,#tires-quick{display:none!important}} + +/* ── Tires tab: figures ── */ +.tires-quick{margin:20px 0 0} +.tires-quick .eyebrow{margin-bottom:10px} +.tires-tiles{grid-template-columns:minmax(0,2fr) minmax(0,1fr) minmax(0,1fr)} +.tires-tiles .market-tile-main b{font-size:clamp(19px,5.4vw,28px);letter-spacing:-.4px;overflow-wrap:anywhere} +.tires-tiles b.tires-two{font-size:18px} +.tires-basis{margin:10px 2px 0;font-size:12px;line-height:1.6;color:var(--text-muted);max-width:760px} +.tires-basis strong{color:var(--text-dim);font-weight:650} +.tires-basis-near{color:var(--orange)} +.tires-basis-near strong{color:var(--orange)} /* ── Price tab ── */ .market-head{display:flex;align-items:flex-end;justify-content:space-between;gap:20px;flex-wrap:wrap;margin-bottom:16px} @@ -112,7 +129,10 @@ @media(max-width:560px){ .report-nav{margin:14px -16px 0;padding:6px 16px 0} .report-tabs{margin:0 -16px;padding:0 10px} - .report-tabs button{padding:10px 10px;font-size:13.5px} + .report-tabs button{padding:10px 7px;font-size:13px} + .tab-figure{padding:2px 6px} + .tires-tiles{grid-template-columns:1fr 1fr} + .tires-tiles .market-tile-main{grid-column:1/-1} .market-head{align-items:stretch;flex-direction:column;gap:12px} .market-form label{flex:1 1 0} .market-form input{width:100%} diff --git a/public/report-tabs.js b/public/report-tabs.js index a7d63b9..96ee4c7 100644 --- a/public/report-tabs.js +++ b/public/report-tabs.js @@ -1,9 +1,9 @@ -/* Tabs over the VIN report: Overview (the car sheet), Price, Safety, Specs, All data. +/* Tabs over the VIN report: Overview (the car sheet), Price, Tires, Safety, Specs, All. * One attribute does the work: #results[data-tab]. The style sheet (market.css) shows the matching view on screen; * print ignores the tabs and prints the full report as before. The choice is kept in the address as ?tab=price, * because the #hash already names the workspace view. */ const ReportTabs = (() => { - const TABS = ['sheet', 'price', 'safety', 'specs', 'all']; + const TABS = ['sheet', 'price', 'tires', 'safety', 'specs', 'all']; const listeners = []; let current = 'sheet'; diff --git a/public/tires-tab.js b/public/tires-tab.js new file mode 100644 index 0000000..7831c44 --- /dev/null +++ b/public/tires-tab.js @@ -0,0 +1,43 @@ +/* Tires tab: the quick view above the car sheet's own "Tires and wheels" section. + * The tab shows that section alone (market.css), so its wording, write-in blanks and correction form are the same + * ones as on the sheet. This file adds only the figures up top: tire size and cold pressures of the closest vehicle + * NHTSA tested (report field tire_placard), with how it matches this VIN. The owner's door placard governs. */ +const TiresTab = (() => { + const esc = s => String(s ?? '').replace(/[&<>"']/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c])); + const same = v => JSON.stringify([v.tires, v.cold_pressure_psi, v.cold_pressure_kpa]); + const kpa = n => Number.isInteger(n) ? String(n) : String(Math.round(n * 10) / 10); + + /** One short sentence on how the tested vehicle matches this VIN; the full wording is in the section below. */ + function basisText(group) { + const m = group[0].match || {}; + if (!m.kind || m.kind === 'exact') return 'From the vehicle NHTSA tested for this model year.'; + if (m.kind === 'different_variant') return 'From a different version NHTSA tested for this model year.'; + const years = [...new Set(group.map(x => x.match && x.match.tested_model_year).filter(Boolean))].sort(); + return `From NHTSA’s ${years.join(' and ')} test vehicle${years.length > 1 ? 's' : ''}; yours is ${m.vin_model_year}.`; + } + + /** The figures block, or '' when NHTSA's test vehicles give no values for this VIN. `tested` = CarSheet.testedPlacards(). */ + function quickHtml(tested) { + if (!tested || !tested.length) return ''; + const v = tested[0], group = tested.filter(x => same(x) === same(v)); + const others = new Set(tested.map(same)).size - 1; + const exact = group.every(x => !x.match || x.match.kind === 'exact'); + const size = v.tires.front === v.tires.rear + ? `${esc(v.tires.front)}front and rear` + : `${esc(v.tires.front)}front${esc(v.tires.rear)}rear`; + const psi = (label, side) => `
${label}, cold${esc(v.cold_pressure_psi[side])} psi${esc(kpa(v.cold_pressure_kpa[side]))} kPa
`; + return `
Tire size${size}
${psi('Front', 'front')}${psi('Rear', 'rear')}
+

${esc(basisText(group))} Your door placard governs.${others > 0 ? ` ${others} other tested version${others > 1 ? 's list' : ' lists'} different values below.` : ''}

`; + } + + function render(report) { + const box = typeof document !== 'undefined' && document.querySelector('#tires-quick'); + if (!box) return; + const sheet = typeof window !== 'undefined' && window.CarSheet; + const html = sheet ? quickHtml(sheet.testedPlacards(report?.tire_placard)) : ''; + box.innerHTML = `

TIRES

${html || '

No tire values from an NHTSA test vehicle for this car. The sizes and pressures are on the placard on the driver’s door pillar.

'}`; + } + + return { basisText, quickHtml, render }; +})(); +if (typeof window !== 'undefined') window.TiresTab = TiresTab; diff --git a/tests/market.test.mjs b/tests/market.test.mjs index cf6a60e..44cc6dd 100644 --- a/tests/market.test.mjs +++ b/tests/market.test.mjs @@ -96,7 +96,7 @@ test('Price tab: outage and empty answers say so plainly', () => { test('report tabs: the tab lives in ?tab= and Overview is the default', () => { const T = page('report-tabs.js', 'ReportTabs'); - assert.deepEqual([...T.TABS], ['sheet', 'price', 'safety', 'specs', 'all']); + assert.deepEqual([...T.TABS], ['sheet', 'price', 'tires', 'safety', 'specs', 'all']); assert.equal(T.fromSearch('?tab=price'), 'price'); assert.equal(T.fromSearch('?tab=nonsense'), 'sheet'); assert.equal(T.fromSearch(''), 'sheet'); @@ -110,10 +110,31 @@ test('report tabs: the tab lives in ?tab= and Overview is the default', () => { test('report page: tab bar, price panel and their scripts are in place; print still shows the whole report', () => { const html = readFileSync(new URL('../public/index.html', import.meta.url), 'utf8'); - for (const tab of ['sheet', 'price', 'safety', 'specs', 'all']) assert.ok(html.includes(`data-report-tab="${tab}"`), tab); + for (const tab of ['sheet', 'price', 'tires', 'safety', 'specs', 'all']) assert.ok(html.includes(`data-report-tab="${tab}"`), tab); assert.ok(html.includes('id="market-panel"')); assert.ok(html.indexOf('/report-tabs.js') < html.indexOf('/app.js') && html.indexOf('/market.js') < html.indexOf('/app.js')); const css = readFileSync(new URL('../public/market.css', import.meta.url), 'utf8'); - assert.match(css, /@media screen\{[\s\S]*#results:not\(\[data-tab=sheet\]\) #car-sheet\{display:none\}/); // hiding is screen-only - assert.match(css, /@media print\{\.report-nav,#market-panel\{display:none!important\}\}/); + assert.match(css, /@media screen\{[\s\S]*#results:not\(\[data-tab=sheet\],\[data-tab=tires\]\) #car-sheet\{display:none\}/); // hiding is screen-only + assert.match(css, /@media print\{\.report-nav,#market-panel,#tires-quick\{display:none!important\}\}/); + assert.ok(html.includes('id="tires-quick"') && html.indexOf('/tires-tab.js') < html.indexOf('/app.js')); +}); + +test('Tires tab: figures come from the closest NHTSA test vehicle, with the match stated and the placard governing', () => { + const T = page('tires-tab.js', 'TiresTab'); + const v = {tested_as: '2019 Honda CR-V AWD LX 5-Door MPV', tires: {front: 'P235/65R17 104H', rear: 'P235/65R17 104H'}, + cold_pressure_psi: {front: 32, rear: 30}, cold_pressure_kpa: {front: 220, rear: 210}, match: {kind: 'nearest_model_year', tested_model_year: 2019, vin_model_year: 2021}}; + const html = T.quickHtml([v]); + assert.match(html, /Tire size<\/span>P235\/65R17 104H<\/b>front and rear/); + assert.match(html, /Front, cold<\/span>32 psi<\/b>220 kPa/); + assert.match(html, /Rear, cold<\/span>30 psi<\/b>210 kPa/); + assert.match(html, /tires-basis-near">From NHTSA’s 2019 test vehicle; yours is 2021\.<\/strong> Your door placard governs\./); // a mismatch is stated and marked + const exact = T.quickHtml([{...v, match: {kind: 'exact'}}]); + assert.doesNotMatch(exact, /tires-basis-near/); + assert.match(exact, /From the vehicle NHTSA tested for this model year\./); + assert.match(T.quickHtml([{...v, match: {kind: 'different_variant'}}]), /tires-basis-near">From a different version NHTSA tested for this model year\./); + const staggered = {...v, tested_as: 'Another version', tires: {front: '245/40R19 98Y', rear: '275/35R19 <100Y>'}, cold_pressure_psi: {front: 35, rear: 38}}; + const two = T.quickHtml([staggered, v]); + assert.match(two, /245\/40R19 98Y<\/b>front<\/small>[\s\S]*275\/35R19 <100Y><\/b>rear/); + assert.match(two, /1 other tested version lists different values below\./); + assert.equal(T.quickHtml([]), ''); // nothing tested: no figures, never a guess });