I have an arrow icon inside a menu item. When I click on this item, a small additional menu drops down. I need to find a solution how to rotate my icon at the same time as my dropdown menu appears. My approach doesn't work.
Here is what I have in the Vue component:
<nav>
<section class="nav-item" @click="showDropdown = !showDropdown">
<div class="nav-icon">
<img src="../../../assets/img/users.svg" />
</div>
<h4>Users</h4>
<div class="arrow" :class="arrowLeft">
<img src="../../../assets/img/arrow_down.svg" />
</div>
<div v-if="showDropdown">
<span class="sub-nav-item">Import</span>
<span class="sub-nav-item">Invitations</span>
</div>
</section>
<section class="nav-item">
<div class="nav-icon">
<img src="../../../assets/img/polls.svg" />
</div>
<h4>Poll</h4>
</section>
</nav>
In my script tags:
<script>
export default {
data() {
return {
showDropdown: false,
};
},
computed: {
arrowLeft() {
let arrow = 'turn-arrow';
if (this.showDropdown === true) {
return arrow;
}
return true;
},
},
};
</script>
My CSS:
.arrow {
display: inline;
height: 7px;
width: 13px;
margin-left: 13px;
}
.turn-arrow {
-moz-transform: rotate(90deg);
-ms-transform: rotate(90deg);
-webkit-transform: rotate(90deg);
transform: rotate(90deg);
}