Skip to content

Commit 8989fe9

Browse files
committed
11Jul24 update prettier.json config
1 parent 0afac3b commit 8989fe9

18 files changed

+101
-118
lines changed

.prettierrc.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
{
22
"$schema": "https://json.schemastore.org/prettierrc",
3-
"semi": false,
3+
"semi": true,
44
"tabWidth": 2,
55
"singleQuote": true,
6-
"printWidth": 100,
7-
"trailingComma": "none"
6+
"printWidth": 120
87
}

src/App.vue

+18-18
Original file line numberDiff line numberDiff line change
@@ -9,36 +9,36 @@ import questionIcon from "@/assets/question.svg";
99
const route = useRoute();
1010
const title = useTitle();
1111
watch(
12-
() => route.path,
13-
(newPath) => {
14-
title.value = `VueEx${newPath}` || 'VueEx';
15-
},
12+
() => route.path,
13+
(newPath) => {
14+
title.value = `VueEx${newPath}` || "VueEx";
15+
},
1616
);
1717
</script>
1818

1919
<template>
2020
<div class="flex h-full w-full flex-row gap-x-2">
2121
<div
22-
class="scrollable-area flex h-full w-64 flex-col gap-y-4 overflow-y-auto rounded bg-green-300 px-3 py-2"
22+
class="scrollable-area flex h-full w-64 flex-col gap-y-4 overflow-y-auto rounded bg-green-300 px-3 py-2"
2323
>
2424
<div class="sticky text-3xl font-semibold">Vue 3 Examples</div>
2525
<div
26-
v-for="{ name, examples, link } in ALL_EXAMPLES"
27-
:key="name"
28-
class="flex flex-col gap-y-2"
26+
v-for="{ name, examples, link } in ALL_EXAMPLES"
27+
:key="name"
28+
class="flex flex-col gap-y-2"
2929
>
30-
<p
31-
class="text-xl font-bold"
32-
>{{ name }} <a :href="link" target="_blank">
33-
<img class="w-4 inline" :src="questionIcon" alt="Question" />
34-
</a>
30+
<p class="text-xl font-bold">
31+
{{ name }}
32+
<a :href="link" target="_blank">
33+
<img class="inline w-4" :src="questionIcon" alt="Question" />
34+
</a>
3535
</p>
3636

3737
<RouterButton
38-
v-for="example in examples"
39-
:key="example.name"
40-
:to-path="example.path"
41-
:name="example.name"
38+
v-for="example in examples"
39+
:key="example.name"
40+
:to-path="example.path"
41+
:name="example.name"
4242
/>
4343
</div>
4444
<RouterButton to-path="/test" name="test me" />
@@ -58,4 +58,4 @@ watch(
5858
.scrollable-area:hover::-webkit-scrollbar-thumb {
5959
background: #999; /* darker gray color on hover */
6060
}
61-
</style>
61+
</style>

src/ReplFactory.js

-2
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,3 @@ export function createReplComponent(codeString, files = {}) {
99
},
1010
});
1111
}
12-
13-

