main

mattermost/focalboard

Last updated at: 29/12/2023 09:48

blockIcons.ts

TLDR

This file contains a class called BlockIcons which has a static property shared and a method randomIcon(). The BlockIcons class is used to generate a random emoji icon from a predefined list.

Classes

BlockIcons

The BlockIcons class is responsible for generating random emoji icons. It has a static property shared which holds a singleton instance of the class. This class exports a method called randomIcon() that returns a randomly selected emoji icon from the randomEmojiList array.

Methods

randomIcon

This method generates a random index within the range of the randomEmojiList array. It then retrieves the emoji icon at that index and returns it. The emoji list is imported from the emojiList module.

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {randomEmojiList} from './emojiList'

class BlockIcons {
    static readonly shared = new BlockIcons()

    randomIcon(): string {
        const index = Math.floor(Math.random() * randomEmojiList.length)
        const icon = randomEmojiList[index]
        return icon
    }
}

export {BlockIcons}