@@ -2,7 +2,7 @@ import React, { memo, useState } from 'react'
2
2
import screenfull from 'screenfull'
3
3
import { LogCommand } from '../../../types/Messages'
4
4
import { EditorPaneOptions } from '../../../utils/Panes'
5
- import { columnStyle , mergeStyles , prefixObject } from '../../../utils/Styles'
5
+ import { columnStyle , mergeStyles , prefixObject , rowStyle } from '../../../utils/Styles'
6
6
import {
7
7
compareTabs ,
8
8
getTabChanged ,
@@ -24,6 +24,7 @@ import { useOptions } from '../../../contexts/OptionsContext'
24
24
import { CodeSandboxButton } from '../CodeSandboxButton'
25
25
import { CubeIcon , EnterFullScreenIcon , ExternalLinkIcon } from '../Icons'
26
26
import { HorizontalSpacer } from '../Spacer'
27
+ import WorkspacesList from '../WorkspacesList'
27
28
28
29
const toggleFullscreen = ( ) => ( screenfull as any ) . toggle ( )
29
30
@@ -59,6 +60,11 @@ const styles = prefixObject({
59
60
backgroundColor : 'rgba(0,0,0,0.02)' ,
60
61
border : '1px solid rgba(0,0,0,0.05)' ,
61
62
} ,
63
+ sidebar : mergeStyles ( columnStyle , {
64
+ flex : '0 0 220px' ,
65
+ overflowX : 'hidden' ,
66
+ overflowY : 'auto' ,
67
+ } ) ,
62
68
} )
63
69
64
70
interface Props {
@@ -116,6 +122,10 @@ export default memo(function EditorPane({
116
122
const isError = ! ! error
117
123
118
124
const style = mergeStyles ( styles . editorPane , options . style )
125
+ const sidebarStyle = mergeStyles (
126
+ styles . sidebar ,
127
+ externalStyles . workspacesList
128
+ )
119
129
120
130
const headerElements = (
121
131
< >
@@ -147,6 +157,39 @@ export default memo(function EditorPane({
147
157
</ >
148
158
)
149
159
160
+ const tabsElement = fileTabs . length > 1 && (
161
+ < Tabs
162
+ tabs = { fileTabs }
163
+ getTitle = { getTabTitle }
164
+ getChanged = { getTabChanged }
165
+ activeTab = { activeFileTab }
166
+ compareTabs = { compareTabs }
167
+ onClickTab = { onClickTab }
168
+ tabStyle = { externalStyles . tab }
169
+ textStyle = { externalStyles . tabText }
170
+ activeTextStyle = { externalStyles . tabTextActive }
171
+ changedTextStyle = { externalStyles . tabTextChanged }
172
+ >
173
+ { ! title && headerElements }
174
+ </ Tabs >
175
+ )
176
+
177
+ const editorElement = (
178
+ < Editor
179
+ key = { activeFile }
180
+ initialValue = { files [ activeFile ] }
181
+ filename = { activeStepIndex + ':' + activeFile }
182
+ onChange = { onChange }
183
+ errorLineNumber = { error ?. lineNumber }
184
+ showDiff = { true }
185
+ diff = { fileDiff }
186
+ logs = { playgroundOptions . enabled ? logs : undefined }
187
+ playgroundOptions = { playgroundOptions }
188
+ getTypeInfo = { typescriptOptions . enabled ? getTypeInfo : undefined }
189
+ tooltipStyle = { externalStyles . tooltip }
190
+ />
191
+ )
192
+
150
193
return (
151
194
< div style = { style } >
152
195
{ title && (
@@ -158,35 +201,38 @@ export default memo(function EditorPane({
158
201
{ headerElements }
159
202
</ Header >
160
203
) }
161
- { fileTabs . length > 1 && (
162
- < Tabs
163
- tabs = { fileTabs }
164
- getTitle = { getTabTitle }
165
- getChanged = { getTabChanged }
166
- activeTab = { activeFileTab }
167
- compareTabs = { compareTabs }
168
- onClickTab = { onClickTab }
169
- tabStyle = { externalStyles . tab }
170
- textStyle = { externalStyles . tabText }
171
- activeTextStyle = { externalStyles . tabTextActive }
172
- changedTextStyle = { externalStyles . tabTextChanged }
173
- >
174
- { ! title && headerElements }
175
- </ Tabs >
204
+ { options . fileList === 'sidebar' ? (
205
+ < div style = { rowStyle } >
206
+ < WorkspacesList
207
+ activeStepIndex = {
208
+ // Index of active tab
209
+ fileTabs . findIndex ( ( tab ) => tab === activeFileTab )
210
+ }
211
+ onChangeActiveStepIndex = { ( index ) => {
212
+ onClickTab ( fileTabs [ index ] )
213
+ } }
214
+ showNextButton = { false }
215
+ steps = { fileTabs }
216
+ style = { sidebarStyle }
217
+ rowStyle = { externalStyles . workspacesRow }
218
+ rowStyleActive = { externalStyles . workspacesRowActive }
219
+ rowTitleStyle = { externalStyles . workspacesRowTitle }
220
+ rowTitleStyleActive = { externalStyles . workspacesRowTitleActive }
221
+ descriptionStyle = { externalStyles . workspacesDescription }
222
+ descriptionTextStyle = { externalStyles . workspacesDescriptionText }
223
+ buttonTextStyle = { externalStyles . workspacesButtonText }
224
+ buttonContainerStyle = { externalStyles . workspacesButtonContainer }
225
+ buttonWrapperStyle = { externalStyles . workspacesButtonWrapper }
226
+ dividerStyle = { externalStyles . workspacesDivider }
227
+ />
228
+ { editorElement }
229
+ </ div >
230
+ ) : (
231
+ < React . Fragment >
232
+ { tabsElement }
233
+ { editorElement }
234
+ </ React . Fragment >
176
235
) }
177
- < Editor
178
- key = { activeFile }
179
- initialValue = { files [ activeFile ] }
180
- filename = { activeStepIndex + ':' + activeFile }
181
- onChange = { onChange }
182
- errorLineNumber = { error ?. lineNumber }
183
- showDiff = { true }
184
- diff = { fileDiff }
185
- logs = { playgroundOptions . enabled ? logs : undefined }
186
- playgroundOptions = { playgroundOptions }
187
- getTypeInfo = { typescriptOptions . enabled ? getTypeInfo : undefined }
188
- tooltipStyle = { externalStyles . tooltip }
189
- />
190
236
{ showDetails && (
191
237
< div style = { styles . overlayContainer } >
192
238
< div style = { styles . overlay } >
0 commit comments