Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cloud homepage rory #258

Merged
merged 44 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
d0e3a6e
New homepage start
AydinHassan Jun 19, 2023
65defb2
Made a animated background gradient for hero section
roryhmartin Jun 29, 2023
09444fb
Added images to correct location. Started content
roryhmartin Jul 1, 2023
6bcbb15
linked to external stylesheet. Moved styles to cloud.css
roryhmartin Jul 1, 2023
d68367c
Vue component created
roryhmartin Jul 4, 2023
b25fba2
Fix /cloud endpoint by removing cloud folder in public directory
AydinHassan Jul 8, 2023
7225e0e
Update deps
AydinHassan Jul 8, 2023
717e2e0
continued adding main page content
roryhmartin Jul 10, 2023
795d4f2
Merge branch 'cloud-homepage-rory' of github.com:php-school/phpschool…
roryhmartin Jul 10, 2023
9f0777b
latest additions
roryhmartin Aug 28, 2023
7923717
Extra button component
AydinHassan Aug 28, 2023
3113c86
Add viewport meta tag
AydinHassan Aug 28, 2023
0a9b56b
made changes to nav bar to mae it mroe responsive, still WIP
roryhmartin Aug 29, 2023
dbe08c4
Navigation bar created
roryhmartin Sep 1, 2023
98575c4
nav updated
roryhmartin Sep 4, 2023
c63ad81
info section updated
roryhmartin Sep 6, 2023
8e848fd
section 4 started
roryhmartin Sep 12, 2023
5fc2da6
Finished Section 4
roryhmartin Sep 12, 2023
0fce16f
Changed wording
roryhmartin Sep 12, 2023
bb91bda
next section
roryhmartin Sep 18, 2023
1127ecb
Fixes
roryhmartin Sep 18, 2023
d49712c
Command line section
AydinHassan Sep 18, 2023
221e655
Equal x padding and capitalisation fixes
AydinHassan Sep 18, 2023
0791973
Dividers changed. Workshop section added
roryhmartin Sep 19, 2023
5741601
style changes to workshop section
roryhmartin Sep 19, 2023
ae1d819
Started adding animations on scroll
roryhmartin Sep 23, 2023
f0a83ff
Started rewriting ui images to html + fixed animate in
AydinHassan Sep 25, 2023
dfc762a
mini editor
AydinHassan Sep 25, 2023
6809723
improve editor
AydinHassan Sep 25, 2023
67d537d
Created Footer
roryhmartin Sep 28, 2023
fd487ea
Fixed error in horizontal rule
roryhmartin Sep 28, 2023
0a666d5
Fix diff order
AydinHassan Sep 29, 2023
b94d1a3
Allow to override modal padding
AydinHassan Sep 29, 2023
fe62922
Pad lines in solutions files so ace gutter width is consistent + impr…
AydinHassan Sep 29, 2023
294f40d
Improve editor styles + fix bug with file content syncing
AydinHassan Sep 29, 2023
4458c47
Fix reset after I just broke it, plus improve create file function
AydinHassan Sep 29, 2023
b5388eb
Don't close last tab
AydinHassan Sep 30, 2023
31ed8de
Don't allow adding package without tags
AydinHassan Sep 30, 2023
08d4449
Fix official solution v-model
AydinHassan Sep 30, 2023
633a43f
Created problem modal preview
roryhmartin Oct 1, 2023
7fd8b2c
Merge branch 'cloud-homepage-rory' of github.com:php-school/phpschool…
roryhmartin Oct 1, 2023
c289d42
Remaining homepage mocks
AydinHassan Oct 1, 2023
3a589ef
update deps
AydinHassan Oct 1, 2023
93a4df5
Editor gutter gradient
AydinHassan Oct 1, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"singleQuote": true,
"semi": false,
"tabWidth": 2

}
4 changes: 2 additions & 2 deletions app/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@
]
);

$renderer->addJs('jquery', '//code.jquery.com/jquery-1.12.0.min.js');
$renderer->addJs('highlight.js', '//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/highlight.min.js');
//$renderer->addJs('jquery', '//code.jquery.com/jquery-1.12.0.min.js');
//$renderer->addJs('highlight.js', '//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/highlight.min.js');

$manifest = $c->get(ViteManifest::class);
$renderer->addJs('main-js', $manifest->assetUrl('main.js'));
Expand Down
4 changes: 3 additions & 1 deletion assets/cloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import VueShepherdPlugin from './shepherd-plugin';
import results from "./components/results/results.js";
import StudentDropdown from "./components/StudentDropdown.vue";
import ListWorkshops from "./components/ListWorkshops.vue";
import Home from "./components/Home.vue";

