From 47151e83db989915ae7afa6e4870b26f67353cd0 Mon Sep 17 00:00:00 2001 From: Adam Bem Date: Wed, 6 Dec 2023 12:42:01 +0100 Subject: [PATCH 1/4] Wrote draft of project conventions --- Frontend/README.md | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/Frontend/README.md b/Frontend/README.md index 831a223..2d82fee 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,31 @@ 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 officialy. + +### Main structure + +Each file should start with \ tag followed by \ tag. If \ tag is used (which should be avoided, this project uses Tailwind CSS for styling) it should be placed at the end of the file. + +### Scripts + +Elements should be placed in this order: + - Props - constant defined by defineProps function + - Emits - constant defined by defineEmits function + - Refs - contstans defined by ref functions with appropriate values + - Other functions + +Rules regarding functions: + - Functions ought to have descriptive name + - Ought to do one thing. ie. function fetchRequest should send request, but not prepare request body + - In practice, if function has more than 10 SLoC, it probably should be split + - DO NOT use "any" type. Just don't. + - Function used in current function should be placed below it (if posible, as function can be called from many places in the code) + - + +Rules regarding variables and refs: + - + -- 2.51.0 From 660c250ad861503034b58442f106a33719fbb6f9 Mon Sep 17 00:00:00 2001 From: Adam Bem Date: Wed, 6 Dec 2023 12:42:56 +0100 Subject: [PATCH 2/4] Formatting fix --- Frontend/README.md | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/Frontend/README.md b/Frontend/README.md index 2d82fee..20374a3 100644 --- a/Frontend/README.md +++ b/Frontend/README.md @@ -47,28 +47,38 @@ 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 officialy. +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 -Each file should start with \ tag followed by \ tag. If \ tag is used (which should be avoided, this project uses Tailwind CSS for styling) it should be placed at the end of the file. +- \ +- \ +- \ - if really needed ### Scripts -Elements should be placed in this order: - - Props - constant defined by defineProps function - - Emits - constant defined by defineEmits function - - Refs - contstans defined by ref functions with appropriate values +#### Elements should be placed in this order: + - 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) +``` + - Refs - constants defined by ref functions with appropriate values - Other functions -Rules regarding functions: +#### Rules regarding functions: - Functions ought to have descriptive name - - Ought to do one thing. ie. function fetchRequest should send request, but not prepare request body + - 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. - - Function used in current function should be placed below it (if posible, as function can be called from many places in the code) - - + - Function used in other function should be placed below it (if posible, as function can be called from many places in the code) -Rules regarding variables and refs: - - +#### 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 -- 2.51.0 From 2a60cecf2a64593ab79a2f124fe0c93f841ea1f6 Mon Sep 17 00:00:00 2001 From: Adam Bem Date: Thu, 7 Dec 2023 10:36:13 +0100 Subject: [PATCH 3/4] Adjusted project to match convention --- Frontend/README.md | 7 +++- .../components/common/CodeEditorComponent.vue | 24 ++++++------- .../common/ThemeSwitcherComponent.vue | 34 +++++++------------ .../HtmlButtonFormatterComponent.vue | 4 +-- .../components/landing/LandingComponent.vue | 2 +- .../src/components/man/ElementDescription.vue | 4 --- Frontend/src/components/man/ImgMan.vue | 4 --- .../components/man/ManTooltipComponent.vue | 12 ------- .../components/mock/BodyDetailComponent.vue | 2 +- .../src/components/mock/HistoryRecords.vue | 15 ++++---- .../mock/MockedMessageToastComponent.vue | 1 - .../mock/RestMockMessageComponent.vue | 10 +++--- .../components/xml/XmlInputFieldComponent.vue | 3 +- .../xml/XmlTabbedInputComponent.vue | 6 ++-- .../xml/tooltips/TooltipDiffsComponent.vue | 6 ++-- Frontend/src/views/Base64EncoderView.vue | 10 +++--- 16 files changed, 59 insertions(+), 85 deletions(-) diff --git a/Frontend/README.md b/Frontend/README.md index 20374a3..1e672a4 100644 --- a/Frontend/README.md +++ b/Frontend/README.md @@ -58,6 +58,7 @@ For this document's needs components and views will be named "modules" even thou ### 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 @@ -67,7 +68,11 @@ 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: @@ -75,7 +80,7 @@ This name allows to have readable code sending data to parent module: - 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. - - Function used in other function should be placed below it (if posible, as function can be called from many places in the code) + - 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 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 @@