4
4
CodeStep ,
5
5
} from "../smooth-code"
6
6
import React from "react"
7
+ import { codeToText } from "utils"
7
8
8
9
export type CodeFile = CodeStep & {
9
10
name : string
@@ -37,6 +38,8 @@ type OutputPanel = {
37
38
type Transition = {
38
39
northPanel : OutputPanel
39
40
southPanel ?: OutputPanel | null
41
+ northContent : string
42
+ southContent : string
40
43
}
41
44
42
45
type TabsSnapshot = Record <
@@ -110,6 +113,7 @@ export function useTransition(
110
113
)
111
114
112
115
return {
116
+ northContent : getContentFromFile ( nextNorthFile ) ,
113
117
northPanel : {
114
118
tabs : northTabs ,
115
119
style : northStyle ,
@@ -126,6 +130,7 @@ export function useTransition(
126
130
/>
127
131
) ,
128
132
} ,
133
+ southContent : getContentFromFile ( nextSouthFile ) ,
129
134
southPanel : inputSouthPanel && {
130
135
tabs : southTabs ! ,
131
136
style : southStyle ! ,
@@ -162,6 +167,7 @@ function startingPosition(
162
167
} = getStepFiles ( prev , next , true )
163
168
164
169
return {
170
+ northContent : getContentFromFile ( prevNorthFile ) ,
165
171
northPanel : {
166
172
tabs : inputNorthPanel . tabs . map ( title => ( {
167
173
title,
@@ -182,6 +188,7 @@ function startingPosition(
182
188
/>
183
189
) ,
184
190
} ,
191
+ southContent : getContentFromFile ( prevSouthFile ) ,
185
192
southPanel : inputSouthPanel && {
186
193
tabs : inputSouthPanel . tabs . map ( title => ( {
187
194
title,
@@ -229,6 +236,7 @@ function endingPosition(
229
236
}
230
237
231
238
return {
239
+ northContent : getContentFromFile ( nextNorthFile ) ,
232
240
northPanel : {
233
241
tabs : inputNorthPanel . tabs . map ( title => ( {
234
242
title,
@@ -249,6 +257,7 @@ function endingPosition(
249
257
/>
250
258
) ,
251
259
} ,
260
+ southContent : getContentFromFile ( nextSouthFile ) ,
252
261
southPanel : inputSouthPanel && {
253
262
tabs : inputSouthPanel . tabs . map ( title => ( {
254
263
title,
@@ -305,6 +314,10 @@ function CodeTransition({
305
314
)
306
315
}
307
316
317
+ function getContentFromFile ( file ?: CodeFile ) {
318
+ return file ? codeToText ( file . code ) : ""
319
+ }
320
+
308
321
/**
309
322
* Get the StepFiles for a transition
310
323
* in each panel, if the prev and next active files are the same
0 commit comments