|
|
@ -10,6 +10,8 @@ import { InlineIcon } from "./InlineIcon";
|
|
|
|
import { Paragraph } from "./Paragraph";
|
|
|
|
import { Paragraph } from "./Paragraph";
|
|
|
|
|
|
|
|
|
|
|
|
import "./MagicSettings.scss";
|
|
|
|
import "./MagicSettings.scss";
|
|
|
|
|
|
|
|
import TTDDialogTabs from "./TTDDialog/TTDDialogTabs";
|
|
|
|
|
|
|
|
import { TTDDialogTab } from "./TTDDialog/TTDDialogTab";
|
|
|
|
|
|
|
|
|
|
|
|
export const MagicSettings = (props: {
|
|
|
|
export const MagicSettings = (props: {
|
|
|
|
openAIKey: string | null;
|
|
|
|
openAIKey: string | null;
|
|
|
@ -18,16 +20,21 @@ export const MagicSettings = (props: {
|
|
|
|
onConfirm: (key: string, shouldPersist: boolean) => void;
|
|
|
|
onConfirm: (key: string, shouldPersist: boolean) => void;
|
|
|
|
onClose: () => void;
|
|
|
|
onClose: () => void;
|
|
|
|
}) => {
|
|
|
|
}) => {
|
|
|
|
const { theme } = useUIAppState();
|
|
|
|
|
|
|
|
const [keyInputValue, setKeyInputValue] = useState(props.openAIKey || "");
|
|
|
|
const [keyInputValue, setKeyInputValue] = useState(props.openAIKey || "");
|
|
|
|
const [shouldPersist, setShouldPersist] = useState<boolean>(
|
|
|
|
const [shouldPersist, setShouldPersist] = useState<boolean>(
|
|
|
|
props.isPersisted,
|
|
|
|
props.isPersisted,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const appState = useUIAppState();
|
|
|
|
|
|
|
|
|
|
|
|
const onConfirm = () => {
|
|
|
|
const onConfirm = () => {
|
|
|
|
props.onConfirm(keyInputValue.trim(), shouldPersist);
|
|
|
|
props.onConfirm(keyInputValue.trim(), shouldPersist);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (appState.openDialog?.name !== "settings") {
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<Dialog
|
|
|
|
<Dialog
|
|
|
|
onCloseRequest={() => {
|
|
|
|
onCloseRequest={() => {
|
|
|
@ -36,7 +43,7 @@ export const MagicSettings = (props: {
|
|
|
|
}}
|
|
|
|
}}
|
|
|
|
title={
|
|
|
|
title={
|
|
|
|
<div style={{ display: "flex" }}>
|
|
|
|
<div style={{ display: "flex" }}>
|
|
|
|
Diagram to Code (AI){" "}
|
|
|
|
Wireframe to Code (AI){" "}
|
|
|
|
<div
|
|
|
|
<div
|
|
|
|
style={{
|
|
|
|
style={{
|
|
|
|
display: "flex",
|
|
|
|
display: "flex",
|
|
|
@ -46,7 +53,8 @@ export const MagicSettings = (props: {
|
|
|
|
marginLeft: "1rem",
|
|
|
|
marginLeft: "1rem",
|
|
|
|
fontSize: 14,
|
|
|
|
fontSize: 14,
|
|
|
|
borderRadius: "12px",
|
|
|
|
borderRadius: "12px",
|
|
|
|
background: theme === "light" ? "#FFCCCC" : "#703333",
|
|
|
|
color: "#000",
|
|
|
|
|
|
|
|
background: "pink",
|
|
|
|
}}
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
>
|
|
|
|
Experimental
|
|
|
|
Experimental
|
|
|
@ -56,19 +64,39 @@ export const MagicSettings = (props: {
|
|
|
|
className="MagicSettings"
|
|
|
|
className="MagicSettings"
|
|
|
|
autofocus={false}
|
|
|
|
autofocus={false}
|
|
|
|
>
|
|
|
|
>
|
|
|
|
<Paragraph
|
|
|
|
{/* <h2
|
|
|
|
style={{
|
|
|
|
style={{
|
|
|
|
display: "inline-flex",
|
|
|
|
margin: 0,
|
|
|
|
alignItems: "center",
|
|
|
|
fontSize: "1.25rem",
|
|
|
|
marginBottom: 0,
|
|
|
|
paddingLeft: "2.5rem",
|
|
|
|
}}
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
>
|
|
|
|
For the diagram-to-code feature we use <InlineIcon icon={OpenAIIcon} />
|
|
|
|
AI Settings
|
|
|
|
|
|
|
|
</h2> */}
|
|
|
|
|
|
|
|
<TTDDialogTabs dialog="settings" tab={appState.openDialog.tab}>
|
|
|
|
|
|
|
|
{/* <TTDDialogTabTriggers>
|
|
|
|
|
|
|
|
<TTDDialogTabTrigger tab="text-to-diagram">
|
|
|
|
|
|
|
|
<InlineIcon icon={brainIcon} /> Text to diagram
|
|
|
|
|
|
|
|
</TTDDialogTabTrigger>
|
|
|
|
|
|
|
|
<TTDDialogTabTrigger tab="diagram-to-code">
|
|
|
|
|
|
|
|
<InlineIcon icon={MagicIcon} /> Wireframe to code
|
|
|
|
|
|
|
|
</TTDDialogTabTrigger>
|
|
|
|
|
|
|
|
</TTDDialogTabTriggers> */}
|
|
|
|
|
|
|
|
{/* <TTDDialogTab className="ttd-dialog-content" tab="text-to-diagram">
|
|
|
|
|
|
|
|
TODO
|
|
|
|
|
|
|
|
</TTDDialogTab> */}
|
|
|
|
|
|
|
|
<TTDDialogTab
|
|
|
|
|
|
|
|
// className="ttd-dialog-content"
|
|
|
|
|
|
|
|
tab="diagram-to-code"
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
<Paragraph>
|
|
|
|
|
|
|
|
For the diagram-to-code feature we use{" "}
|
|
|
|
|
|
|
|
<InlineIcon icon={OpenAIIcon} />
|
|
|
|
OpenAI.
|
|
|
|
OpenAI.
|
|
|
|
</Paragraph>
|
|
|
|
</Paragraph>
|
|
|
|
<Paragraph>
|
|
|
|
<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
|
|
|
|
we require you use your own API key. You can create an{" "}
|
|
|
|
such we require you use your own API key. You can create an{" "}
|
|
|
|
<a
|
|
|
|
<a
|
|
|
|
href="https://platform.openai.com/login?launch"
|
|
|
|
href="https://platform.openai.com/login?launch"
|
|
|
|
rel="noopener noreferrer"
|
|
|
|
rel="noopener noreferrer"
|
|
|
@ -87,8 +115,8 @@ export const MagicSettings = (props: {
|
|
|
|
.
|
|
|
|
.
|
|
|
|
</Paragraph>
|
|
|
|
</Paragraph>
|
|
|
|
<Paragraph>
|
|
|
|
<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
|
|
|
|
own limit in your OpenAI account dashboard if needed.
|
|
|
|
your own limit in your OpenAI account dashboard if needed.
|
|
|
|
</Paragraph>
|
|
|
|
</Paragraph>
|
|
|
|
<TextField
|
|
|
|
<TextField
|
|
|
|
isRedacted
|
|
|
|
isRedacted
|
|
|
@ -103,9 +131,9 @@ export const MagicSettings = (props: {
|
|
|
|
onKeyDown={(event) => event.key === KEYS.ENTER && onConfirm()}
|
|
|
|
onKeyDown={(event) => event.key === KEYS.ENTER && onConfirm()}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
<Paragraph>
|
|
|
|
<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
|
|
|
|
insert it again after reload. But, you can persist locally in your
|
|
|
|
to insert it again after reload. But, you can persist locally in
|
|
|
|
browser below.
|
|
|
|
your browser below.
|
|
|
|
</Paragraph>
|
|
|
|
</Paragraph>
|
|
|
|
|
|
|
|
|
|
|
|
<CheckboxItem checked={shouldPersist} onChange={setShouldPersist}>
|
|
|
|
<CheckboxItem checked={shouldPersist} onChange={setShouldPersist}>
|
|
|
@ -114,9 +142,9 @@ export const MagicSettings = (props: {
|
|
|
|
|
|
|
|
|
|
|
|
<Paragraph>
|
|
|
|
<Paragraph>
|
|
|
|
Once API key is set, you can use the <InlineIcon 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
|
|
|
|
it into code. This dialog can be accessed using the <b>AI Settings</b>{" "}
|
|
|
|
turn it into code. This dialog can be accessed using the{" "}
|
|
|
|
<InlineIcon icon={OpenAIIcon} />.
|
|
|
|
<b>AI Settings</b> <InlineIcon icon={OpenAIIcon} />.
|
|
|
|
</Paragraph>
|
|
|
|
</Paragraph>
|
|
|
|
|
|
|
|
|
|
|
|
<FilledButton
|
|
|
|
<FilledButton
|
|
|
@ -125,6 +153,8 @@ export const MagicSettings = (props: {
|
|
|
|
label="Confirm"
|
|
|
|
label="Confirm"
|
|
|
|
onClick={onConfirm}
|
|
|
|
onClick={onConfirm}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
|
|
|
|
</TTDDialogTab>
|
|
|
|
|
|
|
|
</TTDDialogTabs>
|
|
|
|
</Dialog>
|
|
|
|
</Dialog>
|
|
|
|
);
|
|
|
|
);
|
|
|
|
};
|
|
|
|
};
|
|
|
|