All files / Bandstand/src/components/cues CueView.tsx

41.02% Statements 16/39
16.66% Branches 1/6
100% Functions 1/1
41.02% Lines 16/39

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      1x             13x 13x 13x 13x 13x 13x             13x 13x 13x 13x         13x 13x                                       13x               13x   13x  
'use client'
 
import type {Cue} from '@/lib/cues'
import NotationBlock from '@/components/chart/NotationBlock'
 
/**
 * One personal cue as it reads on the chart. Sized in em, so it follows the
 * chart's text size (and performance mode's fitting). Only its owner ever
 * sees it.
 */
export default function CueView({
  cue,
  songKey,
  steps = 0,
  where,
}: {
  cue: Cue
  songKey?: string | null
  /** Semitones the chart is shown transposed by (notation follows) */
  steps?: number
  /** For a cue whose section is gone: "was on Chorus 2" */
  where?: string
}) {
  return (
    <div className="chart-cue mb-[0.5em] rounded-r-md border-l-[0.22em] border-amber bg-panel px-[0.6em] py-[0.35em] text-[0.82em]">
      {where && (
        <span className="mb-[0.2em] block text-[0.8em] text-faint">
          {where}
        </span>
      )}
      {cue.kind === 'TEXT' && <p className="whitespace-pre-wrap">{cue.text}</p>}
      {cue.kind === 'IMAGE' && cue.image && (
        <figure>
          {/* eslint-disable-next-line @next/next/no-img-element */}
          <img
            src={cue.image.url}
            alt={cue.text ?? 'Your picture'}
            width={cue.image.width}
            height={cue.image.height}
            // Its own aspect ratio, so fitting the chart to the screen can
            // measure it before it has loaded
            style={{aspectRatio: `${cue.image.width} / ${cue.image.height}`}}
            className="h-auto w-full max-w-full rounded bg-white"
          />
          {cue.text && (
            <figcaption className="mt-[0.2em] text-[0.85em] text-muted">
              {cue.text}
            </figcaption>
          )}
        </figure>
      )}
      {cue.kind === 'ABC' && cue.text && (
        <NotationBlock
          label="Your notation"
          abc={cue.text}
          songKey={songKey ?? null}
          steps={steps}
        />
      )}
    </div>
  )
}