Skip to content

Commit

Permalink
feat: create useDevice composable
Browse files Browse the repository at this point in the history
  • Loading branch information
wazolab committed Mar 6, 2024
1 parent faabf9a commit 33562a7
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions composables/useDevice.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { useGrid, useScreen } from 'vue-screen'

export default function (): ComputedRef<{
smallScreen: boolean
touch: boolean
phone: boolean
}> {
const screen = useScreen()
const grid = useGrid('tailwind')

const device = computed(() => ({
smallScreen: !grid.md,
touch: screen.touch,
// Quick heuristic for device havng phone capability
phone: screen.touch && !grid.lg,
}))

return device
}

0 comments on commit 33562a7

Please sign in to comment.