-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
324 additions
and
352 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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
69 changes: 0 additions & 69 deletions
69
apps/trip-tick/web/vite.config.ts.timestamp-1710171524420.mjs
This file was deleted.
Oops, something went wrong.
This file contains 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 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 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,52 @@ | ||
import { useEffect } from 'react'; | ||
import { getIsMobile, getIsPWAInstalled } from '../platform.js'; | ||
import { appsById, isValidAppId } from '@biscuits/apps'; | ||
import { Button } from '@a-type/ui/components/button'; | ||
import { InstallButton } from './InstallButton.js'; | ||
import { useSnapshot } from 'valtio'; | ||
import { installState } from '../install.js'; | ||
|
||
export interface AppPreviewNoticeProps {} | ||
|
||
export function AppPreviewNotice({}: AppPreviewNoticeProps) { | ||
const searchParams = new URLSearchParams(window.location.search); | ||
const appPickerFrom = searchParams.get('appPickerFrom'); | ||
|
||
const { installReady } = useSnapshot(installState); | ||
|
||
useEffect(() => { | ||
// consume the param if present | ||
if (appPickerFrom) { | ||
const searchParams = new URLSearchParams(window.location.search); | ||
searchParams.delete('appPickerFrom'); | ||
const url = new URL(window.location.href); | ||
url.search = searchParams.toString(); | ||
window.history.replaceState(null, '', url.toString()); | ||
} | ||
}, [appPickerFrom]); | ||
|
||
if (!appPickerFrom) return null; | ||
|
||
// if we can't install this as a PWA, there's not much point in showing this warning | ||
if (!installReady) { | ||
return null; | ||
} | ||
|
||
if (!isValidAppId(appPickerFrom)) return null; | ||
const fromApp = appsById[appPickerFrom]; | ||
|
||
// this app is probably rendered inside a frame in the other app | ||
return ( | ||
<div className="w-full bg-accent-light p-2 flex flex-row gap-3 items-center"> | ||
<p className="text-sm text-accent-dark flex-1"> | ||
{`You're previewing this app.`} | ||
</p> | ||
<Button asChild> | ||
<a href={fromApp.url} target="_blank" rel="noopener noreferrer"> | ||
{`Back to ${fromApp.name}`} | ||
</a> | ||
</Button> | ||
<InstallButton /> | ||
</div> | ||
); | ||
} |
This file contains 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 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 |
---|---|---|
@@ -1,47 +1,56 @@ | ||
export async function requestPersistentStorage() { | ||
if (getIsPWAInstalled() && navigator.storage && navigator.storage.persist) { | ||
const result = await navigator.storage.persist(); | ||
console.log('Persistent storage:', result ? 'granted' : 'denied'); | ||
} | ||
if (getIsPWAInstalled() && navigator.storage && navigator.storage.persist) { | ||
const result = await navigator.storage.persist(); | ||
console.log('Persistent storage:', result ? 'granted' : 'denied'); | ||
} | ||
} | ||
|
||
export function getIsPWAInstalled() { | ||
return window.matchMedia('(display-mode: standalone)').matches; | ||
return window.matchMedia('(display-mode: standalone)').matches; | ||
} | ||
|
||
export function getOS() { | ||
const userAgent = window.navigator.userAgent; | ||
const platform = window.navigator.platform; | ||
const macosPlatforms = ['Macintosh', 'MacIntel', 'MacPPC', 'Mac68K']; | ||
const windowsPlatforms = ['Win32', 'Win64', 'Windows', 'WinCE']; | ||
const iosPlatforms = ['iPhone', 'iPad', 'iPod']; | ||
|
||
if (macosPlatforms.indexOf(platform) !== -1) { | ||
return 'Mac OS'; | ||
} else if (iosPlatforms.indexOf(platform) !== -1) { | ||
return 'iOS'; | ||
} else if (windowsPlatforms.indexOf(platform) !== -1) { | ||
return 'Windows'; | ||
} else if (/Android/.test(userAgent)) { | ||
return 'Android'; | ||
} else if (!platform && /Linux/.test(userAgent)) { | ||
return 'Linux'; | ||
} | ||
|
||
return 'Other'; | ||
const userAgent = window.navigator.userAgent; | ||
const platform = window.navigator.platform; | ||
const macosPlatforms = ['Macintosh', 'MacIntel', 'MacPPC', 'Mac68K']; | ||
const windowsPlatforms = ['Win32', 'Win64', 'Windows', 'WinCE']; | ||
const iosPlatforms = ['iPhone', 'iPad', 'iPod']; | ||
|
||
if (macosPlatforms.indexOf(platform) !== -1) { | ||
return 'Mac OS'; | ||
} else if (iosPlatforms.indexOf(platform) !== -1) { | ||
return 'iOS'; | ||
} else if (windowsPlatforms.indexOf(platform) !== -1) { | ||
return 'Windows'; | ||
} else if (/Android/.test(userAgent)) { | ||
return 'Android'; | ||
} else if (!platform && /Linux/.test(userAgent)) { | ||
return 'Linux'; | ||
} | ||
|
||
return 'Other'; | ||
} | ||
|
||
export function getIsSafari() { | ||
const ua = navigator.userAgent.toLowerCase(); | ||
return !!ua.match(/WebKit/i) && !ua.match(/CriOS/i); | ||
const ua = navigator.userAgent.toLowerCase(); | ||
return !!ua.match(/WebKit/i) && !ua.match(/CriOS/i); | ||
} | ||
|
||
export function getIsFirefox() { | ||
const ua = navigator.userAgent.toLowerCase(); | ||
return !!ua.match(/Firefox/i); | ||
const ua = navigator.userAgent.toLowerCase(); | ||
return !!ua.match(/Firefox/i); | ||
} | ||
|
||
export function getIsEdge() { | ||
const ua = navigator.userAgent.toLowerCase(); | ||
return !!ua.match(/Edge/i); | ||
const ua = navigator.userAgent.toLowerCase(); | ||
return !!ua.match(/Edge/i); | ||
} | ||
|
||
export function getIsMobile() { | ||
return ( | ||
/Mobi/.test(navigator.userAgent) || | ||
/Android/i.test(navigator.userAgent) || | ||
/iPhone/i.test(navigator.userAgent) || | ||
/iPad/i.test(navigator.userAgent) | ||
); | ||
} |
Oops, something went wrong.