Skip to content

Commit 37eb075

Browse files
committed
feat: add composables
1 parent 1b7810e commit 37eb075

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

src/runtime/composables/dialog.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { useState } from '#imports'
2+
3+
// Types
4+
export interface Dialog {
5+
show: boolean
6+
title: string
7+
message: string
8+
action: {
9+
function: () => Promise<void>
10+
buttonText: string
11+
buttonColor: string
12+
}
13+
closeButtonText: string
14+
}
15+
16+
export const dialogInitialState = <Dialog>{
17+
show: false,
18+
title: '',
19+
message: '',
20+
action: {
21+
function: () => new Promise<void>(resolve => resolve()),
22+
buttonText: '',
23+
buttonColor: '',
24+
},
25+
closeButtonText: 'Cancel',
26+
}
27+
28+
export const useDialog = () =>
29+
useState('dialog', () => {
30+
return dialogInitialState
31+
})

src/runtime/composables/state.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { ref, useState } from '#imports'
2+
3+
// App
4+
export const useErrorMessage = () => useState('errorMessage', () => '')
5+
export const useToast = () =>
6+
useState('toast', () =>
7+
ref({
8+
show: false,
9+
message: '',
10+
}),
11+
)

0 commit comments

Comments
 (0)