src/components/ReplWrapper.vue

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const props = defineProps({
77
codeString: {
88
type: String,
99
required: false,
10-
default: ""
10+
default: "",
1111
},
1212
files: {
1313
type: Object,
@@ -28,7 +28,6 @@ if (props.codeString) {
2828
...props.files,
2929
});
3030
}
31-
3231
</script>
3332

3433
<template>

src/components/RouterButton.vue

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script setup>
2-
import {computed, defineProps} from "vue";
3-
import {useRoute} from "vue-router";
2+
import { computed, defineProps } from "vue";
3+
import { useRoute } from "vue-router";
44
55
const props = defineProps({
66
toPath: {
@@ -15,7 +15,7 @@ const props = defineProps({
1515
1616
const route = useRoute();
1717
const isSelected = computed(() => {
18-
return route.path === props.toPath
18+
return route.path === props.toPath;
1919
});
2020
</script>
2121

src/exampleButtons.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { IntroductionButtonExamples } from "@/factory/IntroductionFactory.js";
33
import { StyleButtonExamples } from "@/factory/StylesFactory.js";
44
import { RenderingButtonExamples } from "@/factory/RenderingFactory.js";
55
import { EventHandlingButtonExamples } from "@/factory/EventHandlingFactory.js";
6-
import {OthersButtonExamples} from "@/factory/OthersFactory.js";
7-
import {PropsButtonExamples} from "@/factory/PropsFactory.js";
6+
import { OthersButtonExamples } from "@/factory/OthersFactory.js";
7+
import { PropsButtonExamples } from "@/factory/PropsFactory.js";
88

99
export const ALL_EXAMPLES = [
1010
IntroductionButtonExamples,

src/factory/EventHandling2Factory.js

+16-26
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
2-
3-
4-
51
// Events
62
import ComponentEventsAppVue from "@/views/eventhandling/componentevents/AppView.vue?raw";
73
import ComponentEventsInnerVue from "@/views/eventhandling/componentevents/InnerView.vue?raw";
@@ -10,43 +6,37 @@ import DomEventForwardingInnerVue from "@/views/eventhandling/domeventforwarding
106
import EventForwardingAppVue from "@/views/eventhandling/eventforwarding/GrandParentView.vue?raw";
117
import EventForwardingChildVue from "@/views/eventhandling/eventforwarding/ChildView.vue?raw";
128
import EventForwardingParentVue from "@/views/eventhandling/eventforwarding/ParentView.vue?raw";
13-
import {createReplComponent} from "@/ReplFactory.js";
14-
import {createExample, createRouterObjAdvanced} from "@/util.js";
15-
16-
9+
import { createReplComponent } from "@/ReplFactory.js";
10+
import { createExample, createRouterObjAdvanced } from "@/util.js";
1711

1812
const ComponentEventsVue = {
1913
name: "Component Events",
20-
component: createReplComponent(ComponentEventsAppVue, {
14+
component: createReplComponent(ComponentEventsAppVue, {
2115
"InnerView.vue": ComponentEventsInnerVue,
22-
})
23-
}
24-
16+
}),
17+
};
2518

2619
const DomEventForwardingVue = {
2720
name: "Dom Event Forwarding",
2821
component: createReplComponent(DomEventForwardingAppVue, {
2922
"InnerView.vue": DomEventForwardingInnerVue,
30-
})
31-
}
23+
}),
24+
};
3225

3326
const EventForwardingVue = {
3427
name: "Event Forwarding",
3528
component: createReplComponent(EventForwardingAppVue, {
3629
"ChildView.vue": EventForwardingChildVue,
3730
"ParentView.vue": EventForwardingParentVue,
38-
})
39-
40-
}
41-
42-
const list = [
43-
ComponentEventsVue,
44-
DomEventForwardingVue,
45-
EventForwardingVue,
46-
]
47-
48-
export const EventHandling2Router = list.map((component) => createRouterObjAdvanced(component.name, component.component));
31+
}),
32+
};
4933

34+
const list = [ComponentEventsVue, DomEventForwardingVue, EventForwardingVue];
5035

36+
export const EventHandling2Router = list.map((component) =>
37+
createRouterObjAdvanced(component.name, component.component),
38+
);
5139

52-
export const EventHandling2ButtonExamples = list.map((component) => createExample(component.name));
40+
export const EventHandling2ButtonExamples = list.map((component) =>
41+
createExample(component.name),
42+
);

src/factory/EventHandlingFactory.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import { createExample, createRouterObj, sortExamples } from "@/util.js";
2-
import {EventHandling2ButtonExamples, EventHandling2Router} from "@/factory/EventHandling2Factory.js";
2+
import {
3+
EventHandling2ButtonExamples,
4+
EventHandling2Router,
5+
} from "@/factory/EventHandling2Factory.js";
36

47
const path = "/src/views/eventhandling/";
58

@@ -15,12 +18,12 @@ const fileNames = Object.keys(modules).map((key) =>
1518
);
1619

1720
let exampleList = fileNames.map((filename) => createExample(filename));
18-
exampleList = [...exampleList, ...EventHandling2ButtonExamples]
21+
exampleList = [...exampleList, ...EventHandling2ButtonExamples];
1922

2023
let EventHandlingRouterList = fileNames.map((filename) =>
2124
createRouterObj(filename, modules, path),
2225
);
23-
EventHandlingRouterList = [...EventHandlingRouterList, ...EventHandling2Router]
26+
EventHandlingRouterList = [...EventHandlingRouterList, ...EventHandling2Router];
2427

