Skip to content

Commit 2ca4f3d

Browse files
committed
Some UI fixes
1 parent ffe43c5 commit 2ca4f3d

File tree

3 files changed

+21
-10
lines changed

3 files changed

+21
-10
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ You can try out the live demo at [qr.15c.me/tiny-qr.html](https://qr.15c.me/tiny
3333

3434
- QR code size limitation: A maximum of 2950 characters can be used with error correction level L, less if you choose better error correction.
3535
- When opening `qr.html` using a file URL in chromium and enabling the clipboard monitoring, a permissions dialog is triggered every time the clipboard is read (every second).
36+
- When resizing the page to make it smaller, the QR code often refuses to shrink. I don't know why and any help/hints are welcome. My current workaround is just reloading the page.
3637

3738
## Additional features
3839

qr.html

+19-9
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646

4747
header {
4848
width: 100%;
49-
height: 40px;
49+
min-height: 40px;
5050
background-color: #444;
5151
color: lightgray;
5252
display: flex;
@@ -74,21 +74,20 @@
7474
width: 100%;
7575
min-height: 50px;
7676
flex: 1;
77-
margin-bottom: 10px;
77+
resize: none;
7878
}
7979

80-
#error, #clipboard-error {
80+
#clipboard-error {
8181
display: none;
8282
}
83-
83+
8484
.error, .info {
8585
width: 100%;
8686
background-color: rgb(255, 140, 140);
8787
border: 2px solid red;
8888
border-radius: 10px;
8989
padding: 5px;
9090
text-align: center;
91-
margin-bottom: 10px;
9291
}
9392

9493
.info {
@@ -112,6 +111,11 @@
112111
margin: auto;
113112
display: block;
114113
}
114+
115+
.block {
116+
padding-top: 5px;
117+
display: none;
118+
}
115119
</style>
116120
</head>
117121
<body>
@@ -122,9 +126,8 @@
122126
<a href="https://github.com/six-two/qr.html" target="_blank" rel="noopener noreferrer">Source code</a>
123127
</header>
124128
<div class="content">
125-
<noscript><div class="error">You need to enable JavaScript to use this page</div></noscript>
126-
<div id="error" class="error">BUG: You should not see this text</div>
127-
<textarea id="input" name="input" id="" autofocus>You can generate QR codes from any text by typing in in this box. The code generation is performed on your local device, no data is sent anywhere.
129+
<div id="error" class="error">You need to enable JavaScript to use this page</div>
130+
<textarea id="input" class="block" name="input" id="" autofocus>You can generate QR codes from any text by typing in in this box. The code generation is performed on your local device, no data is sent anywhere.
128131
You can even download this file (see button on the top right) and use it when you are not connected to the Internet.
129132

130133
⚠️ The maximum size of a QR code is 2950 bytes
@@ -134,7 +137,7 @@
134137
📁 And you can copy-paste a file to this text area
135138
</textarea>
136139

137-
<div id="clipboard-div">
140+
<div id="clipboard-div" class="block">
138141
<div id="clipboard-settings">
139142
<input type="checkbox" id="clipboard-checkbox">
140143
<label for="clipboard-checkbox"><abbr title="Whenever you copy text, the QR code will be updated to reflect the copied text. You may need to focus this website for this feature to work">Monitor the system clipboard</abbr></label>
@@ -147,6 +150,11 @@
147150

148151

149152
<script type="text/javascript">
153+
// Only show if JS is enabled
154+
for (e of document.getElementsByClassName("block")) {
155+
e.style.display = "block"
156+
}
157+
150158
const getQRRecommendedSize = (element) => {
151159
if (QR_SIZE <= 0) {
152160
width = element.clientWidth;
@@ -299,6 +307,8 @@
299307
// This error only occured on Mac with Safari
300308
showClipboardError(`Failed to read clipboard contents because of the follwoing error:<br><i>${error}</i>`);
301309
});
310+
} else {
311+
showClipboardError(null);
302312
}
303313
};
304314

tiny-qr.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<noscript>Enable JavaScript!</noscript><textarea autofocus id=i>qr.15c.me</textarea><div id=q></div><style>*{box-sizing:border-box}body{width:100vw;height:100vh;margin:0;padding:5px;display:flex;flex-direction:column;background-color:#ddd}#i{width:100%;min-height:50px;flex:1;margin-bottom:10px}#q{margin:auto;width:100%;padding:5px;flex:3}#q canvas{margin:auto;display:block}</style>
1+
<noscript><h1>Enable JavaScript!</h1></noscript><textarea autofocus id=i>qr.15c.me</textarea><div id=q></div><style>*{box-sizing:border-box}body{width:100vw;height:100vh;margin:0;padding:5px;display:flex;flex-direction:column;background-color:#ddd}#i{width:100%;min-height:50px;flex:1;margin-bottom:10px;resize:none;}#q{margin:auto;width:100%;padding:5px;flex:3}#q canvas{margin:auto;display:block}</style>
22
<script>M=2950,window.onload=(()=>{q=document.getElementById("q"),i=document.getElementById("i"),u=(()=>{if(s=Math.max(Math.min(q.clientWidth,q.clientHeight)-10,50),t=i.value,t.length>M)alert(`Text is ${t.length-M} bytes too long`);else try{q.innerHTML="",QrCreator.render({text:t,radius:0,ecLevel:"L",background:"#fff",size:s},q)}catch(e){alert("Failed to generate QR code")}}),u(),i.oninput=u,window.onresize=u});</script>
33
<script>
44
//SOURCE: https://cdn.jsdelivr.net/npm/qr-creator/dist/qr-creator.min.js

0 commit comments

Comments
 (0)