PWA functionality

This commit is contained in:
Philipp Traber
2024-10-20 20:15:58 +02:00
parent c49e1b6020
commit 65a75080a4
17 changed files with 74 additions and 40 deletions
Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 28 KiB

+4 -4
View File
@@ -19,11 +19,11 @@ h2 {
}
.form-field-error {
@apply border-red-500;
@apply common-red;
}
.form-label-error {
@apply text-red-500;
@apply common-red;
}
form {
@@ -51,11 +51,11 @@ button {
}
.zebra {
@apply even:bg-slate-800 p-2 rounded;
@apply even:bg-slate-800 p-2 py-5 rounded;
}
.common-red {
@apply text-red-500;
@apply text-red-800;
}
@keyframes slide-in {
+27
View File
@@ -0,0 +1,27 @@
import type { MetadataRoute } from "next";
export default function manifest(): MetadataRoute.Manifest {
return {
name: "traberph/short",
short_name: "short",
description: "A URL shortener",
start_url: "/~/dash",
display: "standalone",
theme_color: "#111827",
background_color: "#111827",
icons: [
{
src:'/icon-192x192.png',
sizes: '192x192',
type: 'image/png',
},
{
src:'/icon-512x512.png',
sizes: '512x512',
type: 'image/png',
},
],
};
}
+2 -2
View File
@@ -7,7 +7,7 @@ import CustomPageDashboard from "@/components/CustomPageDashboard";
import LinkFavicon from "@/components/LinkFavicon";
import { hashToColor } from "@/utils";
import PinPageToRootForm from "@/components/forms/pinPageToRootForm";
import { ArrowTopRightOnSquareIcon } from "@heroicons/react/24/solid";
import { ArrowTopRightOnSquareIcon, BookmarkIcon } from "@heroicons/react/24/solid";
import QRCode from "@/components/QRCode";
interface PageProps {
@@ -90,7 +90,7 @@ export default async function DetailedStats({ params }: PageProps) {
<p><a className="underline" href={page.redirectPage[0].dest}>{page.redirectPage[0].dest}</a></p> : ""}
</div>
<div className="ml-5">
{page.pinnedPage ? <p className="common-red">Pinned to root</p> : ""}
{page.pinnedPage ? <BookmarkIcon className="button-icon common-red"/> : ""}
</div>
</div>
+1 -1
View File
@@ -19,7 +19,7 @@ export default async function Dashboard({ children }: { children: ReactNode }) {
}
return (
<div className='p-10 max-w-7xl mx-auto'>
<div className='p-10 max-w-7xl mx-auto max-sm:px-6'>
<div className='flex justify-between max-sm:flex-col mb-10'>
<Link href="/~/dash/">
+1 -1
View File
@@ -15,7 +15,7 @@ export default async function AdminRoot() {
return (<div className="vcenter">
<Link href="https://github.com/traberph/short"><h1>traberph/short</h1></Link>
<Link href="https://github.com/traberph/short"><h1 className="my-5">traberph/short</h1></Link>
<SignInButton />
<Link href="/" className="mt-3 hover:underline">or back to root</Link>
</div>
+9 -11
View File
@@ -23,24 +23,22 @@ export default async function CustomPageDashboard(params: { customPage: CustomPa
});
return (<>
<h2>Links on Page</h2>
<h2 className="mb-5">Links on Page</h2>
{linkBlocks.map((block) => (
<div key={block.uuid} className="flex items-center justify-center mb-2 zebra">
<div className="mr-5">order: {block.order}</div>
<div className="mr-5">title: <span className="font-bold">{block.title}</span></div>
<div>connected link page: <span className="font-bold">{block.redirectPage.page.shortcode}</span></div>
<div className="ml-auto">
<div key={block.uuid} className="flex items-center justify-between zebra max-sm:flex-col max-sm:items-start">
<div className="flex">
<div className="mr-5">order: {block.order}</div>
<div className="mr-5">title: <span className="font-bold">{block.title}</span></div>
<div>link page: <span className="font-bold">{block.redirectPage.page.shortcode}</span></div>
</div>
<div className="flex max-sm:mt-3 max-sm:w-full max-sm:justify-between">
<button>
<a href={`/${block.redirectPage.page.shortcode}`} className="btn btn-primary"><ArrowTopRightOnSquareIcon className="button-icon" /></a>
</button>
</div>
<div className="ml-5">
<button>
<button className="ml-3">
<a href={`/~/dash/${block.redirectPage.page.uuid}`} className="btn btn-primary"><ArrowTrendingUpIcon className="button-icon" /></a>
</button>
</div>
<div className="ml-5">
<DeleteLinkBlockForm linkBlockUuid={block.uuid} />
</div>
</div>
+1 -2
View File
@@ -4,7 +4,7 @@ export default function LinkFavicon({ url }: { url: string }) {
const hostname = new URL(url).hostname;
return (<div className=" h-10 w-10">
return (
<Image
src={`https://logo.clearbit.com/${hostname}?`}
width={100}
@@ -12,6 +12,5 @@ export default function LinkFavicon({ url }: { url: string }) {
alt=" "
className="rounded-full"
/>
</div>
);
}
+15 -14
View File
@@ -4,6 +4,7 @@ import Image from 'next/image';
import Link from 'next/link';
import LinkFavicon from './LinkFavicon';
import PinPageToRootForm from './forms/pinPageToRootForm';
import { BookmarkIcon } from '@heroicons/react/24/solid';
type PageWithRelations = Prisma.PageGetPayload<{
include: {
@@ -24,9 +25,11 @@ export default async function PageListComponent({ page }: { page: PageWithRelati
return (
<Link href={`/~/dash/${page.uuid}`}>
<div className="w-full my-3 flex items-center hover:bg-slate-600 rounded p-1">
<div className="flex-shrink-0 h-8 w-8 flex items-center justify-center mr-4">
{redirectPage ? <LinkFavicon url={redirectPage.dest} /> :
<div className='flex justify-between items-center hover:bg-slate-700 my-2 p-1 rounded'>
<div className='flex items-center'>
<div className='w-8 h-8'>
{redirectPage ?
<LinkFavicon url={redirectPage.dest} /> :
<Image
loading='lazy'
width={100}
@@ -35,19 +38,17 @@ export default async function PageListComponent({ page }: { page: PageWithRelati
alt="icon"
className="rounded-full"
/>}
</div>
<div className='ml-3'>
<p className="font-bold text-lg text-white">{page.shortcode}</p>
<p className="text-sm text-gray-400">{redirectPage ? redirectPage.dest : customPage.title}</p>
</div>
<div className="ml-5">
{page.pinnedPage ? <BookmarkIcon className='button-icon common-red'/> : ""}
</div>
</div>
<div>
<p className="font-bold text-lg text-white">{page.shortcode}</p>
<p className="text-sm text-gray-400">{redirectPage ? redirectPage.dest : customPage.title}</p>
</div>
<div className="ml-5">
{page.pinnedPage ? <p className="text-red-500">Pinned to root</p> : ""}
</div>
<div className="ml-auto">
{page._count.stat ? <p className="text-gray-400 font-bold">{page._count.stat} visits</p> : ""}
{//<DeletePageForm uuid={page.uuid} />
}
{page._count.stat ? <p className="text-gray-400 font-bold text-right">{page._count.stat} visits</p> : ""}
</div>
</div>
</Link>
+1 -1
View File
@@ -24,7 +24,7 @@ export default function QRCode({ url }: { url: string }) {
{values.map((value, index) => (
<span
key={index}
className={`mx-2 ${errorCorrectionLevel === index ? 'text-white' : 'text-gray-400'}`}
className={`cursor-pointer mx-2 ${errorCorrectionLevel === index ? 'text-white' : 'text-gray-400'}`}
onClick={() => setErrorCorrectionLevel(index)}>
{value}
</span>
+1 -1
View File
@@ -18,7 +18,7 @@ export default function CreateLinkBlockForm({ customPage, shortcodes }: { custom
useEffect(() => { handleToast(state); }, [state]);
return (<form action={formAction}>
return (<form action={formAction} className="mt-5">
<div className="form-group">
<label htmlFor="redirectPageShortcode">Redirect Page</label>
<select name="redirectPageShortcode" id="redirectPageShortcode" className={state.error?.redirectPageShortcode ? "border-red-400" : ""}>
+1 -1
View File
@@ -17,7 +17,7 @@ export default function DeleteLinkBlockForm({ linkBlockUuid }: { linkBlockUuid:
useEffect(() => { handleToast(state); }, [state]);
return (<form action={formAction}>
return (<form action={formAction} className="ml-3 w-min">
<input type="hidden" name="uuid" id="uuid" value={linkBlockUuid} />
<SubmitButton>
<LinkSlashIcon className="button-icon" />