blob: 557bbbe4cbddfc5c088443f8c8bcee9941b50b0b [file] [log] [blame]
pineafan34369e62022-05-18 16:52:37 +01001import getEmojiByName from "./getEmojiByName.js";
2
TheCodedProf4a088b12023-06-06 15:29:59 -04003function pageIndicator(amount: number, selected: number, showDetails?: boolean, disabled?: boolean | string | boolean[]) {
pineafan34369e62022-05-18 16:52:37 +01004 let out = "";
TheCodedProf4a088b12023-06-06 15:29:59 -04005 // disabled = disabled ? "GRAY." : "";
6 // If disabled is a string, make a list of booleans the same length as amount.
7 if (!Array.isArray(disabled)) disabled = new Array(amount).fill(disabled);
8 // If the length is wrong, fill extra with false
9 if (disabled.length !== amount) { disabled = disabled.concat(new Array(amount).fill(false)); }
10 const grey = disabled.map((x) => (x ? "GRAY." : ""));
pineafane23c4ec2022-07-27 21:56:27 +010011 if (amount === 1) {
TheCodedProf4a088b12023-06-06 15:29:59 -040012 out += getEmojiByName("TRACKS.SINGLE." + grey[0] + (selected === 0 ? "ACTIVE" : "INACTIVE"));
pineafan34369e62022-05-18 16:52:37 +010013 } else {
14 for (let i = 0; i < amount; i++) {
Skyler Grey75ea9172022-08-06 10:22:23 +010015 out += getEmojiByName(
16 "TRACKS.HORIZONTAL." +
Skyler Greyda16adf2023-03-05 10:22:12 +000017 (i === 0 ? "LEFT" : i === amount - 1 ? "RIGHT" : "MIDDLE") +
18 "." +
TheCodedProf4a088b12023-06-06 15:29:59 -040019 grey[i] +
Skyler Greyda16adf2023-03-05 10:22:12 +000020 (i === selected ? "ACTIVE" : "INACTIVE")
pineafan34369e62022-05-18 16:52:37 +010021 );
22 }
23 }
24 if (showDetails) {
25 out += " Page " + selected + " of " + amount;
26 }
27 return out;
28}
29
Skyler Greyda16adf2023-03-05 10:22:12 +000030export const verticalTrackIndicator = (
31 position: number,
32 active: string | boolean,
33 size: number,
34 disabled: string | boolean
35) => {
TheCodedProfb5e9d552023-01-29 15:43:26 -050036 active = active ? "ACTIVE" : "INACTIVE";
TheCodedProf46518a42023-02-18 17:08:23 -050037 disabled = disabled ? "GRAY." : "";
TheCodedProfb5e9d552023-01-29 15:43:26 -050038 if (position === 0 && size === 1) return "TRACKS.SINGLE." + disabled + active;
39 if (position === size - 1) return "TRACKS.VERTICAL.BOTTOM." + disabled + active;
40 if (position === 0) return "TRACKS.VERTICAL.TOP." + disabled + active;
41 return "TRACKS.VERTICAL.MIDDLE." + disabled + active;
42};
43
44export const createVerticalTrack = (items: string[], active: boolean[], disabled?: boolean[]) => {
45 let out = "";
46 if (!disabled) disabled = new Array(items.length).fill(false);
47 for (let i = 0; i < items.length; i++) {
48 out += getEmojiByName(verticalTrackIndicator(i, active[i] ?? false, items.length, disabled[i] ?? false));
49 out += items[i] + "\n";
50 }
51 return out;
Skyler Greyda16adf2023-03-05 10:22:12 +000052};
TheCodedProfb5e9d552023-01-29 15:43:26 -050053
Skyler Grey75ea9172022-08-06 10:22:23 +010054export default pageIndicator;