alpha
Login
or
Join now
xcc.es
/
morganwill.com
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
[READ-ONLY] Mirror of https://github.com/mrgnw/morganwill.com.
morganwill.com
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
Overview
Issues
Pulls
Pipelines
qr
author
Morgan
date
2 years ago
(Jan 24, 2024, 3:13 PM -0500)
commit
ce4091f2
ce4091f2509a03397d7684413967fecf264369a5
parent
063448a3
063448a3c34656718f97ce4966ff932182057aa2
+76
1 changed file
Expand all
Collapse all
Unified
Split
src
routes
qr
+page.svelte
+76
src/routes/qr/+page.svelte
View file
Reviewed
···
1
1
+
<script>
2
2
+
import { onMount } from 'svelte';
3
3
+
import QRCode from 'qrcode';
4
4
+
5
5
+
let ssid = '';
6
6
+
let password = '';
7
7
+
let qrCodeData = null;
8
8
+
$: qr_filetype = 'svg';
9
9
+
10
10
+
const generateQR = async () => {
11
11
+
if (ssid && password) {
12
12
+
// Convert the QR code to a data object suitable for SVG rendering
13
13
+
qrCodeData = await QRCode.toString(`WIFI:S:${ssid};T:WPA;P:${password};;`, { type: qr_filetype });
14
14
+
}
15
15
+
};
16
16
+
17
17
+
onMount(generateQR);
18
18
+
</script>
19
19
+
20
20
+
<style>
21
21
+
22
22
+
.container {
23
23
+
width: 100vw;
24
24
+
height: 100vh;
25
25
+
padding: 1em;
26
26
+
box-sizing: border-box;
27
27
+
display: flex;
28
28
+
flex-direction: column;
29
29
+
align-items: center;
30
30
+
}
31
31
+
32
32
+
.input-container {
33
33
+
width: calc(100% - 2em);
34
34
+
max-width: 300px;
35
35
+
/* margin-top: 1em; */
36
36
+
}
37
37
+
38
38
+
.input-group input {
39
39
+
width: 100%;
40
40
+
padding: 10px;
41
41
+
/* margin-bottom: 1em; */
42
42
+
}
43
43
+
44
44
+
.qr-container {
45
45
+
width: 90vh;
46
46
+
max-width: 90%;
47
47
+
/* max-width: 500px; */
48
48
+
/* height: auto; */
49
49
+
max-height:90%;
50
50
+
margin-top: 1em; /* Adjust space between input and QR code */
51
51
+
}
52
52
+
53
53
+
.qr-container {
54
54
+
width: 90%;
55
55
+
height: 90%;
56
56
+
padding: 5%; /* This acts as a margin for the QR code */
57
57
+
box-sizing: border-box;
58
58
+
}
59
59
+
60
60
+
svg {
61
61
+
width: 100%;
62
62
+
height: 100%;
63
63
+
}
64
64
+
</style>
65
65
+
66
66
+
<div class="container">
67
67
+
<div class="input-container">
68
68
+
<div class="input-group">
69
69
+
<input type="text" placeholder="WiFi Name (SSID)" bind:value={ssid} on:input={generateQR}>
70
70
+
<input type="text" placeholder="Password" bind:value={password} on:input={generateQR}>
71
71
+
</div>
72
72
+
</div>
73
73
+
<div class="qr-container">
74
74
+
{@html qrCodeData ? qrCodeData : '<div class="placeholder"></div>'}
75
75
+
</div>
76
76
+
</div>