Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
Element
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
林焕东
Element
Commits
75d248e1
Commit
75d248e1
authored
Nov 26, 2016
by
baiyaaaaa
Committed by
杨奕
Nov 26, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support radio button custom style
parent
64f1caea
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
67 additions
and
33 deletions
+67
-33
examples/docs/en-US/radio.md
examples/docs/en-US/radio.md
+2
-0
examples/docs/zh-CN/radio.md
examples/docs/zh-CN/radio.md
+2
-0
packages/radio/src/radio-button.vue
packages/radio/src/radio-button.vue
+8
-1
packages/radio/src/radio-group.vue
packages/radio/src/radio-group.vue
+9
-1
packages/theme-default/src/radio.css
packages/theme-default/src/radio.css
+0
-9
test/unit/specs/radio.spec.js
test/unit/specs/radio.spec.js
+46
-22
No files found.
examples/docs/en-US/radio.md
View file @
75d248e1
...
...
@@ -137,5 +137,7 @@ change | triggers when the bound value changes | the label value of the chosen r
---- | ---- | ---- | ---- | ----
label | the value of radio | string/number | — | —
disabled | whether radio is disabled | boolean | — | false
fill | border and background color when button is active | string | — | #20a0ff |
text-color | font color when button is active | string | — | #ffffff |
examples/docs/zh-CN/radio.md
View file @
75d248e1
...
...
@@ -138,3 +138,5 @@
|---------- |-------- |---------- |------------- |-------- |
| label | Radio 的 value | string,number | — | — |
| disabled | 是否禁用 | boolean | — | false |
| fill | 按钮激活时的填充色和边框色 | string | — | #20a0ff |
| text-color | 按钮激活时的文本颜色 | string | — | #ffffff |
packages/radio/src/radio-button.vue
View file @
75d248e1
...
...
@@ -23,6 +23,13 @@
set
(
newValue
)
{
this
.
$parent
.
$emit
(
'
input
'
,
newValue
);
}
},
activeStyle
()
{
return
{
backgroundColor
:
this
.
$parent
.
fill
,
borderColor
:
this
.
$parent
.
fill
,
color
:
this
.
$parent
.
textColor
};
}
}
};
...
...
@@ -43,7 +50,7 @@
v-model=
"value"
:name=
"name"
:disabled=
"disabled"
>
<span
class=
"el-radio-button__inner"
>
<span
class=
"el-radio-button__inner"
:style=
"value === label ? activeStyle : null"
>
<slot></slot>
<template
v-if=
"!$slots.default"
>
{{
label
}}
</
template
>
</span>
...
...
packages/radio/src/radio-group.vue
View file @
75d248e1
...
...
@@ -10,7 +10,15 @@
props
:
{
value
:
[
String
,
Number
],
size
:
String
size
:
String
,
fill
:
{
type
:
String
,
default
:
'
#20a0ff
'
},
textColor
:
{
type
:
String
,
default
:
'
#fff
'
}
},
watch
:
{
value
(
value
)
{
...
...
packages/theme-default/src/radio.css
View file @
75d248e1
...
...
@@ -160,15 +160,6 @@
z-index
:
-1
;
left
:
-999px
;
&:checked
{
&
+
.el-radio-button__inner
{
z-index
:
1
;
background-color
:
var
(
--color-primary
);
border-color
:
@
background-color
;
color
:
#fff
;
}
}
&:disabled
{
&
+
.el-radio-button__inner
{
color
:
var
(
--button-disabled-color
);
...
...
test/unit/specs/radio.spec.js
View file @
75d248e1
...
...
@@ -76,28 +76,52 @@ describe('Radio', () => {
});
},
50
);
});
it
(
'
radio button
'
,
done
=>
{
vm
=
createVue
({
template
:
`
<el-radio-group v-model="radio">
<el-radio-button :label="3" ref="radio1">备选项</el-radio-button>
<el-radio-button :label="6" ref="radio2">备选项</el-radio-button>
<el-radio-button :label="9">备选项</el-radio-button>
</el-radio-group>
`
,
data
()
{
return
{
radio
:
3
};
}
},
true
);
expect
(
vm
.
$refs
.
radio1
.
$el
.
classList
.
contains
(
'
is-active
'
)).
to
.
be
.
true
;
let
radio
=
vm
.
$refs
.
radio2
;
radio
.
$el
.
click
();
vm
.
$nextTick
(
_
=>
{
expect
(
radio
.
$el
.
classList
.
contains
(
'
is-active
'
)).
to
.
be
.
true
;
expect
(
vm
.
radio
===
6
).
to
.
be
.
true
;
done
();
describe
(
'
Radio
'
,
()
=>
{
it
(
'
create
'
,
done
=>
{
vm
=
createVue
({
template
:
`
<el-radio-group v-model="radio">
<el-radio-button :label="3" ref="radio1">备选项</el-radio-button>
<el-radio-button :label="6" ref="radio2">备选项</el-radio-button>
<el-radio-button :label="9">备选项</el-radio-button>
</el-radio-group>
`
,
data
()
{
return
{
radio
:
3
};
}
},
true
);
expect
(
vm
.
$refs
.
radio1
.
$el
.
classList
.
contains
(
'
is-active
'
)).
to
.
be
.
true
;
let
radio
=
vm
.
$refs
.
radio2
;
radio
.
$el
.
click
();
vm
.
$nextTick
(
_
=>
{
expect
(
radio
.
$el
.
classList
.
contains
(
'
is-active
'
)).
to
.
be
.
true
;
expect
(
vm
.
radio
===
6
).
to
.
be
.
true
;
done
();
});
});
it
(
'
custom color
'
,
done
=>
{
vm
=
createVue
({
template
:
`
<el-radio-group v-model="radio" fill="#000" text-color="#ff0">
<el-radio-button :label="3" ref="radio1">备选项</el-radio-button>
<el-radio-button :label="6" ref="radio2">备选项</el-radio-button>
<el-radio-button :label="9">备选项</el-radio-button>
</el-radio-group>
`
,
data
()
{
return
{
radio
:
3
};
}
},
true
);
vm
.
$nextTick
(
_
=>
{
expect
(
vm
.
$refs
.
radio1
.
activeStyle
.
backgroundColor
).
to
.
equal
(
'
#000
'
);
expect
(
vm
.
$refs
.
radio1
.
activeStyle
.
borderColor
).
to
.
equal
(
'
#000
'
);
expect
(
vm
.
$refs
.
radio1
.
activeStyle
.
color
).
to
.
equal
(
'
#ff0
'
);
done
();
});
});
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment