Skip to content

Commit

Permalink
fix: copy correct code (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
ephraimduncan authored Jun 23, 2024
1 parent 30411f2 commit 341a9a4
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions apps/web/src/app/(main)/onboarding/form/code-example-step.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type CodeExampleStepProps = {
};

export const CodeExampleStep = async ({ formId }: CodeExampleStepProps) => {
const htmlCode = await highlightCode(`<form
const rawHtmlCode = `<form
action="https://formbase.dev/s/${formId ?? 'abcdefghijkl'}" method="POST"
enctype="multipart/form-data"
>
Expand All @@ -25,10 +25,9 @@ export const CodeExampleStep = async ({ formId }: CodeExampleStepProps) => {
<textarea name="message"></textarea>
<button type="submit">Submit</button>
</form>`);
</form>`;

const reactCode =
await highlightCode(`export default function FormbaseForm() {
const rawReactCode = `export default function FormbaseForm() {
return (
<form
action="https://formbase.dev/s/${formId ?? 'abcdefghijkl'}"
Expand All @@ -42,7 +41,10 @@ export const CodeExampleStep = async ({ formId }: CodeExampleStepProps) => {
<button type="submit">Submit</button>
</form>
);
}`);
}`;

const htmlCode = await highlightCode(rawHtmlCode);
const reactCode = await highlightCode(rawReactCode);

return (
<div
Expand All @@ -68,7 +70,7 @@ export const CodeExampleStep = async ({ formId }: CodeExampleStepProps) => {
}}
/>
<CopyButton
text={htmlCode}
text={rawHtmlCode}
className="absolute top-4 text-white right-4"
/>
</TabsContent>
Expand All @@ -80,7 +82,7 @@ export const CodeExampleStep = async ({ formId }: CodeExampleStepProps) => {
}}
/>
<CopyButton
text={reactCode}
text={rawReactCode}
className="absolute top-4 text-white right-4"
/>
</TabsContent>
Expand Down

0 comments on commit 341a9a4

Please sign in to comment.