Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(select): add hover for option #1157

Merged
merged 1 commit into from
Aug 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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