Files
ThreadNet-Web/src/components/views/elements/effects/index.ts
T

76 lines
1.9 KiB
TypeScript
Raw Normal View History

2020-10-21 14:29:25 +02:00
import { _t, _td } from "../../../../languageHandler";
2020-10-21 19:06:10 +02:00
export type Effect<TOptions extends { [key: string]: any }> = {
/**
* one or more emojis that will trigger this effect
*/
2020-10-21 13:56:58 +02:00
emojis: Array<string>;
2020-10-21 19:06:10 +02:00
/**
* the matrix message type that will trigger this effect
*/
2020-10-21 13:56:58 +02:00
msgType: string;
2020-10-21 19:06:10 +02:00
/**
* the room command to trigger this effect
*/
2020-10-21 13:56:58 +02:00
command: string;
2020-10-21 19:06:10 +02:00
/**
* a function that returns the translated description of the effect
*/
2020-10-21 13:56:58 +02:00
description: () => string;
2020-10-21 19:06:10 +02:00
/**
* a function that returns the translated fallback message. this message will be shown if the user did not provide a custom message
*/
2020-10-21 13:56:58 +02:00
fallbackMessage: () => string;
2020-10-21 19:06:10 +02:00
/**
* animation options
*/
options: TOptions;
2020-10-21 17:58:54 +02:00
}
type ConfettiOptions = {
2020-10-21 19:06:10 +02:00
/**
* max confetti count
*/
2020-10-21 17:58:54 +02:00
maxCount: number,
2020-10-21 19:06:10 +02:00
/**
* particle animation speed
*/
2020-10-21 17:58:54 +02:00
speed: number,
2020-10-21 19:06:10 +02:00
/**
* the confetti animation frame interval in milliseconds
*/
2020-10-21 17:58:54 +02:00
frameInterval: number,
2020-10-21 19:06:10 +02:00
/**
* the alpha opacity of the confetti (between 0 and 1, where 1 is opaque and 0 is invisible)
*/
2020-10-21 17:58:54 +02:00
alpha: number,
2020-10-21 19:06:10 +02:00
/**
* use gradient instead of solid particle color
*/
2020-10-21 17:58:54 +02:00
gradient: boolean,
2020-10-21 13:56:58 +02:00
}
2020-10-21 19:06:10 +02:00
/**
* This configuration defines room effects that can be triggered by custom message types and emojis
*/
const effects: Array<Effect<{ [key: string]: any }>> = [
{
emojis: ['🎊', '🎉'],
msgType: 'nic.custom.confetti',
command: 'confetti',
description: () => _td("Sends the given message with confetti"),
fallbackMessage: () => _t("sends confetti") + " 🎉",
2020-10-21 17:58:54 +02:00
options: {
maxCount: 150,
speed: 3,
frameInterval: 15,
alpha: 1.0,
gradient: false,
2020-10-21 19:06:10 +02:00
},
} as Effect<ConfettiOptions>,
2020-10-21 13:56:58 +02:00
];
export default effects;