blob: 29ea83b2a9b30f6d21fd576ffd8bc874369eac52 [file] [log] [blame]
import getEmojiByName from "./getEmojiByName.js";
function pageIndicator(amount: number, selected: number, showDetails?: boolean, disabled?: boolean | string) {
let out = "";
disabled = disabled ? "GREY." : ""
if (amount === 1) {
out += getEmojiByName("TRACKS.SINGLE." + (disabled) + (selected === 0 ? "ACTIVE" : "INACTIVE"));
} else {
for (let i = 0; i < amount; i++) {
out += getEmojiByName(
"TRACKS.HORIZONTAL." +
(i === 0 ? "LEFT" : i === amount - 1 ? "RIGHT" : "MIDDLE") +
"." + (disabled) +
(i === selected ? "ACTIVE" : "INACTIVE")
);
}
}
if (showDetails) {
out += " Page " + selected + " of " + amount;
}
return out;
}
export const verticalTrackIndicator = (position: number, active: string | boolean, size: number, disabled: string | boolean) => {
active = active ? "ACTIVE" : "INACTIVE";
disabled = disabled ? "GREY." : "";
if (position === 0 && size === 1) return "TRACKS.SINGLE." + disabled + active;
if (position === size - 1) return "TRACKS.VERTICAL.BOTTOM." + disabled + active;
if (position === 0) return "TRACKS.VERTICAL.TOP." + disabled + active;
return "TRACKS.VERTICAL.MIDDLE." + disabled + active;
};
export const createVerticalTrack = (items: string[], active: boolean[], disabled?: boolean[]) => {
let out = "";
if (!disabled) disabled = new Array(items.length).fill(false);
for (let i = 0; i < items.length; i++) {
out += getEmojiByName(verticalTrackIndicator(i, active[i] ?? false, items.length, disabled[i] ?? false));
out += items[i] + "\n";
}
return out;
}
export default pageIndicator;