ElectronicBabylonianLiterature/ebl-frontend

View on GitHub
src/transliteration/ui/line-number.tsx

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
import { TextLine } from 'transliteration/domain/text-line'
import React, { forwardRef, PropsWithChildren } from 'react'
import lineNumberToString from 'transliteration/domain/lineNumberToString'

export function LineNumber({ line }: { line: TextLine }): JSX.Element {
  return <sup>({lineNumberToString(line.lineNumber)})</sup>
}

export const Anchor = forwardRef<
  HTMLAnchorElement,
  PropsWithChildren<{ id: string; className: string }>
>(function Anchor({ id, children, className }, ref): JSX.Element {
  return (
    <a
      className={className}
      id={id}
      href={`#${encodeURIComponent(id)}`}
      ref={ref}
    >
      {children}
    </a>
  )
})