refactor: refactor style and children components

master
chenghx 6 years ago
parent 5d35737db5
commit cfd0b38a53
  1. 44
      src/components/layout/HeaderSearch.vue

@ -1,14 +1,13 @@
<template> <template>
<span class=""> <span class="header-search">
<a-icon type="search" style="font-size: 16px; cursor: pointer;" @click="enterSearchMode"/> <a-icon type="search" class="search-icon" @click="enterSearchMode"/>
<a-auto-complete <a-auto-complete
ref="input" ref="input"
:dataSource="dataSource" :dataSource="dataSource"
:class="[searchMode ? 'enterSearch' : 'leaveSearch']" :class="['search-input', searchMode ? 'enter' : 'leave']"
placeholder="站内搜索" placeholder="站内搜索"
@blur="leaveSearchMode" @blur="leaveSearchMode"
> >
<a-input style="" />
</a-auto-complete> </a-auto-complete>
</span> </span>
</template> </template>
@ -29,7 +28,7 @@ export default {
methods: { methods: {
enterSearchMode () { enterSearchMode () {
this.searchMode = true this.searchMode = true
this.$refs.input.focus() setTimeout(() => this.$refs.input.focus(), 300)
}, },
leaveSearchMode () { leaveSearchMode () {
this.searchMode = false this.searchMode = false
@ -38,35 +37,32 @@ export default {
} }
</script> </script>
<style scoped> <style lang="less">
.enterSearch { .header-search{
width: 225px; .search-icon{
border-bottom: 1px rgba(3, 5, 6, 0.23) solid; font-size: 16px;
transition: width 0.3s ease-in-out; cursor: pointer;
} }
.leaveSearch { .search-input{
width: 0px; border: 0;
border-bottom: 1px rgba(3, 5, 6, 0.23) solid; border-bottom: 1px rgba(3, 5, 6, 0.23) solid;
transition: width 0.3s ease-in-out; transition: width 0.3s ease-in-out;
} input{
.enterSearch input, .leaveSearch input {
border: 0;
}
.enterSearch input:focus {
border: 0; border: 0;
box-shadow: 0 0 0 0; box-shadow: 0 0 0 0;
} }
.leaveSearch input{ &.leave{
width: 0px; width: 0px;
border: 0; input{
display: none;
} }
.fade-enter-active, .fade-leave-active {
transition: width .3s;
} }
.fade-enter{ &.enter{
width: 200px; width: 200px;
input:focus{
box-shadow: 0 0 0 0;
}
}
} }
.fade-leave{
width: 0px;
} }
</style> </style>

Loading…
Cancel
Save