SolarumAsteridion commited on
Commit
43f431b
·
verified ·
1 Parent(s): d197106

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +59 -18
index.html CHANGED
@@ -45,7 +45,7 @@ body.dark{
45
  --desk-bg: #2c2a27;
46
  --desk-dot: #3a3733;
47
 
48
- --paper-bg: #302e2b;
49
  --paper-text: #e9e7e2;
50
  --shadow: rgba(0,0,0,.55);
51
 
@@ -136,9 +136,16 @@ h1{font-family:'Libre Baskerville',serif;margin:0;font-size:28px;letter-spacing:
136
  position:relative;
137
  padding:18px 6px 10px 6px;
138
  display:grid;
139
- grid-template-columns:repeat(auto-fill,minmax(220px,1fr));
140
  gap:16px;
141
  overflow:visible;
 
 
 
 
 
 
 
 
142
  }
143
  #board::before{
144
  content:'';
@@ -169,6 +176,8 @@ h1{font-family:'Libre Baskerville',serif;margin:0;font-size:28px;letter-spacing:
169
  transform:rotate(var(--tilt,0deg)) scale(1);
170
  transition:transform .12s ease, box-shadow .12s ease, opacity .16s ease;
171
  animation:pop .18s ease-out;
 
 
172
  }
173
  .sticky:hover{
174
  transform:rotate(var(--tilt,0deg)) translateY(-2px) scale(1.01);
@@ -198,10 +207,13 @@ h1{font-family:'Libre Baskerville',serif;margin:0;font-size:28px;letter-spacing:
198
  body.dark .badge{background:rgba(255,255,255,.12)}
199
 
200
  .sticky img{
201
- width:100%;height:auto;display:block;
 
 
202
  border-bottom-left-radius:10px;border-bottom-right-radius:10px;
203
- background:
204
- linear-gradient(180deg,rgba(255,255,255,.25),rgba(255,255,255,0));
 
205
  }
206
 
207
  /* delete button */
@@ -233,7 +245,10 @@ body.dark .badge{background:rgba(255,255,255,.12)}
233
  @media(max-width:768px){
234
  .container{margin:20px 16px;padding:24px}
235
  h1{font-size:24px}
236
- #board{grid-template-columns:repeat(auto-fill,minmax(180px,1fr))}
 
 
 
237
  }
238
  @media print{
239
  body{background:#fff}
@@ -283,8 +298,35 @@ function removePlaceholder(){
283
  if(ph) ph.remove();
284
  }
285
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
286
  function randTilt(){
287
- // small friendly tilt between -2.2deg and 2.2deg
288
  const d = (Math.random()*4.4 - 2.2).toFixed(2);
289
  return d + 'deg';
290
  }
@@ -323,16 +365,10 @@ function createSticky(src, isBlobUrl=false){
323
  wrap.style.opacity = '0';
324
  wrap.style.transform = 'scale(.96)';
325
  setTimeout(()=>{
326
- // release blob URL to avoid memory leaks
327
  if(isBlobUrl) URL.revokeObjectURL(src);
328
  wrap.remove();
329
- if(!board.querySelector('.sticky')){
330
- // restore placeholder if empty
331
- const ph = document.createElement('div');
332
- ph.className = 'placeholder';
333
- ph.innerHTML = `Press <kbd>Ctrl</kbd>+<kbd>V</kbd> (or <kbd>⌘</kbd>+<kbd>V</kbd>) to paste screenshots/images.<br/>You can also drag &amp; drop images here.`;
334
- board.appendChild(ph);
335
- }
336
  },140);
337
  });
338
 
@@ -340,6 +376,8 @@ function createSticky(src, isBlobUrl=false){
340
  wrap.appendChild(img);
341
  wrap.appendChild(btn);
342
  board.prepend(wrap); // newest on top
 
 
343
  }
344
 
345
  /* ======= handle pasted images ======= */
@@ -357,7 +395,6 @@ function filesFromClipboard(dataTransfer){
357
 
358
  async function handleImages(files){
359
  if(!files.length){
360
- // no images, brief nudge
361
  processingNode.textContent = 'No images found in clipboard';
362
  showProcessing(); hideProcessing();
363
  processingNode.textContent = 'Processing…';
@@ -377,7 +414,7 @@ document.addEventListener('paste', e=>{
377
  if(files.length){ e.preventDefault(); handleImages(files); }
378
  });
379
 
380
- /* ======= drag & drop (optional bonus) ======= */
381
  board.addEventListener('dragover', e=>{
382
  e.preventDefault();
383
  board.style.outline = '2px dashed rgba(0,0,0,.2)';
@@ -418,7 +455,11 @@ function updateIcon(){
418
  document.addEventListener('DOMContentLoaded',()=>{
419
  const sheet=document.querySelector('.container');
420
  sheet.style.opacity='0';
421
- setTimeout(()=>{sheet.style.transition='opacity .6s ease';sheet.style.opacity='1'},80);
 
 
 
 
422
  });
423
  </script>
424
  </body>
 
45
  --desk-bg: #2c2a27;
46
  --desk-dot: #3a3733;
47
 
48
+ --paper-bg: #302e3b; /* slightly deeper to add contrast with tiles */
49
  --paper-text: #e9e7e2;
50
  --shadow: rgba(0,0,0,.55);
51
 
 
136
  position:relative;
137
  padding:18px 6px 10px 6px;
138
  display:grid;
 
139
  gap:16px;
140
  overflow:visible;
141
+
142
+ /* NEW: prevent short images from becoming tall boxes */
143
+ align-items:start;
144
+
145
+ /* NEW: dynamic columns
146
+ --cols: 1 -> one column (full width), 2 -> two columns (50/50),
147
+ else auto-fit with a sensible min width */
148
+ grid-template-columns: repeat(var(--cols, auto-fit), minmax(var(--minCol, 220px), 1fr));
149
  }
150
  #board::before{
151
  content:'';
 
176
  transform:rotate(var(--tilt,0deg)) scale(1);
177
  transition:transform .12s ease, box-shadow .12s ease, opacity .16s ease;
178
  animation:pop .18s ease-out;
179
+ /* NEW: ensure the tile itself doesn't stretch via grid */
180
+ align-self:start;
181
  }
182
  .sticky:hover{
183
  transform:rotate(var(--tilt,0deg)) translateY(-2px) scale(1.01);
 
207
  body.dark .badge{background:rgba(255,255,255,.12)}
208
 
209
  .sticky img{
210
+ width:100%;
211
+ height:auto;
212
+ display:block;
213
  border-bottom-left-radius:10px;border-bottom-right-radius:10px;
214
+ background: linear-gradient(180deg,rgba(255,255,255,.25),rgba(255,255,255,0));
215
+ /* NEW: keep gigantic/tall screenshots sane on viewport */
216
+ max-height:80vh;
217
  }
218
 
219
  /* delete button */
 
245
  @media(max-width:768px){
246
  .container{margin:20px 16px;padding:24px}
247
  h1{font-size:24px}
248
+ /* CHANGED: still use dynamic columns on mobile, but with a smaller min */
249
+ #board{
250
+ grid-template-columns: repeat(var(--cols, auto-fit), minmax(180px,1fr));
251
+ }
252
  }
253
  @media print{
254
  body{background:#fff}
 
298
  if(ph) ph.remove();
299
  }
300
 
301
+ function ensurePlaceholder(){
302
+ if(!board.querySelector('.sticky') && !board.querySelector('.placeholder')){
303
+ const ph = document.createElement('div');
304
+ ph.className = 'placeholder';
305
+ ph.innerHTML = `Press <kbd>Ctrl</kbd>+<kbd>V</kbd> (or <kbd>⌘</kbd>+<kbd>V</kbd>) to paste screenshots/images.<br/>You can also drag &amp; drop images here.`;
306
+ board.appendChild(ph);
307
+ }
308
+ }
309
+
310
+ /* NEW: set grid columns smartly based on number of stickies */
311
+ function updateLayout(){
312
+ const count = board.querySelectorAll('.sticky').length;
313
+ if(count === 1){
314
+ // 1 image → full width (one column)
315
+ board.style.setProperty('--cols', '1');
316
+ board.style.setProperty('--minCol', '0px');
317
+ }else if(count === 2){
318
+ // 2 images → half/half
319
+ board.style.setProperty('--cols', '2');
320
+ board.style.setProperty('--minCol', '0px');
321
+ }else{
322
+ // 3+ → responsive, nice min width
323
+ board.style.setProperty('--cols', 'auto-fit');
324
+ board.style.setProperty('--minCol', '220px');
325
+ }
326
+ }
327
+
328
+ /* random tilt & color */
329
  function randTilt(){
 
330
  const d = (Math.random()*4.4 - 2.2).toFixed(2);
331
  return d + 'deg';
332
  }
 
365
  wrap.style.opacity = '0';
366
  wrap.style.transform = 'scale(.96)';
367
  setTimeout(()=>{
 
368
  if(isBlobUrl) URL.revokeObjectURL(src);
369
  wrap.remove();
370
+ ensurePlaceholder();
371
+ updateLayout(); // NEW: update grid when items are removed
 
 
 
 
 
372
  },140);
373
  });
374
 
 
376
  wrap.appendChild(img);
377
  wrap.appendChild(btn);
378
  board.prepend(wrap); // newest on top
379
+
380
+ updateLayout(); // NEW: update grid after adding
381
  }
382
 
383
  /* ======= handle pasted images ======= */
 
395
 
396
  async function handleImages(files){
397
  if(!files.length){
 
398
  processingNode.textContent = 'No images found in clipboard';
399
  showProcessing(); hideProcessing();
400
  processingNode.textContent = 'Processing…';
 
414
  if(files.length){ e.preventDefault(); handleImages(files); }
415
  });
416
 
417
+ /* ======= drag & drop ======= */
418
  board.addEventListener('dragover', e=>{
419
  e.preventDefault();
420
  board.style.outline = '2px dashed rgba(0,0,0,.2)';
 
455
  document.addEventListener('DOMContentLoaded',()=>{
456
  const sheet=document.querySelector('.container');
457
  sheet.style.opacity='0';
458
+ setTimeout(()=>{
459
+ sheet.style.transition='opacity .6s ease';
460
+ sheet.style.opacity='1';
461
+ updateLayout(); // NEW: set initial grid
462
+ },80);
463
  });
464
  </script>
465
  </body>