import { memo } from 'react' import { getErrorColor } from '@app/lib/base-colors' import { Issue } from '@app/types' import SyntaxHighlighter from 'react-syntax-highlighter' type CellIssue = Partial & { hidden?: boolean //the entire section is hidden } export const codeFormatter = (code?: string) => { const codeDisplay = code?.replace(/_+/g, '') const hrefCode = `https://www.w3.org/TR/WCAG20-TECHS/${codeDisplay ?.replace('.Fail', '') ?.replace('.Alpha', '') ?.replace('.BgColour', '') ?.replace('.BgImage', '') ?.replace('.Abs', '') ?.replace('.NoContent', '') ?.replace('.Button.Name', '') ?.replace('.A.Empty', '') ?.substring(codeDisplay?.lastIndexOf('.') + 1)}`.split(',') const codeHref = hrefCode?.length ? hrefCode[hrefCode.length - 1] : '' return { codeDisplay, codeHref, } } // Display issue UI without events export function FeedIssueCardComponent({ message, code, context, type: issueType = 'notice', selector, recurrence, }: CellIssue) { const { codeHref, codeDisplay } = codeFormatter(code) const [m, rec] = message?.split('Recommendation:') || [message, ''] const largeBody = m && m?.length < 80 return (

{selector}

{recurrence ? (

Recurrence: {recurrence}

) : null}
{codeDisplay}
{m} {rec ? ( <> {` Recommendation:`}
{rec}
) : null}
{context ? ( {context} ) : null}
) } export const FeedIssueCard = memo(FeedIssueCardComponent) // list item wrapper of issue cell export function FeedIssueComponent({ message, code, context, type: issueType = 'notice', selector, recurrence, hidden, }: CellIssue) { return (
  • ) } // Generic issue UI display to re-use across application export const FeedIssue = memo(FeedIssueComponent)