Skip to content

Add safe-area insets for notched devices (#222) - #257

Merged
arisu6804 merged 1 commit into
RemitFlow:mainfrom
Hollujay:fix/222-safe-area-insets
Jul 21, 2026
Merged

Add safe-area insets for notched devices (#222)#257
arisu6804 merged 1 commit into
RemitFlow:mainfrom
Hollujay:fix/222-safe-area-insets

Conversation

@Hollujay

@Hollujay Hollujay commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Summary

Add safe-area inset support so content stays clear of notches, rounded corners, and the home indicator on devices like iPhone X+ and modern Android flagships.

Changes

CSS custom properties (src/index.css)

  • Added --safe-area-inset-top, --safe-area-inset-bottom, --safe-area-inset-left, --safe-area-inset-right using env(safe-area-inset-*) with 0px fallback for non-notched browsers.

Layout components

  • Navbar — applied var(--safe-area-inset-top) to top padding so the navigation bar clears the notch.
  • Footer — applied var(--safe-area-inset-bottom) to bottom padding so content avoids the home indicator.
  • Sidebar — applied var(--safe-area-inset-top) to top padding for the sticky sidebar.
  • Modal — applied all four safe-area variables to the overlay padding so the dialog panel remains fully visible.

index.html

  • Added viewport-fit=cover to the <meta name="viewport"> tag to allow the viewport to extend into the unsafe areas (prerequisite for env(safe-area-inset-*) to return non-zero values).

New hook: useSafeAreaInsets (src/hooks/useSafeAreaInsets.js)

  • Reads the CSS custom property values via getComputedStyle and returns { top, bottom, left, right } in CSS pixels.
  • Listens to resize and orientationchange events so values update on device rotation.

Testing

  • test/hooks/useSafeAreaInsets.test.js — 6 tests covering default state, pixel parsing, fractional values, and reactive updates on resize/orientationchange.
  • test/safe-area.test.js — 8 tests verifying the CSS custom properties are declared in index.css and referenced by all four component CSS files.

Documentation

  • Added a "Notched / Rounded Devices" section to README.md.

Closes #222

- Define --safe-area-inset-* CSS custom properties in :root using
  env(safe-area-inset-*) with 0px fallback
- Apply safe-area padding to Navbar (top), Footer (bottom),
  Sidebar (top), and Modal (all four sides) layout components
- Add useSafeAreaInsets hook for JS access to safe-area pixel values
- Add <meta viewport-fit=cover> to index.html for iOS notch support
- Write test coverage for the hook and CSS declarations
- Document safe-area support in README
@arisu6804

Copy link
Copy Markdown
Contributor

Solid work, exactly what the issue asked for. ✨

@arisu6804
arisu6804 merged commit e57b7c1 into RemitFlow:main Jul 21, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add safe-area insets for notched devices

2 participants