Skip to content

Commit

Permalink
feat(snackbar): add types
Browse files Browse the repository at this point in the history
  • Loading branch information
BeADre committed Apr 14, 2021
1 parent 189053c commit cdd48dc
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 4 deletions.
3 changes: 1 addition & 2 deletions packages/varlet-ui/src/snackbar/example/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
</template>

<script>
import { defineComponent, ref, reactive, toRefs } from 'vue'
import { defineComponent, reactive, toRefs } from 'vue'
import Button from '../../button'
import Snackbar from '..'
import { pack, use } from './locale'
Expand All @@ -71,7 +71,6 @@ export default defineComponent({
AppType,
},
setup() {
const isAllowMultiple = ref(true)
const shows = reactive({
show1: false,
show2: false,
Expand Down
4 changes: 2 additions & 2 deletions packages/varlet-ui/src/snackbar/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { h, reactive, TransitionGroup, App, RendererElement } from 'vue'
import { h, reactive, TransitionGroup, App, Component } from 'vue'
import VarSnackbarCore from './core.vue'
import VarSnackbar from './Snackbar.vue'
import { mountInstance } from '../utils/components'
Expand Down Expand Up @@ -60,7 +60,7 @@ interface Snackbar {

isAllowMultiple: boolean

Component: RendererElement
Component: Component
}

let sid = 0
Expand Down
55 changes: 55 additions & 0 deletions packages/varlet-ui/types/snackbar.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { App, Component } from 'vue'
import { VarComponent } from './varComponent'

export class SnackbarComponent extends VarComponent {
static Component: Component
}

export type SnackbarType = 'success' | 'warning' | 'info' | 'error' | 'loading'

export interface SnackbarHandel {
clear: () => void
}

export interface SnackbarOptions {
type?: SnackbarType
content?: string
position?: 'top' | 'center' | 'bottom'
loadingType?: string
loadingSize?: string
teleport?: string
lockScroll?: boolean
contentClass?: string
duration?: number
vertical?: boolean
show?: boolean
forbidClick?: boolean
onOpen?: () => void
onClose?: () => void
onOpened?: () => void
onClosed?: () => void
}

export interface ISnackbar {
(options: SnackbarOptions): SnackbarHandel

install(app: App): void

allowMultiple(bool: boolean): void

success(options: SnackbarOptions | string): SnackbarHandel

warning(options: SnackbarOptions | string): SnackbarHandel

info(options: SnackbarOptions | string): SnackbarHandel

error(options: SnackbarOptions | string): SnackbarHandel

loading(options: SnackbarOptions | string): SnackbarHandel

clear(): void

Component: SnackbarComponent
}

export const Snackbar: ISnackbar

0 comments on commit cdd48dc

Please sign in to comment.