Skip to content

Commit 6d6dcb3

Browse files
Lonely-shangkagol
authored andcommitted
fix(Rate): 修复type属性下color属性失效问题
1 parent fc5ad91 commit 6d6dcb3

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

packages/devui-vue/devui/rate/__tests__/rate.spec.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,18 @@ describe('rate', () => {
3030
const container = wrapper.find('.devui-star-container');
3131
expect(container.exists()).toBeTruthy();
3232
});
33+
34+
it('Rate is color attributes should have content', async () => {
35+
const _wrapper = mount(DRate, {
36+
props: { modelValue: 2 },
37+
});
38+
39+
await nextTick();
40+
expect(_wrapper.find('.devui-star-color-').exists()).toBeTruthy();
41+
42+
await _wrapper.setProps({ color: 'red' });
43+
expect(_wrapper.find('.devui-star-color-customize').exists()).toBeTruthy();
44+
});
3345
});
3446

3547
describe('rate change', () => {

packages/devui-vue/devui/rate/src/rate.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@
4848
}
4949
}
5050

51+
.devui-star-color-customize {
52+
color: var(--star-color);
53+
54+
svg g {
55+
fill: var(--star-color);
56+
}
57+
}
58+
5159
.devui-active-star {
5260
position: absolute;
5361
top: 0;

packages/devui-vue/devui/rate/src/rate.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export default defineComponent({
9494
const { totalLevelArray, icon, character, read, type, color, hoverToggle, selectValue, onMouseleave } = this;
9595

9696
return (
97-
<div class="devui-star-container" onMouseleave={onMouseleave}>
97+
<div class="devui-star-container" onMouseleave={onMouseleave} style={`--star-color: ${color}`}>
9898
{totalLevelArray.map((item, index) => (
9999
<div
100100
class={`devui-star-align devui-pointer ${read ? 'devui-only-read' : ''}`}
@@ -141,8 +141,12 @@ export default defineComponent({
141141
)}
142142
{!character && !icon && (
143143
<span
144-
class={`devui-star-color-active devui-active-star devui-star-color-${type}`}
145-
style={{ color: color, width: item.width }}>
144+
class={[
145+
'devui-star-color-active',
146+
'devui-active-star',
147+
!color ? `devui-star-color-${type}` : 'devui-star-color-customize'
148+
]}
149+
style={{ width: item.width }}>
146150
<svg
147151
width="16px"
148152
height="16px"

0 commit comments

Comments
 (0)