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
82b4582c
Commit
82b4582c
authored
Aug 04, 2016
by
FuryBean
Committed by
GitHub
Aug 04, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #40 from Leopoldthecoder/next
update switch
parents
47293a13
f80f2d55
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
67 additions
and
41 deletions
+67
-41
examples/docs/select.md
examples/docs/select.md
+1
-1
examples/docs/switch.md
examples/docs/switch.md
+19
-7
packages/date-picker/src/css/time-picker.css
packages/date-picker/src/css/time-picker.css
+2
-0
packages/select/src/select.vue
packages/select/src/select.vue
+4
-0
packages/switch/src/component.vue
packages/switch/src/component.vue
+36
-28
packages/theme-default/src/select.css
packages/theme-default/src/select.css
+3
-0
packages/theme-default/src/switch.css
packages/theme-default/src/switch.css
+2
-5
No files found.
examples/docs/select.md
View file @
82b4582c
...
@@ -115,7 +115,7 @@
...
@@ -115,7 +115,7 @@
this.loading = true;
this.loading = true;
setTimeout(() => {
setTimeout(() => {
this.loading = false;
this.loading = false;
this.options5 = this.states.filter(item => item.toLowerCase().indexOf(query) > -1).map(item => { return { value: item, label: item }; });
this.options5 = this.states.filter(item => item.toLowerCase().indexOf(query
.toLowerCase()
) > -1).map(item => { return { value: item, label: item }; });
}, 200);
}, 200);
}
}
}
}
...
...
examples/docs/switch.md
View file @
82b4582c
...
@@ -7,14 +7,26 @@
...
@@ -7,14 +7,26 @@
}
}
</style>
</style>
<script>
export default {
data() {
return {
value1: true,
value2: true,
value3: true
}
}
};
</script>
## 基本用法
## 基本用法
<div
class=
"demo-box demo-switch"
>
<div
class=
"demo-box demo-switch"
>
<el-switch></el-switch>
<el-switch
v-model=
"value1"
></el-switch>
</div>
</div>
```
html
```
html
<el-switch></el-switch>
<el-switch
v-model=
"value1"
></el-switch>
```
```
## 禁用状态
## 禁用状态
...
@@ -36,13 +48,13 @@
...
@@ -36,13 +48,13 @@
## 自定义颜色
## 自定义颜色
<div
class=
"demo-box demo-switch"
>
<div
class=
"demo-box demo-switch"
>
<el-switch
on-color=
"#13ce66"
off-color=
"#ff4949"
></el-switch>
<el-switch
on-color=
"#13ce66"
off-color=
"#ff4949"
v-model=
"value2"
></el-switch>
<el-switch
on-color=
"#13ce66"
off-color=
"#ff4949"
on-text=
""
off-text=
""
></el-switch>
<el-switch
on-color=
"#13ce66"
off-color=
"#ff4949"
on-text=
""
off-text=
""
v-model=
"value3"
></el-switch>
</div>
</div>
```
html
```
html
<el-switch
on-color=
"#13ce66"
off-color=
"#ff4949"
></el-switch>
<el-switch
on-color=
"#13ce66"
off-color=
"#ff4949"
v-model=
"value2"
></el-switch>
<el-switch
on-color=
"#13ce66"
off-color=
"#ff4949"
on-text=
""
off-text=
""
></el-switch>
<el-switch
on-color=
"#13ce66"
off-color=
"#ff4949"
on-text=
""
off-text=
""
v-model=
"value3"
></el-switch>
```
```
## API
## API
...
@@ -58,4 +70,4 @@
...
@@ -58,4 +70,4 @@
| on-color | switch 打开时的背景色 | string | | |
| on-color | switch 打开时的背景色 | string | | |
| off-color | switch 关闭时的背景色 | string | | |
| off-color | switch 关闭时的背景色 | string | | |
| name | 对应 input 的 name 属性 | string | | |
| name | 对应 input 的 name 属性 | string | | |
| change | value 发生变化时的回调函数 | function | | |
packages/date-picker/src/css/time-picker.css
View file @
82b4582c
...
@@ -25,6 +25,7 @@
...
@@ -25,6 +25,7 @@
position
:
absolute
;
position
:
absolute
;
font-size
:
14px
;
font-size
:
14px
;
margin-top
:
-8px
;
margin-top
:
-8px
;
line-height
:
16px
;
z-index
:
1
;
z-index
:
1
;
}
}
...
@@ -43,6 +44,7 @@
...
@@ -43,6 +44,7 @@
border-top
:
1px
solid
var
(
--datepicker-inner-border-color
);
border-top
:
1px
solid
var
(
--datepicker-inner-border-color
);
padding
:
4px
;
padding
:
4px
;
height
:
36px
;
height
:
36px
;
line-height
:
25px
;
text-align
:
right
;
text-align
:
right
;
box-sizing
:
border-box
;
box-sizing
:
border-box
;
}
}
...
...
packages/select/src/select.vue
View file @
82b4582c
...
@@ -424,6 +424,9 @@
...
@@ -424,6 +424,9 @@
toggleMenu
()
{
toggleMenu
()
{
if
(
!
this
.
disabled
)
{
if
(
!
this
.
disabled
)
{
this
.
visible
=
!
this
.
visible
;
this
.
visible
=
!
this
.
visible
;
if
(
this
.
remote
&&
this
.
visible
)
{
this
.
selectedLabel
=
''
;
}
}
}
},
},
...
@@ -475,6 +478,7 @@
...
@@ -475,6 +478,7 @@
event
.
stopPropagation
();
event
.
stopPropagation
();
this
.
selected
=
{};
this
.
selected
=
{};
this
.
selectedLabel
=
''
;
this
.
selectedLabel
=
''
;
this
.
$emit
(
'
input
'
,
''
);
this
.
visible
=
false
;
this
.
visible
=
false
;
},
},
...
...
packages/switch/src/component.vue
View file @
82b4582c
...
@@ -2,27 +2,29 @@
...
@@ -2,27 +2,29 @@
<div
class=
"el-switch"
:class=
"
{ 'is-disabled': disabled, 'el-switch--wide': hasText, 'el-switch--color': onColor || offColor }">
<div
class=
"el-switch"
:class=
"
{ 'is-disabled': disabled, 'el-switch--wide': hasText, 'el-switch--color': onColor || offColor }">
<div
class=
"el-switch__mask"
v-show=
"disabled"
></div>
<div
class=
"el-switch__mask"
v-show=
"disabled"
></div>
<input
class=
"el-switch__input"
type=
"checkbox"
v-model=
"value"
:name=
"name"
:disabled=
"disabled"
style=
"display: none;"
>
<input
class=
"el-switch__input"
type=
"checkbox"
v-model=
"value"
:name=
"name"
:disabled=
"disabled"
style=
"display: none;"
>
<span
class=
"el-switch__core"
v-el:core
@
click=
"handleMiscClick"
:style=
"
{ 'width': w
idth + 'px' }">
<span
class=
"el-switch__core"
ref=
"core"
@
click=
"handleMiscClick"
:style=
"
{ 'width': coreW
idth + 'px' }">
<span
class=
"el-switch__button"
v-el:button
></span>
<span
class=
"el-switch__button"
ref=
"button"
></span>
</span>
</span>
<div
<transition
name=
"label-fade"
>
class=
"el-switch__label el-switch__label--left"
<div
v-show=
"value"
class=
"el-switch__label el-switch__label--left"
@
click=
"handleMiscClick"
v-show=
"value"
:style=
"
{ 'width': width + 'px' }"
@
click=
"handleMiscClick"
transition="label-fade">
:style=
"
{ 'width': coreWidth + 'px' }">
<i
:class=
"[onIconClass]"
v-if=
"onIconClass"
></i>
<i
:class=
"[onIconClass]"
v-if=
"onIconClass"
></i>
<span
v-if=
"onText"
>
{{
onText
}}
</span>
<span
v-if=
"onText"
>
{{
onText
}}
</span>
</div>
</div>
<div
</transition>
class=
"el-switch__label el-switch__label--right"
<transition
name=
"label-fade"
>
v-show=
"!value"
<div
@
click=
"handleMiscClick"
class=
"el-switch__label el-switch__label--right"
:style=
"
{ 'width': width + 'px' }"
v-show=
"!value"
transition="label-fade">
@
click=
"handleMiscClick"
<i
:class=
"[offIconClass]"
v-if=
"offIconClass"
></i>
:style=
"
{ 'width': coreWidth + 'px' }">
<span
v-if=
"offText"
>
{{
offText
}}
</span>
<i
:class=
"[offIconClass]"
v-if=
"offIconClass"
></i>
</div>
<span
v-if=
"offText"
>
{{
offText
}}
</span>
</div>
</transition>
</div>
</div>
</
template
>
</
template
>
...
@@ -71,6 +73,11 @@
...
@@ -71,6 +73,11 @@
default
:
''
default
:
''
}
}
},
},
data
()
{
return
{
coreWidth
:
0
};
},
computed
:
{
computed
:
{
hasText
()
{
hasText
()
{
return
this
.
onText
||
this
.
offText
;
return
this
.
onText
||
this
.
offText
;
...
@@ -82,30 +89,31 @@
...
@@ -82,30 +89,31 @@
this
.
handleCoreColor
();
this
.
handleCoreColor
();
}
}
this
.
handleButtonTransform
();
this
.
handleButtonTransform
();
this
.
$emit
(
'
change
'
);
}
}
},
},
methods
:
{
methods
:
{
handleMiscClick
()
{
handleMiscClick
()
{
if
(
!
this
.
disabled
)
{
if
(
!
this
.
disabled
)
{
this
.
value
=
!
this
.
value
;
this
.
$emit
(
'
input
'
,
!
this
.
value
)
;
}
}
},
},
handleButtonTransform
()
{
handleButtonTransform
()
{
this
.
$
els
.
button
.
style
.
transform
=
this
.
value
?
`translate3d(
${
this
.
w
idth
-
20
}
px, 2px, 0)`
:
'
translate3d(2px, 2px, 0)
'
;
this
.
$
refs
.
button
.
style
.
transform
=
this
.
value
?
`translate3d(
${
this
.
coreW
idth
-
20
}
px, 2px, 0)`
:
'
translate3d(2px, 2px, 0)
'
;
},
},
handleCoreColor
()
{
handleCoreColor
()
{
if
(
this
.
value
)
{
if
(
this
.
value
)
{
this
.
$
el
s
.
core
.
style
.
borderColor
=
this
.
onColor
;
this
.
$
ref
s
.
core
.
style
.
borderColor
=
this
.
onColor
;
this
.
$
el
s
.
core
.
style
.
backgroundColor
=
this
.
onColor
;
this
.
$
ref
s
.
core
.
style
.
backgroundColor
=
this
.
onColor
;
}
else
{
}
else
{
this
.
$
el
s
.
core
.
style
.
borderColor
=
this
.
offColor
;
this
.
$
ref
s
.
core
.
style
.
borderColor
=
this
.
offColor
;
this
.
$
el
s
.
core
.
style
.
backgroundColor
=
this
.
offColor
;
this
.
$
ref
s
.
core
.
style
.
backgroundColor
=
this
.
offColor
;
}
}
}
}
},
},
ready
()
{
mounted
()
{
if
(
this
.
width
===
0
)
{
if
(
this
.
width
===
0
)
{
this
.
w
idth
=
this
.
hasText
?
58
:
46
;
this
.
coreW
idth
=
this
.
hasText
?
58
:
46
;
}
}
this
.
handleButtonTransform
();
this
.
handleButtonTransform
();
if
((
this
.
onColor
||
this
.
offColor
)
&&
!
this
.
disabled
)
{
if
((
this
.
onColor
||
this
.
offColor
)
&&
!
this
.
disabled
)
{
...
...
packages/theme-default/src/select.css
View file @
82b4582c
...
@@ -115,6 +115,9 @@
...
@@ -115,6 +115,9 @@
right
:
10px
;
right
:
10px
;
font-family
:
'element-icons'
;
font-family
:
'element-icons'
;
content
:
"\e920"
;
content
:
"\e920"
;
font-size
:
13px
;
-webkit-font-smoothing
:
antialiased
;
-moz-osx-font-smoothing
:
grayscale
;
}
}
}
}
}
}
...
...
packages/theme-default/src/switch.css
View file @
82b4582c
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
}
}
@e
label
{
@e
label
{
transition
:
.2s
;
position
:
absolute
;
position
:
absolute
;
z-index
:
10
;
z-index
:
10
;
size
:
46px
22px
;
size
:
46px
22px
;
...
@@ -111,12 +112,8 @@
...
@@ -111,12 +112,8 @@
}
}
}
}
&
.label-fade-transition
{
transition
:
.2s
;
}
&
.label-fade-enter
,
&
.label-fade-enter
,
&
.label-fade-leave
{
&
.label-fade-leave
-active
{
opacity
:
0
;
opacity
:
0
;
}
}
}
}
...
...
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