13 lines
793 B
Plaintext
13 lines
793 B
Plaintext
<%/* delta-pill.ejs — renders a Δ-pill span.
|
||
Locals:
|
||
value {number|null} — the delta value (null/undefined → flat pill with '—')
|
||
extraClass {string} — optional additional CSS class (e.g. 'delta-predicted-pill')
|
||
*/%>
|
||
<%
|
||
const _isNull = (typeof value === 'undefined' || value == null);
|
||
const _cls = _isNull ? 'flat' : value > 0 ? 'up' : value < 0 ? 'down' : 'flat';
|
||
const _glyph = (_isNull || value === 0) ? '–' : value > 0 ? '▲' : '▼';
|
||
const _num = _isNull ? '—' : value > 0 ? '+' + value : value.toString();
|
||
const _xtra = (typeof extraClass !== 'undefined' && extraClass) ? ' ' + extraClass : '';
|
||
%><span class="delta-pill <%= _cls %><%= _xtra %>"><span class="delta-glyph"><%= _glyph %></span><span class="delta-num"><%= _num %></span></span>
|