Skip to content

Commit b2192c8

Browse files
committed
TCA-299 - update editor UI to match the classic view according to figma
1 parent b34b5a6 commit b2192c8

File tree

6 files changed

+67
-49
lines changed

6 files changed

+67
-49
lines changed

client/src/components/layouts/global.css

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,10 @@ fieldset[disabled] .btn-primary.focus {
491491
}
492492
}
493493

494-
.button-group .btn:not(:last-child) {
494+
.button-group {
495+
margin-bottom: -10px;
496+
}
497+
.button-group .btn {
495498
margin-bottom: 10px;
496499
}
497500
strong {

client/src/components/layouts/learn.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,7 @@
2424
#learn-app-wrapper .reflex-container.horizontal > .reflex-splitter {
2525
height: 5px;
2626
}
27+
28+
#learn-app-wrapper .reflex-container > .reflex-element:first-child:last-child {
29+
flex: 1 1 auto !important;
30+
}

client/src/templates/Challenges/classic/action-row.tsx

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import EditorTabs from './editor-tabs';
88
interface ActionRowProps {
99
block: string;
1010
hasNotes: boolean;
11+
hasPreview: boolean;
1112
isMultifileCertProject: boolean;
1213
showInstructions: boolean;
1314
showConsole: boolean;
@@ -25,6 +26,7 @@ const mapDispatchToProps = {
2526

2627
const ActionRow = ({
2728
hasNotes,
29+
hasPreview,
2830
togglePane,
2931
showNotes,
3032
showPreview,
@@ -44,17 +46,15 @@ const ActionRow = ({
4446
</div>
4547
)}
4648
<div className='tabs-row'>
47-
{isMultifileCertProject && (
48-
<button
49-
aria-expanded={showInstructions ? 'true' : 'false'}
50-
className={
51-
showInstructions ? 'btn-tab-primary' : 'btn-tab-primary--outline'
52-
}
53-
onClick={() => togglePane('showInstructions')}
54-
>
55-
Instructions
56-
</button>
57-
)}
49+
<button
50+
aria-expanded={showInstructions ? 'true' : 'false'}
51+
className={
52+
showInstructions ? 'btn-tab-primary' : 'btn-tab-primary--outline'
53+
}
54+
onClick={() => togglePane('showInstructions')}
55+
>
56+
Instructions
57+
</button>
5858
<EditorTabs />
5959
<button
6060
aria-expanded={showConsole ? 'true' : 'false'}
@@ -76,15 +76,17 @@ const ActionRow = ({
7676
{t('learn.editor-tabs.notes')}
7777
</button>
7878
)}
79-
<button
80-
aria-expanded={showPreview ? 'true' : 'false'}
81-
className={
82-
showPreview ? 'btn-tab-primary' : 'btn-tab-primary--outline'
83-
}
84-
onClick={() => togglePane('showPreview')}
85-
>
86-
{t('learn.editor-tabs.preview')}
87-
</button>
79+
{hasPreview && (
80+
<button
81+
aria-expanded={showPreview ? 'true' : 'false'}
82+
className={
83+
showPreview ? 'btn-tab-primary' : 'btn-tab-primary--outline'
84+
}
85+
onClick={() => togglePane('showPreview')}
86+
>
87+
{t('learn.editor-tabs.preview')}
88+
</button>
89+
)}
8890
</div>
8991
</div>
9092
);

client/src/templates/Challenges/classic/desktop-layout.tsx

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ interface DesktopLayoutProps {
3434
resizeProps: ResizeProps;
3535
superBlock: string;
3636
testOutput: ReactElement;
37+
visibleEditors: { [key: string]: boolean };
3738
}
3839

3940
const reflexProps = {
@@ -85,20 +86,20 @@ const DesktopLayout = (props: DesktopLayoutProps): JSX.Element => {
8586
notes,
8687
preview,
8788
hasEditableBoundaries,
88-
superBlock
89+
superBlock,
90+
visibleEditors
8991
} = props;
9092

9193
const challengeFile = getChallengeFile();
9294
const projectBasedChallenge = hasEditableBoundaries;
9395
const isMultifileCertProject =
9496
challengeType === challengeTypes.multifileCertProject;
95-
const displayPreview =
96-
projectBasedChallenge || isMultifileCertProject
97-
? showPreview && hasPreview
98-
: hasPreview;
97+
const displayPreview = showPreview && hasPreview;
9998
const displayNotes = projectBasedChallenge ? showNotes && hasNotes : false;
100-
const displayConsole =
101-
projectBasedChallenge || isMultifileCertProject ? showConsole : true;
99+
const displayConsole = showConsole;
100+
const displayEditor = Object.entries(visibleEditors).some(
101+
([, visible]) => visible
102+
);
102103
const {
103104
codePane,
104105
editorPane,
@@ -110,33 +111,32 @@ const DesktopLayout = (props: DesktopLayoutProps): JSX.Element => {
110111

111112
return (
112113
<div className='desktop-layout'>
113-
{(projectBasedChallenge || isMultifileCertProject) && (
114-
<ActionRow
115-
block={block}
116-
hasNotes={hasNotes}
117-
isMultifileCertProject={isMultifileCertProject}
118-
showConsole={showConsole}
119-
showNotes={showNotes}
120-
showInstructions={showInstructions}
121-
showPreview={showPreview}
122-
superBlock={superBlock}
123-
showBreadcrumbs={false}
124-
togglePane={togglePane}
125-
/>
126-
)}
114+
<ActionRow
115+
block={block}
116+
hasNotes={hasNotes}
117+
isMultifileCertProject={isMultifileCertProject}
118+
showConsole={showConsole}
119+
showNotes={showNotes}
120+
showInstructions={showInstructions}
121+
hasPreview={hasPreview}
122+
showPreview={showPreview}
123+
superBlock={superBlock}
124+
showBreadcrumbs={false}
125+
togglePane={togglePane}
126+
/>
127127
<div className='editor-row'>
128128
<ReflexContainer orientation='vertical'>
129129
{!projectBasedChallenge && showInstructions && (
130130
<ReflexElement flex={instructionPane.flex} {...resizeProps}>
131131
{instructions}
132132
</ReflexElement>
133133
)}
134-
{!projectBasedChallenge && (
134+
{!projectBasedChallenge && displayEditor && (
135135
<ReflexSplitter propagate={true} {...resizeProps} />
136136
)}
137137

138-
<ReflexElement flex={editorPane.flex} {...resizeProps}>
139-
{challengeFile && (
138+
{challengeFile && displayEditor && (
139+
<ReflexElement flex={editorPane.flex} {...resizeProps}>
140140
<ReflexContainer
141141
key={challengeFile.fileKey}
142142
orientation='horizontal'
@@ -157,8 +157,8 @@ const DesktopLayout = (props: DesktopLayoutProps): JSX.Element => {
157157
</ReflexElement>
158158
)}
159159
</ReflexContainer>
160-
)}
161-
</ReflexElement>
160+
</ReflexElement>
161+
)}
162162

163163
{(displayPreview || displayConsole) && (
164164
<ReflexSplitter propagate={true} {...resizeProps} />

client/src/templates/Challenges/classic/show.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import {
3838
challengeMounted,
3939
challengeTestsSelector,
4040
consoleOutputSelector,
41+
visibleEditorsSelector,
4142
createFiles,
4243
executeChallenge,
4344
initConsole,
@@ -58,14 +59,19 @@ import MobileLayout from './mobile-layout';
5859
import './classic.css';
5960
import '../components/test-frame.css';
6061

62+
type VisibleEditors = {
63+
[key: string]: boolean;
64+
};
65+
6166
// Redux Setup
6267
const mapStateToProps = createStructuredSelector({
6368
challengeFiles: challengeFilesSelector,
6469
tests: challengeTestsSelector,
6570
testsRunning: testsRunningSelector,
6671
output: consoleOutputSelector,
6772
isChallengeCompleted: isChallengeCompletedSelector,
68-
savedChallenges: savedChallengesSelector
73+
savedChallenges: savedChallengesSelector,
74+
visibleEditors: visibleEditorsSelector
6975
});
7076

7177
const mapDispatchToProps = (dispatch: Dispatch) =>
@@ -112,6 +118,7 @@ interface ShowClassicProps {
112118
setEditorFocusability: (canFocus: boolean) => void;
113119
previewMounted: () => void;
114120
savedChallenges: CompletedChallenge[];
121+
visibleEditors: VisibleEditors;
115122
}
116123

117124
interface ShowClassicState {
@@ -429,6 +436,7 @@ class ShowClassic extends Component<ShowClassicProps, ShowClassicState> {
429436
challengeMeta: { nextChallengePath, prevChallengePath }
430437
},
431438
challengeFiles,
439+
visibleEditors,
432440
t
433441
} = this.props;
434442

@@ -480,6 +488,7 @@ class ShowClassic extends Component<ShowClassicProps, ShowClassicState> {
480488
resizeProps={this.resizeProps}
481489
superBlock={superBlock}
482490
testOutput={this.renderTestOutput()}
491+
visibleEditors={visibleEditors}
483492
/>
484493
</Media>
485494
<CompletionModal

client/src/templates/Challenges/components/side-panel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export function SidePanel({
8282
{challengeTitle}
8383
{challengeDescription}
8484
<div className='test-area-wrap'>
85-
{showToolPanel && (
85+
{showToolPanel && tests.length > 10 && (
8686
<ToolPanel
8787
guideUrl={guideUrl}
8888
videoUrl={videoUrl}

0 commit comments

Comments
 (0)