-
-
Notifications
You must be signed in to change notification settings - Fork 478
feat(ui): premium app features — installability, WCO, share, badging #2982
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tomayac
wants to merge
19
commits into
npmx-dev:main
Choose a base branch
from
tomayac:pwa-and-premium-app-features
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
606cb61
feat: enable PWA installability via @vite-pwa/nuxt
tomayac 21ae868
feat: add Share button to package pages via Web Share API
tomayac 3d0af90
feat: add window controls overlay and app shortcuts
tomayac b02e663
feat(ui): replace custom toggle with native input switch polyfill
tomayac 56be1fd
feat: add App Badging API for new likes on user's packages
tomayac d38aa74
feat: generate PWA screenshots for richer install UI
tomayac f116059
feat: add PWA manifest id, generate screenshots for richer install UI
tomayac 1615b3e
Merge remote-tracking branch 'upstream/main' into pwa-and-premium-app…
tomayac b6f93a1
feat(pwa): improve WCO, Share button shortcut, and polyfill live theming
tomayac 7e682b9
fix(types): fix vue-tsc failures in input-switch-polyfill plugin
tomayac 7325eb7
Merge remote-tracking branch 'upstream/main' into pwa-and-premium-app…
tomayac 7c9faf3
[autofix.ci] apply automated fixes
autofix-ci[bot] 2f32b65
fix(pwa): validate full share payload before attaching og:image file
tomayac b222d1f
fix(pwa): fail fast when --url flag is passed without a value
tomayac 988ed44
Merge remote-tracking branch 'origin/pwa-and-premium-app-features' in…
tomayac 7047054
fix(pwa): propagate preview-server errors and clean up on startup fai…
tomayac 07ed5b4
fix: resolve CI failures — knip, i18n schema, duplicate vue resolution
tomayac 184cb52
fix(pwa): fix sticky sub-header gap under window controls overlay
tomayac 49a4d7b
fix(pwa): enable install prompt capture
tomayac File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| <script setup lang="ts"> | ||
| const props = defineProps<{ | ||
| packageName: string | ||
| description?: string | null | ||
| }>() | ||
|
|
||
| const canShare = 'share' in navigator | ||
| const buttonRef = useTemplateRef<{ click: () => void }>('buttonRef') | ||
|
|
||
| if (canShare) { | ||
| onKeyStroke( | ||
| e => isKeyWithoutModifiers(e, 'v') && !isEditableElement(e.target), | ||
| e => { | ||
| e.preventDefault() | ||
| // Click the button element so the browser anchors the share sheet at | ||
| // the button's position rather than the current mouse cursor position. | ||
| buttonRef.value?.click() | ||
| }, | ||
| ) | ||
| } | ||
|
|
||
| async function getOgImageFile(): Promise<File | null> { | ||
| // Files sharing is not universally supported; bail out early if not available. | ||
| if (!navigator.canShare?.({ files: [new File([], 'x.png', { type: 'image/png' })] })) { | ||
| return null | ||
| } | ||
| try { | ||
| const ogMeta = document.querySelector<HTMLMetaElement>('meta[property="og:image"]') | ||
| if (!ogMeta?.content) return null | ||
| const blob = await fetch(ogMeta.content).then(r => r.blob()) | ||
| if (!blob.type.startsWith('image/')) return null | ||
| return new File([blob], `${props.packageName}.png`, { type: blob.type }) | ||
| } catch { | ||
| return null | ||
| } | ||
| } | ||
|
|
||
| async function share() { | ||
| const shareData: ShareData = { | ||
| title: props.packageName, | ||
| text: props.description ?? props.packageName, | ||
| url: window.location.href, | ||
| } | ||
|
|
||
| const imageFile = await getOgImageFile() | ||
| if (imageFile) { | ||
| const shareDataWithFile: ShareData = { ...shareData, files: [imageFile] } | ||
| // Some implementations support sharing files or url/text, but not the | ||
| // combination of both. Only attach the file once the full payload | ||
| // (title + text + url + files) is confirmed shareable, so we keep the | ||
| // url/text fallback otherwise. | ||
| if (navigator.canShare?.(shareDataWithFile)) { | ||
| shareData.files = shareDataWithFile.files | ||
| } | ||
| } | ||
|
|
||
| await navigator.share(shareData).catch(() => {}) | ||
| } | ||
| </script> | ||
|
|
||
| <template> | ||
| <ButtonBase | ||
| v-if="canShare" | ||
| ref="buttonRef" | ||
| variant="secondary" | ||
| classicon="i-lucide:share-2" | ||
| :aria-label="$t('package.share_aria_label', { package: packageName })" | ||
| :ariaKeyshortcuts="'v'" | ||
| @click="share" | ||
| > | ||
| <span class="max-sm:sr-only">{{ $t('package.links.share') }}</span> | ||
| </ButtonBase> | ||
| </template> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| <script setup lang="ts"> | ||
| const { $pwa } = useNuxtApp() | ||
| </script> | ||
|
|
||
| <template> | ||
| <Transition name="pwa-toast" appear> | ||
| <div | ||
| v-if="$pwa?.needRefresh" | ||
| role="alert" | ||
| aria-live="polite" | ||
| class="fixed bottom-4 inset-ie-4 z-50 flex items-start gap-3 px-4 py-3 bg-bg border border-border rounded-lg shadow-lg max-w-sm" | ||
| > | ||
| <span class="i-lucide:refresh-cw w-4 h-4 text-fg-muted shrink-0 mt-0.5" aria-hidden="true" /> | ||
| <p class="text-sm text-fg flex-1">{{ $t('pwa.update_available') }}</p> | ||
| <div class="flex items-center gap-2 shrink-0"> | ||
| <ButtonBase size="sm" @click="$pwa?.cancelPrompt()"> | ||
| {{ $t('common.close') }} | ||
| </ButtonBase> | ||
| <ButtonBase size="sm" variant="primary" @click="$pwa?.updateServiceWorker()"> | ||
| {{ $t('pwa.refresh') }} | ||
| </ButtonBase> | ||
| </div> | ||
| </div> | ||
| </Transition> | ||
| </template> | ||
|
|
||
| <style scoped> | ||
| .pwa-toast-enter-active, | ||
| .pwa-toast-leave-active { | ||
| transition: | ||
| opacity 0.25s ease, | ||
| transform 0.25s ease; | ||
| } | ||
|
|
||
| .pwa-toast-enter-from, | ||
| .pwa-toast-leave-to { | ||
| opacity: 0; | ||
| transform: translateY(8px); | ||
| } | ||
| </style> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.