GUI Cheatsheet

p.subtitle — Podtytuł strony kalkulatora

All reusable UI components for kalkulator pages — HTML, CSS & JS reference

1. Text & Number Inputs

2. Unit Badge with cycleUnit()

                    /* HTML pattern */ <div class="input-unit"> <input type="number" id="len" value="1"
                    step="0.1" oninput="calc()"> <span class="unit-badge" onclick="cycleUnit(this)"
                    data-unit="m,cm,mm,ft">m</span> </div> /* JS — getV() handles unit conversion
                    automatically */ const len = getV('len'); // always returns value in SI base unit
                

3. Select / Dropdown

4. Stepper (+/−)

                    function stepperInc(id, step=1) { var el = document.getElementById(id); el.value =
                    (parseFloat(el.value)||0) + step; el.dispatchEvent(new Event('input')); } function stepperDec(id,
                    step=1) { var el = document.getElementById(id); el.value = Math.max(parseFloat(el.min)||0,
                    (parseFloat(el.value)||0) - step); el.dispatchEvent(new Event('input')); }
                

5. Slider with live value

60
45°

6. Toggle Switch

Włączony
Tryb prosty

7. Radio Group

8. Checkbox

9. Result Boxes

                    /* HTML */ <div class="result-box [success|warning|error|empty]" id="box-NAME"> <div
                    class="result-label">Label</div> <span class="result-value"
                    id="res-NAME">—</span> <span class="result-unit">unit</span> </div> /* JS
                    — via shared.js */ setResult('NAME', value); // sets value, removes empty class setResult('NAME',
                    null); // shows —, adds empty class
                

10. Formula Box

S = (2 · L · I · ρ) / (dU/100 · Un)

S — przekrój żyły [mm²]
L — długość kabla w jedną stronę [m]
I — natężenie prądu [A]
ρ — rezystywność materiału [Ω·mm²/m]
dU — dopuszczalny spadek napięcia [%]
Un — napięcie nominalne [V]
                    /* Useful HTML entities for formulas */ · → · (multiply) ÷ → ÷ α → α β → β γ → γ δ → δ λ → λ μ → μ η
                    → η ρ → ρ σ → σ τ → τ ω → ω φ → φ Δ → Δ Σ → Σ Π → Π ∞ → ∞ ² → ² ³ → ³ ½ → ½ Ω → Ω ° → ° ± → ± ≠ → ≠
                    ≤ → ≤ ≥ → ≥ √ → √ ∑ → ∑
                

11. Progress Bars

Postęp60%
OK85%
Uwaga72%
Przekroczono95%
40%

12. Alerts / Callouts

ℹ️ Informacja: wynik obliczono przy założeniu przepływu laminarnego.
✅ Przekrój spełnia wymagania normy PN-EN.
⚠️ Temperatura zbliża się do wartości granicznej.
❌ Błąd: wprowadź wartości większe od zera.

13. Badges & Pills

Hydraulika ✓ OK Błąd Uwaga todo v2.1 done

14. Buttons

Primary

Secondary / outline

Sizes

Icon buttons

15. Table

Symbol Opis Jednostka Wartość
Re Liczba Reynoldsa 2300
v Prędkość przepływu m/s 1.42
D Średnica rury mm 50
ν Lepkość kinematyczna m²/s 1.0×10⁻⁶
λ Współczynnik oporów 0.028

16. Tabs

Formularz dla rury okrągłej: D, L, Q…
Formularz dla przekroju prostokątnego: a × b, L…
Tu wstaw tabelę wyników porównawczych.

17. Accordion

Tutaj możesz wstawić wzory, wyprowadzenia lub słownik symboli używanych w kalkulatorze.
Dana rura stalowa DN50, długość 10 m, przepływ 1 l/s. Oblicz prędkość i liczbę Reynoldsa.
PN-EN 806, PN-EN 1057, Rozporządzenie MTiGM 2002, Knapp R. — Cavitation, 1970.

18. Tooltip

To jest tooltip z dodatkową informacją
Re = ? Re = v·D/ν — Liczba Reynoldsa
Przepływ laminarny Re < 2300

