Skip to content

Commit 766c1d0

Browse files
committed
Show expand button
1 parent 62d10bb commit 766c1d0

File tree

5 files changed

+38
-13
lines changed

5 files changed

+38
-13
lines changed

packages/mdx/src/mdx-client/code.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export function InnerCode({
2929
const {
3030
lineNumbers,
3131
showCopyButton,
32+
showExpandButton,
3233
className,
3334
style,
3435
...editorProps
@@ -44,6 +45,10 @@ export function InnerCode({
4445
showCopyButton == null
4546
? props.codeConfig?.showCopyButton
4647
: showCopyButton,
48+
showExpandButton:
49+
showExpandButton == null
50+
? props.codeConfig?.showExpandButton
51+
: showExpandButton,
4752
}
4853

4954
if (

packages/mdx/src/mdx-client/scrollycoding.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ export function Scrollycoding({
9191
{...(tab as any)}
9292
codeConfig={codeConfig}
9393
onTabClick={onTabClick}
94+
showExpandButton={true}
9495
/>
9596
{presetConfig && (
9697
<Preview

packages/mdx/src/mini-editor/editor-tween.tsx

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { useTransition, EditorStep } from "./editor-shift"
88
import { CodeConfig } from "../smooth-code"
99
import { useLayoutEffect } from "../utils"
1010
import { CopyButton } from "smooth-code/copy-button"
11-
import { ExpandButton } from "smooth-code/expand-button"
11+
import { ExpandButton } from "mini-editor/expand-button"
1212

1313
export { EditorTransition, EditorTween }
1414
export type { EditorTransitionProps, EditorTweenProps }
@@ -56,7 +56,8 @@ function EditorTween({
5656
}: EditorTweenProps) {
5757
const ref = React.createRef<HTMLDivElement>()
5858

59-
const { showCopyButton, ...config } = codeConfig
59+
const { showCopyButton, showExpandButton, ...config } =
60+
codeConfig
6061
const {
6162
northPanel,
6263
southPanel,
@@ -95,6 +96,31 @@ function EditorTween({
9596
framePropsWithHeight.style.maxHeight = frozenHeight
9697
}
9798

99+
const northButtons = (
100+
<>
101+
{showCopyButton ? (
102+
<CopyButton
103+
content={northContent}
104+
style={{ marginRight: "0.8em" }}
105+
/>
106+
) : undefined}
107+
{showExpandButton ? (
108+
<ExpandButton
109+
style={{ marginRight: "0.8em" }}
110+
step={next || prev}
111+
theme={codeConfig.theme}
112+
/>
113+
) : undefined}
114+
</>
115+
)
116+
117+
const southCopyButton = showCopyButton ? (
118+
<CopyButton
119+
content={southContent}
120+
style={{ marginRight: "0.8em" }}
121+
/>
122+
) : undefined
123+
98124
const terminalPanel = (
99125
<TerminalPanel
100126
prev={prev.terminal}
@@ -111,17 +137,8 @@ function EditorTween({
111137
southPanel={southPanel}
112138
terminalPanel={terminalPanel}
113139
theme={codeConfig.theme}
114-
northButton={
115-
<ExpandButton style={{ margin: "0 0.8em" }} />
116-
}
117-
southButton={
118-
showCopyButton ? (
119-
<CopyButton
120-
content={southContent}
121-
style={{ margin: "0 0.8em" }}
122-
/>
123-
) : undefined
124-
}
140+
northButton={northButtons}
141+
southButton={southCopyButton}
125142
/>
126143
)
127144
}

packages/mdx/src/remark/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ export type CodeHikeConfig = {
22
theme: any
33
lineNumbers?: boolean
44
autoImport?: boolean
5+
showExpandButton?: boolean
56
showCopyButton?: boolean
67
}
78

packages/mdx/src/smooth-code/code-tween.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export type CodeConfig = {
4545
theme: IRawTheme
4646
lineNumbers?: boolean
4747
showCopyButton?: boolean
48+
showExpandButton?: boolean
4849
}
4950

5051
function useCodeShift({

0 commit comments

Comments
 (0)