Skip to content

Commit cbd7bc3

Browse files
committed
Mapped Endian Format Options
I thought there might be a way to title case a word using an `Intl` function, but I couldn't find any. I also wanted to strictly check the value of my endian types mapped value array, but I'm not sure how you could make a tuple out of a union. I'd like to do `["big", "little"] satisfies tupleof Endian` essentially. This works nicely as well though. I also removed the demo Launch Handler manifest config from the last commit. microsoft/TypeScript#13298 https://stackoverflow.com/questions/1026069/how-do-i-make-the-first-letter-of-a-string-uppercase-in-javascript https://dev.to/zenulabidin/moment-js-vs-intl-object-4f8n https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames https://stackoverflow.com/questions/1026069/how-do-i-make-the-first-letter-of-a-string-uppercase-in-javascript/60751434#60751434 https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter https://www.geeksforgeeks.org/convert-string-to-title-case-in-javascript/
1 parent d1be71e commit cbd7bc3

File tree

2 files changed

+16
-24
lines changed

2 files changed

+16
-24
lines changed

public/manifest.webmanifest

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,5 @@
3232
"application/octet-stream": [".nbt", ".dat", ".dat_old", ".mcstructure", ".litematic", ".schem", ".schematic"]
3333
}
3434
}
35-
],
36-
"launch_handler": {
37-
"client_mode": "focus-existing"
38-
}
35+
]
3936
}

src/FormatOptions.tsx

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -65,26 +65,21 @@ export function FormatOptions(props: FormatOptionsProps){
6565
<fieldset>
6666
<legend>Endian</legend>
6767

68-
<label>
69-
<input
70-
type="radio"
71-
name="endian"
72-
value="big"
73-
checked={props.getEndian() === "big"}
74-
oninput={() => props.setEndian("big")}
75-
/>
76-
Big
77-
</label>
78-
<label>
79-
<input
80-
type="radio"
81-
name="endian"
82-
value="little"
83-
checked={props.getEndian() === "little"}
84-
oninput={() => props.setEndian("little")}
85-
/>
86-
Little
87-
</label>
68+
{
69+
(["big", "little"] satisfies Endian[])
70+
.map(endian =>
71+
<label>
72+
<input
73+
type="radio"
74+
name="endian"
75+
value={endian}
76+
checked={props.getEndian() === endian}
77+
oninput={() => props.setEndian(endian)}
78+
/>
79+
{`${endian.slice(0,1).toUpperCase()}${endian.slice(1)}`}
80+
</label>
81+
)
82+
}
8883
</fieldset>
8984

9085
<fieldset>

0 commit comments

Comments
 (0)