created:3/5/2021
updated:3/5/2021
loc
105
comments
34%
passed
12
coverage
55%

SyntaxHighlighter

avatar of atanasster

Syntax highlighter component using prism for the actual source display.

Overview

import { Button } from 'theme-ui';

Test data

select
#
dark
children
1
Johnny Oberbrunner
2
Jolie Beahan Sr.
3
Cleo Lindgren
4
Tyler Blanda
5
Krista Zulauf
5 data rows

Controls

Name
Description
Default
Controls
children

source code to be displayed.

(string & (boolean | ReactChild | ReactFragment | ReactPortal | null))
dark

used to specify a "dark" color theme - applcable only if no custom theme prop is provided. if dark: true, duotoneDark theme is used. if dark: false, duotoneLight theme is used.

boolean
false

Tests results

Status
Full name
Title
Time(ms)
SyntaxHighlighter.test.ts(12 tests)
passed
SyntaxHighlighter > overview > 1
snapshot
75
passed
SyntaxHighlighter > overview > 1
accessibility
101
passed
SyntaxHighlighter > overview > 2
snapshot
40
passed
SyntaxHighlighter > overview > 2
accessibility
61
passed
SyntaxHighlighter > overview > 3
snapshot
35
passed
SyntaxHighlighter > overview > 3
accessibility
72
passed
SyntaxHighlighter > overview > 4
snapshot
42
passed
SyntaxHighlighter > overview > 4
accessibility
101
passed
SyntaxHighlighter > overview > 5
snapshot
60
total 12 tests

Tests coverage

Kind
Total
Covered
Skipped
%
SyntaxHighlighter.tsx
lines
30
22
0
73.33%
functions
11
6
0
54.54%
statements
33
24
0
72.72%
branches
22
14
0
63.63%

A11y tests

import { Button } from 'theme-ui';
 
impact
id
description
serious
color-contrast

Ensures the contrast between foreground and background colors meets WCAG 2 AA contrast ratio thresholds...

summary
target
Fix any of the following: Element has insufficient color contrast of 3.04 (foreground color: #728fcb, background color: #faf8f5, font size: 12.0pt (16px), font weight: normal). Expected contrast ratio of 4.5:1
.rah-static--height-auto.rah-static[aria-hidden="false"] > div > .css-154oin1[data-testid="story"] > .story-render-container.css-dhmrnb > .prism-code.language-jsx > .token-line.css-vurnku
Fix any of the following: Element has insufficient color contrast of 3.04 (foreground color: #728fcb, background color: #faf8f5, font size: 12.0pt (16px), font weight: normal). Expected contrast ratio of 4.5:1
.rah-static--height-auto.rah-static[aria-hidden="false"] > div > .css-154oin1[data-testid="story"] > .story-render-container.css-dhmrnb > .prism-code.language-jsx > .token-line.css-vurnku
Fix any of the following: Element has insufficient color contrast of 3.04 (foreground color: #728fcb, background color: #faf8f5, font size: 12.0pt (16px), font weight: normal). Expected contrast ratio of 4.5:1
.rah-static--height-auto.rah-static[aria-hidden="false"] > div > .css-154oin1[data-testid="story"] > .story-render-container.css-dhmrnb > .prism-code.language-jsx > .token-line.css-vurnku
Fix any of the following: Element has insufficient color contrast of 3.04 (foreground color: #728fcb, background color: #faf8f5, font size: 12.0pt (16px), font weight: normal). Expected contrast ratio of 4.5:1
.rah-static--height-auto.rah-static[aria-hidden="false"] > div > .css-154oin1[data-testid="story"] > .story-render-container.css-dhmrnb > .prism-code.language-jsx > .token-line.css-vurnku

Viewport

import { Button } from 'theme-ui';
320px
import { Button } from 'theme-ui';
375px
import { Button } from 'theme-ui';
768px
import { Button } from 'theme-ui';
1024px