Skip to content

Commit

Permalink
refactor(ui/card): optimize ripple feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
qytayh committed May 23, 2022
1 parent ac832b1 commit eb9a019
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
21 changes: 11 additions & 10 deletions packages/varlet-ui/src/card/Card.vue
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
<template>
<div ref="card" :class="classes(n(), [isRow, n('--layout-row')])" @click="onClick">
<div
ref="card"
:class="classes(n(), [isRow, n('--layout-row')], [elevation, `var-elevation--${elevation}`, 'var-elevation--1'])"
:style="{
zIndex: floated ? zIndex : undefined,
}"
@click="onClick"
v-ripple="{ disabled: !ripple || floater }"
>
<div
ref="cardFloater"
:class="classes(n('floater'), [elevation, `var-elevation--${elevation}`, 'var-elevation--1'])"
:class="classes(n('floater'))"
:style="{
width: floaterWidth,
height: floaterHeight,
top: floaterTop,
left: floaterLeft,
overflow: floaterOverflow,
position: floaterPosition,
borderRadius: floaterBorderRadius,
zIndex: floated ? zIndex : undefined,
transition: floated
? `background-color ${floatingDuration}ms, border-radius ${floatingDuration}ms, width ${floatingDuration}ms, height ${floatingDuration}ms, top ${floatingDuration}ms, left ${floatingDuration}ms`
? `background-color ${floatingDuration}ms, width ${floatingDuration}ms, height ${floatingDuration}ms, top ${floatingDuration}ms, left ${floatingDuration}ms`
: undefined,
}"
v-ripple="{ disabled: !ripple || floater }"
>
<slot name="image">
<img
Expand Down Expand Up @@ -120,7 +125,6 @@ export default defineComponent({
const floaterLeft: Ref<string> = ref('auto')
const floaterPosition: Ref<string | undefined> = ref(undefined)
const floaterOverflow: Ref<string> = ref('hidden')
const floaterBorderRadius: Ref<string | undefined> = ref(undefined)
const contentHeight: Ref<string> = ref('0px')
const opacity: Ref<string> = ref('0')
const { zIndex } = useZIndex(() => props.floating, 1)
Expand Down Expand Up @@ -167,7 +171,6 @@ export default defineComponent({
contentHeight.value = 'auto'
opacity.value = '1'
floaterOverflow.value = 'auto'
floaterBorderRadius.value = '0px'
floated.value = true
},
props.ripple ? RIPPLE_DELAY : 0
Expand All @@ -183,7 +186,6 @@ export default defineComponent({
floaterHeight.value = holderHeight.value
floaterTop.value = dropdownFloaterTop
floaterLeft.value = dropdownFloaterLeft
floaterBorderRadius.value = undefined
contentHeight.value = '0px'
opacity.value = '0'
showFloatingButtons.value = false
Expand Down Expand Up @@ -234,7 +236,6 @@ export default defineComponent({
floaterLeft,
floaterPosition,
floaterOverflow,
floaterBorderRadius,
contentHeight,
opacity,
zIndex,
Expand Down
4 changes: 3 additions & 1 deletion packages/varlet-ui/src/card/card.less
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,10 @@
}

.var-card {
border-radius: var(--card-border-radius);
overflow: hidden;

&__floater {
border-radius: var(--card-border-radius);
display: flex;
flex-direction: column;
position: static;
Expand Down

0 comments on commit eb9a019

Please sign in to comment.