Fixed includes

This commit is contained in:
Sambo Chea 2022-05-17 09:15:05 +07:00
parent 4544c365bb
commit c1f72a1b60
Signed by: sombochea
GPG Key ID: 3C7CF22A05D95490
4 changed files with 5 additions and 93 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@cubetiq/muui", "name": "@cubetiq/muui",
"version": "0.0.1-alpha.5", "version": "0.0.1-alpha.6",
"author": { "author": {
"name": "Sambo Chea", "name": "Sambo Chea",
"email": "sombochea@cubetiqs.com" "email": "sombochea@cubetiqs.com"

View File

@ -1,5 +1,3 @@
import Button from "./button"; export { default as Button } from "./button";
import Box from "./box"; export { default as Box } from "./box";
import Skeleton from "./skeleton"; export { default as Skeleton } from "./skeleton";
export default { Skeleton, Box, Button };

View File

@ -1,86 +0,0 @@
import { useEffect, useState } from "react";
import { QrReader } from "react-qr-reader";
import { useSnackbar, useTimeout } from "../../hooks";
import Button from "../button";
import Snackbar from "../snackbar";
export const Scanner = (props: any) => {
const [data, setData] = useState("No data");
const { handleClose, open, setOpen, message, setMessage } = useSnackbar();
const [loading, setLoading] = useState(true);
const timeout = useTimeout(() => {
setLoading(false);
}, 1000);
useEffect(() => {
timeout;
}, []);
const _onChangeFacingMode = () => {
let mode = getFacingMode() === "environment" ? "user" : "environment";
localStorage.setItem("facingMode", mode);
window.location.reload();
};
const getFacingMode = () => {
return localStorage.getItem("facingMode") || "environment";
};
return (
<>
<Snackbar message={message} open={open} onClose={handleClose} />
<Button onClick={() => _onChangeFacingMode()}>
{getFacingMode() !== "environment" ? "Back Camera" : "Front Camera"}
</Button>
<QrReader
ViewFinder={(props: any) => {
return (
<>
{loading ? (
<>Loading...</>
) : (
<video id="qr-video" width={"250px"} />
)}
</>
);
}}
onResult={(result: any, error: any) => {
if (!!result) {
setData(result?.text);
}
if (!!error) {
let _error = error?.toString() || "";
let message = "Something error!";
if (
_error.includes("DOMException") ||
_error.includes("NotAllowedError")
) {
message = "Camera access denied!";
} else if (_error.includes("e2")) {
message = "QR code not found!";
}
setMessage(message);
setOpen(true);
console.info("QR Code Error", error, _error);
}
}}
constraints={{
facingMode: getFacingMode(),
}}
scanDelay={1000}
// videoId={"video"}
// videoContainerStyle={{
// width: "100%",
// height: "100%",
// }}
// videoStyle={{
// width: "100%",
// height: "100%",
// }}
/>
<p>{data}</p>
</>
);
};

View File

@ -16,6 +16,6 @@
"noEmit": true, "noEmit": true,
"jsx": "react-jsx" "jsx": "react-jsx"
}, },
"include": ["example", "src/vite-env.d.ts", "src/App.tsx", "src/main.tsx"], "include": ["./src"],
"references": [{ "path": "./tsconfig.node.json" }] "references": [{ "path": "./tsconfig.node.json" }]
} }