Skip to content

Commit

Permalink
feat: add hover
Browse files Browse the repository at this point in the history
  • Loading branch information
binbin authored and binbin committed Aug 21, 2023
1 parent 95153e5 commit b896c35
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/varlet-ui/src/option/Option.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
color: optionSelected ? focusColor : undefined,
}"
v-ripple
v-hover:desktop="handleHovering"
@click="handleClick"
>
<div
Expand All @@ -27,6 +28,8 @@
{{ label }}
</slot>
</div>

<var-hover-overlay :hovering="hovering" />
</div>
</template>

Expand All @@ -39,14 +42,17 @@ import { createNamespace } from '../utils/components'
import { props } from './props'
import type { Ref, ComputedRef } from 'vue'
import type { OptionProvider } from './provide'
import Hover from '../hover'
import VarHoverOverlay, { useHoverOverlay } from '../hover-overlay'
const { n, classes } = createNamespace('option')
export default defineComponent({
name: 'VarOption',
directives: { Ripple },
directives: { Ripple, Hover },
components: {
VarCheckbox,
VarHoverOverlay,
},
props,
setup(props) {
Expand All @@ -56,6 +62,7 @@ export default defineComponent({
const value: ComputedRef = computed(() => props.value)
const { select, bindSelect } = useSelect()
const { multiple, focusColor, onSelect, computeLabel } = select
const { hovering, handleHovering } = useHoverOverlay()
const handleClick = () => {
if (multiple.value) {
Expand Down Expand Up @@ -87,6 +94,8 @@ export default defineComponent({
optionSelected,
multiple,
focusColor,
hovering,
handleHovering,
handleClick,
handleSelect,
}
Expand Down

0 comments on commit b896c35

Please sign in to comment.