Skip to content

Commit b34b5a6

Browse files
authored
Merge pull request #40 from topcoder-platform/PROD-2649_mobile-fixes
PROD-2649 - handle mobile fixes
2 parents 6511a4a + fb93fdc commit b34b5a6

File tree

6 files changed

+46
-9
lines changed

6 files changed

+46
-9
lines changed

client/src/templates/Challenges/classic/classic.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@
4040
padding-bottom: 16px;
4141
}
4242

43+
#challenge-page-tabs .tab-content.no-toolpanel {
44+
height: calc(
45+
100vh - var(--header-height, 0px) - var(--flash-message-height, 0px) - 24px -
46+
16px
47+
);
48+
}
49+
4350
#challenge-page-tabs .tab-pane {
4451
height: 100%;
4552
overflow: hidden;

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1054,7 +1054,11 @@ const Editor = (props: EditorProps): JSX.Element => {
10541054
focusIfTargetEditor();
10551055
}
10561056

1057-
if (props.initialTests) initTests(props.initialTests);
1057+
// Once a challenge has been completed, we don't want changes to the content
1058+
// to reset the tests since the user is already done with the challenge.
1059+
if (props.initialTests && !challengeIsComplete()) {
1060+
initTests(props.initialTests);
1061+
}
10581062

10591063
if (hasEditableRegion() && editor) {
10601064
if (props.isResetting) {

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

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
import React, { Component, ReactElement } from 'react';
2+
import { connect } from 'react-redux';
3+
import { createSelector } from 'reselect';
24

5+
import { Test } from '../../../redux/prop-types';
36
import ToolPanel from '../components/tool-panel';
7+
import { challengeTestsSelector } from '../redux';
48
import MobilePaneSelector, { Tab } from './mobile-pane-selector';
59

10+
const mapStateToProps = createSelector(
11+
challengeTestsSelector,
12+
(tests: Test[]) => ({
13+
tests
14+
})
15+
);
616
interface MobileLayoutProps {
717
editor: JSX.Element | null;
818
guideUrl: string;
@@ -15,6 +25,8 @@ interface MobileLayoutProps {
1525
testOutput: JSX.Element;
1626
videoUrl: string;
1727
usesMultifileEditor: boolean;
28+
testsRunning: boolean;
29+
tests: Test[];
1830
}
1931

2032
interface MobileLayoutState {
@@ -45,11 +57,13 @@ class MobileLayout extends Component<MobileLayoutProps, MobileLayoutState> {
4557
hasPreview,
4658
notes,
4759
preview,
48-
guideUrl,
49-
videoUrl,
60+
tests,
61+
testsRunning,
5062
usesMultifileEditor
5163
} = this.props;
5264

65+
const isChallengeComplete = tests.every(test => test.pass && !test.err);
66+
5367
// Unlike the desktop layout the mobile version does not have an ActionRow,
5468
// but still needs a way to switch between the different tabs.
5569

@@ -63,19 +77,29 @@ class MobileLayout extends Component<MobileLayoutProps, MobileLayoutState> {
6377
hasNotes={hasNotes}
6478
usesMultifileEditor={usesMultifileEditor}
6579
/>
66-
<div className='tab-content'>
80+
<div
81+
className={`tab-content ${
82+
hasEditableBoundaries ? 'no-toolpanel' : ''
83+
}`}
84+
>
6785
{currentTab === Tab.Editor && editor}
6886
{currentTab === Tab.Instructions && instructions}
6987
{currentTab === Tab.Console && testOutput}
7088
{currentTab === Tab.Notes && notes}
7189
{currentTab === Tab.Preview && preview}
7290
</div>
73-
<ToolPanel guideUrl={guideUrl} isMobile={true} videoUrl={videoUrl} />
91+
{!hasEditableBoundaries && (
92+
<ToolPanel
93+
isMobile={true}
94+
isRunningTests={testsRunning}
95+
challengeIsCompleted={isChallengeComplete}
96+
/>
97+
)}
7498
</div>
7599
);
76100
}
77101
}
78102

79103
MobileLayout.displayName = 'MobileLayout';
80104

81-
export default MobileLayout;
105+
export default connect(mapStateToProps)(MobileLayout);

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ class ShowClassic extends Component<ShowClassicProps, ShowClassicState> {
446446
<Helmet title={`${this.getBlockNameTitle(t)} | freeCodeCamp.org`} />
447447
<Media maxWidth={MAX_MOBILE_WIDTH}>
448448
<MobileLayout
449-
editor={this.renderEditor()}
449+
editor={this.renderEditor(hasEditableBoundaries)}
450450
guideUrl={getGuideUrl({ forumTopicId, title })}
451451
hasEditableBoundaries={hasEditableBoundaries}
452452
hasNotes={!!notes}
@@ -459,6 +459,7 @@ class ShowClassic extends Component<ShowClassicProps, ShowClassicState> {
459459
testOutput={this.renderTestOutput()}
460460
usesMultifileEditor={usesMultifileEditor}
461461
videoUrl={this.getVideoUrl()}
462+
testsRunning={this.props.testsRunning}
462463
/>
463464
</Media>
464465
<Media minWidth={MAX_MOBILE_WIDTH + 1}>

client/src/templates/Challenges/components/output.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
width: 100%;
77
overflow-y: auto;
88
background: var(--tc-black-5);
9+
margin-bottom: 0;
910
}
1011

1112
pre.output-text code {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ interface ToolPanelProps {
5252
openHelpModal: () => void;
5353
openVideoModal: () => void;
5454
openResetModal: () => void;
55-
guideUrl: string;
56-
videoUrl: string;
55+
guideUrl?: string;
56+
videoUrl?: string;
5757
challengeIsCompleted?: boolean;
5858
}
5959

0 commit comments

Comments
 (0)