nandorojo / zeego

Menus for React (Native) done right.
https://zeego.dev
MIT License
1.45k stars 42 forks source link

Should we add autocomplete for `iosIconName`? #9

Closed nandorojo closed 1 year ago

nandorojo commented 2 years ago

The list of iOS icons is here: https://github.com/noahsark769/sfsymbols.com/blob/master/src/data/symbols.json

It would be easy to add TS autocomplete by turning that file into a union type. However, I worry that it might make the types slow.

Maybe we could do something like:

import * as DropdownMenu from 'zeego/dropdown-menu'
import { iosIconName } from 'zeego/ios-icons'

<DropdownMenu.ItemIcon iosIconName={iosIconName("xmark.circle.fill")} />

That way, you get autocomplete from iosIconName as a pure convenience feature, but it doesn't slow down TS if you don't use it. I don't know for fact this would slow it down, but with 2k + items I can only assume.

jesuscovam commented 1 year ago

could it be simpler as an enum?

nandorojo commented 1 year ago

at runtime an enum would be a giant object, so probably better to keep it as strings and offload any work to the type checker only

nandorojo commented 1 year ago

Done in 1.4