Skip to content

Commit 4ba1fe6

Browse files
committed
fix: simplify container slots markup
1 parent 083cc8c commit 4ba1fe6

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

src/App.vue

+12-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,18 @@
5757
>
5858
</ve-progress>
5959
</div>
60-
<ve-progress half color-fill="red" line-position="center"> </ve-progress>
60+
<ve-progress
61+
half
62+
line-position="center"
63+
:progress="50"
64+
:legend-formatter="
65+
({ currentValue }) => `<span><b>${currentValue}</b></span> <span><b>${currentValue}</b></span> `
66+
"
67+
>
68+
<template #default="{ counterTick }">
69+
<span> Olechka {{ counterTick.currentValue }} </span>
70+
</template>
71+
</ve-progress>
6172
</div>
6273
</div>
6374
</template>

src/components/VueEllipseProgress.vue

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
:style="{ fontSize, color: fontColor }"
1717
>
1818
<counter :value="computedLegend" :animation="normalizedCircles[0].animation" :loading="loading">
19-
<template v-slot:default="{ counterTick }">
20-
<span v-if="legendFormatter">
19+
<template #default="{ counterTick }">
20+
<template v-if="legendFormatter">
2121
<span v-if="isHTML" v-html="legendFormatter(counterTick)"></span>
2222
<span v-else>{{ legendFormatter(counterTick) }}</span>
23-
</span>
23+
</template>
2424
<slot v-else :counterTick="counterTick">
2525
<span>{{ counterTick.currentFormattedValue }}</span>
2626
</slot>

tests/unit/container.spec.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ describe("[ EllipseProgressContainer.vue ]", () => {
109109
});
110110
});
111111
// FIXME: blocked by vue-test-utils v2 beta
112-
/* describe("#slots", () => {
112+
describe("#slots", () => {
113113
describe("#legend", () => {
114114
it("renders provided slot content", () => {
115115
const wrapper = mount(VueEllipseProgress, {
@@ -118,7 +118,6 @@ describe("[ EllipseProgressContainer.vue ]", () => {
118118
legend: '<span id="my-slot">Hello Circle</span>',
119119
},
120120
});
121-
const c = wrapper.vm.$slots;
122121
expect(wrapper.find("#my-slot").exists()).to.be.true;
123122
});
124123
});
@@ -150,7 +149,7 @@ describe("[ EllipseProgressContainer.vue ]", () => {
150149

151150
it("renders via provided slot formatted value", (done) => {
152151
setTimeout(() => {
153-
expect(wrapper.find(".my-formatter-slot").element.textContent).to.equal("Formatted 35");
152+
expect(wrapper.html()).to.contain("35");
154153
done();
155154
}, 100);
156155
});
@@ -159,7 +158,7 @@ describe("[ EllipseProgressContainer.vue ]", () => {
159158
expect(wrapper.findComponent(Counter).findAll("span")).to.have.lengthOf(2);
160159
});
161160
});
162-
}); */
161+
});
163162
describe("#data", () => {
164163
const data = [
165164
{ progress: 25, color: "red" },

0 commit comments

Comments
 (0)