feat: Add Python consistency tests for calculator definitions and refactor QuickConversionTable to explicitly pass calculator configuration to its row builder.
This commit is contained in:
@@ -8,8 +8,8 @@
|
||||
|
||||
type Row = { input: number; output: string };
|
||||
|
||||
const buildRow = (value: number): Row => {
|
||||
const formatted = solve(config, 1, value.toString(), '', '');
|
||||
const buildRow = (value: number, c: CalculatorDef): Row => {
|
||||
const formatted = solve(c, 1, value.toString(), '', '');
|
||||
return {
|
||||
input: value,
|
||||
output: formatted.val2 || '—',
|
||||
@@ -22,8 +22,8 @@
|
||||
let outputLabel = 'target units';
|
||||
|
||||
$: supportsTable = ['standard', 'inverse'].includes(config.type);
|
||||
$: rows = supportsTable
|
||||
? numericSamples.map(buildRow)
|
||||
$: rows = (config && supportsTable)
|
||||
? numericSamples.map(v => buildRow(v, config))
|
||||
: [];
|
||||
$: inputLabel = config.labels?.in1 ?? 'source units';
|
||||
$: outputLabel = config.labels?.in2 ?? 'target units';
|
||||
|
||||
@@ -82,7 +82,9 @@
|
||||
|
||||
<h1 class="page-title calculator-page-title">{calc.name}</h1>
|
||||
|
||||
<Calculator config={calc} showTitle={false} />
|
||||
{#key calc.slug}
|
||||
<Calculator config={calc} showTitle={false} />
|
||||
{/key}
|
||||
|
||||
<div class="seo-content">
|
||||
{#if calc.descriptionHTML}
|
||||
|
||||
Reference in New Issue
Block a user