All files / player-ui/src/components judgment-table.ts

25% Statements 2/8
0% Branches 0/8
0% Functions 0/3
33.33% Lines 2/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65            48x               48x                                                                                                    
import { css, html, nothing, type CSSResultGroup, type TemplateResult } from 'lit';
import { DataElement } from '../base.ts';
import type { BeMusicJudgmentData } from '../models.ts';
import { structureStyles } from '../styles/structure.ts';
import { stats } from '../templates.ts';
 
const JUDGES = [
  ['PERFECT', 'perfect'],
  ['GREAT', 'great'],
  ['GOOD', 'good'],
  ['BAD', 'bad'],
  ['POOR', 'poor'],
] as const;
export class BeMusicJudgmentTableElement extends DataElement<BeMusicJudgmentData> {
  static override styles: CSSResultGroup = [
    structureStyles,
    css`
      @container be-music (max-width: 22rem) {
        th:nth-child(n + 3),
        td:nth-child(n + 3) {
          display: none;
        }
      }
    `,
  ];
  protected override render(): TemplateResult | typeof nothing {
    const d = this.data;
    if (!d) return nothing;
    return html`<section class="panel" part="panel">
      <h3>Judgments</h3>
      <table part="table">
        <thead>
          <tr>
            <th scope="col">Judge</th>
            <th scope="col">Count</th>
            <th scope="col">Early</th>
            <th scope="col">Late</th>
          </tr>
        </thead>
        <tbody>
          ${JUDGES.map(
            ([judge, key]) =>
              html`<tr>
                <th scope="row">${judge}</th>
                <td>${d[key]}</td>
                <td>${d.earlyLate[judge].early}</td>
                <td>${d.earlyLate[judge].late}</td>
              </tr>`,
          )}
        </tbody>
      </table>
      ${stats([
        ['Empty POOR', d.emptyPoor],
        ['FAST / SLOW', `${d.fast} / ${d.slow}`],
        ['Last judgment', d.lastJudge ?? '—'],
        [
          'Last offset',
          d.lastDeltaMs === undefined ? '—' : `${d.lastDeltaMs > 0 ? '+' : ''}${d.lastDeltaMs.toFixed(1)} ms`,
        ],
      ])}
      <p class="muted">FAST / SLOW totals count GREAT and GOOD.</p>
    </section>`;
  }
}