Changeset a036251 in Klonkt


Ignore:
Timestamp:
06/26/2026 03:24:06 PM (2 months ago)
Author:
Robin Genis <roboburr@…>
Branches:
main
Children:
76f0e61
Parents:
7ca3ffc
Message:

fix(ios): hand-built safe-area inset (env() returns 0 on iOS Safari + standalone)

env(safe-area-inset-top) resolves to 0 on this iOS in both Safari and the installed PWA
(content under the camera). A boot script measures the inset directly and, if it comes
back empty on a notch/Dynamic-Island iPhone (logical height >= 812), falls back to a fixed
50px. The masthead padding reads --ios-safe-top. CSS buster -> v54.

Location:
src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/assets/css/style.css

    r7ca3ffc ra036251  
    6363    --radius: 8px; --transition: 180ms cubic-bezier(.4,0,.2,1);
    6464    --safe-top: env(safe-area-inset-top, 0); --safe-bot: env(safe-area-inset-bottom, 0);
     65    /* iOS top inset: starts from env(), but a tiny boot script overrides it with a
     66       real/measured value (env() resolves to 0 in some iOS standalone states). */
     67    --ios-safe-top: env(safe-area-inset-top, 0px);
    6568    color-scheme: light dark;
    6669}
     
    507510.masthead {
    508511    border-bottom: 1px solid var(--rule);
    509     padding: calc(1rem + env(safe-area-inset-top, 0px)) 0 1rem;
     512    padding: calc(1rem + var(--ios-safe-top, 0px)) 0 1rem;
    510513    /* GEEN backdrop-filter hier: een voorouder met backdrop-filter blokkeert de
    511514       frosted blur van het user-menu-dropdown eronder. Masthead is toch bijna
     
    16201623        border-top-right-radius: 0;
    16211624        box-shadow: none;
    1622         padding-top: calc(.75rem + env(safe-area-inset-top, 0px));
     1625        padding-top: calc(.75rem + var(--ios-safe-top, 0px));
    16231626        padding-bottom: calc(2rem + env(safe-area-inset-bottom, 0px));
    16241627    }
     
    16781681}
    16791682@media (max-width: 400px) {
    1680     .masthead { padding: calc(.5rem + env(safe-area-inset-top, 0px)) 0 .5rem; }
     1683    .masthead { padding: calc(.5rem + var(--ios-safe-top, 0px)) 0 .5rem; }
    16811684    .masthead-inner { gap: .25rem; }
    16821685    .site-title { font-size: 1.05rem; }
     
    27592762
    27602763/* Masthead: compacter */
    2761 .masthead { padding: calc(.55rem + env(safe-area-inset-top, 0px)) 0 .55rem; }
     2764.masthead { padding: calc(.55rem + var(--ios-safe-top, 0px)) 0 .55rem; }
    27622765.masthead-inner { gap: 1rem; }
    27632766.site-title { font-size: 1.25rem; }
  • src/views/shell.ejs

    r7ca3ffc ra036251  
    198198
    199199<!-- v9 stylesheet (full palette system) -->
    200 <link rel="stylesheet" href="/assets/css/style.css?v=53">
     200<link rel="stylesheet" href="/assets/css/style.css?v=54">
     201<script>
     202/* iOS safe-area, built by hand: env(safe-area-inset-top) resolves to 0 in some iOS
     203   states (Safari + standalone) even with viewport-fit=cover. Measure it directly, and
     204   if it comes back empty on a notch/Dynamic-Island iPhone, fall back to a fixed inset.
     205   The masthead reads --ios-safe-top. */
     206(function(){
     207  var ua = navigator.userAgent || '';
     208  var isIOS = /iP(hone|od|ad)/.test(ua) || (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1);
     209  if (!isIOS) return;
     210  function setInset(){
     211    if (!document.body) return;
     212    var p = document.createElement('div');
     213    p.style.cssText = 'position:fixed;top:0;left:0;width:0;height:0;padding-top:env(safe-area-inset-top,0px);visibility:hidden;pointer-events:none';
     214    document.body.appendChild(p);
     215    var i = parseFloat(getComputedStyle(p).paddingTop) || 0;
     216    p.remove();
     217    // env() gave nothing but this looks like a notched iPhone (logical height >= 812)
     218    // -> use a fixed status-bar inset so the masthead clears the camera anyway.
     219    if (i < 20 && Math.max(screen.width, screen.height) >= 812) i = 50;
     220    document.documentElement.style.setProperty('--ios-safe-top', i + 'px');
     221  }
     222  if (document.body) setInset(); else document.addEventListener('DOMContentLoaded', setInset);
     223  window.addEventListener('orientationchange', function(){ setTimeout(setInset, 250); });
     224})();
     225</script>
    201226
    202227<!-- Audio player styles: loaded on every page so the mini-player works
Note: See TracChangeset for help on using the changeset viewer.