20. Skeleton Loader

21. Copy Button

Re = v·D/ν = 1.42·0.05/1e-6 = 71000

22. Star Rating

Ocena: 3/5

23. Tag Input

Hydraulika Przepływ

24. Big Number Display

2300
Liczba Reynoldsa Re
1.42m/s
Prędkość przepływu v
87%
Sprawność pompy

25. Colour Palette (CSS variables)

primary
primary-tint
success
success-tint
warning
warning-tint
error
error-tint
text
muted
border
bg
bg-card

26. Typography Scale

h1 — Nagłówek strony

h2 — Sekcja

h3 — Podsekcja

p — Tekst akapitu. Lorem ipsum dolor sit amet consectetur.

small/muted — Dodatkowe info, opisy pól

code — wzór inline: Re = v·D/ν

bold · italic · sub · sup · del

27. Layout Classes

                    /* Sections */ <div class="section"> — full width section, card background <div
                    class="section section--narrow"> — narrower, centered /* Column layouts */ <div
                    class="one-column"> — single column (inputs top, results below) <div class="two-columns"> —
                    inputs left | results right (responsive) /* Input group */ <div class="field"> — label + input
                    wrapper <div class="input-unit"> — input + unit badge side by side /* Shape forms (for
                    multi-shape calculators) */ <div class="shape-form" id="form-NAME"> — hidden by default
                    <div class="shape-form active"> — visible form /* switchForm('NAME', calc) from shared.js
                    toggles these */
                

28. Circular Progress (SVG)

70%
primary
85%
success
95%
error
                    /* SVG circular progress — circumference = 2πr = 2π×32 ≈ 201 */ /* stroke-dashoffset = 201 × (1 -
                    percentage/100) */ /* 0%→201, 50%→100.5, 70%→60, 100%→0 */ <circle r="32" stroke-dasharray="201"
                    stroke-dashoffset="60" .../>
                

29. Range Knob (dial-style)

25

30. shared.js API Reference

                    /* ── Reading inputs ── */ getV('id') // read input, auto-convert unit badge → SI base unit //
                    returns NaN if empty/invalid /* ── Writing results ── */ setResult('id', value) // set result-box
                    value; null → shows '—' + adds .empty clearResults(['a','b']) // setResult(id, null) for each id /*
                    ── Unit badge ── */ cycleUnit(badgeEl) // click handler — converts value, cycles to next unit /* ──
                    Multi-form (shape pickers) ── */ switchForm('name', calcFn) // shows #form-name, hides others, calls
                    calcFn /* ── URL state ── */ saveToUrl() // saves all input[id] values to URL hash (auto-called)
                    loadFromUrl() // restores from hash, returns true if any found /* ── Formatting ── */ formatNum(n)
                    // toPrecision(4) as float — e.g. 1.2345678 → 1.235 /* ── Auto-init ── */ // On DOMContentLoaded:
                    loadFromUrl() || calc() // calc() must be defined in script.js
                

31. Full calc() Pattern (script.js template)

                    /* script.js — standard pattern for a single-formula calculator */ function calc() { // 1. Read
                    inputs (auto-converts units via shared.js getV) const v = getV('velocity'); // m/s const D =
                    getV('diameter'); // m (even if badge shows mm) const nu = getV('viscosity'); // m²/s // 2. Validate
                    — clear and bail if invalid if ([v, D, nu].some(isNaN) || v <= 0 || D <= 0 || nu <= 0) {
                    clearResults(['re', 'regime']); return; } // 3. Compute const Re = v * D / nu; // 4. Write outputs
                    setResult('re', Re); setResult('regime', Re < 2300 ? 'Laminarny' : Re < 4000 ? 'Przejściowy' :
                    'Turbulentny'); // 5. Optional: update result box class for colour coding
                    document.getElementById('box-regime').className = 'result-box ' + (Re < 2300 ? 'success' : Re < 4000
                    ? 'warning' : 'error'); } calc(); // run on load so defaults populate immediately