Skip to content

Commit

Permalink
feat(sink): qr code generator (#631)
Browse files Browse the repository at this point in the history
Co-authored-by: deeola <71495600+deeola@users.noreply.github.com>
  • Loading branch information
aelew and deeola authored Oct 2, 2023
1 parent 833e5ab commit a334f16
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 13 deletions.
1 change: 1 addition & 0 deletions packages/kitchen-sink/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"react-dom": "^18.2.0",
"react-error-boundary": "^4.0.11",
"react-icons": "^4.11.0",
"react-qr-code": "^2.0.12",
"react-redux": "^8.1.3",
"react-router-dom": "^6.15.0",
"styled-components": "^6.0.7",
Expand Down
38 changes: 38 additions & 0 deletions packages/kitchen-sink/src/examples/qr-code-generator.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { block } from 'million/react';
import { useState, useRef } from 'react';
import QRCode from 'react-qr-code';

const QRCodeGenerator = block(() => {
const [data, setData] = useState<string | null>(null);
const inputRef = useRef<HTMLInputElement>(null);
return (
<div>
<h1>QR Code Generator</h1>
<div>
<input
placeholder="Enter text or URL"
style={{ width: '40%' }}
ref={inputRef}
type="text"
/>
<button
style={{ marginLeft: 10 }}
onClick={() => {
if (inputRef.current) {
setData(inputRef.current.value);
}
}}
>
Generate
</button>
</div>
{data && (
<div className="qr-code-wrapper">
<QRCode value={data} />
</div>
)}
</div>
);
});

export default QRCodeGenerator;
10 changes: 9 additions & 1 deletion packages/kitchen-sink/src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,12 @@ input[type="range"] {
}
}

/* */
/* */

/* QR code styles */
.qr-code-wrapper {
display: inline-flex;
background: white;
margin-top: 2rem;
padding: 1rem;
}
46 changes: 34 additions & 12 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 comments on commit a334f16

@vercel
Copy link

@vercel vercel bot commented on a334f16 Oct 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

sink – ./packages/kitchen-sink

sink-millionjs.vercel.app
sink-git-main-millionjs.vercel.app
million-kitchen-sink-atit.vercel.app
sink.million.dev

@vercel
Copy link

@vercel vercel bot commented on a334f16 Oct 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

million-kitchen-sink – ./packages/kitchen-sink

million-kitchen-sink-millionjs.vercel.app
million-kitchen-sink-git-main-millionjs.vercel.app
million-kitchen-sink.vercel.app

Please # to comment.