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 | 12x 2x 9x 9x 9x 9x 9x 4x 4x 9x 9x 3x 3x 3x 3x 1x 9x 12x 1x 1x 9x 1x 1x | <template>
<div v-if="ribbonsStore.activeRibbons.length" ref="bannerRef" class="ribbons-banner">
<div
v-for="ribbon in ribbonsStore.activeRibbons"
:key="ribbon.id"
class="ribbon"
:style="{ backgroundColor: ribbon.color, color: getContrastTextColor(ribbon.color) }"
>
{{ getTranslation(ribbon.message, uiLanguage) }}
</div>
</div>
</template>
<script setup lang="ts">
// @implements UC-ADMIN-005.1
import { onBeforeUnmount, onMounted, ref, watch, nextTick } from 'vue'
import { useRibbonsStore } from '@/stores/ribbons'
import { useUILanguage } from '@/composables/useUILanguage'
import { useLanguage } from '@/composables/useLanguage'
import { getContrastTextColor } from '@/utils/color'
const ribbonsStore = useRibbonsStore()
const { uiLanguage } = useUILanguage()
const { getTranslation } = useLanguage()
const bannerRef = ref<HTMLElement | null>(null)
let resizeObserver: ResizeObserver | null = null
function updateHeightVar() {
const height = bannerRef.value?.offsetHeight || 0
document.documentElement.style.setProperty('--bw-ribbons-height', `${height}px`)
}
onMounted(async () => {
await ribbonsStore.fetchActiveRibbons()
await nextTick()
updateHeightVar()
resizeObserver = new ResizeObserver(updateHeightVar)
if (bannerRef.value) {
resizeObserver.observe(bannerRef.value)
}
})
watch(
() => ribbonsStore.activeRibbons.length,
async () => {
await nextTick()
updateHeightVar()
}
)
onBeforeUnmount(() => {
resizeObserver?.disconnect()
document.documentElement.style.setProperty('--bw-ribbons-height', '0px')
})
</script>
<style scoped>
.ribbons-banner {
position: fixed;
top: 74px;
left: 0;
right: 0;
z-index: 1050;
}
.ribbon {
padding: 0.5rem 1rem;
text-align: center;
font-size: 0.9rem;
font-weight: 500;
word-break: break-word;
white-space: pre-line;
/* Same shadow as .navbar (see flows.scss) so each ribbon reads as part of
the same fixed header stack rather than floating detached from it. */
-webkit-box-shadow: 0px 2px 5px 2px rgba(0, 0, 0, 0.3);
-moz-box-shadow: 0px 2px 5px 2px rgba(0, 0, 0, 0.3);
box-shadow: 0px 2px 5px 2px rgba(0, 0, 0, 0.3);
}
@media (max-width: 767px) {
.ribbons-banner {
top: 62px;
}
.ribbon {
padding: 0.4rem 0.75rem;
font-size: 0.8rem;
}
}
</style>
|