All files / components TextSection.tsx

0% Statements 0/6
0% Branches 0/5
0% Functions 0/2
0% Lines 0/5

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                                                                                                                         
import { Division } from '../lib/graphql-utils'
import TextDivision from './TextDivision'
import { getIcon } from '../components/MaterialIcon'
 
interface TextSectionProps {
  sectionName?: string
  divisions: Division[]
  aaPrefix: string
  icon?: string
}
 
const TextSection = ({
  sectionName,
  divisions,
  aaPrefix,
  icon,
}: TextSectionProps) => {
  const divisionsJsx = (
    <>
      {divisions.map((division: Division, index) => {
        return (
          <TextDivision
            key={index}
            divisionType={division.divisionType}
            divisionPartitions={division.divisionPartitions}
            subDivisions={division.subDivisions}
            aaPrefix={aaPrefix}
          />
        )
      })}
    </>
  )
  const divisionsWithOrWithoutIconJsx =
    icon === undefined || icon.trim() === '' ? (
      <div>{divisionsJsx}</div>
    ) : (
      <div className="grid gap-4 md:grid-cols-12">
        <div className="col-span-1 col-start-1 row-start-1 justify-self-center text-xl">
          {getIcon(icon)}
        </div>
        <div className="col-span-12 col-start-1 row-start-2 md:col-span-11 md:col-start-2 md:row-start-1">
          {divisionsJsx}
        </div>
      </div>
    )
  return (
    <>
      {sectionName ? (
        <h2 className="pb-4 font-display text-32px font-bold text-gray-darker md:text-36px">
          {sectionName}
        </h2>
      ) : (
        ''
      )}
      {divisionsWithOrWithoutIconJsx}
    </>
  )
}
 
export default TextSection