Skip to content

Instantly share code, notes, and snippets.

View asadmalik's full-sized avatar

asadmalik

  • Pakistan
View GitHub Profile
import { useFullscreen } from "@vueuse/core";
const { isFullscreen, enter, exit, toggle } = useFullscreen();
import { usePermission } from "@vueuse/core";
const microphoneAccess = usePermission("microphone");
const accelerometer = usePermission('accelerometer')
const accessibilityEvents = usePermission('accessibility-events')
const ambientLightSensor = usePermission('ambient-light-sensor')
const backgroundSync = usePermission('background-sync')
const camera = usePermission('camera')
const clipboardRead = usePermission('clipboard-read')
const clipboardWrite = usePermission('clipboard-write')
import { useScreenOrientation } from "@vueuse/core";
const {
isSupported, // boolean
orientation, //orientation type, reactive
angle, // orientation angle, reactive
lockOrientation, // lock orientation, accepts orientation type, function
unlockOrientation, // unlock orientation, function
} = useScreenOrientation();
import { useDeviceOrientation } from "@vueuse/core";
const {
isAbsolute,
alpha, // z-axis, range: 0-360
beta, // x-axis, range: -180 to 180
gamma, // y-axis, range: -90 to 90
} = useDeviceOrientation();
@asadmalik
asadmalik / useWakeLock.vue
Created May 23, 2024 13:26
This composable make a way to prevent screen from dimming or locking the screen.
import { useWakeLock } from "@vueuse/core";
const { isSupported, isActive, request, release } = useWakeLock();
import { useBattery } from "@vueuse/core";
const { charging, chargingTime, dischargingTime, level } = useBattery();
import { useDevicesList } from "@vueuse/core";
const {
devices,
videoInputs: cameras,
audioInputs: microphones,
audioOutputs: speakers,
} = useDevicesList();
@asadmalik
asadmalik / useBattery.vue
Created May 23, 2024 13:24
This provides the battery level and charging status.
import { useBattery } from "@vueuse/core";
const { charging, chargingTime, dischargingTime, level } = useBattery();
<script setup>
import { useVibrate } from "@vueuse/core";
// This vibrates the device for 300 ms
// then pauses for 100 ms before vibrating the device again for another 300 ms:
const { vibrate, stop, isSupported } = useVibrate({ pattern: [300, 100, 300] });
// Start the vibration, it will automatically stop when the pattern is complete:
vibrate();
@asadmalik
asadmalik / treeview.html
Last active February 5, 2023 09:40
HTML CSS Treeview
<style>
.tree{
--spacing : 1.5rem;
--radius : 10px;
}
.tree li{
display : block;
position : relative;
padding-left : calc(2 * var(--spacing) - var(--radius) - 2px);