pineafan | 34369e6 | 2022-05-18 16:52:37 +0100 | [diff] [blame] | 1 | import getEmojiByName from "./getEmojiByName.js"; |
| 2 | |
TheCodedProf | c2acbcc | 2023-01-20 17:23:51 -0500 | [diff] [blame] | 3 | function pageIndicator(amount: number, selected: number, showDetails?: boolean, disabled?: boolean | string) { |
pineafan | 34369e6 | 2022-05-18 16:52:37 +0100 | [diff] [blame] | 4 | let out = ""; |
TheCodedProf | c2acbcc | 2023-01-20 17:23:51 -0500 | [diff] [blame] | 5 | disabled = disabled ? "GREY." : "" |
pineafan | e23c4ec | 2022-07-27 21:56:27 +0100 | [diff] [blame] | 6 | if (amount === 1) { |
TheCodedProf | c2acbcc | 2023-01-20 17:23:51 -0500 | [diff] [blame] | 7 | out += getEmojiByName("TRACKS.SINGLE." + (disabled) + (selected === 0 ? "ACTIVE" : "INACTIVE")); |
pineafan | 34369e6 | 2022-05-18 16:52:37 +0100 | [diff] [blame] | 8 | } else { |
| 9 | for (let i = 0; i < amount; i++) { |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 10 | out += getEmojiByName( |
| 11 | "TRACKS.HORIZONTAL." + |
TheCodedProf | c2acbcc | 2023-01-20 17:23:51 -0500 | [diff] [blame] | 12 | (i === 0 ? "LEFT" : i === amount - 1 ? "RIGHT" : "MIDDLE") + |
| 13 | "." + (disabled) + |
| 14 | (i === selected ? "ACTIVE" : "INACTIVE") |
pineafan | 34369e6 | 2022-05-18 16:52:37 +0100 | [diff] [blame] | 15 | ); |
| 16 | } |
| 17 | } |
| 18 | if (showDetails) { |
| 19 | out += " Page " + selected + " of " + amount; |
| 20 | } |
| 21 | return out; |
| 22 | } |
| 23 | |
TheCodedProf | b5e9d55 | 2023-01-29 15:43:26 -0500 | [diff] [blame] | 24 | export const verticalTrackIndicator = (position: number, active: string | boolean, size: number, disabled: string | boolean) => { |
| 25 | active = active ? "ACTIVE" : "INACTIVE"; |
| 26 | disabled = disabled ? "GREY." : ""; |
| 27 | if (position === 0 && size === 1) return "TRACKS.SINGLE." + disabled + active; |
| 28 | if (position === size - 1) return "TRACKS.VERTICAL.BOTTOM." + disabled + active; |
| 29 | if (position === 0) return "TRACKS.VERTICAL.TOP." + disabled + active; |
| 30 | return "TRACKS.VERTICAL.MIDDLE." + disabled + active; |
| 31 | }; |
| 32 | |
| 33 | export const createVerticalTrack = (items: string[], active: boolean[], disabled?: boolean[]) => { |
| 34 | let out = ""; |
| 35 | if (!disabled) disabled = new Array(items.length).fill(false); |
| 36 | for (let i = 0; i < items.length; i++) { |
| 37 | out += getEmojiByName(verticalTrackIndicator(i, active[i] ?? false, items.length, disabled[i] ?? false)); |
| 38 | out += items[i] + "\n"; |
| 39 | } |
| 40 | return out; |
| 41 | } |
| 42 | |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 43 | export default pageIndicator; |