Skip to content

Commit

Permalink
Mapped Endian Format Options
Browse files Browse the repository at this point in the history
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/
  • Loading branch information
Offroaders123 committed Feb 3, 2024
1 parent d1be71e commit cbd7bc3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 24 deletions.
5 changes: 1 addition & 4 deletions public/manifest.webmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,5 @@
"application/octet-stream": [".nbt", ".dat", ".dat_old", ".mcstructure", ".litematic", ".schem", ".schematic"]
}
}
],
"launch_handler": {
"client_mode": "focus-existing"
}
]
}
35 changes: 15 additions & 20 deletions src/FormatOptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,26 +65,21 @@ export function FormatOptions(props: FormatOptionsProps){
<fieldset>
<legend>Endian</legend>

<label>
<input
type="radio"
name="endian"
value="big"
checked={props.getEndian() === "big"}
oninput={() => props.setEndian("big")}
/>
Big
</label>
<label>
<input
type="radio"
name="endian"
value="little"
checked={props.getEndian() === "little"}
oninput={() => props.setEndian("little")}
/>
Little
</label>
{
(["big", "little"] satisfies Endian[])
.map(endian =>
<label>
<input
type="radio"
name="endian"
value={endian}
checked={props.getEndian() === endian}
oninput={() => props.setEndian(endian)}
/>
{`${endian.slice(0,1).toUpperCase()}${endian.slice(1)}`}
</label>
)
}
</fieldset>

<fieldset>
Expand Down

0 comments on commit cbd7bc3

Please sign in to comment.