Skip to content

Commit ca6f70b

Browse files
committed
Add pwa configuration
1 parent 9b6f5a2 commit ca6f70b

File tree

2 files changed

+95
-0
lines changed

2 files changed

+95
-0
lines changed

index.html

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,60 @@
2222
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
2323
<link href="https://fonts.googleapis.com/css2?family=Baloo+2:wght@400;700&family=Inter:wght@400;700&display=swap" rel="stylesheet">
2424
<title>Hora de Silêncio Interrompido</title>
25+
<meta name="theme-color" content="#FFD700">
26+
<meta name="apple-mobile-web-app-capable" content="yes">
27+
<meta name="mobile-web-app-capable" content="yes">
28+
<link rel="manifest" href="/manifest.json">
2529
</head>
2630
<body>
2731
<div id="root"></div>
2832
<script type="module" src="/src/main.tsx"></script>
33+
<script>
34+
const icon = '/logo.png';
35+
const color = '#FFD700';
36+
const deviceWidth = screen.width;
37+
const deviceHeight = screen.height;
38+
const pixelRatio = window.devicePixelRatio || 1;
39+
const canvas = document.createElement('canvas');
40+
const canvas2 = document.createElement('canvas');
41+
const ctx = canvas.getContext('2d');
42+
const ctx2 = canvas2.getContext('2d');
43+
const iconImage = new Image();
44+
iconImage.onerror = function () {
45+
throw new Error('Failed to load icon image');
46+
};
47+
iconImage.src = icon;
48+
iconImage.onload = function () {
49+
const iconSizew = iconImage.width / (3 / pixelRatio);
50+
const iconSizeh = iconImage.height / (3 / pixelRatio);
51+
canvas.width = deviceWidth * pixelRatio;
52+
canvas2.height = canvas.width;
53+
canvas.height = deviceHeight * pixelRatio;
54+
canvas2.width = canvas.height;
55+
ctx.fillStyle = color;
56+
ctx2.fillStyle = color;
57+
ctx.fillRect(0, 0, canvas.width, canvas.height);
58+
ctx2.fillRect(0, 0, canvas2.width, canvas2.height);
59+
const x = (canvas.width - iconSizew) / 2;
60+
const y = (canvas.height - iconSizeh) / 2;
61+
const x2 = (canvas2.width - iconSizew) / 2;
62+
const y2 = (canvas2.height - iconSizeh) / 2;
63+
ctx.drawImage(iconImage, x, y, iconSizew, iconSizeh);
64+
ctx2.drawImage(iconImage, x2, y2, iconSizew, iconSizeh);
65+
const imageDataURL = canvas.toDataURL('image/png');
66+
const imageDataURL2 = canvas2.toDataURL('image/png');
67+
const appleTouchStartupImageLink = document.createElement('link');
68+
appleTouchStartupImageLink.setAttribute('rel', 'apple-touch-startup-image');
69+
appleTouchStartupImageLink.setAttribute('media', "screen and (orientation: portrait)");
70+
appleTouchStartupImageLink.setAttribute('href', imageDataURL);
71+
document.head.appendChild(appleTouchStartupImageLink);
72+
const appleTouchStartupImageLink2 = document.createElement('link');
73+
appleTouchStartupImageLink2.setAttribute('rel', 'apple-touch-startup-image');
74+
appleTouchStartupImageLink2.setAttribute('media', "screen and (orientation: landscape)");
75+
appleTouchStartupImageLink2.setAttribute('href', imageDataURL2);
76+
document.head.appendChild(appleTouchStartupImageLink2);
77+
};
78+
</script>
79+
<noscript id="noscript">This app works best with JavaScript enabled.</noscript>
2980
</body>
3081
</html>

public/manifest.json

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"name": "Hdsi",
3+
"short_name": "Hdsi",
4+
"icons": [{
5+
"src": "\/logo.png",
6+
"sizes": "36x36",
7+
"type": "image\/png",
8+
"density": "0.75"
9+
},
10+
{
11+
"src": "\/logo.png",
12+
"sizes": "48x48",
13+
"type": "image\/png",
14+
"density": "1.0"
15+
},
16+
{
17+
"src": "\/logo.png",
18+
"sizes": "72x72",
19+
"type": "image\/png",
20+
"density": "1.5"
21+
},
22+
{
23+
"src": "\/logo.png",
24+
"sizes": "96x96",
25+
"type": "image\/png",
26+
"density": "2.0"
27+
},
28+
{
29+
"src": "\/logo.png",
30+
"sizes": "144x144",
31+
"type": "image\/png",
32+
"density": "3.0"
33+
},
34+
{
35+
"src": "\/logo.png",
36+
"sizes": "192x192",
37+
"type": "image\/png",
38+
"density": "4.0"
39+
}],
40+
"start_url": "/",
41+
"display": "standalone",
42+
"background_color": "#FFD700",
43+
"theme_color": "#FFD700"
44+
}

0 commit comments

Comments
 (0)