Skip to content

Commit

Permalink
pwa update (#252)
Browse files Browse the repository at this point in the history
  • Loading branch information
noahlitvin authored Jan 19, 2025
2 parents a37f26a + baf3cb5 commit 67652f2
Show file tree
Hide file tree
Showing 17 changed files with 266 additions and 105 deletions.
2 changes: 0 additions & 2 deletions packages/app/public/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
"name": "Foil",
"short_name": "Foil",
"description": "The fully decentralized marketplace for onchain resources",
"start_url": "https://app.foil.xyz",
"scope": "https://app.foil.xyz/",
"display": "standalone",
"background_color": "#FFFFFF",
"theme_color": "#2C2C2E",
Expand Down
22 changes: 15 additions & 7 deletions packages/app/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Providers from '~/app/providers';
import '@rainbow-me/rainbowkit/styles.css';
import '../lib/styles/globals.css';
import { LoadingSpinner } from '~/lib/components/foil/loadingSpinner';
import { InstallDialog } from '~/lib/components/InstallDialog';
import { LoadingProvider } from '~/lib/context/LoadingContext';
import { Toaster } from '@/components/ui/toaster';
import Layout from '~/lib/layout';
Expand All @@ -13,11 +14,14 @@ type RootLayoutProps = {
};

const APP_NAME = 'Foil';
const APP_DESCRIPTION =
'The fully decentralized marketplace for onchain resources';

export const metadata: Metadata = {
title: { default: APP_NAME, template: '%s | Foil' },
description: 'Foil App',
description: APP_DESCRIPTION,
applicationName: APP_NAME,
manifest: '/manifest.json',
appleWebApp: {
capable: true,
title: APP_NAME,
Expand All @@ -27,24 +31,27 @@ export const metadata: Metadata = {
telephone: false,
},
openGraph: {
type: 'website',
url: 'https://foil.xyz',
title: 'Foil',
description: '',
images: {
url: '',
alt: 'foil og-image',
},
title: APP_NAME,
description: APP_DESCRIPTION,
siteName: APP_NAME,
},
twitter: {
creator: '@foilxyz',
card: 'summary_large_image',
title: APP_NAME,
description: APP_DESCRIPTION,
},
};

export const viewport: Viewport = {
width: 'device-width',
initialScale: 1,
maximumScale: 1,
userScalable: false,
themeColor: '#FFFFFF',
viewportFit: 'cover',
};

const RootLayout = ({ children }: RootLayoutProps) => {
Expand All @@ -55,6 +62,7 @@ const RootLayout = ({ children }: RootLayoutProps) => {
<LoadingProvider>
<LoadingSpinner />
<Layout>{children}</Layout>
<InstallDialog />
<Toaster />
</LoadingProvider>
</Providers>
Expand Down
75 changes: 75 additions & 0 deletions packages/app/src/lib/components/InstallDialog.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
'use client';

import { Share, PlusSquare } from 'lucide-react';
import Image from 'next/image';
import { useEffect, useState } from 'react';

import {
Dialog,
DialogContent,
DialogDescription,
DialogHeader,
DialogTitle,
} from '@/components/ui/dialog';

export const InstallDialog = () => {
const [isOpen, setIsOpen] = useState(false);

useEffect(() => {
// Check if we're on mobile and not in standalone mode
const isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);
const isStandalone = window.matchMedia(
'(display-mode: standalone)'
).matches;

if (isMobile && !isStandalone) {
setIsOpen(true);
}
}, []);

return (
<Dialog open={isOpen} onOpenChange={setIsOpen}>
<DialogContent>
<div className="mx-auto w-full max-w-sm">
<DialogHeader className="mb-6">
<div className="my-4 flex justify-center">
<Image
src="/icons/icon-192x192.png"
alt="Foil App Icon"
width={72}
height={72}
className="rounded-2xl border border-border shadow-lg"
/>
</div>
<DialogTitle className="text-center text-2xl">
Install Foil
</DialogTitle>
<DialogDescription>
Add the app to your home screen
</DialogDescription>
</DialogHeader>
<div className="space-y-4 rounded-lg bg-muted px-4 py-8 text-center">
<div className="space-y-2">
<p className="text-lg">
Tap the{' '}
<span className="mx-0.5 inline-flex translate-y-[3px] items-center">
<Share className="h-5 w-5" />
</span>{' '}
share icon in your browser
</p>
</div>
<div className="space-y-2">
<p className="text-lg">
Select{' '}
<span className="mx-0.5 inline-flex translate-y-[3px] items-center">
<PlusSquare className="h-5 w-5" />
</span>{' '}
Add to Home Screen
</p>
</div>
</div>
</div>
</DialogContent>
</Dialog>
);
};
1 change: 1 addition & 0 deletions packages/website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"tailwind-merge": "^2.5.4",
"tailwindcss-animate": "^1.0.7",
"usehooks-ts": "^3.1.0",
"vaul": "^1.1.2",
"zod": "^3.23.8"
},
"devDependencies": {
Expand Down
Binary file removed packages/website/public/icons/icon-128x128.png
Binary file not shown.
Binary file removed packages/website/public/icons/icon-144x144.png
Binary file not shown.
Binary file removed packages/website/public/icons/icon-152x152.png
Binary file not shown.
Binary file removed packages/website/public/icons/icon-192x192.png
Binary file not shown.
Binary file removed packages/website/public/icons/icon-384x384.png
Binary file not shown.
Binary file removed packages/website/public/icons/icon-512x512.png
Binary file not shown.
Binary file removed packages/website/public/icons/icon-72x72.png
Binary file not shown.
Binary file removed packages/website/public/icons/icon-96x96.png
Binary file not shown.
61 changes: 0 additions & 61 deletions packages/website/public/manifest.json

This file was deleted.

2 changes: 1 addition & 1 deletion packages/website/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import '@/lib/styles/globals.css';

const APP_NAME = 'Foil';
const APP_DESCRIPTION =
'Lock in your onchain costs regardless of network congestion';
'The fully decentralized marketplace for onchain resources';

export const metadata: Metadata = {
title: APP_NAME,
Expand Down
111 changes: 111 additions & 0 deletions packages/website/src/components/ui/drawer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
'use client';

import * as React from 'react';
import { Drawer as DrawerPrimitive } from 'vaul';

import { cn } from '@/lib/utils';

const Drawer = ({
shouldScaleBackground = true,
...props
}: React.ComponentProps<typeof DrawerPrimitive.Root>) => (
<DrawerPrimitive.Root
shouldScaleBackground={shouldScaleBackground}
{...props}
/>
);
Drawer.displayName = 'Drawer';

const DrawerTrigger = DrawerPrimitive.Trigger;

const DrawerPortal = DrawerPrimitive.Portal;

const DrawerClose = DrawerPrimitive.Close;

const DrawerOverlay = React.forwardRef(({ className, ...props }: any, ref) => (
<DrawerPrimitive.Overlay
ref={ref}
className={cn('fixed inset-0 z-50 bg-black/80', className)}
{...props}
/>
));
DrawerOverlay.displayName = DrawerPrimitive.Overlay.displayName;

const DrawerContent = React.forwardRef(
({ className, children, ...props }: any, ref) => (
<DrawerPortal>
<DrawerOverlay />
<DrawerPrimitive.Content
ref={ref}
className={cn(
'fixed inset-x-0 bottom-0 z-50 mt-24 flex h-auto flex-col rounded-t-[10px] border bg-background',
className
)}
{...props}
>
<div className="mx-auto mt-4 h-2 w-[100px] rounded-full bg-muted" />
{children}
</DrawerPrimitive.Content>
</DrawerPortal>
)
);
DrawerContent.displayName = 'DrawerContent';

const DrawerHeader = ({
className,
...props
}: React.HTMLAttributes<HTMLDivElement>) => (
<div
className={cn('grid gap-1.5 p-4 text-center sm:text-left', className)}
{...props}
/>
);
DrawerHeader.displayName = 'DrawerHeader';

const DrawerFooter = ({
className,
...props
}: React.HTMLAttributes<HTMLDivElement>) => (
<div
className={cn('mt-auto flex flex-col gap-2 p-4', className)}
{...props}
/>
);
DrawerFooter.displayName = 'DrawerFooter';

const DrawerTitle = React.forwardRef(({ className, ...props }: any, ref) => (
<DrawerPrimitive.Title
ref={ref}
className={cn(
'text-lg font-semibold leading-none tracking-tight',
className
)}
{...props}
/>
));
DrawerTitle.displayName = DrawerPrimitive.Title.displayName;

const DrawerDescription = React.forwardRef(
({ className, ...props }: any, ref) => (
<DrawerPrimitive.Description
ref={ref}
className={cn('text-sm text-muted-foreground', className)}
{...props}
/>
)
);
DrawerDescription.displayName = DrawerPrimitive.Description.displayName;

export {
Drawer,
DrawerPortal,
DrawerOverlay,
DrawerTrigger,
DrawerClose,
DrawerContent,
DrawerHeader,
DrawerFooter,
DrawerTitle,
DrawerDescription,
};
15 changes: 13 additions & 2 deletions packages/website/src/lib/layout/components/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,19 @@ export const Header = () => {
>
Docs
</a>
<Button asChild className="rounded-2xl p-6 font-semibold">
<a href="https://app.foil.xyz">Go to App</a>
<Button
asChild
className="flex items-center rounded-2xl p-6 font-semibold"
>
<a href="https://app.foil.xyz" className="hidden md:inline-flex">
Go to App
</a>
</Button>
<Button
asChild
className="flex items-center rounded-2xl p-6 font-semibold md:hidden"
>
<a href="https://app.foil.xyz">Install App</a>
</Button>
</div>
</section>
Expand Down
Loading

0 comments on commit 67652f2

Please sign in to comment.