refactor: safe area inset fallback (#2329)

This commit is contained in:
Aman Harwara
2023-05-10 15:59:45 +05:30
committed by GitHub
parent 8c3a2d3bc8
commit b506137655
6 changed files with 49 additions and 22 deletions

View File

@@ -0,0 +1,15 @@
export const useAvailableSafeAreaPadding = () => {
const documentStyle = getComputedStyle(document.documentElement)
const top = parseInt(documentStyle.getPropertyValue('--safe-area-inset-top'))
const right = parseInt(documentStyle.getPropertyValue('--safe-area-inset-right'))
const bottom = parseInt(documentStyle.getPropertyValue('--safe-area-inset-bottom'))
const left = parseInt(documentStyle.getPropertyValue('--safe-area-inset-left'))
return {
hasTopInset: !!top,
hasRightInset: !!right,
hasBottomInset: !!bottom,
hasLeftInset: !!left,
}
}