Skip to content

Commit d7e2695

Browse files
done
2 parents c550136 + 30556a7 commit d7e2695

File tree

9 files changed

+26493
-181
lines changed

9 files changed

+26493
-181
lines changed

package-lock.json

Lines changed: 26383 additions & 155 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/Canvas.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
<template>
88
<!-- the background Canvas grid -->
99
<div class="component-display grid-bg" :style="{backgroundColor:'#FFFFF' }" v-on:click="handleClick" v-on:click.right="handleRight">
10-
<div class="cssContainer" :style="{
11-
'background-size': `${gridWidth}px ${gridHeight}px,
12-
${gridWidth}px ${gridHeight}px`,
13-
'height': `${this.containerH}px`, 'width': `${this.containerW}px`
10+
<div class="cssContainer" :style="{
11+
'background-size': `${gridWidth}px ${gridHeight}px,
12+
${gridWidth}px ${gridHeight}px`,
13+
'height': `${this.containerH}px`, 'width': `${this.containerW}px`
1414
}">
1515
<!-- This is the actual component box -->
1616
<!-- https://www.npmjs.com/package/vue-draggable-resizable -->
@@ -467,7 +467,7 @@ export default {
467467
// find the amount of grid lines for width
468468
gridWidth() {
469469
return this.containerW / this.gridLayout[0];
470-
},
470+
},
471471
// find the amount of grid lines for height
472472
gridHeight() {
473473
return this.containerH / this.gridLayout[1];

src/components/left-sidebar/ComponentTab/CreateMenu.vue

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,16 @@ Description:
2828
></q-input>
2929
</form>
3030

31-
<ParentMultiselect
31+
<ParentMultiselect
3232
@addparent="parent = $event"
3333
v-if="activeComponent === ''"></ParentMultiselect>
3434

3535
<!-- <q-expansion-item group="accordion" label="Create Component" > -->
3636
<LibComponents></LibComponents>
3737
<div class="searchinput">
38-
<q-input outlined v-model="input" placeholder="Please input" label="Search Element+ Components"
3938

39+
<q-input outlined v-model="input" placeholder="Please input" label="Search Element+ Components"
40+
id="searchbox"
4041
color="white"
4142
dark
4243
dense
@@ -45,6 +46,7 @@ Description:
4546
class="input-add"
4647
no-error-icon
4748
/>
49+
4850
</div>
4951

5052

@@ -308,8 +310,11 @@ pickComponent(componentName){
308310
max-width: 600px;
309311
}
310312
.searchinput{
311-
margin-right: 10px;
313+
314+
width: 260px;
315+
312316
}
313317
314318
319+
315320
</style>

src/components/nav-buttons/ExportMenu.vue

Lines changed: 49 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,25 @@ test('renders ${componentName}', () => {
535535
fs.writeFileSync(path.join(location, "firebaseConfig.js"), str);
536536
}
537537
},
538+
539+
createjestConfigFile(location){
540+
if(this.$store.state.importTest ==='on'){
541+
let str = `module.exports = {`;
542+
str += `\n\tpreset: '@vue/cli-plugin-unit-jest'`;
543+
str += `\n}`
544+
fs.writeFileSync(path.join(location,"jest.config.js"), str);
545+
}
546+
},
547+
createbabelConfigFile(location){
548+
if(this.$store.state.importTest ==='on'){
549+
let str = `module.exports = {`;
550+
str += `\n\tpresets: [`;
551+
str += `\n\t\t'@vue/cli-plugin-babel/preset'`;
552+
str += `\n\t]`;
553+
str += `\n}`
554+
fs.writeFileSync(path.join(location,"babel.config.js"), str);
555+
}
556+
},
538557
createOauthFile(location){
539558
if(this.$store.state.exportOauth ==='on'||this.$store.state.exportOauthGithub ==='on'){
540559
let str = `<template>`;
@@ -648,21 +667,14 @@ test('renders ${componentName}', () => {
648667
str += `\nimport store from './store'`
649668
str += `\nimport App from './App.vue';`;
650669
str += `\nimport router from './router';\n`;
651-
if(this.$store.state.importLibraries.includes('element')){
652-
str+= `\nimport ElementPlus from 'element-plus';`
653-
str+=`\nimport 'element-plus/dist/index.css';`
654-
};
670+
str+= `\nimport ElementPlus from 'element-plus';`
671+
str+=`\nimport 'element-plus/dist/index.css';`
655672
str += `\nconst app = createApp(App);`;
656673
str += `\napp.use(router);`;
657674
str += `\napp.use(store)`;
658-
if(this.$store.state.importLibraries.includes('element')){
659-
str+=`\napp.use(ElementPlus);`;
660-
};
675+
str+=`\napp.use(ElementPlus);`;
661676
str += `\napp.mount('#app');`;
662677
663-
664-
665-
666678
// if using typescript, export with .ts extension
667679
if (this.exportAsTypescript === "on") {
668680
fs.writeFileSync(path.join(location, "src", "main.ts"), str);
@@ -785,11 +797,19 @@ test('renders ${componentName}', () => {
785797
str += `\n\t"scripts": {`;
786798
str += `\n\t\t"dev": "vite",`;
787799
if (this.exportAsTypescript === "on") {
800+
788801
str += `\n\t\t"build": "vue-tsc --noEmit && vite build",`;
802+
if(this.$store.state.importTest ==='on'){
803+
str +=`\n\t\t"test:unit": "vue-cli-service test:unit",`
804+
}
805+
789806
str += `\n\t\t"typecheck": "vue-tsc --noEmit",`;
790807
str += `\n\t\t"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",`;
791808
} else {
792809
str += `\n\t\t"build": "vite build",`;
810+
if(this.$store.state.importTest ==='on'){
811+
str +=`\n\t\t"test:unit": "vue-cli-service test:unit",`
812+
}
793813
str += `\n\t\t"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs --fix --ignore-path .gitignore",`;
794814
}
795815
str += `\n\t\t"preview": "vite preview --port 5050"`;
@@ -798,9 +818,8 @@ test('renders ${componentName}', () => {
798818
str += `\n\t\t"vue": "^3.2.31",`;
799819
str += `\n\t\t"vue-router": "^4.0.12",`;
800820
str += `\n\t\t"vuex": "^4.0.2"`;
801-
if(this.$store.state.importLibraries.includes('element')){
802-
str += `,\n\t\t"element-plus": "^2.2.16"`;
803-
};
821+
str += `,\n\t\t"element-plus": "^2.2.16"`;
822+
804823
if(this.$store.state.exportOauth ==='on'||this.$store.state.exportOauthGithub ==='on'){
805824
str += `,\n\t\t "firebase": "^9.6.9"`
806825
}
@@ -810,6 +829,18 @@ test('renders ${componentName}', () => {
810829
str += `\n\t\t"eslint": "^8.5.0",`;
811830
str += `\n\t\t"eslint-plugin-vue": "^8.2.0",`;
812831
str += `\n\t\t"vite": "^2.8.4"`
832+
if(this.$store.state.importTest ==='on'){
833+
str+=`,\n\t\t"@babel/core": "^7.12.16",`
834+
str+=`\n\t\t"@babel/eslint-parser": "^7.12.16",`
835+
str+=`\n\t\t"@vue/cli-plugin-babel": "~5.0.0",`
836+
str+=`\n\t\t"@vue/cli-plugin-eslint": "~5.0.0",`
837+
str+=`\n\t\t"@vue/cli-plugin-unit-jest": "~5.0.0",`
838+
str+=`\n\t\t"@vue/cli-service": "~5.0.0",`
839+
str+=`\n\t\t"@vue/test-utils": "^2.0.0-0",`
840+
str+=`\n\t\t"@vue/vue3-jest": "^27.0.0-alpha.1",`
841+
str+=`\n\t\t"babel-jest": "^27.0.6",`
842+
str+=`\n\t\t"jest": "^27.0.5"`
843+
}
813844
if (this.exportAsTypescript === "on") {
814845
str += `,\n\t\t"@rushstack/eslint-patch": "^1.1.0",`
815846
str += `\n\t\t"@vue/tsconfig": "^0.1.3",`;
@@ -832,8 +863,8 @@ test('renders ${componentName}', () => {
832863
fs.mkdirSync(path.join(data, "src", "views"));
833864
fs.mkdirSync(path.join(data, "src", "router"));
834865
fs.mkdirSync(path.join(data, "src", "store"));
835-
fs.mkdirSync(path.join(data, "test-templates"));
836-
fs.mkdirSync(path.join(data, "test-templates", "components"));
866+
fs.mkdirSync(path.join(data, "tests"));
867+
fs.mkdirSync(path.join(data, "tests", "unit"));
837868
}
838869
// creating basic boilerplate for vue app
839870
this.createIndexFile(data);
@@ -847,6 +878,8 @@ test('renders ${componentName}', () => {
847878
this.createStore(data);
848879
this.createFirebaseConfigFile(data);
849880
this.createOauthFile(data);
881+
this.createjestConfigFile(data);
882+
this.createbabelConfigFile(data)
850883
// exports images to the /assets folder
851884
// eslint-disable-next-line no-unused-vars
852885
for (let [routeImage, imageLocation] of Object.entries(this.imagePath)) {
@@ -876,7 +909,7 @@ test('renders ${componentName}', () => {
876909
componentName,
877910
this.componentMap
878911
);
879-
this.createComponentTestCode(path.join(data, "test-templates", "components", componentName + '.spec.js'),
912+
this.createComponentTestCode(path.join(data, "tests", "unit", componentName + '.spec.js'),
880913
componentName,
881914
this.componentMap)
882915
}

src/layouts/MyLayout.vue

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,20 @@ Description:
6767
<span class="switch-handle" :value="this.exportAsTypescript"></span>
6868
</label>
6969
</div>
70+
71+
<div class="Test">
72+
<p class="Test-text"> <b>
73+
Vue Test:
74+
75+
</b> </p>
76+
<label for="Test" class="switch" >
77+
<input v-if="this.importTest === 'on'" class="switch-input" type="checkbox" name="Test" id="Test" :value="this.importTest" @change="syncTestFlag" checked/>
78+
<input v-else class="switch-input" type="checkbox" name="Test" id="Test" :value="this.importTest" @change="syncTestFlag"/>
79+
<span class="switch-label" :value="this.importTest" data-on="on" data-off="off"></span>
80+
<span class="switch-handle" :value="this.importTest"></span>
81+
</label>
82+
</div>
83+
7084
<div class="drawer">
7185
<q-expansion-item group="accordion" label="Create Oauth" >
7286
<div class="Oauth">
@@ -95,6 +109,7 @@ Description:
95109
</label>
96110
</div>
97111
</q-expansion-item>
112+
98113
</div>
99114
</div>
100115
<i id="btn"></i>
@@ -212,7 +227,7 @@ export default {
212227
GridDensity
213228
},
214229
computed: {
215-
...mapState(["exportAsTypescript","exportOauth","exportOauthGithub"]),
230+
...mapState(["exportAsTypescript","exportOauth","exportOauthGithub","importTest"]),
216231
},
217232
methods: {
218233
...mapActions(["toggleTutorial"]),
@@ -267,6 +282,19 @@ export default {
267282
}
268283
this.$store.commit("EXPORT_AS_TYPESCRIPT", checkboxValue);
269284
},
285+
syncTestFlag(e) {
286+
console.log(this.$store.state.importTest )
287+
288+
let checkboxValue;
289+
if (e.target.value === "off") {
290+
checkboxValue = "on";
291+
} else {
292+
checkboxValue = "off";
293+
}
294+
this.$store.commit("EXPORT_TEST", checkboxValue);
295+
console.log(this.$store.state.importTest )
296+
297+
},
270298
syncOauthFlag(e) {
271299
272300
let checkboxValue;
@@ -626,4 +654,15 @@ q-btn > i {
626654
margin-left: 25px;
627655
628656
}
657+
.Test{
658+
659+
display: flex;
660+
align-items: flex-end;
661+
margin: 10px;
662+
flex-direction: row;
663+
664+
}
665+
.Test-text{
666+
margin-right: 10px;
667+
}
629668
</style>

src/store/mutations.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ const mutations = {
116116
[types.EXPORT_OAUTH_GIT]: (state, payload) => {
117117
state.exportOauthGithub = payload;
118118
},
119+
[types.EXPORT_TEST]: (state, payload) => {
120+
state.importTest = payload;
121+
},
119122

120123
[types.CREATE_ACTION]: (state, payload) => {
121124
state.userActions.push(payload);

src/store/state/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ const newState :types.State = {
7272
containerH: 720, // in px
7373
containerW: 1280, // in px
7474
importLibraries:[],
75-
displaylibComponent:false
75+
displaylibComponent:false,
76+
importTest:'off'
7677
//push libraries string to the array
7778
};
7879

src/store/types.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ export const DELETE_USER_STATE = 'DELETE_USER_STATE'
6969
export const EXPORT_AS_TYPESCRIPT = 'EXPORT_AS_TYPESCRIPT'
7070
export const EXPORT_OAUTH = 'EXPORT_OAUTH'
7171
export const EXPORT_OAUTH_GIT = 'EXPORT_OAUTH_GIT'
72+
export const EXPORT_TEST = 'EXPORT_TEST'
7273
export const TOGGLE_TUTORIAL = 'TOGGLE_TUTORIAL'
7374
export const ADD_ACTIVE_COMPONENT_NOTE = 'ADD_ACTIVE_COMPONENT_NOTE'
7475
export const DELETE_ACTIVE_COMPONENT_NOTE = 'DELETE_ACTIVE_COMPONENT_NOTE'

types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ export type State = {
5959
containerW: number,
6060
importLibraries: string[],
6161
displaylibComponent: boolean,
62+
importTest:string
63+
6264
};
6365

6466
// Type for HTML Element Map that used in multiple files

0 commit comments

Comments
 (0)