Chat Stock Element

You can use this Stock Element by extending the exported global: window.casthub.elements.chat

This Stock Element will render a ready-to-go Chat System with an easy-to-use Message management system.

Adding a Message

Messages must abide by a given specification to be rendered in the Module. See below for the object specification.

All Messages added to the Stock Element require a unique ID. This will avoid duplicate messages being added.

this.add('some-unique-id', {
    sender: {
        name: 'John Smith', // The name of the Sender.
        color: '#FF0000', // Optional. Used to color the Name of the Sender.
        badges: [], // Optional, ordered array of image URLs for Badges.
    },
    /**
     * The text content of the Message.
     * This supports HTML for things like emoticons.
     */
    message: 'Hello <strong>World</strong>',
});

Removing a Message

Given all Messages require a unique identifier, it's relatively easy to remove an existing Message from the UI.

this.remove('some-unique-id');