Skip to content

Commit

Permalink
fix(offset): change order (#971)
Browse files Browse the repository at this point in the history
* fix(offset): change order

* test(badge): update
  • Loading branch information
LeeJim authored Nov 3, 2022
1 parent 79f1478 commit f6bc580
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/badge/__test__/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ describe('badge', () => {
comp.attach(document.createElement('parent-wrapper'));

const $count = comp.querySelector('.badge >>> .t-badge--basic');
expect($count.dom.style.top).toBe('15px');
expect($count.dom.style.right).toBe('20em');
expect($count.dom.style.top).toBe('20em');
expect($count.dom.style.right).toBe('15px');
});

it(':offset number without unit', async () => {
Expand All @@ -208,7 +208,7 @@ describe('badge', () => {
comp.attach(document.createElement('parent-wrapper'));

const $count = comp.querySelector('.badge >>> .t-badge--basic');
expect($count.dom.style.top).toBe('16px');
expect($count.dom.style.right).toBe('29px');
expect($count.dom.style.top).toBe('29px');
expect($count.dom.style.right).toBe('16px');
});
});
4 changes: 2 additions & 2 deletions src/badge/badge.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ var getBadgeStyles = function (props) {
styleStr += 'background:' + props.color + ';';
}
if (props.offset[0]) {
styleStr += 'top:' + (hasUnit(props.offset[0].toString()) ? props.offset[0] : props.offset[0] + 'px') + ';';
styleStr += 'right:' + (hasUnit(props.offset[0].toString()) ? props.offset[0] : props.offset[0] + 'px') + ';';
}
if (props.offset[1]) {
styleStr += 'right:' + (hasUnit(props.offset[1].toString()) ? props.offset[1] : props.offset[1] + 'px') + ';';
styleStr += 'top:' + (hasUnit(props.offset[1].toString()) ? props.offset[1] : props.offset[1] + 'px') + ';';
}
return styleStr;
};
Expand Down

0 comments on commit f6bc580

Please sign in to comment.