All files / src/components/Code SingleLineRenderer.tsx

0% Statements 0/4
100% Branches 0/0
0% Functions 0/3
0% Lines 0/4

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                                                     
import { Box, Flex, Grid } from "@chakra-ui/react";
import type { FunctionComponent } from "react";
import type { RendererProps } from "./types";
import { CopyButton } from "../CopyButton";
 
export const SingleLineRenderer: FunctionComponent<RendererProps> = ({
  code,
  tokens,
  getLineProps,
  getTokenProps,
}) => (
  <Grid p={3} templateColumns="1fr min-content" w="full">
    <Box m={-3} maxW="full" overflow="auto" p={3}>
      {tokens.map((line, i) => (
        <div key={i} {...getLineProps({ line, key: i })}>
          {line.map((token, key) => (
            <span key={key} {...getTokenProps({ token, key })} />
          ))}
        </div>
      ))}
    </Box>
    <Flex align="center" ml={1}>
      <CopyButton value={code} />
    </Flex>
  </Grid>
);