fix: t2c settings dialog spacing for apps that use CSS resets (#7337)
This commit is contained in:
parent
3d1631f375
commit
fda5c6fdf7
15
src/components/InlineIcon.tsx
Normal file
15
src/components/InlineIcon.tsx
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
export const InlineIcon = ({ icon }: { icon: JSX.Element }) => {
|
||||||
|
return (
|
||||||
|
<span
|
||||||
|
style={{
|
||||||
|
width: "1em",
|
||||||
|
margin: "0 0.5ex 0 0.5ex",
|
||||||
|
display: "inline-block",
|
||||||
|
lineHeight: 0,
|
||||||
|
verticalAlign: "middle",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{icon}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
};
|
@ -2,28 +2,14 @@ import { useState } from "react";
|
|||||||
import { Dialog } from "./Dialog";
|
import { Dialog } from "./Dialog";
|
||||||
import { TextField } from "./TextField";
|
import { TextField } from "./TextField";
|
||||||
import { MagicIcon, OpenAIIcon } from "./icons";
|
import { MagicIcon, OpenAIIcon } from "./icons";
|
||||||
|
|
||||||
import "./MagicSettings.scss";
|
|
||||||
import { FilledButton } from "./FilledButton";
|
import { FilledButton } from "./FilledButton";
|
||||||
import { CheckboxItem } from "./CheckboxItem";
|
import { CheckboxItem } from "./CheckboxItem";
|
||||||
import { KEYS } from "../keys";
|
import { KEYS } from "../keys";
|
||||||
import { useUIAppState } from "../context/ui-appState";
|
import { useUIAppState } from "../context/ui-appState";
|
||||||
|
import { InlineIcon } from "./InlineIcon";
|
||||||
|
import { Paragraph } from "./Paragraph";
|
||||||
|
|
||||||
const InlineButton = ({ icon }: { icon: JSX.Element }) => {
|
import "./MagicSettings.scss";
|
||||||
return (
|
|
||||||
<span
|
|
||||||
style={{
|
|
||||||
width: "1em",
|
|
||||||
margin: "0 0.5ex 0 0.5ex",
|
|
||||||
display: "inline-block",
|
|
||||||
lineHeight: 0,
|
|
||||||
verticalAlign: "middle",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{icon}
|
|
||||||
</span>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const MagicSettings = (props: {
|
export const MagicSettings = (props: {
|
||||||
openAIKey: string | null;
|
openAIKey: string | null;
|
||||||
@ -70,18 +56,17 @@ export const MagicSettings = (props: {
|
|||||||
className="MagicSettings"
|
className="MagicSettings"
|
||||||
autofocus={false}
|
autofocus={false}
|
||||||
>
|
>
|
||||||
<p
|
<Paragraph
|
||||||
style={{
|
style={{
|
||||||
display: "inline-flex",
|
display: "inline-flex",
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
marginBottom: 0,
|
marginBottom: 0,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
For the diagram-to-code feature we use{" "}
|
For the diagram-to-code feature we use <InlineIcon icon={OpenAIIcon} />
|
||||||
<InlineButton icon={OpenAIIcon} />
|
|
||||||
OpenAI.
|
OpenAI.
|
||||||
</p>
|
</Paragraph>
|
||||||
<p>
|
<Paragraph>
|
||||||
While the OpenAI API is in beta, its use is strictly limited — as such
|
While the OpenAI API is in beta, its use is strictly limited — as such
|
||||||
we require you use your own API key. You can create an{" "}
|
we require you use your own API key. You can create an{" "}
|
||||||
<a
|
<a
|
||||||
@ -100,11 +85,11 @@ export const MagicSettings = (props: {
|
|||||||
generate your own API key
|
generate your own API key
|
||||||
</a>
|
</a>
|
||||||
.
|
.
|
||||||
</p>
|
</Paragraph>
|
||||||
<p>
|
<Paragraph>
|
||||||
Your OpenAI key does not leave the browser, and you can also set your
|
Your OpenAI key does not leave the browser, and you can also set your
|
||||||
own limit in your OpenAI account dashboard if needed.
|
own limit in your OpenAI account dashboard if needed.
|
||||||
</p>
|
</Paragraph>
|
||||||
<TextField
|
<TextField
|
||||||
isRedacted
|
isRedacted
|
||||||
value={keyInputValue}
|
value={keyInputValue}
|
||||||
@ -117,22 +102,22 @@ export const MagicSettings = (props: {
|
|||||||
selectOnRender
|
selectOnRender
|
||||||
onKeyDown={(event) => event.key === KEYS.ENTER && onConfirm()}
|
onKeyDown={(event) => event.key === KEYS.ENTER && onConfirm()}
|
||||||
/>
|
/>
|
||||||
<p>
|
<Paragraph>
|
||||||
By default, your API token is not persisted anywhere so you'll need to
|
By default, your API token is not persisted anywhere so you'll need to
|
||||||
insert it again after reload. But, you can persist locally in your
|
insert it again after reload. But, you can persist locally in your
|
||||||
browser below.
|
browser below.
|
||||||
</p>
|
</Paragraph>
|
||||||
|
|
||||||
<CheckboxItem checked={shouldPersist} onChange={setShouldPersist}>
|
<CheckboxItem checked={shouldPersist} onChange={setShouldPersist}>
|
||||||
Persist API key in browser storage
|
Persist API key in browser storage
|
||||||
</CheckboxItem>
|
</CheckboxItem>
|
||||||
|
|
||||||
<p>
|
<Paragraph>
|
||||||
Once API key is set, you can use the <InlineButton icon={MagicIcon} />{" "}
|
Once API key is set, you can use the <InlineIcon icon={MagicIcon} />{" "}
|
||||||
tool to wrap your elements in a frame that will then allow you to turn
|
tool to wrap your elements in a frame that will then allow you to turn
|
||||||
it into code. This dialog can be accessed using the <b>AI Settings</b>{" "}
|
it into code. This dialog can be accessed using the <b>AI Settings</b>{" "}
|
||||||
<InlineButton icon={OpenAIIcon} />.
|
<InlineIcon icon={OpenAIIcon} />.
|
||||||
</p>
|
</Paragraph>
|
||||||
|
|
||||||
<FilledButton
|
<FilledButton
|
||||||
className="MagicSettings__confirm"
|
className="MagicSettings__confirm"
|
||||||
|
10
src/components/Paragraph.tsx
Normal file
10
src/components/Paragraph.tsx
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
export const Paragraph = (props: {
|
||||||
|
children: React.ReactNode;
|
||||||
|
style?: React.CSSProperties;
|
||||||
|
}) => {
|
||||||
|
return (
|
||||||
|
<p className="excalidraw__paragraph" style={props.style}>
|
||||||
|
{props.children}
|
||||||
|
</p>
|
||||||
|
);
|
||||||
|
};
|
@ -734,4 +734,8 @@
|
|||||||
letter-spacing: 0.6px;
|
letter-spacing: 0.6px;
|
||||||
font-family: "Assistant";
|
font-family: "Assistant";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.excalidraw__paragraph {
|
||||||
|
margin: 1rem 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user