khmyznikov / pwa-install

Installation dialog for Progressive Web Application. Provides a more convenient user experience and fixes the lack of native dialogs in some browsers.
https://www.khmyznikov.com/pwa-install
MIT License
379 stars 61 forks source link

Feat: Filter screenshots based on form_factor & added Alt text #97

Closed hccullen closed 1 month ago

hccullen commented 1 month ago

The form_factor member is a string that represents the screen shape of a broad class of devices for which a given screenshot applies. Authors are encouraged to only use this member when the screenshot is only applicable in a specific context.

This PR filters the screenshots to remove those with the form_factor different from the user's client. If the screenshot does not have a form_factor specified, it will be shown.

Also added alt text for the screenshots.

Note on Types

The current types package doesn't seem to correctly type screenshots, which actually have an extension beyond ImageResource. Therefore I created my own type here. https://www.w3.org/TR/manifest-app-info/#dfn-screenshots-object

Resolves:

khmyznikov commented 1 month ago

Looks ok, changed the naming a bit. One downside is the fact it will not change the filtering if you dynamically rotate the screen for example, but I think the detection of this behavior will be costly.