diff --git a/Frontend/README.md b/Frontend/README.md index 831a223..3a9b0e0 100644 --- a/Frontend/README.md +++ b/Frontend/README.md @@ -1,4 +1,4 @@ -# new-frontend +# Modern frontend for Release 11 Tools This template should help get you started developing with Vue 3 in Vite. @@ -44,3 +44,46 @@ npm run build ```sh npm run lint ``` + +## Structure of Vuejs 3 components and views in this project + +For this document's needs components and views will be named "modules" even though this is not a correct term for these files officially. + +### Main structure + +- \ +- \ +- \ - if really needed + +### Scripts + +#### Elements should be placed in this order: + - Imports + - Props - constant defined by defineProps function, named "props" in code +This name allows to have readable code sending data to parent module: +```TS + props.exampleProp +``` + - Emits - constant defined by defineEmits function, named "emit" in code. This name allows to have readable code sending data to parent module: +```TS + emit("update:modelValue", exampleVariable) +``` + - Interfaces + - Refs - constants defined by ref functions with appropriate values + - Injects - variables assigned by "inject" function + - Other variables/constants + - onFunctions - functions like onBeforeUpdate + - Other functions + +#### Rules regarding functions: + - Functions ought to have descriptive name + - Ought to do one thing. ie. function sendRequest should send request, but not prepare request body or process response data + - In practice, if function has more than 10 SLoC, it probably should be split + - DO NOT use "any" type. Just don't. *Optional + - Function used in other function should be placed below it (if possible, as function can be called from many places in the code) + +#### Rules regarding variables and refs: + - Variables ought to have descriptive name + +In cases not covered in this convention, TypeScript, VueJS 3 conventions and good programming practices are applied + diff --git a/Frontend/src/components/common/CodeEditorComponent.vue b/Frontend/src/components/common/CodeEditorComponent.vue index 19252c9..bc233b7 100644 --- a/Frontend/src/components/common/CodeEditorComponent.vue +++ b/Frontend/src/components/common/CodeEditorComponent.vue @@ -7,12 +7,6 @@ import {xml} from '@codemirror/lang-xml' import {json} from '@codemirror/lang-json' import {html} from '@codemirror/lang-html' -function isDarkModeSet(){ - return localStorage.theme == "dark"; -} - -const theme : string = inject('theme')! ; - const props= defineProps({ code : { type: String, @@ -30,21 +24,25 @@ const emit = defineEmits( ] ) +const theme : string = inject('theme')!; +let extensions = parseExtensions(); + +onBeforeUpdate( () => { extensions = parseExtensions(); } ) + function dataUpdated(newData:String){ emit('update:updatedCode',newData) } function selectTheme() { - if (isDarkModeSet()) { + if (isDarkModeSet()) return oneDark; - } - else { + else return espresso; - } } -let extensions = parseExtensions(); - +function isDarkModeSet(){ + return localStorage.theme == "dark"; +} function parseExtensions(){ return [ @@ -68,7 +66,7 @@ function parseLanguage(name: String){ } -onBeforeUpdate( () => { extensions = parseExtensions(); } ) + diff --git a/Frontend/src/components/common/ThemeSwitcherComponent.vue b/Frontend/src/components/common/ThemeSwitcherComponent.vue index 789602f..f5b75ea 100644 --- a/Frontend/src/components/common/ThemeSwitcherComponent.vue +++ b/Frontend/src/components/common/ThemeSwitcherComponent.vue @@ -1,30 +1,22 @@ diff --git a/Frontend/src/components/formatter/HtmlButtonFormatterComponent.vue b/Frontend/src/components/formatter/HtmlButtonFormatterComponent.vue index b65cba0..43a7c9c 100644 --- a/Frontend/src/components/formatter/HtmlButtonFormatterComponent.vue +++ b/Frontend/src/components/formatter/HtmlButtonFormatterComponent.vue @@ -21,6 +21,8 @@ const emit = defineEmits([ 'update:error' ]) +const fetchLink = document.location.protocol + "//" + document.location.hostname + "/libxml/html/" + chooseType(props.formatType); + function chooseType(formatType: String){ if (formatType == "HTML -> XML"){ return "convert"; @@ -45,8 +47,6 @@ function createBody(){ }); } -const fetchLink = document.location.protocol + "//" + document.location.hostname + "/libxml/html/" + chooseType(props.formatType); - function process(){ fetch(fetchLink, {body:createBody(), method: "POST"}) diff --git a/Frontend/src/components/landing/LandingComponent.vue b/Frontend/src/components/landing/LandingComponent.vue index 22cfd17..7c1aef8 100644 --- a/Frontend/src/components/landing/LandingComponent.vue +++ b/Frontend/src/components/landing/LandingComponent.vue @@ -19,7 +19,7 @@
  • XPath - This is tool that allows to parse XPath on selected XML
  • XQuery - Allows to execute XQuery on provided XML file.
  • XSD - Allows to validate XML against provided XSD schema.
  • -
  • XSLT - Allows to transformate XML using XSLT transformate.
  • +
  • XSLT - Allows to transform XML using XSLT transform.
  • Formatter - Tools:

    diff --git a/Frontend/src/components/man/ElementDescription.vue b/Frontend/src/components/man/ElementDescription.vue index 1cd9c8e..6c4c13d 100644 --- a/Frontend/src/components/man/ElementDescription.vue +++ b/Frontend/src/components/man/ElementDescription.vue @@ -1,9 +1,5 @@ \ No newline at end of file diff --git a/Frontend/src/components/mock/HistoryRecords.vue b/Frontend/src/components/mock/HistoryRecords.vue index ab1546c..fa0b9df 100644 --- a/Frontend/src/components/mock/HistoryRecords.vue +++ b/Frontend/src/components/mock/HistoryRecords.vue @@ -1,6 +1,11 @@