1
0
Fork 1
mirror of https://github.com/elk-zone/elk.git synced 2024-07-03 13:06:47 +01:00

ui: update button for mobile

This commit is contained in:
Anthony Fu 2022-12-23 19:26:28 +01:00
parent 589cf463bd
commit cd268c9bc7
6 changed files with 28 additions and 13 deletions

View file

@ -22,6 +22,7 @@ defineProps<{
</div>
<div flex items-center flex-shrink-0 gap-x-2>
<slot name="actions" />
<PwaBadge lg:hidden />
<NavUser v-if="isHydrated.value" />
</div>
</div>

View file

@ -0,0 +1,17 @@
<script setup>
import { pwa } from '~/composables/pwa'
</script>
<template>
<button
v-if="pwa.needRefresh"
bg="fade" relative rounded
flex="~ gap-1 center" px3 py1 text-primary
@click="pwa.updateServiceWorker()"
>
<div i-ri-download-cloud-2-line />
<h2 flex="~ gap-2" items-center>
{{ $t('pwa.update_available_short') }}
</h2>
</button>
</template>

View file

@ -1,28 +1,22 @@
<script setup>
import { usePWA } from '~/composables/pwa'
const { close, needRefresh, updateServiceWorker } = usePWA()
import { pwa } from '~/composables/pwa'
</script>
<!-- TODO: remove shadow on mobile and position it above the bottom nav -->
<template>
<div
v-if="needRefresh"
role="alertdialog"
aria-labelledby="pwa-toast-title"
aria-describedby="pwa-toast-description"
v-if="pwa.needRefresh"
m-2 p5 bg="fade" relative
rounded-lg of-hidden
flex="~ col gap-3"
>
<h2 id="pwa-toast-title" flex="~ gap-2" items-center>
<h2 flex="~ gap-2" items-center>
{{ $t('pwa.title') }}
</h2>
<div flex="~ gap-1">
<button type="button" btn-solid px-4 py-1 text-center text-sm @click="updateServiceWorker()">
<button type="button" btn-solid px-4 py-1 text-center text-sm @click="pwa.updateServiceWorker()">
{{ $t('pwa.update') }}
</button>
<button type="button" btn-text filter-saturate-0 px-4 py-1 text-center text-sm @click="close()">
<button type="button" btn-text filter-saturate-0 px-4 py-1 text-center text-sm @click="pwa.close()">
{{ $t('pwa.dismiss') }}
</button>
</div>

View file

@ -44,3 +44,5 @@ export const usePWA = () => {
close,
}
}
export const pwa = reactive(usePWA())

View file

@ -53,7 +53,7 @@
<slot name="right">
<SearchWidget />
<div flex-auto />
<PWAPrompt />
<PwaPrompt />
<NavFooter />
</slot>
</div>

View file

@ -210,7 +210,8 @@
"message": "@:pwa.title{','} click on the @:pwa.reload button to update.",
"reload": "Reload",
"title": "New Elk update available!",
"update": "Update"
"update": "Update",
"update_available_short": "Update Elk"
},
"search": {
"search_desc": "Search for people & hashtags"