diff --git a/packages/varlet-ui/src/snackbar/core.less b/packages/varlet-ui/src/snackbar/core.less index bf1db6c8663..dbd4fc61a5d 100644 --- a/packages/varlet-ui/src/snackbar/core.less +++ b/packages/varlet-ui/src/snackbar/core.less @@ -9,6 +9,7 @@ top: 0; bottom: 0; pointer-events: none; + z-index: 10; } .var-pointer-auto { @@ -24,6 +25,7 @@ right: 0; bottom: 0; transition: all 0.15s cubic-bezier(0, 0, 0.2, 1); + z-index: 10; &__wrapper { width: 256px; diff --git a/packages/varlet-ui/src/snackbar/core.vue b/packages/varlet-ui/src/snackbar/core.vue index c1362634897..a57ca2e0c39 100644 --- a/packages/varlet-ui/src/snackbar/core.vue +++ b/packages/varlet-ui/src/snackbar/core.vue @@ -2,17 +2,15 @@
- - - {{ content }} - + {{ content }}
- - - - - + + + + + +
diff --git a/packages/varlet-ui/src/snackbar/example/index.vue b/packages/varlet-ui/src/snackbar/example/index.vue index 61dbef1d2a1..c28eb129f77 100644 --- a/packages/varlet-ui/src/snackbar/example/index.vue +++ b/packages/varlet-ui/src/snackbar/example/index.vue @@ -3,89 +3,43 @@
基本使用
- - 基本使用 - - - 自定义action - - - 垂直排列 - - - 自定义关闭时间 - - - 切换单例或多例 - + 基本使用 + 自定义action + 垂直排列 + 自定义关闭时间 + 切换单例或多例
snackbar类型
- - success - - - warning - - - info - - - error - - - loading - + success + warning + info + error + loading
snackbar位置
- - top - - - center - - - bottom - + top + center + bottom
其他配置
- - 自定义内容class - - - 不可穿透点击 - - - 可以穿透滑动 - + 自定义内容class + 不可穿透点击 + 可以穿透滑动
snackbar事件
- - 打开与关闭回调 - + 打开与关闭回调 打开动画与关闭动画结束时回调 @@ -99,18 +53,14 @@ {{ text }} {{ text }} @@ -151,7 +101,7 @@ export default defineComponent({ [Button.name]: Button, }, setup() { - const text: Ref = ref("Hello, I'm a snackbar-core") + const text: Ref = ref("Hello, I'm a snackbar") const isAllowMultiple: Ref = ref(true) const shows: any = reactive({ show1: false, @@ -171,7 +121,7 @@ export default defineComponent({ const create = (type: any) => { const snackbar: any = Snackbar({ - content: "Hello, I'm a snackbar-core", + content: "Hello, I'm a snackbar", type, }) setTimeout(function () { @@ -181,14 +131,22 @@ export default defineComponent({ const createMethod = (type: SnackbarType) => { Snackbar[type]({ - content: "Hello, I'm a snackbar-core", + content: "Hello, I'm a snackbar", forbidClick: type === 'loading', + loadingSize: 'small', }) + if (type === 'loading') { + setTimeout(() => { + Snackbar.success({ + content: "Hello, I'm a snackbar", + }) + }, 3000) + } } const createPosition = (position: 'top' | 'center' | 'bottom') => { Snackbar({ - content: "Hello, I'm a snackbar-core", + content: "Hello, I'm a snackbar", position, }) } diff --git a/packages/varlet-ui/src/utils/elements.ts b/packages/varlet-ui/src/utils/elements.ts index 3be338f79fd..9d2a381a0c8 100644 --- a/packages/varlet-ui/src/utils/elements.ts +++ b/packages/varlet-ui/src/utils/elements.ts @@ -1,7 +1,3 @@ -import { inBrowser } from './shared' - -const root = (inBrowser ? window : global) as Window - export function getTop(element: HTMLElement): number { const { top } = element.getBoundingClientRect() @@ -88,5 +84,5 @@ export function remToPx(rem: string | number): number { } export function requestAnimationFrame(fn: FrameRequestCallback): number { - return root.requestAnimationFrame ? root.requestAnimationFrame(fn) : root.setTimeout(fn, 16) + return window.requestAnimationFrame ? window.requestAnimationFrame(fn) : window.setTimeout(fn, 16) } diff --git a/packages/varlet-ui/src/utils/shared.ts b/packages/varlet-ui/src/utils/shared.ts index 4db0881275f..2283b416849 100644 --- a/packages/varlet-ui/src/utils/shared.ts +++ b/packages/varlet-ui/src/utils/shared.ts @@ -8,8 +8,6 @@ export interface CacheInstance { remove(key: T): void } -export const inBrowser = typeof window !== 'undefined' - export const isString = (val: unknown): val is string => typeof val === 'string' export const isNumber = (val: unknown): val is number => typeof val === 'number'