Skip to content
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
27 changes: 22 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.3",
"postcss": "^8",
"torph": "^0.0.9",
"torph": "^0.1.0",
"typescript": "^5.0.2",
"vite": "^6.4.1"
}
Expand Down
10 changes: 6 additions & 4 deletions site/src/components/codeblock/index.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import { useState } from "react";

import styles from "./styles.module.scss";
import { AutoResize } from "../auto-resizer";
import { TextMorph } from "torph/react";
import { useHaptics } from "../../hooks/useHaptics";

export const CodeBlock = ({
code,
children,
prefix,
}: {
code: string;
children?: React.ReactNode;
prefix?: React.ReactNode;
}) => {
const { trigger } = useHaptics();

Expand All @@ -34,7 +33,10 @@ export const CodeBlock = ({
<TextMorph>{isCopied ? "Copied" : "Copy"}</TextMorph>
</button>
<pre>
<AutoResize>{children ?? code}</AutoResize>
{prefix}
{/* torph's root sets white-space: nowrap, which drops leading
indentation until the first morph rewrites it as nbsp segments */}
<TextMorph style={{ whiteSpace: "pre" }}>{code}</TextMorph>
</pre>
</div>
);
Expand Down
26 changes: 11 additions & 15 deletions site/src/surfaces/installation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { useState } from "react";

import styles from "./styles.module.scss";

import { TextMorph } from "torph/react";

import { CodeBlock } from "../../components/codeblock";
import { useHaptics } from "../../hooks/useHaptics";

Expand Down Expand Up @@ -40,19 +38,17 @@ export const InstallCommands = () => {
<div className={styles.cmd}>
<CodeBlock
code={pkgCmds[Object.keys(pkgCmds)[cmdIndex] as keyof typeof pkgCmds]}
>
<span
style={{
opacity: 0.4,
userSelect: "none",
}}
>
{"$ "}
</span>
<TextMorph>
{pkgCmds[Object.keys(pkgCmds)[cmdIndex] as keyof typeof pkgCmds]}
</TextMorph>
</CodeBlock>
prefix={
<span
style={{
opacity: 0.4,
userSelect: "none",
}}
>
{"$ "}
</span>
}
/>
</div>
</div>
);
Expand Down