const components = {
AceEditor,
Expand All @@ -32,7 +33,8 @@ const components = {
ExerciseVerify,
ExerciseEditor,
StudentDropdown,
ListWorkshops
ListWorkshops,
Home
}

const app = createApp({
Expand Down
74 changes: 61 additions & 13 deletions assets/components/AceEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import ace from 'ace-builds';
import 'ace-builds/src-noconflict/theme-monokai';
import 'ace-builds/src-noconflict/mode-php';
import 'ace-builds/src-noconflict/ext-language_tools';
import 'ace-builds/src-noconflict/snippets/php';
import {markRaw} from "vue";

export default {
Expand All @@ -11,7 +13,10 @@ export default {
default: false,
type: Boolean
},
file: Object,
value: {
type: String,
required: true,
},
minLines: Number,
maxLines: Number,
},
Expand All @@ -25,31 +30,55 @@ export default {
options.maxLines = this.maxLines;
}

ace.require("ace/ext/language_tools");
this._editor = markRaw(ace.edit(this.$el, options));

this._editor.setOption('useWorker', false);
this._editor.setShowPrintMargin(false);
this._editor.setTheme("ace/theme/monokai");
this._editor.container.style.lineHeight = 2
this._editor.session.setMode("ace/mode/php");
this._editor.setValue(this.file.content, 1);

this._editor.setOptions({
enableBasicAutocompletion: true,
enableSnippets: true,
enableLiveAutocompletion: false
});

this._editor.setValue(this.value, 1);
this._contentBackup = this.value;
this._isSettingContent = false;

if (this.readonly) {
this._editor.setReadOnly(true);
} else {
this._editor.session.on('change', this.change);
}
},
watch: {
'file.content'(newValue, oldValue) {
if (newValue !== oldValue) {
this._editor.setValue(newValue, 1);
}
}
},
methods: {
change() {
this.file.content = this._editor.session.getValue();
this.$emit('changeContent', this.file);
// ref: https://github.com/CarterLi/vue3-ace-editor/issues/11
if (this._isSettingContent) {
return;
}
const content = this._editor.session.getValue();
this._contentBackup = content;
this.$emit('update:value', content);
},
},
emits: ['update:value'],
watch: {
value(val) {
if (this._contentBackup !== val) {
try {
this._isSettingContent = true;
this._editor.setValue(val, 1);
} finally {
this._isSettingContent = false;
}
this._contentBackup = val;
}
},
},
beforeUnmount() {
this._editor.destroy();
Expand All @@ -58,5 +87,24 @@ export default {
</script>

<template>
<div class="h-full border-0"></div>
</template>
<div class="h-full border-0 bg-gray-900"></div>
</template>

<style>
.ace_gutter {
@apply !bg-gradient-to-b to-30% !from-gray-900 !to-[#0c1220];
}

.ace_marker-layer .ace_selection {
@apply !bg-gray-800;
}

.ace_gutter-active-line {
@apply !bg-gray-900;
}

.ace_active-line {
background-color: #0c1220 !important;
}

</style>
66 changes: 43 additions & 23 deletions assets/components/ExerciseEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import {
MapIcon,
HomeIcon,
ChevronRightIcon,
ExclamationCircleIcon
ExclamationCircleIcon,
AcademicCapIcon
} from '@heroicons/vue/24/solid';
import {TrophyIcon} from '@heroicons/vue/24/outline'
import PackageSearch from './PackageSearch.vue';
Expand Down Expand Up @@ -48,6 +49,7 @@ export default {
HomeIcon,
ChevronRightIcon,
ExclamationCircleIcon,
AcademicCapIcon,
OutputMismatch,
Confirm,
},
Expand All @@ -63,14 +65,7 @@ export default {
links: Object
},
mounted() {
const files = this.getSavedFiles();
for (const fileName in files) {
const fileContent = files[fileName];
const folderParts = fileName.split("/");

this.createFileInFolderStructure(this.studentFiles, folderParts, fileContent);
this.studentFiles = this.toTree(this.studentFiles);
}
},
data() {
//sort the initial files so entry point is at the top
Expand All @@ -82,7 +77,18 @@ export default {
const initialFileCopy = this.initialFiles.map(file => {
return {...file}
});
const studentFiles = this.toTree(initialFileCopy);
let studentFiles = this.toTree(initialFileCopy);

const files = this.getSavedFiles();
for (const fileName in files) {
const fileContent = files[fileName];
const folderParts = fileName.split("/");

this.createFileInFolderStructure(studentFiles, folderParts, fileContent);
}

//make sure new files added from saved files have two way relationship
studentFiles = this.toTree(studentFiles);

return {
firstRunLoaded: false,
Expand Down Expand Up @@ -122,7 +128,7 @@ export default {
methods: {
getSavedFiles() {
const items = { ...localStorage };
const key = this.currentExercise.workshop.code + '.' + this.currentExercise.exercise.slug;
const key = this.workshop.code + '.' + this.exercise.slug;

const files = {};
for (const localStorageKey in items) {
Expand Down Expand Up @@ -198,12 +204,12 @@ export default {

return subdirectory;
},
saveSolution(file) {
saveSolution(fileContent, file) {
const filePath = toFilePath(file);

localStorage.setItem(
this.currentExercise.workshop.code + '.' + this.currentExercise.exercise.slug + '.' + filePath,
file.content
fileContent
);
},
resetState() {
Expand Down Expand Up @@ -244,6 +250,16 @@ export default {
return;
}

if (!selectedFile.content) {
selectedFile.content = '';

if (selectedFile.name.endsWith('.php')) {
selectedFile.content = '<?php\n\n';
}

this.saveSolution(selectedFile.content, selectedFile);
}

const found = this.openFiles.find(file => file === selectedFile);

if (!found) {
Expand Down Expand Up @@ -316,6 +332,10 @@ export default {
this.loadingResults = false;
},
closeTab(tab) {
if (this.openFiles.length === 1) {
return;
}

let index = this.openFiles.findIndex(file => file.name === tab);

this.openFiles.splice(index, 1);
Expand Down Expand Up @@ -449,37 +469,37 @@ export default {

<div class="h-full flex flex-col">
<div class="flex flex-1 h-full relative">
<div class="w-1/5 p-4 min-w-[300px]">
<file-tree
<div class="w-3/12 xl:w-2/12">
<FileTree
:files="studentFiles"
:file-select-function="studentSelectFile"
:initial-selected-item="studentFiles[0]"
:delete-function="deleteFileOrFolder"
show-controls
@reset="resetFiles"/>
</div>
<div class="flex border-l border-solid border-gray-600 p-4 h-full"
:class="[openResults ? 'w-3/5' : 'w-4/5']">
<div class="flex border-l border-solid border-gray-600 h-full"
:class="[openResults ? 'w-6/12 xl:w-7/12' : 'w-9/12 xl:w-10/12']">
<Tabs :tabList="openFiles.map(file => file.name)" @close-tab="closeTab" :active-tab="activeTab">
<template v-slot:[`tab-content-`+index] v-for="(file, index) in openFiles">
<AceEditor :id="'editor-' + (index + 1)" :file="file" @changeContent="saveSolution"
<AceEditor :id="'editor-' + (index + 1)" v-model:value="file.content" @update:value="(content) => saveSolution(content, file)"
class="w-full h-full border-0"/>
</template>
</Tabs>
</div>
<div v-if="openResults" id="results-col"
class="w-1/5 flex flex-col border-l border-solid border-gray-600 p-4 h-full absolute right-0 overflow-y-scroll">
<div class="ml-8 flex justify-between items-center">
<h1 class="text-2xl pt-0 ">Results</h1>
<div v-show="openResults" id="results-col"
class="w-3/12 flex flex-col bg-gray-950 border-l border-solid border-gray-600 h-full absolute right-0 overflow-y-scroll">
<div class="pl-4 pr-4 py-4 flex justify-between items-center border-solid border-b border-gray-600">
<h1 class="text-2xl pt-0 flex items-center"><AcademicCapIcon class="h-5 w-5 mr-2"/> Results</h1>
<div>
<button @click="openResults = false" type="button"
class="text-gray-400 bg-transparent rounded-lg text-sm p-1.5 ml-auto inline-flex items-center hover:bg-gray-600 hover:text-white">
class="text-gray-400 bg-transparent rounded-lg text-sm p-1.5 ml-auto inline-flex items-center hover:hover:text-white">
<XMarkIcon class="w-5 h-5"/>
</button>
</div>
</div>

<div v-show="loadingResults" class="animate-pulse flex space-x-4 mt-4">
<div v-show="loadingResults" class="animate-pulse flex space-x-4 mt-4 px-4">
<div class="flex-1 space-y-6 py-1">
<div class="h-2 bg-slate-700 rounded"></div>
<div class="space-y-3">
Expand Down
6 changes: 3 additions & 3 deletions assets/components/FileTree.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,16 @@ export default {
</script>

<template>
<div class="border border-solid border-gray-600 rounded">
<div class="border-b border-solid border-gray-600 p-3 flex justify-between">
<div class="">
<div class="border-b border-solid border-gray-600 py-5 px-3 flex justify-between">
<span class="text-white text-base font-mono">Files</span>
<div v-if="showControls" class="flex text-white">
<XMarkIcon @click="reset" class="mr-2 h-5 w-5 cursor-pointer hover:text-pink-500" style="fill: none !important;"/>
<FolderPlusIcon @click="addFolder" class="mr-2 h-5 w-5 cursor-pointer hover:text-pink-500" style="fill: none !important;"/>
<PlusIcon @click="addFile" class="mr-2 h-5 w-5 cursor-pointer hover:text-pink-500" style="fill: none !important;"/>
</div>
</div>
<ul class="w-full text-gray-300 font-mono p-1">
<ul class="w-full text-gray-300 font-mono">
<tree-item
v-for="file in files"
:parent="files"
Expand Down
Loading