Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | <template> <div :class="{ '--subject-badge': true, expandable, expanded, editable, }" :style="{ backgroundColor: bgColor, color: fgColor }" :title="badgeTitle" @mouseenter="expanded = alwaysExpanded || expandable" @mouseleave="expanded = alwaysExpanded" > <button-icon small class="button-edit" @click="$emit('edit')" >edit</button-icon > <div class="name"> <slot></slot> </div> </div> </template> <script lang="ts"> // eslint-disable-next-line no-unused-vars import Vue, { PropOptions } from 'vue' import { isHexColor } from '~/utils/validators' import { lightColor, darkColor } from '~/utils/colors' import ButtonIcon from '~/components/ButtonIcon.vue' export default Vue.extend({ components: { ButtonIcon }, props: { expandable: { type: Boolean, default: false, } as PropOptions<boolean>, alwaysExpanded: { type: Boolean, default: false, } as PropOptions<boolean>, color: { type: String, required: true, validator: isHexColor, } as PropOptions<string>, editable: { type: Boolean, default: false, } as PropOptions<boolean>, }, data() { return { expanded: this.alwaysExpanded } }, computed: { bgColor(): string { return this.expanded ? lightColor(this.color) : this.color }, fgColor(): string { return darkColor(this.color) }, badgeTitle(): string | null { const slotText = this.$slots.default?.[0]?.text if (slotText && !this.expanded) { return slotText } return null }, }, }) </script> <style lang="stylus" scoped> // //Definitions // dot-size = 1.8em // //Positioning // .--subject-badge display inline-flex align-items center .--subject-badge.editable .name margin-left 0.5em .name white-space nowrap .--subject-badge:not(.editable) .button-edit width 0 // //Sizing // .--subject-badge:not(.expanded) max-width dot-size // //Spacing // .button-edit width dot-size font-size 0.85em .--subject-badge padding 0 0.5em height dot-size // //Color // // //Decoration // .--subject-badge border-radius 1000px .--subject-badge:not(.editable) .button-edit cursor default // //Visibility // .name overflow hidden opacity 0 .button-edit opacity 0 // //States // //When the element is not expanded and _can_ be expanded .expandable transition 250ms ease all .expanded.editable cursor pointer .button-edit opacity 1 .expanded max-width 20ch .name opacity 1 </style> |