refactor: safe area inset fallback (#2329)
This commit is contained in:
15
packages/web/src/javascripts/Hooks/useSafeAreaPadding.ts
Normal file
15
packages/web/src/javascripts/Hooks/useSafeAreaPadding.ts
Normal 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,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user