Skip to content

Commit b6e99ff

Browse files
committed
fix: remove redundancies on options parsing
1 parent 1561066 commit b6e99ff

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
lines changed

src/App.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export default {
9090
line: "round",
9191
price: "",
9292
circles: [
93-
{ progress: 50, color: "red", dot: "50 green" },
93+
{ progress: 50, color: "red" },
9494
{ progress: 50, color: "yellow" /* half: true, angle: -90, dot: "10 green" */ },
9595
{ progress: 50, color: "blue", reverse: false },
9696
],

src/components/Circle/circleMixin.js

+1
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ export default {
118118
globalGap() {
119119
return this.options.globalGap;
120120
},
121+
121122
dotSize() {
122123
return this.options.dot.size;
123124
},

src/components/optionsParser.js

+15-11
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,18 @@ const calcThickness = (thickness, size) => {
5454
return thickness.toString().includes("%") ? (value * size) / 100 : value;
5555
};
5656

57-
export default (options) => ({
58-
...options,
59-
thickness: calcThickness(options.thickness, options.size),
60-
emptyThickness: calcThickness(options.emptyThickness, options.size),
61-
globalThickness: calcThickness(options.thickness, options.size),
62-
dot: { ...dotParser(options.dot), size: calcThickness(dotParser(options.dot).size, options.size) },
63-
globalDot: { ...dotParser(options.globalDot), size: calcThickness(dotParser(options.globalDot).size, options.size) },
64-
dash: dashParser(options.dash),
65-
lineMode: lineModeParser(options),
66-
animation: animationParser(options.animation),
67-
});
57+
export default (options) => {
58+
const dot = dotParser(options.dot);
59+
const globalDot = dotParser(options.globalDot);
60+
return {
61+
...options,
62+
thickness: calcThickness(options.thickness, options.size),
63+
emptyThickness: calcThickness(options.emptyThickness, options.size),
64+
globalThickness: calcThickness(options.globalThickness, options.size),
65+
dot: { ...dot, size: calcThickness(dot.size, options.size) },
66+
globalDot: { ...globalDot, size: calcThickness(globalDot.size, options.size) },
67+
dash: dashParser(options.dash),
68+
lineMode: lineModeParser(options),
69+
animation: animationParser(options.animation),
70+
};
71+
};

0 commit comments

Comments
 (0)