Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: datapilot code block ui #1452

Merged
merged 1 commit into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename classname to className to follow camelCase convention.

Suggested change
classname?: string;
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