Repository navigation
Add formatToParts API #41
Closed
alexandernanberg
started this conversation in
Ideas
Replies: 2 comments
|
I've been thinking about having a more organized approach to all the formatForDisplay stuff. We probably only need 1 interface/function with options for how to display. Or maybe a multi-return object is better. Maybe a root |
0 replies
|
This shipped as the formatForDisplay('Shift+ArrowUp', { parts: true })
// macOS: ['⇧', '↑']
// Windows/Linux: ['Shift', '↑']
formatForDisplay(['G', 'Mod+K'], { parts: true })
// macOS: [['G'], ['⌘', 'K']]The parts don't include separators. You add those when you render. If you need typed parts that include the separators, comment here and we can reopen. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Would be nice to have an alternative to
formatForDisplaywhen you need render more complex things, like highlighting the currently pressed key or rendering each key in a custom<span>etc.Maybe an API similar to
new Intl.DateTimeFormat().formatToParts()makes sense? Where it would return an array of objects with the useful data.E.g.
All reactions