Skip to content

Commit aedbe40

Browse files
committed
Update codehike 1.0.0-beta.8
1 parent e2414cb commit aedbe40

File tree

5 files changed

+51
-44
lines changed

5 files changed

+51
-44
lines changed

clone-swiftui-tutorial/components/code.tsx

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
import { AnnotationHandler, Pre, RawCode, highlight } from "codehike/code"
1+
import {
2+
AnnotationHandler,
3+
InnerLine,
4+
Pre,
5+
RawCode,
6+
highlight,
7+
} from "codehike/code"
28
import { FileIcon } from "./file-icon"
39
import theme from "./theme"
410

@@ -28,23 +34,32 @@ export async function ProseCode({ codeblock }: { codeblock: RawCode }) {
2834

2935
const mark: AnnotationHandler = {
3036
name: "Mark",
31-
Block: ({ children }) => (
32-
<div className="bg-indigo-50 shadow-[-4px_0_0] shadow-blue-400">
33-
{children}
34-
</div>
35-
),
37+
Line: ({ annotation, ...props }) => {
38+
const className = annotation
39+
? "flex bg-indigo-50 border-l-4 border-blue-400"
40+
: "flex border-l-4 border-transparent"
41+
return (
42+
<div className={className}>
43+
<InnerLine merge={props} className="px-2 flex-1" />
44+
</div>
45+
)
46+
},
3647
}
3748

3849
const lineNumber: AnnotationHandler = {
3950
name: "LineNumber",
40-
Line: ({ annotation, icon, InnerLine, lineNumber, children, ...props }) => {
51+
Line: ({ annotation, ...props }) => {
52+
const width = props.totalLines.toString().length + 1
4153
return (
42-
<InnerLine merge={props} data-line="true" className="px-2">
43-
<span className="pl-2 pr-4 inline-block w-[2ch] box-content !opacity-50 text-right select-none">
44-
{lineNumber}
54+
<>
55+
<span
56+
style={{ minWidth: `${width}ch` }}
57+
className="text-right opacity-50 select-none mx-1"
58+
>
59+
{props.lineNumber}
4560
</span>
46-
{children}
47-
</InnerLine>
61+
<InnerLine merge={props} />
62+
</>
4863
)
4964
},
5065
}

clone-swiftui-tutorial/components/section.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import { slugify } from "@/lib/utils"
22
import { Code } from "@/components/code"
33
import { Preview } from "@/components/preview"
4-
import { Selectable, Selection, SelectionProvider } from "codehike/utils"
4+
import {
5+
Selectable,
6+
Selection,
7+
SelectionProvider,
8+
} from "codehike/utils/selection"
59
import { RawCode } from "codehike/code"
610
import { SectionData, loadImage } from "@/lib/content"
711
import { Asset, AssetProvider } from "./context"

clone-swiftui-tutorial/license

Lines changed: 0 additions & 21 deletions
This file was deleted.

clone-swiftui-tutorial/package-lock.json

Lines changed: 18 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

clone-swiftui-tutorial/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"@radix-ui/react-tooltip": "^1.0.7",
2020
"class-variance-authority": "^0.7.0",
2121
"clsx": "^2.1.0",
22-
"codehike": "^1.0.0-alpha.18",
22+
"codehike": "^1.0.0-beta.8",
2323
"lucide-react": "^0.323.0",
2424
"next": "14.2.3",
2525
"react": "^18",

0 commit comments

Comments
 (0)