2528
const orderedList = [
2629
"If Conditional",

src/factory/IntroductionFactory.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
import {
2-
createExample,
3-
createRouterObj,
4-
sortExamples,
5-
} from "@/util.js";
1+
import { createExample, createRouterObj, sortExamples } from "@/util.js";
62

73
const path = "/src/views/introduction/";
84

@@ -29,7 +25,7 @@ const orderedList = [
2925
"Dynamic Attributes",
3026
"Text Input",
3127
"Checkbox Input",
32-
"Numeric Input"
28+
"Numeric Input",
3329
];
3430

3531
// write a util method given to sort exampleList based on orderedList

src/factory/OthersFactory.js

+8-6
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,31 @@ import {
44
createRouterObjAdvanced,
55
extractUniqueFolderNames,
66
organizeFilesByFolder,
7-
sortExamples
7+
sortExamples,
88
} from "@/util.js";
99
import { createReplComponent } from "@/ReplFactory.js";
1010

1111
const path = "/src/views/others/";
1212

1313
// Import single file components
14-
const singleFileComponents = import.meta.glob('/src/views/others/*.vue', {
14+
const singleFileComponents = import.meta.glob("/src/views/others/*.vue", {
1515
eager: true,
1616
query: "?raw",
1717
import: "default",
1818
});
1919

2020
// Generate examples and router objects for single file components
21-
let exampleList = Object.keys(singleFileComponents).map(key => {
21+
let exampleList = Object.keys(singleFileComponents).map((key) => {
2222
const filename = key.replace(path, "").replace(".vue", "");
2323
return createExample(filename);
2424
});
2525

26-
let othersRouterList = exampleList.map(({ name }) => createRouterObj(name, singleFileComponents, path));
26+
let othersRouterList = exampleList.map(({ name }) =>
27+
createRouterObj(name, singleFileComponents, path),
28+
);
2729

2830
// Import components from folders
29-
const folderComponents = import.meta.glob('/src/views/others/*/*.vue', {
31+
const folderComponents = import.meta.glob("/src/views/others/*/*.vue", {
3032
eager: true,
3133
query: "?raw",
3234
import: "default",
@@ -59,4 +61,4 @@ export const OthersButtonExamples = {
5961
link: "https://vuejs.org/guide/essentials/class-and-style.html",
6062
};
6163

62-
export { othersRouterList };
64+
export { othersRouterList };

src/factory/PropsFactory.js

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1-
import {generateButtonExamplesAndRouterList} from "@/factoryUtil.js";
1+
import { generateButtonExamplesAndRouterList } from "@/factoryUtil.js";
22

33
const path = "/src/views/props/";
44
const sectionName = "Props";
55
const link = "https://vuejs.org/guide/components/props.html";
66

7-
const singleFileComponents = import.meta.glob('/src/views/props/*.vue', {
7+
const singleFileComponents = import.meta.glob("/src/views/props/*.vue", {
88
eager: true,
99
query: "?raw",
1010
import: "default",
1111
});
1212

13-
const folderComponents = import.meta.glob('/src/views/props/*/*.vue', {
13+
const folderComponents = import.meta.glob("/src/views/props/*/*.vue", {
1414
eager: true,
1515
query: "?raw",
1616
import: "default",
1717
});
1818

19-
20-
const {
21-
ButtonExamples: PropsButtonExamples,
22-
RouterList: PropsRouterList
23-
} = generateButtonExamplesAndRouterList(path, singleFileComponents,
24-
folderComponents, sectionName, link);
25-
19+
const { ButtonExamples: PropsButtonExamples, RouterList: PropsRouterList } =
20+
generateButtonExamplesAndRouterList(
21+
path,
22+
singleFileComponents,
23+
folderComponents,
24+
sectionName,
25+
link,
26+
);
2627

2728
export { PropsButtonExamples, PropsRouterList };
28-

src/factoryUtil.js

+15-13
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
createRouterObjAdvanced,
55
extractUniqueFolderNames,
66
organizeFilesByFolder,
7-
sortExamples
7+
sortExamples,
88
} from "@/util.js";
99
import { createReplComponent } from "@/ReplFactory.js";
1010

@@ -16,21 +16,23 @@ import { createReplComponent } from "@/ReplFactory.js";
1616
* @param {string} sectionName - The name of the section.
1717
* @returns {{ ButtonExamples: Object, RouterList: Object[] }}
1818
*/
19-
export function generateButtonExamplesAndRouterList(basePath,
20-
singleFileComponents,
21-
folderComponents,
22-
sectionName,
23-
link,
24-
orderedList = []) {
25-
26-
19+
export function generateButtonExamplesAndRouterList(
20+
basePath,
21+
singleFileComponents,
22+
folderComponents,
23+
sectionName,
24+
link,
25+
orderedList = [],
26+
) {
2727
// Generate examples and router objects for single file components
28-
let exampleList = Object.keys(singleFileComponents).map(key => {
28+
let exampleList = Object.keys(singleFileComponents).map((key) => {
2929
const filename = key.replace(basePath, "").replace(".vue", "");
3030
return createExample(filename);
3131
});
3232

33-
let routerList = exampleList.map(({ name }) => createRouterObj(name, singleFileComponents, basePath));
33+
let routerList = exampleList.map(({ name }) =>
34+
createRouterObj(name, singleFileComponents, basePath),
35+
);
3436

3537
// Extract folder names and generate examples for them
3638
const folderNames = extractUniqueFolderNames(folderComponents);
@@ -56,8 +58,8 @@ export function generateButtonExamplesAndRouterList(basePath,
5658
ButtonExamples: {
5759
name: sectionName,
5860
examples: exampleList,
59-
link: link
61+
link: link,
6062
},
6163
RouterList: routerList,
6264
};
63-
}
65+
}

0 commit comments

Comments
 (0)