mirror of
https://github.com/traberph/short.git
synced 2026-11-22 22:55:12 +00:00
add QRCode
This commit is contained in:
@@ -23,6 +23,7 @@ export default async function CustomPageDashboard(params: { customPage: CustomPa
|
||||
});
|
||||
|
||||
return (<>
|
||||
<h2>Links on Page</h2>
|
||||
{linkBlocks.map((block) => (
|
||||
|
||||
<div key={block.uuid} className="flex items-center justify-center mb-2 zebra">
|
||||
@@ -44,7 +45,7 @@ export default async function CustomPageDashboard(params: { customPage: CustomPa
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
<h2>Add new link page connection</h2>
|
||||
<h2 className="mt-10">Add new link page connection</h2>
|
||||
<CreateLinkBlockForm customPage={customPage.uuid} shortcodes={shortcodes || []} />
|
||||
|
||||
</>
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
"use client"
|
||||
|
||||
import { useQRCode } from "next-qrcode"
|
||||
import { useState } from "react";
|
||||
|
||||
export default function QRCode({ url }: { url: string }) {
|
||||
|
||||
const { Canvas } = useQRCode();
|
||||
|
||||
const values = ['L', 'M', 'Q', 'H'];
|
||||
|
||||
const [errorCorrectionLevel, setErrorCorrectionLevel] = useState(2);
|
||||
const [dark, setDark] = useState('#000000');
|
||||
const [light, setLight] = useState('#FFFFFF');
|
||||
|
||||
|
||||
return (<>
|
||||
|
||||
<div className="flex justify-between max-sm:flex-col">
|
||||
<div className="flex justify-between flex-col">
|
||||
<h2>QR Code</h2>
|
||||
<span className="flex items-center justify-between"> Error Correction Level:
|
||||
<div className="flex justify-between">
|
||||
{values.map((value, index) => (
|
||||
<span
|
||||
key={index}
|
||||
className={`mx-2 ${errorCorrectionLevel === index ? 'text-white' : 'text-gray-400'}`}
|
||||
onClick={() => setErrorCorrectionLevel(index)}>
|
||||
{value}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
</span>
|
||||
<span className="flex items-center justify-between">
|
||||
Dark:
|
||||
<input type="color" className="ml-3 w-5 h-5 p-0" value={dark} onChange={(e) => setDark(e.target.value)} />
|
||||
</span>
|
||||
<span className="flex items-center justify-between">
|
||||
Light:
|
||||
<input type="color" className="ml-3 w-5 h-5 p-0" value={light} onChange={(e) => setLight(e.target.value)} />
|
||||
</span>
|
||||
</div>
|
||||
<div className="max-sm:mt-5">
|
||||
<Canvas
|
||||
text={"https://"+ window.location.host + "/" + url}
|
||||
options={{
|
||||
errorCorrectionLevel: values[errorCorrectionLevel],
|
||||
width: 150,
|
||||
color: {
|
||||
dark: dark,
|
||||
light: light
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
@@ -3,13 +3,13 @@ import { signOut } from "@/auth"
|
||||
export default function SignOutButton() {
|
||||
return (
|
||||
<form
|
||||
className="flex"
|
||||
className="flex m-0 p-0"
|
||||
action={async () => {
|
||||
"use server"
|
||||
await signOut()
|
||||
}}
|
||||
>
|
||||
<button className='ml-auto bg-transparent p-1 hover:underline hover:bg-transparent' type="submit">logout</button>
|
||||
<button className='max-sm:ml-0 ml-auto bg-transparent p-0 hover:underline hover:bg-transparent' type="submit">logout</button>
|
||||
</form>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user