-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: provide native applications composables
- Loading branch information
Mr.Mao
committed
May 3, 2023
1 parent
0b96126
commit 51179c1
Showing
7 changed files
with
96 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './meta' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { context, setupOptions } from '../internal' | ||
|
||
export interface OverlayOptions { | ||
/** animation duration to avoid premature destruction of components */ | ||
duration?: number | ||
} | ||
|
||
export function useOverlay(options?: OverlayOptions) { | ||
const trigger = context.trigger | ||
if (!trigger) | ||
throw new Error('Please execute in the overlays constructor') | ||
|
||
setupOptions(options) | ||
return trigger | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import type { OverlayOptions } from '../composable' | ||
import type { Context } from '../types' | ||
|
||
export const context = { | ||
trigger: undefined as Context | undefined, | ||
options: undefined as OverlayOptions | undefined, | ||
} | ||
|
||
export function setupTrigger(c: Context) { | ||
context.trigger = c | ||
} | ||
|
||
export function clearTrigger() { | ||
context.trigger = undefined | ||
} | ||
|
||
export function setupOptions(o: OverlayOptions = {}) { | ||
context.options = o | ||
} | ||
|
||
export function clearOptions() { | ||
context.options = undefined | ||
} | ||
|
||
export function useOptions() { | ||
return context.options || {} | ||
} |
51179c1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
unoverlays – ./
unoverlays-git-master-tuimao.vercel.app
unoverlays-tuimao.vercel.app
unoverlays.vercel.app