Skip to content

Commit 68387b1

Browse files
authored
Merge pull request #157 from covidpass-org/dev
Romanian translation and minor fixes
2 parents 9534a5d + 685bbcb commit 68387b1

File tree

17 files changed

+213
-48
lines changed

17 files changed

+213
-48
lines changed

components/Button.tsx

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,28 @@
11
interface ButtonProps {
22
text?: string,
33
icon?: string,
4-
onClick?: () => void,
54
loading?: boolean,
6-
type?: ButtonType,
5+
onClick: () => void,
76
}
87

9-
export enum ButtonType {
10-
submit = 'submit',
11-
button = 'button',
12-
}
8+
function Button(props: ButtonProps): JSX.Element {
139

14-
Button.defaultProps = {
15-
loading: false,
16-
type: ButtonType.button,
17-
}
10+
function handleTouchEnd(event: React.TouchEvent<HTMLButtonElement>) {
11+
event.preventDefault();
12+
event.stopPropagation();
13+
14+
props.onClick();
15+
}
1816

19-
function Button(props: ButtonProps): JSX.Element {
2017
return (
2118
<button
22-
type={props.type}
19+
type="button"
2320
onClick={props.onClick}
24-
className={`${props.type == ButtonType.submit ? "bg-green-600 hover:bg-green-700" : "bg-gray-400 dark:bg-gray-600 hover:bg-gray-500"} relative focus:outline-none h-20 text-white font-semibold rounded-md items-center flex justify-center`}>
21+
onTouchEnd={handleTouchEnd}
22+
className="bg-gray-400 dark:bg-gray-600 hover:bg-gray-500 relative focus:outline-none h-20 text-white font-semibold rounded-md items-center flex justify-center">
2523
{
2624
props.icon && <img src={props.icon} className="w-12 h-12 mr-2 -ml-4" />
2725
}
28-
{
29-
props.type == ButtonType.submit &&
30-
<div id="spin" className={`${props.loading ? undefined : "hidden"} absolute left-2`}>
31-
<svg className="animate-spin h-5 w-5 ml-4" viewBox="0 0 24 24">
32-
<circle className="opacity-0" cx="12" cy="12" r="10" stroke="currentColor"
33-
strokeWidth="4"/>
34-
<path className="opacity-80" fill="currentColor"
35-
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"/>
36-
</svg>
37-
</div>
38-
}
3926
{props.text}
4027
</button>
4128
)

components/Form.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {getPayloadBodyFromFile, getPayloadBodyFromQR} from "../src/process";
1313
import {PassData} from "../src/pass";
1414
import {COLORS} from "../src/colors";
1515
import Colors from './Colors';
16-
import Button, { ButtonType } from './Button';
16+
import Button from './Button';
1717

1818
function Form(): JSX.Element {
1919
const {t} = useTranslation(['index', 'errors', 'common']);
@@ -278,7 +278,19 @@ function Form(): JSX.Element {
278278
</p>
279279
</label>
280280
<div className="grid grid-cols-1">
281-
<Button type={ButtonType.submit} text={t('index:addToWallet')} loading={loading} />
281+
<button
282+
type="submit"
283+
className="bg-green-600 hover:bg-green-700 relative focus:outline-none h-20 text-white font-semibold rounded-md items-center flex justify-center">
284+
<div id="spin" className={`${loading ? undefined : "hidden"} absolute left-2`}>
285+
<svg className="animate-spin h-5 w-5 ml-4" viewBox="0 0 24 24">
286+
<circle className="opacity-0" cx="12" cy="12" r="10" stroke="currentColor"
287+
strokeWidth="4"/>
288+
<path className="opacity-80" fill="currentColor"
289+
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"/>
290+
</svg>
291+
</div>
292+
{t('index:addToWallet')}
293+
</button>
282294
</div>
283295
</div>
284296
}/>

next-i18next.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ module.exports = {
1212
'es', 'es-ES',
1313
'no', 'no-NO',
1414
'nb', 'nb-NO',
15-
'sv', 'sv-SE', 'sv-FI'
15+
'sv', 'sv-SE', 'sv-FI',
16+
'ro', 'ro-RO', 'ro-MD'
1617
],
1718
localeExtension: 'yml',
1819
},

next.config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,12 @@ const {i18n} = require('./next-i18next.config');
22

33
module.exports = {
44
i18n,
5+
async rewrites() {
6+
return [
7+
{
8+
source: '/pass/note',
9+
destination: '/pass'
10+
}
11+
];
12+
}
513
};

pages/imprint.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ function Imprint(): JSX.Element {
1212
<Card step="§" heading={t('common:imprint')} content={
1313
<div className="space-y-3">
1414
<p className="font-bold">{t('imprint:heading')}</p>
15-
<p>Marvin Sextro</p>
15+
<p>
16+
Marvin Sextro<br />
17+
Kopenhagener Straße 45<br />
18+
10437 Berlin
19+
</p>
1620
<p className="font-bold">{t('imprint:contact')}</p>
1721
<p>
1822
<a href="mailto:[email protected]" className="underline">[email protected]</a>

pages/pass.tsx

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,55 @@
1+
import {useTranslation} from 'next-i18next';
12
import {serverSideTranslations} from 'next-i18next/serverSideTranslations';
23

34
import React, {useEffect, useState} from "react";
45
import QRCode from "react-qr-code";
56

7+
import Alert from '../components/Alert';
68
import Card from '../components/Card';
79
import Logo from "../components/Logo";
810

911
function Pass(): JSX.Element {
10-
const [fragment, setFragment] = useState<string>(undefined);
12+
const { t } = useTranslation(['common', 'index']);
1113

12-
function closeViewer() {
13-
setFragment(undefined);
14-
window.location.replace('/');
15-
}
14+
const [fragment, setFragment] = useState<string>(undefined);
15+
const [view, setView] = useState<boolean>(true);
1616

1717
useEffect(() => {
1818
const rawFragment = window.location.hash.substring(1);
19-
const decodedFragment = Buffer.from(rawFragment, 'base64').toString();
20-
setFragment(decodedFragment);
2119

22-
document.addEventListener('visibilitychange', () => {
23-
if (document.hidden) {
24-
closeViewer();
20+
if (!rawFragment) {
21+
setView(false);
22+
}
23+
24+
const resizeTimeout = window.setTimeout(() => {
25+
if (rawFragment) {
26+
window.location.replace('/pass/note');
2527
}
26-
});
28+
}, 200);
2729

28-
window.addEventListener('blur', closeViewer);
29-
window.addEventListener('beforeunload', closeViewer);
30-
window.addEventListener('pagehide', closeViewer);
30+
window.addEventListener('resize', () => {
31+
clearTimeout(resizeTimeout);
32+
const decodedFragment = Buffer.from(rawFragment, 'base64').toString();
33+
setFragment(decodedFragment);
34+
});
3135
}, []);
3236

3337
return (
34-
<div className="py-6 flex flex-col space-y-5 items-center">
38+
<div className="py-5 flex flex-col space-y-5 md:w-2/3 xl:w-2/5 md:mx-auto items-center justify-center px-5">
3539
<Logo/>
3640
<div className="flex flex-row items-center">
3741
{
3842
fragment &&
3943
<Card content={
4044
<div className="p-2 bg-white rounded-md">
41-
<QRCode value={fragment} size={280} level="L" />
45+
<QRCode value={fragment} size={280} level="L" />
4246
</div>
4347
} />
4448
}
49+
{
50+
!view &&
51+
<Alert isWarning={true} message={t('index:viewerNote')} onClose={undefined} />
52+
}
4553
</div>
4654
</div>
4755
)
@@ -50,7 +58,7 @@ function Pass(): JSX.Element {
5058
export async function getStaticProps({ locale }) {
5159
return {
5260
props: {
53-
...(await serverSideTranslations(locale, ['common'])),
61+
...(await serverSideTranslations(locale, ['index', 'common'])),
5462
},
5563
};
5664
}

public/locales/de/index.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ privacyPolicy: Datenschutzerklärung
2525
createdOnDevice: Auf Deinem Gerät erstellt
2626
openSourceTransparent: Open Source und transparent
2727
hostedInEU: In der EU gehostet
28-
share: Weiterempfehlen
28+
share: Weiterempfehlen
29+
viewerNote: Bitte drücke und halte den Link auf der Rückseite des Passes, um den QR Code unter iOS vergrößert anzuzeigen.

public/locales/en/index.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ privacyPolicy: Privacy Policy
2525
createdOnDevice: Created on your device
2626
openSourceTransparent: Open source and transparent
2727
hostedInEU: Hosted in the EU
28-
share: Share
28+
share: Share
29+
viewerNote: Please press and hold the link on the back of the pass in order to enlarge the QR code on iOS.

public/locales/ro-MD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ro

public/locales/ro-RO

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ro

0 commit comments

Comments
 (0)