From 24ff629ef0e0a99947d08d845ec64b44e72f3ccf Mon Sep 17 00:00:00 2001 From: appleicat Date: Tue, 6 Feb 2024 04:48:34 +0400 Subject: [PATCH] add settings --- src/pages/_page.jsx | 143 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 137 insertions(+), 6 deletions(-) diff --git a/src/pages/_page.jsx b/src/pages/_page.jsx index e104a32..06dbbe0 100644 --- a/src/pages/_page.jsx +++ b/src/pages/_page.jsx @@ -1,9 +1,26 @@ import { useState, useEffect, useRef } from 'react'; import { motion } from 'framer-motion'; import QRcode from 'qrcode'; + +const Button = ({ children, onClick, isActive }) => { + return ( + + ); +}; + export default function Page() { const ref = useRef(); const [data, setData] = useState(''); + const [errorCorrectionLevel, setErrorCorrectionLevel] = useState('L'); + const [maskPattern, setMaskPattern] = useState(undefined); + const [version, setVersion] = useState(undefined); useEffect(() => { QRcode.toString( data, @@ -11,9 +28,12 @@ export default function Page() { type: 'svg', margin: 0, color: { dark: '000000FF', light: '00000000' }, + errorCorrectionLevel, + maskPattern, + version, }, (err, qrc) => { - err ? err : (ref.current.innerHTML = qrc); + err ? console.log(err) : (ref.current.innerHTML = qrc); err ? (ref.current.style.backgroundColor = 'red') : (ref.current.style.backgroundColor = 'transparent'); @@ -23,19 +43,130 @@ export default function Page() { return (
-
+ className="p-[1.5rem] grid-flow-row-dense w-full h-full" + > +
QRcode
+
+
version
+
+
+ +
+ {[ + '1', + '2', + '3', + '4', + '5', + '6', + '7', + '8', + '9', + '10', + '11', + '12', + '13', + '14', + '15', + '16', + '17', + '18', + '19', + '20', + '21', + '22', + '23', + '24', + '25', + '26', + '27', + '28', + '29', + '30', + '31', + '32', + '33', + '34', + '35', + '36', + '37', + '38', + '39', + '40', + ].map((v, key) => ( + + ))} +
+
+
+
mask pattern
+
+
+ +
+ {['0', '1', '2', '3', '4', '5', '6', '7'].map((mp, key) => ( + + ))} +
+
+
+
error correction level
+
+ {['L', 'M', 'Q', 'H'].map((ecl, key) => ( + + ))} +
+
+
+