Open-source live-chat, email support, omni-channel desk. An alternative to Intercom, Zendesk, Salesforce Service Cloud etc. 🔥💬
Ruby actioncablechat-widgetconversationcustomer-supportdashboarddesigndockerdocker-imageherokuintercomjavascriptlivechatopensourcerailsrubysassvuejswhatsappzendesk
<script setup>
import { computed } from 'vue';
import { PercentageChart } from '@chatwoot/viz';
const props = defineProps({
label: { type: String, required: true },
showLabel: { type: Boolean, default: true },
used: { type: Number, default: 0 },
total: { type: Number, default: 0 },
usageLabel: { type: String, default: '' },
valueLabel: { type: String, default: '' },
color: { type: String, default: 'rgb(var(--blue-9))' },
loading: { type: Boolean, default: false },
});
const chartData = computed(() => ({
total: Math.max(props.total, 0),
segments: [
{
id: 'used',
label: props.label,
value: Math.min(Math.max(props.used, 0), Math.max(props.total, 0)),
color: props.color,
},
],
}));
</script>
<template>
<div class="flex flex-col gap-2">
<div class="flex items-center justify-between gap-3 text-body-main">
<span
class="inline-flex flex-wrap items-baseline gap-x-1 text-n-slate-11"
>
<span v-if="showLabel">{{ label }}</span>
<span v-if="usageLabel" :class="{ 'text-n-teal-11': showLabel }">
{{ usageLabel }}
</span>
</span>
<span class="tabular-nums text-n-slate-11">{{ valueLabel }}</span>
</div>
<div
v-if="loading"
class="w-full h-[0.5625rem] rounded-full bg-n-slate-3 animate-pulse"
/>
<PercentageChart
v-else-if="total > 0"
:data="chartData"
:aria-label="label"
:bar-height="9"
:bar-gap="0"
:bar-radius="999"
:show-legend="false"
:show-tooltip="false"
class="[--cw-viz-percentage-remainder-color:rgb(var(--slate-3))] [--cw-viz-percentage-remainder-border-color:rgb(var(--slate-6))]"
/>
<div v-else class="w-full h-[0.5625rem] rounded-full bg-n-alpha-2" />
</div>
</template>