From aa6dcf52231e499c4e39d6476a9ae76ea55cd65e Mon Sep 17 00:00:00 2001 From: Anton Date: Fri, 1 Sep 2023 00:57:53 +0200 Subject: [PATCH] make app an PWA --- src/App.tsx | 2 +- src/pages/MapContainer.tsx | 9 ++++++--- vite.config.ts | 21 ++++++++++++++++++++- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 4774e542..198b12ca 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -20,7 +20,7 @@ function App() { - + } /> } /> diff --git a/src/pages/MapContainer.tsx b/src/pages/MapContainer.tsx index 098b16fb..1c176480 100644 --- a/src/pages/MapContainer.tsx +++ b/src/pages/MapContainer.tsx @@ -1,7 +1,6 @@ import { UtopiaMap, Tags, Layer, ItemForm, ItemView, PopupTextAreaInput, PopupStartEndInput, TextView, StartEndView } from 'utopia-ui' -import { tags } from './data' import { itemsApi } from '../api/itemsApi' -import { Place, Event } from '../api/directus'; +import { Place, Event, Tag } from '../api/directus'; import { useEffect, useState } from 'react'; function MapContainer() { @@ -9,12 +8,16 @@ function MapContainer() { const [placesApi, setPlacesApi] = useState>(); const [eventsApi, setEventsApi] = useState>(); + const [tagsApi, setTagsApi] = useState>(); + useEffect(() => { setPlacesApi(new itemsApi('places')); setEventsApi(new itemsApi('events')); + setTagsApi(new itemsApi('tags')); + }, []); @@ -58,7 +61,7 @@ function MapContainer() { // data={places} api={placesApi} /> - + ) } diff --git a/vite.config.ts b/vite.config.ts index 5a33944a..9858d0e4 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,7 +1,26 @@ import { defineConfig } from 'vite' import react from '@vitejs/plugin-react' +// vite.config.js +import { VitePWA } from 'vite-plugin-pwa' + // https://vitejs.dev/config/ export default defineConfig({ - plugins: [react()], + plugins: [ + react(), + VitePWA({manifest: { + "short_name": "Utopia Game", + "name": "Utopia Game: A Cooperative Real Life Manifestation Game", + "icons": [ + { + "src": "3markers.svg", + "sizes": "192x192", + "type": "image/svg" + } + ], + "start_url": "/index.html", + "display": "fullscreen", + "orientation": "portrait" + }}) + ] })