mirror of
https://github.com/ente-io/ente.git
synced 2025-05-24 20:19:17 +00:00
39 lines
943 B
TypeScript
39 lines
943 B
TypeScript
import EnteSpinner from "@ente/shared/components/EnteSpinner";
|
|
import { type BoxProps, styled } from "@mui/material";
|
|
import React from "react";
|
|
import CopyButton from "./CopyButton";
|
|
import { CodeWrapper, CopyButtonWrapper, Wrapper } from "./styledComponents";
|
|
|
|
type Iprops = React.PropsWithChildren<{
|
|
code: string | null;
|
|
}>;
|
|
|
|
export default function CodeBlock({
|
|
code,
|
|
...props
|
|
}: BoxProps<"div", Iprops>) {
|
|
if (!code) {
|
|
return (
|
|
<Wrapper>
|
|
<EnteSpinner />
|
|
</Wrapper>
|
|
);
|
|
}
|
|
return (
|
|
<Wrapper {...props}>
|
|
<CodeWrapper>
|
|
<FreeFlowText>{code}</FreeFlowText>
|
|
</CodeWrapper>
|
|
<CopyButtonWrapper>
|
|
<CopyButton code={code} />
|
|
</CopyButtonWrapper>
|
|
</Wrapper>
|
|
);
|
|
}
|
|
|
|
const FreeFlowText = styled("div")`
|
|
word-break: break-word;
|
|
min-width: 30%;
|
|
text-align: left;
|
|
`;
|