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

[feature] Changed 'interactive' implementation to css pseudo-classes #46

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions dev/serve.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@
--popper-theme-border-radius: 6px;
--popper-theme-padding: 32px;
--popper-theme-box-shadow: 0 6px 30px -6px rgba(0, 0, 0, 0.25);
--popper-theme-interactive-size: -12px;
}
</style>
1 change: 1 addition & 0 deletions docs/components/PopperDemo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,6 @@
--popper-theme-border-radius: 6px;
--popper-theme-padding: 32px;
--popper-theme-box-shadow: 0 6px 30px -6px rgba(0, 0, 0, 0.25);
--popper-theme-interactive-size: -12px;
}
</style>
1 change: 1 addition & 0 deletions docs/components/PopperDynamicTheme.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,6 @@
--popper-theme-border-radius: 6px;
--popper-theme-padding: 32px;
--popper-theme-box-shadow: 0 6px 30px -6px rgba(0, 0, 0, 0.25);
--popper-theme-interactive-size: -12px;
}
</style>
1 change: 1 addition & 0 deletions docs/components/PopperEvents.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,6 @@
--popper-theme-border-radius: 6px;
--popper-theme-padding: 32px;
--popper-theme-box-shadow: 0 6px 30px -6px rgba(0, 0, 0, 0.25);
--popper-theme-interactive-size: -12px;
}
</style>
1 change: 1 addition & 0 deletions docs/components/PopperManual.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,6 @@
--popper-theme-border-radius: 6px;
--popper-theme-padding: 32px;
--popper-theme-box-shadow: 0 6px 30px -6px rgba(0, 0, 0, 0.25);
--popper-theme-interactive-size: -12px;
}
</style>
1 change: 1 addition & 0 deletions docs/components/PopperScopedSlots.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@
--popper-theme-border-radius: 6px;
--popper-theme-padding: 32px;
--popper-theme-box-shadow: 0 6px 30px -6px rgba(0, 0, 0, 0.25);
--popper-theme-interactive-size: -12px;
}
</style>
1 change: 1 addition & 0 deletions docs/components/PopperStyled.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,6 @@
--popper-theme-border-radius: 6px;
--popper-theme-padding: 32px;
--popper-theme-box-shadow: 0 6px 30px -6px rgba(0, 0, 0, 0.25);
--popper-theme-interactive-size: -12px;
}
</style>
1 change: 1 addition & 0 deletions docs/guide/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,4 @@ The `content` slot gives you access to useful variables and functions.
| `--popper-theme-border-radius` | 6px |
| `--popper-theme-padding` | 16px |
| `--popper-theme-box-shadow` | 0 6px 30px -6px rgba(0, 0, 0, 0.25) |
| `--popper-theme-interactive-size` | -12px |
3 changes: 3 additions & 0 deletions docs/guide/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ If your content is more complex, you can use the `#content` slot:
| `--popper-theme-border-radius` | 6px |
| `--popper-theme-padding` | 16px |
| `--popper-theme-box-shadow` | 0 6px 30px -6px rgba(0, 0, 0, 0.25) |
| `--popper-theme-interactive-size` | -12px |

You can overwrite them any way you like, for example in a Vue component:

Expand Down Expand Up @@ -173,6 +174,7 @@ Using the CSS variables you could even add multiple themes to your popover.
--popper-theme-border-radius: 6px;
--popper-theme-padding: 32px;
--popper-theme-box-shadow: 0 6px 30px -6px rgba(0, 0, 0, 0.25);
--popper-theme-interactive-size: -12px;
}

.light {
Expand All @@ -185,6 +187,7 @@ Using the CSS variables you could even add multiple themes to your popover.
--popper-theme-border-radius: 6px;
--popper-theme-padding: 32px;
--popper-theme-box-shadow: 0 6px 30px -6px rgba(0, 0, 0, 0.25);
--popper-theme-interactive-size: -12px;
}
```

Expand Down
31 changes: 17 additions & 14 deletions src/component/Popper.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<template>
<div
class="inline-block"
:style="interactiveStyle"
@mouseleave="hover && closePopper()"
ref="popperContainerNode"
>
<div
class="popper-reference"
:class="{
'popper-reference--interactive': interactive,
}"
ref="triggerNode"
@mouseover="hover && openPopper()"
@click="togglePopper"
Expand Down Expand Up @@ -227,12 +229,6 @@
const enableClickAway = computed(
() => !disableClickAway.value && !manualMode.value,
);
// Add an invisible border to keep the Popper open when hovering from the trigger into it
const interactiveStyle = computed(() =>
interactive.value
? `border: ${offsetDistance.value}px solid transparent; margin: -${offsetDistance.value}px;`
: null,
);

const openPopper = async () => {
if (invalid.value || manualMode.value) {
Expand Down Expand Up @@ -303,9 +299,20 @@
</script>

<style scoped>
.inline-block {
display: inline-block;
.popper-reference--interactive {
position: relative;
}

.popper-reference--interactive::before {
content: '';
position: absolute;
top: var(--popper-theme-interactive-size);
right: var(--popper-theme-interactive-size);
left: var(--popper-theme-interactive-size);
bottom: var(--popper-theme-interactive-size);
display: block;
}

.popper {
transition: background 250ms ease-in-out;
background: var(--popper-theme-background-color);
Expand All @@ -324,10 +331,6 @@
background: var(--popper-theme-background-color-hover);
}

.inline-block {
display: inline-block;
}

.fade-enter-active,
.fade-leave-active {
transition: opacity 0.2s ease;
Expand Down