+
{editMode ? (
<>
-
-
{
setTitleInputValue(e.target.value)
setTitleSavingStateLabel(DEFAULT_SAVE_BUTTON_LABEL)
}}
type="text"
- style={{ all: 'unset', borderBottom: '1px solid' }}
+ className="!py-2 !text-14 !rounded-3 !border-borderColor5"
/>
+
+
>
) : (
- <>
+
+
+ Title: {titleInputValue}
+
- {titleInputValue}
- >
+
)}
diff --git a/app/javascript/components/bootcamp/DrawingPage/useSetupDrawingPage.ts b/app/javascript/components/bootcamp/DrawingPage/useSetupDrawingPage.ts
index 1ffe2d3e93..8196b25535 100644
--- a/app/javascript/components/bootcamp/DrawingPage/useSetupDrawingPage.ts
+++ b/app/javascript/components/bootcamp/DrawingPage/useSetupDrawingPage.ts
@@ -6,10 +6,16 @@ export function useSetupDrawingPage({
setEditorLocalStorageValue,
code,
}) {
- const { setDefaultCode, setShouldAutoRunCode } = useEditorStore()
+ const { setDefaultCode, setActiveEditor, setShouldAutoRunCode } =
+ useEditorStore()
// Setup hook
useEffect(() => {
+ setActiveEditor('drawing')
+ const storedShouldAutoRunCode = localStorage.getItem(
+ 'drawing-should-autorun-code'
+ )
+ setShouldAutoRunCode(storedShouldAutoRunCode === 'true')
if (
editorLocalStorageValue.storedAt &&
code.storedAt &&
@@ -22,6 +28,5 @@ export function useSetupDrawingPage({
// otherwise we are using the code from the storage
setDefaultCode(editorLocalStorageValue.code)
}
- setShouldAutoRunCode(true)
- }, [code, setDefaultCode, setEditorLocalStorageValue])
+ }, [])
}
diff --git a/app/javascript/components/bootcamp/SolveExercisePage/CodeMirror/CodeMirror.tsx b/app/javascript/components/bootcamp/SolveExercisePage/CodeMirror/CodeMirror.tsx
index 1aa91e2e22..eb0bd7ebe4 100644
--- a/app/javascript/components/bootcamp/SolveExercisePage/CodeMirror/CodeMirror.tsx
+++ b/app/javascript/components/bootcamp/SolveExercisePage/CodeMirror/CodeMirror.tsx
@@ -119,6 +119,12 @@ export const CodeMirror = forwardRef(function _CodeMirror(
}, 500)
}, [setEditorLocalStorageValue, readOnlyRangesStateField])
+ const autoRunOnDebounce = useMemo(() => {
+ return debounce(() => {
+ handleRunCode()
+ }, 500)
+ }, [])
+
let value = defaultCode
const getEditorView = (): EditorView | null => {
@@ -207,7 +213,7 @@ export const CodeMirror = forwardRef(function _CodeMirror(
() => {
const { shouldAutoRunCode } = useEditorStore.getState()
if (shouldAutoRunCode) {
- handleRunCode()
+ autoRunOnDebounce()
}
},
() => {
diff --git a/app/javascript/components/bootcamp/SolveExercisePage/CodeMirror/extensions/end-line-information/information-widget.ts b/app/javascript/components/bootcamp/SolveExercisePage/CodeMirror/extensions/end-line-information/information-widget.ts
index 73f830a418..c536b91845 100644
--- a/app/javascript/components/bootcamp/SolveExercisePage/CodeMirror/extensions/end-line-information/information-widget.ts
+++ b/app/javascript/components/bootcamp/SolveExercisePage/CodeMirror/extensions/end-line-information/information-widget.ts
@@ -40,12 +40,6 @@ export class InformationWidget extends WidgetType {
private createRefElement() {
const refElement = document.createElement('span')
- refElement.classList.add('font-bold', 'text-black')
- // refElement.style.float = 'right'
- refElement.style.position = 'absolute'
- refElement.style.right = '0'
- refElement.innerText = ' '
-
return refElement
}
diff --git a/app/javascript/components/bootcamp/SolveExercisePage/Scrubber/Scrubber.tsx b/app/javascript/components/bootcamp/SolveExercisePage/Scrubber/Scrubber.tsx
index c637d1edea..2caf805bc0 100644
--- a/app/javascript/components/bootcamp/SolveExercisePage/Scrubber/Scrubber.tsx
+++ b/app/javascript/components/bootcamp/SolveExercisePage/Scrubber/Scrubber.tsx
@@ -45,7 +45,7 @@ function Scrubber({
rangeRef.current?.focus()
}}
tabIndex={-1}
- className="relative group"
+ className="relative group w-full"
>
{animationTimeline && (
{text}
diff --git a/app/javascript/components/bootcamp/SolveExercisePage/Scrubber/useScrubber.ts b/app/javascript/components/bootcamp/SolveExercisePage/Scrubber/useScrubber.ts
index 82173f1a49..60eae31eba 100644
--- a/app/javascript/components/bootcamp/SolveExercisePage/Scrubber/useScrubber.ts
+++ b/app/javascript/components/bootcamp/SolveExercisePage/Scrubber/useScrubber.ts
@@ -140,7 +140,7 @@ export function useScrubber({
scrollToLine(editorView, highlightedLine)
}
},
- [setValue, setInformationWidgetData]
+ [setValue, setInformationWidgetData, editorView]
)
const handleMouseDown = useCallback(
diff --git a/app/javascript/components/bootcamp/SolveExercisePage/SolveExercisePageContextWrapper.tsx b/app/javascript/components/bootcamp/SolveExercisePage/SolveExercisePageContextWrapper.tsx
index f68223857f..d6aa4661cb 100644
--- a/app/javascript/components/bootcamp/SolveExercisePage/SolveExercisePageContextWrapper.tsx
+++ b/app/javascript/components/bootcamp/SolveExercisePage/SolveExercisePageContextWrapper.tsx
@@ -3,10 +3,9 @@ import React from 'react'
import { createContext } from 'react'
-type SolveExercisePageContextValues = Pick<
- SolveExercisePageProps,
- 'links' | 'solution' | 'exercise' | 'code'
-> & { resetEditorToStub: () => void; editorView: EditorView | null }
+type SolveExercisePageContextValues = Partial<
+ Pick
+> & { resetEditorToStub?: () => void; editorView: EditorView | null }
export const SolveExercisePageContext =
createContext({
diff --git a/app/javascript/components/bootcamp/SolveExercisePage/store/editorStore.ts b/app/javascript/components/bootcamp/SolveExercisePage/store/editorStore.ts
index 2cbd8212e7..3f9c2d6384 100644
--- a/app/javascript/components/bootcamp/SolveExercisePage/store/editorStore.ts
+++ b/app/javascript/components/bootcamp/SolveExercisePage/store/editorStore.ts
@@ -5,6 +5,8 @@ import { createStoreWithMiddlewares } from './utils'
type UnderlineRange = { from: number; to: number } | undefined
type EditorStore = {
+ activeEditor: 'solve-exercise' | 'drawing' | null
+ setActiveEditor: (activeEditor: 'solve-exercise' | 'drawing') => void
defaultCode: string
setDefaultCode: (defaultCode: string) => void
shouldAutoRunCode: boolean
@@ -32,18 +34,40 @@ type EditorStore = {
setReadonlyRanges: (ranges: Array<{ from: number; to: number }>) => void
}
-const useEditorStore = createStoreWithMiddlewares(
- (set) => ({
+const useEditorStore = createStoreWithMiddlewares((set) => {
+ return {
+ activeEditor: null,
+ setActiveEditor: (activeEditor: 'solve-exercise' | 'drawing') => {
+ set({ activeEditor }, false, 'editor/setActiveEditor')
+ },
defaultCode: '',
setDefaultCode: (defaultCode: string) => {
set({ defaultCode }, false, 'editor/setDefaultCode')
},
shouldAutoRunCode: false,
- setShouldAutoRunCode: (shouldAutoRunCode) =>
- set({ shouldAutoRunCode }, false, 'editor/setShouldAutoRunCode'),
+ setShouldAutoRunCode: (shouldAutoRunCode: boolean) => {
+ set(
+ (state) => {
+ localStorage.setItem(
+ `${state.activeEditor}-should-autorun-code`,
+ shouldAutoRunCode.toString()
+ )
+ return { shouldAutoRunCode }
+ },
+ false,
+ 'editor/setShouldAutoRunCode'
+ )
+ },
toggleShouldAutoRunCode: () => {
set(
- (state) => ({ shouldAutoRunCode: !state.shouldAutoRunCode }),
+ (state) => {
+ const newState = !state.shouldAutoRunCode
+ localStorage.setItem(
+ `${state.activeEditor}-should-autorun-code`,
+ newState.toString()
+ )
+ return { shouldAutoRunCode: newState }
+ },
false,
'editor/toggleShouldAutoRunCode'
)
@@ -111,8 +135,7 @@ const useEditorStore = createStoreWithMiddlewares(
setReadonlyRanges: (readonlyRanges) => {
set({ readonlyRanges }, false, 'exercise/setReadonlyRanges')
},
- }),
- 'EditorStore'
-)
+ }
+}, 'EditorStore')
export default useEditorStore
diff --git a/app/views/bootcamp/projects/show.html.haml b/app/views/bootcamp/projects/show.html.haml
index d37a2ffe04..aa3fcd036d 100644
--- a/app/views/bootcamp/projects/show.html.haml
+++ b/app/views/bootcamp/projects/show.html.haml
@@ -29,9 +29,9 @@
.introduction.c-prose
= raw @project.introduction_html
- - if false #@project.slug == "drawing"
- %h2 Your Drawings
- %p Create your own drawings using code!
+ - if @project.slug == "drawing"
+ %h2.text-h3.mt-20 Make Your Own Drawings
+ %p.text-p-large.mb-20 Create your own drawings using code!
.grid.grid-cols-3
- current_user.bootcamp_drawings.each do |drawing|
= link_to edit_bootcamp_drawing_path(drawing), class: 'drawing' do