mirror of
https://github.com/CharaChorder/DeviceManager.git
synced 2026-01-21 01:12:59 +00:00
layout sharing via url
[deploy]
This commit is contained in:
22
src/lib/share.ts
Normal file
22
src/lib/share.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import type {Action} from "svelte/action"
|
||||
import {readonly, writable} from "svelte/store"
|
||||
|
||||
const setCanShare = writable(false)
|
||||
export const canShare = readonly(setCanShare)
|
||||
|
||||
let shareCallback: ((event: Event) => void) | undefined
|
||||
export function triggerShare(event: Event) {
|
||||
shareCallback?.(event)
|
||||
}
|
||||
|
||||
export const share: Action<Window, (event: Event) => void> = (node, callback: (event: Event) => void) => {
|
||||
setCanShare.set(true)
|
||||
shareCallback = callback
|
||||
|
||||
return {
|
||||
destroy() {
|
||||
setCanShare.set(false)
|
||||
shareCallback = undefined
|
||||
},
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user