UNPKG

@airplane/views

Version:

A React library for building Airplane views. Views components are optimized in style and functionality to produce internal apps that are easy to build and maintain.

60 lines (59 loc) 1.75 kB
import { jsx } from "react/jsx-runtime"; import { createStyles } from "@mantine/core"; import { Prism } from "@mantine/prism"; import dracula from "../../externals/prism-react-renderer/themes/dracula/index.js"; import github from "../../externals/prism-react-renderer/themes/github/index.js"; import { ComponentErrorBoundary } from "../errorBoundary/ComponentErrorBoundary.js"; import { useCommonLayoutStyle } from "../layout/useCommonLayoutStyle.js"; const useStyles = createStyles((theme) => ({ lineNumber: { marginRight: theme.spacing.md, color: theme.colors.gray[3] }, copy: { color: theme.colors.gray[4] } })); const CodeComponent = ({ children, theme = "light", language, className, style, width, height, grow, copy = true, ...restProps }) => { const { classes } = useStyles(); const { classes: layoutClasses } = useCommonLayoutStyle({ width, height, grow }); let prismLanguage; if (language === "pgsql" || language === "mysql") { prismLanguage = "sql"; } else if (language === "none") { prismLanguage = "none"; } else { prismLanguage = language; } return /* @__PURE__ */ jsx(Prism, { className, style, colorScheme: theme, classNames: { lineNumber: classes.lineNumber, copy: classes.copy, scrollArea: layoutClasses.style }, getPrismTheme: (_theme, colorScheme) => colorScheme === "light" ? github : dracula, language: prismLanguage, noCopy: !copy, ...restProps, children }); }; const Code = (props) => /* @__PURE__ */ jsx(ComponentErrorBoundary, { componentName: Code.displayName, children: /* @__PURE__ */ jsx(CodeComponent, { ...props }) }); Code.displayName = "Code"; export { Code, CodeComponent }; //# sourceMappingURL=Code.js.map