Skip to content

Commit 0f49c7d

Browse files
dem4roniHiD
andauthored
Add FrontendExercisePage (exercism#7844)
* Add back deleted files * Render page * Add bunch of stuff, remove bunch of stuff * Capture js parsing and runtime errors * FrontendTraining -> FrontendExercise * Rename component in index haml * Rename more things from FrontendTraining -> FrontendExercise, sort out localStorage, readonly ranges * Only run JS code on "Run code" * Parse JS * Underline error location * Show error using editor's internal state * Make range-error more robust * Sort out runtime errors * Inject loop guard * Add ruby scaffolding, Sort out header, add context data and more * Miniature tweaks * Add scaffolding for expected output * Start bouncy ball exercise * Add to config * Add exercise * Fix config * Get stuff working * Add diff button, expected tab * Fix mising else if * Fix pointer-events on Output * Sort out instructions and overflowing * Add diff * Add expected iframe container * run code on demand, add css normalisation and default css * Add aspect-ratio to iframe body * Try again sizing outputs * Move RHS tab setting logic to store, Set tab to Output on diff mode: on * Add some better styling * Add logger * Move logs to store * Cap logs at 100 * Add overlay mode * Fix cursor moving on paste * Remove infinite loop guarding for now * Add linter + prevent autoclosing tags * Level 15 exercises (exercism#7843) * Add breakout css exercise * WIP * Add portgual * Add trinidad and tobago * Add nambia * Tweak text * Move to output on RunCode if RHS active tab is Instructions * Tweak breakout * Add improved ball * Tweak more * Adjust styles a bit * Add pl to page-body-lhs * Validate HTML then inject JS (exercism#7851) * Adjust activating output tab * Inject JS on RunCode * Slightly refactor * Add css + html theme * Add lint tooltip styles * Add defaultCodes * Add snake game * Dynamically apply pointerEvents changes to iframe containers * Fix lhs control-buttons' style * Add Breakout Instructions * Add border-radius * Fix starting position * Tweak everything * Don't break on logging document out --------- Co-authored-by: Jeremy Walker <[email protected]>
1 parent 41cb984 commit 0f49c7d

File tree

134 files changed

+3942
-93
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

134 files changed

+3942
-93
lines changed

app/css/bootcamp/components/codemirror.css

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#bootcamp-solve-exercise-page,
22
#bootcamp-custom-function-editor-page,
3-
#bootcamp-frontend-training-page {
3+
/* this is the CSSExercise page - change it to bootcamp-css-exercise-page ASAP! */
4+
#bootcamp-frontend-training-page ,
5+
#bootcamp-frontend-exercise-page {
46
.cm-breakpoint-gutter .cm-gutterElement {
57
@apply flex;
68
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#bootcamp-frontend-exercise-page {
2+
.page-body-lhs {
3+
@apply p-0 pl-8;
4+
}
5+
6+
.control-buttons-container {
7+
@apply flex items-center justify-between h-full p-8 gap-8;
8+
@apply bg-bootcamp-very-light-purple;
9+
}
10+
11+
.editor-wrapper {
12+
border: none;
13+
border-radius: 8px;
14+
}
15+
.c-iteration-pane {
16+
.tabs {
17+
@apply bg-bootcamp-light-purple;
18+
.c-tab {
19+
@apply bg-bootcamp-light-purple;
20+
&.selected {
21+
@apply bg-backgroundColorA;
22+
@apply text-textColor1;
23+
}
24+
}
25+
}
26+
}
27+
}

app/css/bootcamp/components/frontend-training-page.css

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
#bootcamp-frontend-training-page {
1+
#bootcamp-frontend-training-page,
2+
#bootcamp-frontend-exercise-page {
23
.page-body-rhs {
34
@apply bg-white;
45
@apply flex-grow;
@@ -44,4 +45,12 @@
4445
.css-render-expected {
4546
pointer-events: none;
4647
}
48+
.fe-render-expected,
49+
.fe-render-actual {
50+
@apply border-textColor1 border-1;
51+
@apply shadow-base;
52+
53+
@apply w-full h-full relative overflow-hidden;
54+
/* max-height: calc(90vh - 80px); */
55+
}
4756
}

app/css/bootcamp/components/logger.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
background: aliceblue;
77

88
@apply overflow-hidden;
9-
@apply p-12 p-16;
9+
@apply p-16;
1010
@apply border-t-1 border-borderColor4;
1111
@apply relative;
1212

app/css/bootcamp/components/scenario.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#bootcamp-solve-exercise-page,
22
#bootcamp-custom-function-editor-page,
3-
#bootcamp-frontend-training-page {
3+
#bootcamp-frontend-training-page,
4+
#bootcamp-frontend-exercise-page {
45
.c-scenario {
56
@apply border-2 rounded-5;
67
@apply overflow-hidden;

app/css/bootcamp/components/solve-exercise-page.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#bootcamp-solve-exercise-page,
22
#bootcamp-custom-function-editor-page,
3-
#bootcamp-frontend-training-page {
3+
#bootcamp-frontend-training-page,
4+
#bootcamp-frontend-exercise-page {
45
@apply flex flex-col w-full h-screen;
56

67
.page-header {

app/css/packs/bootcamp.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
@import "../bootcamp/components/solve-exercise-page";
1111
@import "../bootcamp/components/frontend-training-page";
12+
@import "../bootcamp/components/frontend-exercise-page";
1213
@import "../bootcamp/components/custom-function-selector";
1314
@import "../bootcamp/components/rhs-list";
1415
@import "../bootcamp/components/breadcrumbs";
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
module ReactComponents
2+
class Bootcamp::FrontendExercisePage < ReactComponent
3+
initialize_with :solution
4+
5+
def to_s
6+
super(id, data)
7+
end
8+
9+
def id = "bootcamp-frontend-exercise-page"
10+
11+
def data
12+
{
13+
project: { slug: project&.slug },
14+
exercise: {
15+
id: exercise&.id,
16+
slug: exercise&.slug,
17+
title: exercise&.title,
18+
introduction_html: exercise&.introduction_html,
19+
css_checks: config[:checks] || [],
20+
html_checks: config[:html_checks] || [],
21+
config: {
22+
title: config[:title],
23+
description: config[:description],
24+
allowed_properties: config[:allowed_properties],
25+
disallowed_properties: config[:disallowed_properties],
26+
expected:
27+
}
28+
},
29+
solution: solution_data,
30+
code: {
31+
normalize_css:,
32+
default: {
33+
css: exercise&.default("css")
34+
},
35+
stub: {
36+
css: exercise.stub("css"),
37+
html: exercise.stub("html"),
38+
js: exercise.stub("js")
39+
},
40+
aspect_ratio: editor_config[:aspect_ratio] || 1,
41+
code: solution&.code,
42+
stored_at: submission&.created_at
43+
},
44+
links: solution_links
45+
}
46+
end
47+
48+
def config
49+
exercise&.config || {}
50+
end
51+
52+
def editor_config
53+
exercise&.editor_config || {}
54+
end
55+
56+
def solution_data
57+
return nil unless solution
58+
59+
{
60+
uuid: solution.uuid,
61+
status: solution.status,
62+
passed_basic_tests: solution.passed_basic_tests?
63+
}
64+
end
65+
66+
def solution_links
67+
return {} unless solution
68+
69+
{
70+
post_submission: Exercism::Routes.api_bootcamp_solution_submissions_url(solution_uuid: solution.uuid, only_path: true),
71+
complete_solution: Exercism::Routes.complete_api_bootcamp_solution_url(solution.uuid, only_path: true),
72+
projects_index: Exercism::Routes.bootcamp_projects_url(only_path: true),
73+
dashboard_index: Exercism::Routes.bootcamp_dashboard_url(only_path: true),
74+
bootcamp_level_url: Exercism::Routes.bootcamp_level_url("idx"),
75+
custom_fns_dashboard: Exercism::Routes.bootcamp_custom_functions_url
76+
}
77+
end
78+
79+
def expected
80+
return {} unless exercise
81+
82+
{
83+
html: exercise.example("html"),
84+
css: exercise.example("css"),
85+
js: exercise.example("js")
86+
}
87+
end
88+
89+
def readonly_ranges
90+
submission&.readonly_ranges || exercise&.readonly_ranges
91+
end
92+
93+
# rubocop:disable Layout/LineLength
94+
def normalize_css = "
95+
button,hr,input{overflow:visible}progress,sub,sup{vertical-align:baseline}[type=checkbox],[type=radio],legend{box-sizing:border-box;padding:0}html{line-height:1.15;-webkit-text-size-adjust:100%}body{margin:0}details,main{display:block}h1{font-size:2em;margin:.67em 0}hr{box-sizing:content-box;height:0}code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em}a{background-color:transparent}abbr[title]{border-bottom:none;text-decoration:underline;text-decoration:underline dotted}b,strong{font-weight:bolder}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}img{border-style:none}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;line-height:1.15;margin:0}button,select{text-transform:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button::-moz-focus-inner{border-style:none;padding:0}[type=button]:-moz-focusring,[type=reset]:-moz-focusring,[type=submit]:-moz-focusring,button:-moz-focusring{outline:ButtonText dotted 1px}fieldset{padding:.35em .75em .625em}legend{color:inherit;display:table;max-width:100%;white-space:normal}textarea{overflow:auto}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}[hidden],template{display:none}
96+
h1,h2,h3,h4,h5,h6,ul,ol,li,p { margin: 0; padding: 0; }
97+
body { font-size: 14px; line-height: 1.3 }
98+
"
99+
# rubocop:enable Layout/LineLength
100+
101+
memoize
102+
def submission = solution&.submissions&.last
103+
104+
delegate :exercise, to: :solution, allow_nil: true
105+
delegate :project, to: :exercise, allow_nil: true
106+
end
107+
end

app/helpers/react_components/bootcamp/frontend_training_page.rb

Lines changed: 0 additions & 13 deletions
This file was deleted.

app/javascript/components/bootcamp/CSSExercisePage/FinishLessonModal/FinishLessonModal.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React from 'react'
2-
32
import Modal from 'react-modal'
43
import { FinishLessonModalContext } from './FinishLessonModalContext'
54
import { useContext } from 'react'

0 commit comments

Comments
 (0)