Skip to content

Commit

Permalink
perf(ui/snackbar): add class
Browse files Browse the repository at this point in the history
perf(ui/snackbar): add class

perf(ui/snackbar): add class

perf(ui/snackbar): add class
  • Loading branch information
jj56313751 committed Apr 3, 2022
1 parent ba68dc9 commit b25406d
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions packages/varlet-ui/src/snackbar/core.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<template>
<div class="var-snackbar" :style="{ pointerEvents: isForbidClick ? 'auto' : 'none', zIndex }" v-show="show">
<div :class="n()" :style="{ pointerEvents: isForbidClick ? 'auto' : 'none', zIndex }" v-show="show">
<div :class="snackbarClass" :style="{ zIndex }">
<div class="var-snackbar__content" :class="[contentClass]">
<div :class="[n('content'), contentClass]">
<slot>{{ content }}</slot>
</div>
<div class="var-snackbar__action">
<div :class="n('action')">
<var-icon v-if="iconName" :name="iconName" />
<var-loading v-if="type === 'loading'" :type="loadingType" :size="loadingSize" />
<slot name="action" />
Expand All @@ -23,6 +23,9 @@ import { useLock } from '../context/lock'
import { SNACKBAR_TYPE } from './index'
import type { Ref, ComputedRef } from 'vue'
import type { SnackbarType } from './index'
import { createNamespace } from '../utils/components'
const { n, classes } = createNamespace('snackbar')
const ICON_TYPE_DICT: Record<SnackbarType, string> = {
success: 'checkbox-marked-circle',
Expand All @@ -45,14 +48,16 @@ export default defineComponent({
useLock(props, 'show', 'lockScroll')
const snackbarClass: ComputedRef<string> = computed(() => {
const snackbarClass: ComputedRef<any[]> = computed(() => {
const { position, vertical, type } = props
const baseClass = `var-snackbar__wrapper var-snackbar__wrapper-${position} var-elevation--4`
const verticalClass = vertical ? ' var-snackbar__vertical' : ''
const typeClass = type && SNACKBAR_TYPE.includes(type) ? ` var-snackbar__wrapper-${type}` : ''
return `${baseClass}${verticalClass}${typeClass}`
return classes(
n('wrapper'),
n(`wrapper-${position}`),
'var-elevation--4',
[vertical, n('vertical')],
[type && SNACKBAR_TYPE.includes(type), n(`wrapper-${type}`)]
)
})
const isForbidClick: ComputedRef<boolean> = computed(() => props.type === 'loading' || props.forbidClick)
Expand Down Expand Up @@ -98,6 +103,8 @@ export default defineComponent({
})
return {
n,
classes,
zIndex,
snackbarClass,
iconName,
Expand Down

0 comments on commit b25406d

Please sign in to comment.