<template>
	<view v-if="show" class="device-offline-banner" :class="{ 'device-offline-banner--inline': !fixed }">
		<text class="device-offline-banner__text">{{ label }}</text>
	</view>
</template>

<script>
export default {
	name: 'DeviceOfflineBanner',
	props: {
		show: {
			type: Boolean,
			default: false,
		},
		/** false：嵌入文档流（用于非标准顶栏页面） */
		fixed: {
			type: Boolean,
			default: true,
		},
	},
	computed: {
		label() {
			const t = this.$i18n && this.$i18n.t ? this.$i18n.t.bind(this.$i18n) : (k) => k
			return t('deviceOfflineBanner') || '设备离线'
		},
	},
}
</script>

<style lang="scss" scoped>
.device-offline-banner {
	width: 100%;
	background-color: #f56c6c;
	padding: 18rpx 24rpx;
	text-align: center;
	box-sizing: border-box;
	z-index: 998;
}
.device-offline-banner:not(.device-offline-banner--inline) {
	position: fixed;
	left: 0;
	right: 0;
	top: 160rpx;
}
.device-offline-banner--inline {
	position: relative;
}
.device-offline-banner__text {
	color: #ffffff;
	font-size: 28rpx;
	line-height: 1.4;
}
</style>
