Skip to content

Commit

Permalink
fix: update disabled radiogroup's classname
Browse files Browse the repository at this point in the history
  • Loading branch information
tangjinzhou committed Jun 17, 2018
1 parent 9f307fd commit 9df74be
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 29 deletions.
33 changes: 13 additions & 20 deletions components/radio/Radio.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,24 +41,6 @@ export default {
}
})
},
computed: {
classes () {
const { prefixCls, disabled, stateChecked } = this
return {
[`${prefixCls}-wrapper`]: true,
[`${prefixCls}-wrapper-checked`]: stateChecked,
[`${prefixCls}-wrapper-disabled`]: disabled,
}
},
checkboxClass () {
const { prefixCls, disabled, stateChecked } = this
return {
[`${prefixCls}`]: true,
[`${prefixCls}-checked`]: stateChecked,
[`${prefixCls}-disabled`]: disabled,
}
},
},
methods: {
handleChange (event) {
const targetChecked = event.target.checked
Expand Down Expand Up @@ -114,7 +96,7 @@ export default {
},
},
render () {
const { id, classes, checkboxClass, prefixCls,
const { id, prefixCls,
stateChecked, handleChange, $slots,
onFocus,
onBlur,
Expand All @@ -127,9 +109,20 @@ export default {
name = radioGroupContext.name
disabled = disabled || radioGroupContext.disabled
}
const wrapperClassString = {
[`${prefixCls}-wrapper`]: true,
[`${prefixCls}-wrapper-checked`]: stateChecked,
[`${prefixCls}-wrapper-disabled`]: disabled,
}
const checkboxClass = {
[`${prefixCls}`]: true,
[`${prefixCls}-checked`]: stateChecked,
[`${prefixCls}-disabled`]: disabled,
}

return (
<label
class={classes}
class={wrapperClassString}
onMouseenter={onMouseEnter}
onMouseleave={onMouseLeave}
>
Expand Down
18 changes: 9 additions & 9 deletions components/radio/__tests__/__snapshots__/demo.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ exports[`renders ./components/radio/demo/radioButton.md correctly 1`] = `
</div>
<div style="margin-top: 16px;">
<div class="ant-radio-group ant-radio-group-default">
<label class="ant-radio-button-wrapper ant-radio-button-wrapper-checked"><span class="ant-radio-button ant-radio-button-checked"><input type="radio" class="ant-radio-button-input"><span class="ant-radio-button-inner"></span></span><span>Hangzhou</span></label>
<label class="ant-radio-button-wrapper"><span class="ant-radio-button"><input type="radio" class="ant-radio-button-input"><span class="ant-radio-button-inner"></span></span><span>Shanghai</span></label>
<label class="ant-radio-button-wrapper"><span class="ant-radio-button"><input type="radio" class="ant-radio-button-input"><span class="ant-radio-button-inner"></span></span><span>Beijing</span></label>
<label class="ant-radio-button-wrapper"><span class="ant-radio-button"><input type="radio" class="ant-radio-button-input"><span class="ant-radio-button-inner"></span></span><span>Chengdu</span></label>
<label class="ant-radio-button-wrapper ant-radio-button-wrapper-checked ant-radio-button-wrapper-disabled"><span class="ant-radio-button ant-radio-button-checked ant-radio-button-disabled"><input type="radio" disabled="disabled" class="ant-radio-button-input"><span class="ant-radio-button-inner"></span></span><span>Hangzhou</span></label>
<label class="ant-radio-button-wrapper ant-radio-button-wrapper-disabled"><span class="ant-radio-button ant-radio-button-disabled"><input type="radio" disabled="disabled" class="ant-radio-button-input"><span class="ant-radio-button-inner"></span></span><span>Shanghai</span></label>
<label class="ant-radio-button-wrapper ant-radio-button-wrapper-disabled"><span class="ant-radio-button ant-radio-button-disabled"><input type="radio" disabled="disabled" class="ant-radio-button-input"><span class="ant-radio-button-inner"></span></span><span>Beijing</span></label>
<label class="ant-radio-button-wrapper ant-radio-button-wrapper-disabled"><span class="ant-radio-button ant-radio-button-disabled"><input type="radio" disabled="disabled" class="ant-radio-button-input"><span class="ant-radio-button-inner"></span></span><span>Chengdu</span></label>
</div>
</div>
</div>
Expand Down Expand Up @@ -79,17 +79,17 @@ exports[`renders ./components/radio/demo/radioGroup-options.md correctly 1`] = `
<div class="ant-radio-group ant-radio-group-default">
<label class="ant-radio-wrapper ant-radio-wrapper-checked ant-radio-wrapper-disabled"><span class="ant-radio ant-radio-checked ant-radio-disabled"><input type="radio" disabled="disabled" class="ant-radio-input"><span class="ant-radio-inner"></span></span><span>Apple</span></label>
<label class="ant-radio-wrapper ant-radio-wrapper-disabled"><span class="ant-radio ant-radio-disabled"><input type="radio" disabled="disabled" class="ant-radio-input"><span class="ant-radio-inner"></span></span><span>Pear</span></label>
<label class="ant-radio-wrapper"><span class="ant-radio"><input type="radio" class="ant-radio-input"><span class="ant-radio-inner"></span></span><span>Orange</span></label>
<label class="ant-radio-wrapper ant-radio-wrapper-disabled"><span class="ant-radio ant-radio-disabled"><input type="radio" disabled="disabled" class="ant-radio-input"><span class="ant-radio-inner"></span></span><span>Orange</span></label>
</div>
</div>
`;
exports[`renders ./components/radio/demo/radioGroup-with-name.md correctly 1`] = `
<div class="ant-radio-group ant-radio-group-default">
<label class="ant-radio-wrapper ant-radio-wrapper-checked"><span class="ant-radio ant-radio-checked"><input type="radio" class="ant-radio-input"><span class="ant-radio-inner"></span></span><span>A</span></label>
<label class="ant-radio-wrapper"><span class="ant-radio"><input type="radio" class="ant-radio-input"><span class="ant-radio-inner"></span></span><span>B</span></label>
<label class="ant-radio-wrapper"><span class="ant-radio"><input type="radio" class="ant-radio-input"><span class="ant-radio-inner"></span></span><span>C</span></label>
<label class="ant-radio-wrapper"><span class="ant-radio"><input type="radio" class="ant-radio-input"><span class="ant-radio-inner"></span></span><span>D</span></label>
<label class="ant-radio-wrapper ant-radio-wrapper-checked"><span class="ant-radio ant-radio-checked"><input name="radioGroup" type="radio" class="ant-radio-input"><span class="ant-radio-inner"></span></span><span>A</span></label>
<label class="ant-radio-wrapper"><span class="ant-radio"><input name="radioGroup" type="radio" class="ant-radio-input"><span class="ant-radio-inner"></span></span><span>B</span></label>
<label class="ant-radio-wrapper"><span class="ant-radio"><input name="radioGroup" type="radio" class="ant-radio-input"><span class="ant-radio-inner"></span></span><span>C</span></label>
<label class="ant-radio-wrapper"><span class="ant-radio"><input name="radioGroup" type="radio" class="ant-radio-input"><span class="ant-radio-inner"></span></span><span>D</span></label>
</div>
`;
Expand Down

0 comments on commit 9df74be

Please sign in to comment.