blob: 0831c83ce4de0d1962fb1946b67305c2872f4db1 [file] [log] [blame]
pineafan34369e62022-05-18 16:52:37 +01001import getEmojiByName from "./getEmojiByName.js";
2
TheCodedProfc62b0702023-06-06 15:31:14 -04003function pageIndicator(
4 amount: number,
5 selected: number,
6 showDetails?: boolean,
7 disabled?: boolean | string | boolean[]
8) {
pineafan34369e62022-05-18 16:52:37 +01009 let out = "";
TheCodedProf4a088b12023-06-06 15:29:59 -040010 // disabled = disabled ? "GRAY." : "";
11 // If disabled is a string, make a list of booleans the same length as amount.
12 if (!Array.isArray(disabled)) disabled = new Array(amount).fill(disabled);
13 // If the length is wrong, fill extra with false
TheCodedProfc62b0702023-06-06 15:31:14 -040014 if (disabled.length !== amount) {
15 disabled = disabled.concat(new Array(amount).fill(false));
16 }
TheCodedProf4a088b12023-06-06 15:29:59 -040017 const grey = disabled.map((x) => (x ? "GRAY." : ""));
pineafane23c4ec2022-07-27 21:56:27 +010018 if (amount === 1) {
TheCodedProf4a088b12023-06-06 15:29:59 -040019 out += getEmojiByName("TRACKS.SINGLE." + grey[0] + (selected === 0 ? "ACTIVE" : "INACTIVE"));
pineafan34369e62022-05-18 16:52:37 +010020 } else {
21 for (let i = 0; i < amount; i++) {
Skyler Grey75ea9172022-08-06 10:22:23 +010022 out += getEmojiByName(
23 "TRACKS.HORIZONTAL." +
Skyler Greyda16adf2023-03-05 10:22:12 +000024 (i === 0 ? "LEFT" : i === amount - 1 ? "RIGHT" : "MIDDLE") +
25 "." +
TheCodedProf4a088b12023-06-06 15:29:59 -040026 grey[i] +
Skyler Greyda16adf2023-03-05 10:22:12 +000027 (i === selected ? "ACTIVE" : "INACTIVE")
pineafan34369e62022-05-18 16:52:37 +010028 );
29 }
30 }
31 if (showDetails) {
32 out += " Page " + selected + " of " + amount;
33 }
34 return out;
35}
36
Skyler Greyda16adf2023-03-05 10:22:12 +000037export const verticalTrackIndicator = (
38 position: number,
39 active: string | boolean,
40 size: number,
41 disabled: string | boolean
42) => {
TheCodedProfb5e9d552023-01-29 15:43:26 -050043 active = active ? "ACTIVE" : "INACTIVE";
TheCodedProf46518a42023-02-18 17:08:23 -050044 disabled = disabled ? "GRAY." : "";
TheCodedProfb5e9d552023-01-29 15:43:26 -050045 if (position === 0 && size === 1) return "TRACKS.SINGLE." + disabled + active;
46 if (position === size - 1) return "TRACKS.VERTICAL.BOTTOM." + disabled + active;
47 if (position === 0) return "TRACKS.VERTICAL.TOP." + disabled + active;
48 return "TRACKS.VERTICAL.MIDDLE." + disabled + active;
49};
50
51export const createVerticalTrack = (items: string[], active: boolean[], disabled?: boolean[]) => {
52 let out = "";
53 if (!disabled) disabled = new Array(items.length).fill(false);
54 for (let i = 0; i < items.length; i++) {
55 out += getEmojiByName(verticalTrackIndicator(i, active[i] ?? false, items.length, disabled[i] ?? false));
56 out += items[i] + "\n";
57 }
58 return out;
Skyler Greyda16adf2023-03-05 10:22:12 +000059};
TheCodedProfb5e9d552023-01-29 15:43:26 -050060
Skyler Grey75ea9172022-08-06 10:22:23 +010061export default pageIndicator;