diff --git a/README.md b/README.md index 6f951a0..b37da3a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Pricing Calculator -[](https://github.com/sterlingspares/calc/actions/workflows/tests.yml)          +[](https://github.com/sterlingspares/calc/actions/workflows/tests.yml)          **Live app:** [calc.sterlingspares.com](https://calc.sterlingspares.com) @@ -775,7 +775,7 @@ Every number here is reproducible from the repo — none is hand-written. | Metric | Value | Reproduce with | |---|---|---| -| Tests | 1479 passing, 7 suites | `npm test` | +| Tests | 1489 passing, 7 suites | `npm test` | | Statement coverage | **82.7%** (app.js 86.3%, app-extra.js 72.3%) | `npm run coverage` | | Lighthouse Performance | **97** | `npm i -D lighthouse && npm run lighthouse` | | Lighthouse Accessibility | **100** | ” | @@ -812,7 +812,7 @@ commands after significant changes. ## Tests -1479 assertions across seven suites. They load the real `index.html`, +1489 assertions across seven suites. They load the real `index.html`, `assets/styles.css` and both script bundles, and drive the actual application functions — no application code is mocked. **Node 22 or newer.** @@ -823,13 +823,13 @@ npm test | Suite | Assertions | Covers | |---|---|---| -| `features` | 1041 | GST, incentives, quantity, landed costs, rounding, undo/redo of typed values and controls, quote maths, history | +| `features` | 1049 | GST, incentives, quantity, landed costs, rounding, undo/redo of typed values and controls, quote maths, history | | `errors` | 33 | every failure path logs; a clean run stays silent; storage and payload recovery | | `mobile` | 78 | modal layering, touch targets, sticky result bar, responsive quote layouts | | `fab` | 50 | floating action button behaviour and z-index ordering | | `modes` | 85 | solve modes, price input modes, what-if, comparison, Quick mode, wizard, share-link round trip, theming, auto-save | | `a11y` | 104 | contrast ratios, structure, names, keyboard operability, focus trap, live regions, reduced motion, axe-core | -| `browser` | 88 | real Chromium over HTTP: asset loading, CSS cascade, `defer` timing, clicks, dialogs, control-bar spacing, mobile viewport, axe with layout | +| `browser` | 90 | real Chromium over HTTP: asset loading, CSS cascade, `defer` timing, clicks, dialogs, control-bar spacing, mobile viewport, axe with layout | Individual suites: `npm run test:features`, `test:errors`, `test:mobile`, `test:fab`, `test:modes`, `test:a11y`, `test:browser`. Full assertion output: diff --git a/assets/app.js b/assets/app.js index 62b4b0c..1a33d14 100644 --- a/assets/app.js +++ b/assets/app.js @@ -2865,6 +2865,22 @@ function fillSpIncPanel(sp){ R('sp-inc-total-inr',inc>0?SINR(inc):'—'); R('sp-inc-eff-sp',SINR(eff)); } +/** + * Suffix for a discount field. Both discounts are percentages *off MRP* — the + * bare "%" left that to be inferred, and it is the one thing about the field a + * newcomer gets wrong. + * @param {'excl'|'incl'|'manual'} mode the card's input mode + * @param {number} gst whole-number GST rate for that mode + * @returns {string} + */ +function discSuffix(mode,gst){ + /* The single normal space before the "+" is the only break point; everything + either side is joined with non-breaking spaces. In a narrow field the label + then wraps as "% on MRP" / "+ 18% GST" rather than leaving the "+" dangling + at the end of the first line. */ + var base='%\u00A0on\u00A0MRP'; + return (mode==='excl') ? base+' +\u00A0'+gst+'%\u00A0GST' : base; +} /* ── Dynamic GST label updater ── */ function updateGSTLabels(){ var g = Math.round(G * 100); // main mode @@ -2875,9 +2891,9 @@ function updateGSTLabels(){ // Main mode — disc field suffixes var cpSuf=el('cpd-suf'); - if(cpSuf) cpSuf.textContent = (CM==='excl') ? '% + '+g+'% GST' : '%'; + if(cpSuf) cpSuf.textContent = discSuffix(CM,g); var spSuf=el('spd-suf'); - if(spSuf) spSuf.textContent = (SM==='excl') ? '% + '+g+'% GST' : '%'; + if(spSuf) spSuf.textContent = discSuffix(SM,g); // Manual entry sub-tabs R('cpm-incl','CP incl '+g+'% GST'); R('cpm-excl','CP excl '+g+'% GST'); @@ -2907,9 +2923,9 @@ function updateGSTLabels(){ // Quick mode — disc field suffixes var fcCpSuf=el('fc-cpd-suf'); - if(fcCpSuf) fcCpSuf.textContent = (FC_CM==='excl') ? '% + '+fcg+'% GST' : '%'; + if(fcCpSuf) fcCpSuf.textContent = discSuffix(FC_CM,fcg); var fcSpSuf=el('fc-spd-suf'); - if(fcSpSuf) fcSpSuf.textContent = (FC_SM==='excl') ? '% + '+fcg+'% GST' : '%'; + if(fcSpSuf) fcSpSuf.textContent = discSuffix(FC_SM,fcg); // Quick mode manual sub-tabs R('fc-cpms-incl','CP incl '+fcg+'% GST'); R('fc-cpms-excl','CP excl '+fcg+'% GST'); @@ -2917,7 +2933,7 @@ function updateGSTLabels(){ // Wizard — disc field suffix var wzSuf=el('wz-disc-suf'); - if(wzSuf) wzSuf.textContent = (WZ_CM==='excl') ? '% + '+wzg+'% GST' : '%'; + if(wzSuf) wzSuf.textContent = discSuffix(WZ_CM,wzg); // Wizard labels (replaces inline textContent calls in wzSetT) R('wz-ms-incl-lbl', wzLbl+' incl '+wzg+'% GST'); diff --git a/assets/styles.css b/assets/styles.css index 596b421..6153ae1 100644 --- a/assets/styles.css +++ b/assets/styles.css @@ -160,7 +160,13 @@ body{font-family:var(--font-body);background:var(--bg);color:var(--text);min-hei .field input{border:none;outline:none;background:transparent;padding:0 10px;height:38px;font-size:15px;font-family:var(--font-mono);font-weight:500;color:var(--text);width:100%;min-width:0} .field-next{display:none;flex-shrink:0;width:30px;height:30px;border-radius:50%;border:none;background:var(--accent);color:var(--accent-fg);cursor:pointer;margin-right:4px;align-items:center;justify-content:center;transition:opacity .15s;opacity:0.7} .field-next:hover{opacity:1} -.field .field-suf{padding:0 10px;font-size:12px;font-weight:500;color:var(--text3);border-left:1px solid var(--border);height:38px;display:flex;align-items:center;white-space:nowrap;background:var(--surface2);flex-shrink:0} +/* "% on MRP + 18% GST" on one line would take a third of the field. Wrapped to + two it still clears the 38px row, and it balances the two-line mode tabs + directly above. */ +.field .field-suf{padding:0 10px;font-size:12px;font-weight:500;color:var(--text3);border-left:1px solid var(--border);height:38px;display:flex;align-items:center;text-align:right;line-height:1.2;max-width:86px;background:var(--surface2);flex-shrink:0} +/* The hint is not the data — at the input's own size it would not fit what is + left of a narrow field. */ +.field input::placeholder{font-family:var(--font-body);font-size:12.5px} @media(max-width:800px){.field-next{display:flex}} .rows{display:flex;flex-direction:column} .row{display:flex;justify-content:space-between;align-items:baseline;padding:6px 0;border-bottom:1px solid var(--border);gap:8px} @@ -555,7 +561,7 @@ html[data-theme="dark"] .fc-dot.cur{background:var(--text)} /* Set in fcMkField when the prefix is a word ("Discount") rather than a ₹ or % glyph — at 20px heading weight it would crowd out the number. */ .fc-input-sym.word{font-family:var(--font-body);font-size:13px;font-weight:500;padding:0 12px} -.fc-input-suf{padding:0 12px;font-size:13px;font-weight:500;color:var(--text3);border-left:1px solid var(--border);height:56px;display:flex;align-items:center;white-space:nowrap;flex-shrink:0;font-family:var(--font-body)} +.fc-input-suf{padding:0 12px;font-size:13px;font-weight:500;color:var(--text3);border-left:1px solid var(--border);height:56px;display:flex;align-items:center;text-align:right;line-height:1.2;max-width:88px;flex-shrink:0;font-family:var(--font-body)} .fc-mode-tabs{display:flex;gap:6px;flex-wrap:wrap} .fc-tab{padding:6px 12px;border-radius:20px;border:1px solid var(--border-ctrl);background:transparent;font-size:11.5px;font-weight:500;color:var(--text2);cursor:pointer;font-family:var(--font-body);transition:all .15s} @@ -597,7 +603,7 @@ html[data-theme="dark"] .fc-dot.cur{background:var(--text)} .wz-field{display:flex;align-items:center;background:var(--surface2);border:1.5px solid var(--border-ctrl);border-radius:8px;overflow:hidden;flex:1;transition:border .15s} .wz-field:focus-within{border-color:var(--accent)} .wz-sym{padding:0 10px;font-size:13px;font-weight:600;color:var(--text3);border-right:1px solid var(--border);height:36px;display:flex;align-items:center;white-space:nowrap;background:var(--surface)} -.wz-suf{padding:0 10px;font-size:12px;font-weight:500;color:var(--text3);border-left:1px solid var(--border);height:36px;display:flex;align-items:center;white-space:nowrap;flex-shrink:0;background:var(--surface)} +.wz-suf{padding:0 10px;font-size:12px;font-weight:500;color:var(--text3);border-left:1px solid var(--border);height:36px;display:flex;align-items:center;text-align:right;line-height:1.2;max-width:86px;flex-shrink:0;background:var(--surface)} .wz-input{border:none;outline:none;background:transparent;padding:0 10px;height:36px;font-size:15px;font-family:var(--font-mono);font-weight:500;color:var(--text);width:100%;min-width:0;user-select:text;-webkit-user-select:text} .wz-inc-row{display:flex;align-items:center;gap:8px;padding:7px 0;border-bottom:1px solid var(--border)} .wz-inc-row:last-child{border-bottom:none} diff --git a/docs/screenshot-mobile.png b/docs/screenshot-mobile.png index 1255b74..a62910f 100644 Binary files a/docs/screenshot-mobile.png and b/docs/screenshot-mobile.png differ diff --git a/docs/screenshot.png b/docs/screenshot.png index 8f0feae..acd6a80 100644 Binary files a/docs/screenshot.png and b/docs/screenshot.png differ diff --git a/index.html b/index.html index 499ee5b..d0e237c 100644 --- a/index.html +++ b/index.html @@ -265,7 +265,7 @@