* Tags Dropbown Beta...kinda crappy
This commit is contained in:
109
client/src/components/TagDisplayComponent.vue
Normal file
109
client/src/components/TagDisplayComponent.vue
Normal file
@@ -0,0 +1,109 @@
|
||||
<template>
|
||||
<div class="ui basic button shrinking">
|
||||
|
||||
|
||||
<!-- Dropdown Button -->
|
||||
<span v-if="activeTags.length == 0" v-on:click="menuOpen = true">
|
||||
<i class="green tags icon"></i>
|
||||
Tags
|
||||
<i class="caret down icon"></i>
|
||||
</span>
|
||||
<!-- Remove Tag button -->
|
||||
<span v-if="activeTags.length > 0" v-on:click="toggleActive()">
|
||||
<i class="green tag icon"></i>
|
||||
{{ getActiveTag() }}
|
||||
<i class="caret right icon"></i>
|
||||
</span>
|
||||
|
||||
<!-- hidden dropdown menu -->
|
||||
<div class="dropdown-menu" v-if="menuOpen">
|
||||
<div class="ui raised segment">
|
||||
<div class="ui clickable basic label" v-for="tag in tags">
|
||||
<span v-on:click="onClick(tag.id)">
|
||||
{{ ucWords(tag.text) }}
|
||||
<span class="detail">{{tag.usages}}</span>
|
||||
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="shade" v-if="menuOpen" v-on:click="menuOpen = false"></div>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
export default {
|
||||
name: 'TagDisplay',
|
||||
props: [ 'tags', 'activeTags' ],
|
||||
components: {
|
||||
},
|
||||
methods:{
|
||||
toggleActive(){
|
||||
this.menuOpen = false
|
||||
const current = this.activeTags[0]
|
||||
this.onClick( current )
|
||||
},
|
||||
onClick(tagId){
|
||||
this.menuOpen = false
|
||||
this.$emit('tagClick', tagId)
|
||||
},
|
||||
ucWords(str){
|
||||
return (str + '')
|
||||
.replace(/^(.)|\s+(.)/g, function ($1) {
|
||||
return $1.toUpperCase()
|
||||
})
|
||||
},
|
||||
getActiveTag(){
|
||||
let text = 'Tags'
|
||||
|
||||
if(this.activeTags.length == 0){
|
||||
return text
|
||||
}
|
||||
|
||||
this.tags.forEach(tag => {
|
||||
if( this.activeTags.includes(tag.id) ){
|
||||
text = this.ucWords(tag.text)
|
||||
}
|
||||
})
|
||||
|
||||
return text
|
||||
},
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
menuOpen: false,
|
||||
}
|
||||
},
|
||||
beforeMount(){
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style type="text/css">
|
||||
.dropdown-menu {
|
||||
position: absolute;
|
||||
/*width: 70vw;*/
|
||||
z-index: 1005;
|
||||
left: 0;
|
||||
right: 0;
|
||||
max-width: 600px;
|
||||
text-align: left;
|
||||
}
|
||||
.dropdown-menu .label {
|
||||
margin: 0 5px 5px 0;
|
||||
}
|
||||
.shade {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
z-index: 1004;
|
||||
background-color: transparent;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
}
|
||||
</style>
|
Reference in New Issue
Block a user