Skip to content

Commit

Permalink
Merge pull request #282 from frontendnetwork/staging
Browse files Browse the repository at this point in the history
fix: Scanner is too zoomed in / Polish translation fix
  • Loading branch information
philipbrembeck committed May 8, 2023
2 parents ffc521f + 6f89661 commit d541842
Show file tree
Hide file tree
Showing 8 changed files with 112 additions and 131 deletions.
188 changes: 72 additions & 116 deletions package-lock.json

Large diffs are not rendered by default.

12 changes: 5 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,21 @@
},
"dependencies": {
"@ericblade/quagga2": "^1.8.2",
"@types/node": "18.16.2",
"@types/react": "18.2.0",
"@types/react-dom": "18.2.1",
"next": "13.3.1",
"@types/node": "20.1.0",
"@types/react-dom": "18.2.4",
"next": "13.3.4",
"next-intl": "^2.13.1",
"next-pwa": "^5.6.0",
"nookies": "^2.5.2",
"quagga": "^0.12.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"sass": "^1.62.1",
"typescript": "5.0.4"
},
"devDependencies": {
"@playwright/test": "^1.33.0",
"@types/nookies": "^2.0.3",
"eslint": "8.39.0",
"@types/react": "^18.2.6",
"eslint": "8.40.0",
"eslint-config-next": "^13.3.4",
"eslint-config-sznm": "^1.1.1"
}
Expand Down
28 changes: 22 additions & 6 deletions src/components/Scanner/scanner.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { Component } from "react";
import Quagga from "@ericblade/quagga2";

interface ScannerProps {
onDetected: (result: any) => void;
setScanning: (scanning: boolean) => void;
Expand All @@ -19,18 +18,20 @@ class Scanner extends Component<ScannerProps, ScannerState> {

handleClick = () => {
const { facingMode } = this.state;
const newFacingMode = facingMode === "environment" ? "user" : "environment";
const newFacingMode = facingMode === "environment" ? "environment" : "user";
this.setState({ facingMode: newFacingMode });

const width = window.innerWidth;
const height = window.innerHeight;

Quagga.init(
{
inputStream: {
type: "LiveStream",
constraints: {
width: window.innerWidth * window.devicePixelRatio,
height: window.innerHeight * window.devicePixelRatio,
aspectRatio: { ideal: window.innerHeight / window.innerWidth },
aspectRatio: { ideal: height / width },
facingMode: newFacingMode,
height: { min: 480, ideal: height, max: 1080 },
},
},
locator: {
Expand Down Expand Up @@ -88,13 +89,28 @@ class Scanner extends Component<ScannerProps, ScannerState> {
const vid: React.CSSProperties = {
position: "fixed",
zIndex: 999,
left: 0,
left: "50%",
top: 0,
transform: "translateX(-50%)",
};

const backdrop: React.CSSProperties = {
position: "fixed",
zIndex: 998,
top: 0,
left: 0,
width: "100%",
height: "100%",
background: "rgba(0, 0, 0, 0.2)",
backdropFilter: "blur(0.5rem)",
WebkitBackdropFilter: "blur(0.5rem)",
};


return (
!isHidden && (
<>
<div style={backdrop}></div>
<div id="controls">
<span id="close">
<div className="flex-container">
Expand Down
1 change: 1 addition & 0 deletions src/components/elements/pwainstall.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @next/next/no-img-element */
import { useState, useEffect } from "react";
import ModalWrapper from "@/components/elements/modalwrapper";
import Image from "next/image";
Expand Down
2 changes: 1 addition & 1 deletion src/locales/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"polish": "polski",
"cursed": "przeklęty",
"memeculture": "Niech żyje kultura memów!",
"czech": "Czeski"
"czech": "czeski"
},
"TOS": {
"englishgermanonly": "Ta strona jest dostępna tylko w języku angielskim i niemieckim.",
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
"@/*": ["./src/*"]
}
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "./types/**/*.d.ts"],
"exclude": ["node_modules"]
}
5 changes: 5 additions & 0 deletions types/@ericblade/quagga2.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
declare module "@ericblade/quagga2" {
const Quagga: any;
export default Quagga;
}

5 changes: 5 additions & 0 deletions types/quagga.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
declare module "quagga" {
const Quagga: any;
export default Quagga;
}

0 comments on commit d541842

Please sign in to comment.