feat(Checkbox): icon slot add disabled param (#8839)

This commit is contained in:
neverland 2021-06-09 10:14:24 +08:00 committed by GitHub
parent c426125e2c
commit 2e889b2641
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 34 additions and 17 deletions

View File

@ -90,7 +90,7 @@ export default defineComponent({
style={{ fontSize: addUnit(iconSize) }}
>
{slots.icon ? (
slots.icon({ checked })
slots.icon({ checked, disabled: disabled.value })
) : (
<Icon name="success" style={iconStyle.value} />
)}

View File

@ -283,10 +283,10 @@ export default {
### Checkbox Slots
| Name | Description | SlotProps |
| ------- | ------------ | ------------------ |
| default | Custom label | - |
| icon | Custom icon | _checked: boolean_ |
| Name | Description | SlotProps |
| ------- | ------------ | ----------------------------------------- |
| default | Custom label | - |
| icon | Custom icon | _{ checked: boolean, disabled: boolean }_ |
### CheckboxGroup Methods

View File

@ -301,10 +301,10 @@ export default {
### Checkbox Slots
| 名称 | 说明 | 参数 |
| ------- | ---------- | ------------------ |
| default | 自定义文本 | - |
| icon | 自定义图标 | _checked: boolean_ |
| 名称 | 说明 | 参数 |
| ------- | ---------- | ----------------------------------------- |
| default | 自定义文本 | - |
| icon | 自定义图标 | _{ checked: boolean, disabled: boolean }_ |
### CheckboxGroup 方法

View File

@ -15,3 +15,9 @@ exports[`should adjust label position when using label-position prop 1`] = `
</div>
</div>
`;
exports[`should render icon slot correctly 1`] = `
<div class="van-checkbox__icon van-checkbox__icon--round">
checked: false, disabled: false
</div>
`;

View File

@ -105,3 +105,14 @@ test('should emit click event when checkbox icon is clicked', async () => {
icon.trigger('click');
expect(onClick).toHaveBeenCalledTimes(2);
});
test('should render icon slot correctly', async () => {
const wrapper = mount(Checkbox, {
slots: {
icon: ({ checked, disabled }) =>
`checked: ${checked}, disabled: ${disabled}`,
},
});
expect(wrapper.find('.van-checkbox__icon').html()).toMatchSnapshot();
});

View File

@ -194,10 +194,10 @@ export default {
### Radio Slots
| Name | Description | SlotProps |
| ------- | ------------ | ------------------ |
| default | Custom label | - |
| icon | Custom icon | _checked: boolean_ |
| Name | Description | SlotProps |
| ------- | ------------ | ----------------------------------------- |
| default | Custom label | - |
| icon | Custom icon | _{ checked: boolean, disabled: boolean }_ |
### Less Variables

View File

@ -208,10 +208,10 @@ export default {
### Radio Slots
| 名称 | 说明 | 参数 |
| ------- | ---------- | ------------------ |
| default | 自定义文本 | - |
| icon | 自定义图标 | _checked: boolean_ |
| 名称 | 说明 | 参数 |
| ------- | ---------- | ----------------------------------------- |
| default | 自定义文本 | - |
| icon | 自定义图标 | _{ checked: boolean, disabled: boolean }_ |
### 样式变量