From 13d0ae378e8dffac205b763965cc68d66c14b10e Mon Sep 17 00:00:00 2001 From: tangjinzhou Date: Tue, 7 Nov 2017 11:58:47 +0800 Subject: [PATCH 1/2] add radio demo --- components/checkbox/Checkbox.vue | 18 +++--- components/checkbox/Group.vue | 9 +-- components/radio/Group.vue | 56 +++++++++---------- components/radio/Radio.vue | 48 ++++++++++------ components/radio/demo/basic.vue | 13 +++++ components/radio/demo/disabled.vue | 31 ++++++++++ components/radio/demo/index.vue | 19 +++++++ components/radio/demo/radioButton.vue | 42 ++++++++++++++ components/radio/demo/radioGroup-more.vue | 35 ++++++++++++ components/radio/demo/radioGroup-options.vue | 50 +++++++++++++++++ .../radio/demo/radioGroup-with-name.vue | 17 ++++++ components/radio/demo/radioGroup.vue | 27 +++++++++ components/radio/demo/size.vue | 37 ++++++++++++ 13 files changed, 341 insertions(+), 61 deletions(-) create mode 100644 components/radio/demo/basic.vue create mode 100644 components/radio/demo/disabled.vue create mode 100644 components/radio/demo/index.vue create mode 100644 components/radio/demo/radioButton.vue create mode 100644 components/radio/demo/radioGroup-more.vue create mode 100644 components/radio/demo/radioGroup-options.vue create mode 100644 components/radio/demo/radioGroup-with-name.vue create mode 100644 components/radio/demo/radioGroup.vue create mode 100644 components/radio/demo/size.vue diff --git a/components/checkbox/Checkbox.vue b/components/checkbox/Checkbox.vue index 826666e5a..a8539ddf7 100644 --- a/components/checkbox/Checkbox.vue +++ b/components/checkbox/Checkbox.vue @@ -32,13 +32,13 @@ export default { prop: 'checked', }, inject: { - context: { default: undefined }, + checkboxGroupContext: { default: undefined }, }, data () { - const { context, checked, defaultChecked, value } = this + const { checkboxGroupContext, checked, defaultChecked, value } = this let stateChecked - if (context && context.checkedStatus) { - stateChecked = context.checkedStatus.has(value) + if (checkboxGroupContext && checkboxGroupContext.checkedStatus) { + stateChecked = checkboxGroupContext.checkedStatus.has(value) } return { stateChecked: stateChecked === undefined @@ -72,8 +72,8 @@ export default { handleChange (event) { const targetChecked = event.target.checked this.$emit('input', targetChecked) - const { name, value, checked, context, stateChecked } = this - if ((checked === undefined && !context) || (context && context.value === undefined)) { + const { name, value, checked, checkboxGroupContext, stateChecked } = this + if ((checked === undefined && !checkboxGroupContext) || (checkboxGroupContext && checkboxGroupContext.value === undefined)) { this.stateChecked = targetChecked } const target = { @@ -81,8 +81,8 @@ export default { value, checked: !stateChecked, } - if (this.context) { - this.context.handleChange({ target }) + if (this.checkboxGroupContext) { + this.checkboxGroupContext.handleChange({ target }) } else { this.$emit('change', { target, @@ -100,7 +100,7 @@ export default { checked (val) { this.stateChecked = val }, - 'context.checkedStatus': function (checkedStatus) { + 'checkboxGroupContext.checkedStatus': function (checkedStatus) { this.stateChecked = checkedStatus.has(this.value) }, }, diff --git a/components/checkbox/Group.vue b/components/checkbox/Group.vue index 1668f846a..31ba2252d 100644 --- a/components/checkbox/Group.vue +++ b/components/checkbox/Group.vue @@ -1,8 +1,9 @@ diff --git a/components/radio/demo/basic.vue b/components/radio/demo/basic.vue new file mode 100644 index 000000000..02c275f0c --- /dev/null +++ b/components/radio/demo/basic.vue @@ -0,0 +1,13 @@ + + diff --git a/components/radio/demo/disabled.vue b/components/radio/demo/disabled.vue new file mode 100644 index 000000000..d21f027ac --- /dev/null +++ b/components/radio/demo/disabled.vue @@ -0,0 +1,31 @@ + + diff --git a/components/radio/demo/index.vue b/components/radio/demo/index.vue new file mode 100644 index 000000000..da7f7ff86 --- /dev/null +++ b/components/radio/demo/index.vue @@ -0,0 +1,19 @@ + + diff --git a/components/radio/demo/radioButton.vue b/components/radio/demo/radioButton.vue new file mode 100644 index 000000000..3ee413418 --- /dev/null +++ b/components/radio/demo/radioButton.vue @@ -0,0 +1,42 @@ + + diff --git a/components/radio/demo/radioGroup-more.vue b/components/radio/demo/radioGroup-more.vue new file mode 100644 index 000000000..6ade73275 --- /dev/null +++ b/components/radio/demo/radioGroup-more.vue @@ -0,0 +1,35 @@ + + diff --git a/components/radio/demo/radioGroup-options.vue b/components/radio/demo/radioGroup-options.vue new file mode 100644 index 000000000..6d5f55f14 --- /dev/null +++ b/components/radio/demo/radioGroup-options.vue @@ -0,0 +1,50 @@ + + diff --git a/components/radio/demo/radioGroup-with-name.vue b/components/radio/demo/radioGroup-with-name.vue new file mode 100644 index 000000000..ab272d8f7 --- /dev/null +++ b/components/radio/demo/radioGroup-with-name.vue @@ -0,0 +1,17 @@ + + diff --git a/components/radio/demo/radioGroup.vue b/components/radio/demo/radioGroup.vue new file mode 100644 index 000000000..085211370 --- /dev/null +++ b/components/radio/demo/radioGroup.vue @@ -0,0 +1,27 @@ + + diff --git a/components/radio/demo/size.vue b/components/radio/demo/size.vue new file mode 100644 index 000000000..2739cc763 --- /dev/null +++ b/components/radio/demo/size.vue @@ -0,0 +1,37 @@ + + From 284126e91d13b4c4cc87692c70f44d93033a57f5 Mon Sep 17 00:00:00 2001 From: tangjinzhou Date: Tue, 7 Nov 2017 12:04:50 +0800 Subject: [PATCH 2/2] add radio demo --- components/radio/demo/index.vue | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/components/radio/demo/index.vue b/components/radio/demo/index.vue index da7f7ff86..cf711bade 100644 --- a/components/radio/demo/index.vue +++ b/components/radio/demo/index.vue @@ -4,16 +4,39 @@

Disabled

- +

RadioButton

+ +

RadioGroupMore

+ +

RadioGroupOptions

+ +

RadioGroupWithName

+ +

RadioGroup

+ +

Size

+