<template>
    <div class="chatBubble" :class="{'chatBubble--user': isUser}">
        <div class="chatBubble__content">
            <slot></slot>
        </div>
        <div class="chatBubble__user">
            <small class="chatBubble__time">{{ chatBubbleTime }}</small>
            <small class="chatBubble__user">
                {{ isUser ? 'You' : 'Agent' }}
            </small>
        </div>

    </div>
</template>

<script>
export default {
    name: 'chatBubble',
    props: {
        isUser: {
            type: Boolean,
            default: false
        }
    },
    data() {
        return {
            chatBubbleTime: ''
        }
    },
    mounted() {
        this.chatBubbleTime = this.getCurrentTime();
    },
    methods: {
        getCurrentTime() {
            const now = new Date();
            const hours = now.getHours().toString().padStart(2, '0');
            const minutes = now.getMinutes().toString().padStart(2, '0');
            return `${hours}:${minutes}`;
        }
    }

}
</script>

<style lang="less" scoped>
.chatBubble {
    max-width: 75%;
    margin-bottom: 0.5rem;

    font-size: 0.875rem;
    line-height: 1.25rem;

    &--user {
        background-color: #2563eb;
        color: #ffffff;
        align-self: flex-end;
    }

    &__content {
        word-wrap: break-word;
        background: #efefef;
        padding: 0.5rem 1rem;
        border-radius: 18px;
    }
}

</style>
