Skip to content

Commit

Permalink
fix: static hover prop
Browse files Browse the repository at this point in the history
  • Loading branch information
pirhoo committed Jul 15, 2024
1 parent e7246d3 commit 0e772bf
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
18 changes: 12 additions & 6 deletions lib/components/PhosphorIcon.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<template>
<span class="phosphor-icon" :style="style" :class="classList" @mouseenter="hover = true" @mouseleave="hover = false">
<span
class="phosphor-icon"
:class="classList"
:style="style"
@mouseenter="currentHover = true"
@mouseleave="currentHover = hover ?? false"
>
<component
:size="rawSize"
:is="component"
Expand Down Expand Up @@ -60,8 +66,6 @@ const WEIGHTS = Object.freeze({
[WEIGHT_DUOTONE]: WEIGHT_DUOTONE
})
const hover = ref(false)
const props = defineProps({
name: {
type: String,
Expand Down Expand Up @@ -141,17 +145,19 @@ watch(
}
)
const currentHover = ref(false)
watch(
() => props.hover,
() => {
hover.value = props.hover
currentHover.value = props.hover
},
{ immediate: true }
)
const weight = computed(() => {
if (hover.value && props.hoverWeight) {
if (currentHover.value && props.hoverWeight) {
return WEIGHTS[props.hoverWeight]
}
Expand Down Expand Up @@ -202,7 +208,7 @@ const classList = computed(() => {
return {
[`phosphor-icon--size-${props.size}`]: hasSize.value,
[`phosphor-icon--has-size`]: hasSize.value,
[`phosphor-icon--hover`]: hover.value,
[`phosphor-icon--hover`]: currentHover.value,
}
})
</script>
Expand Down
8 changes: 8 additions & 0 deletions stories/murmur/components/PhosphorIcon.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ export const VariantSecondary = {
size: '32px'
}
}
export const HoverWeight = {
args: {
name: 'lego',
variant: 'primary',
hoverWeight: 'duotone',
size: '32px'
}
}

export const WithText = {
args: {
Expand Down

0 comments on commit 0e772bf

Please sign in to comment.