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

Loading…
Cancel
Save