Skip to content

Commit

Permalink
fix: datapilot code block ui (#1452)
Browse files Browse the repository at this point in the history
  • Loading branch information
saravmajestic authored Oct 7, 2024
1 parent 058fed6 commit 5336c7a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { QueryAnalysisCommands } from "./commands";
import { AltimateIcon } from "@assets/icons";
import { QueryAnalysisType } from "./types";
import { useMemo } from "react";
import classes from "../../datapilot.module.scss";

const QUERY_HAPPY_LIMIT = 10;
const DefaultActions = [
Expand Down Expand Up @@ -52,7 +53,7 @@ const QueryAnalysis = (): JSX.Element | null => {
<Stack direction="column">
<DatapilotHeader />

<CodeBlock code={chat.query} language="sql" fileName={chat.fileName} />
<CodeBlock code={chat.query} language="sql" fileName={chat.fileName} classname={classes.codeblock}/>
{showLineLimitWarning ? (
<Card>
<CardTitle>
Expand Down
4 changes: 4 additions & 0 deletions webview_panels/src/modules/dataPilot/datapilot.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,7 @@ body {
}}
}
}

.codeblock{
--code-bg: transparent;
}
5 changes: 5 additions & 0 deletions webview_panels/src/uiCore/components/codeblock/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,32 @@ interface Props {
fileName?: string;
showLineNumbers?: boolean;
titleActions?: ReactNode;
classname?: string;
}
const CodeBlockComponent = ({
code,
language,
fileName,
showLineNumbers,
titleActions,
classname
}: Props): JSX.Element => {
const {
state: { theme },
} = useAppContext();
const codeBlockTheme = theme === Themes.Dark ? "dark" : "light";
const editorTheme = theme === Themes.Dark ? "vsc-dark-plus" : "vs";
return (
<div className={classes.codeblock}>
<CodeblockLib
showLineNumbers={showLineNumbers}
code={code}
fileName={fileName}
theme={codeBlockTheme}
editorTheme={editorTheme}
language={language}
titleActions={titleActions}
className={classname}
/>
</div>
);
Expand Down

0 comments on commit 5336c7a

Please sign in to comment.