Skip to content

Commit

Permalink
feature: introduce new no-flip modifier
Browse files Browse the repository at this point in the history
Closes #35.
  • Loading branch information
ryangjchandler committed Jan 7, 2024
1 parent 452ad5c commit d63fb36
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 6 deletions.
6 changes: 6 additions & 0 deletions dist/cdn.js
Original file line number Diff line number Diff line change
Expand Up @@ -2939,6 +2939,12 @@
if (modifiers.includes("placement")) {
config.placement = getModifierArgument("placement");
}
const popperOptions = {};
if (modifiers.includes("no-flip")) {
popperOptions.modifiers ||= [];
popperOptions.modifiers.push({name: "flip", enabled: false});
}
config.popperOptions = popperOptions;
return config;
};

Expand Down
12 changes: 6 additions & 6 deletions dist/cdn.min.js

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions dist/module.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -3411,6 +3411,12 @@ var buildConfigFromModifiers = (modifiers) => {
if (modifiers.includes("placement")) {
config.placement = getModifierArgument("placement");
}
const popperOptions = {};
if (modifiers.includes("no-flip")) {
popperOptions.modifiers || (popperOptions.modifiers = []);
popperOptions.modifiers.push({name: "flip", enabled: false});
}
config.popperOptions = popperOptions;
return config;
};

Expand Down
6 changes: 6 additions & 0 deletions dist/module.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -3401,6 +3401,12 @@ var buildConfigFromModifiers = (modifiers) => {
if (modifiers.includes("placement")) {
config.placement = getModifierArgument("placement");
}
const popperOptions = {};
if (modifiers.includes("no-flip")) {
popperOptions.modifiers ||= [];
popperOptions.modifiers.push({name: "flip", enabled: false});
}
config.popperOptions = popperOptions;
return config;
};

Expand Down
35 changes: 35 additions & 0 deletions examples/no-flip.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<html>

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Alpine.js Toolkit - x-html</title>
<link rel="stylesheet" href="https://unpkg.com/tippy.js@6.3.1/dist/tippy.css">
<script type="module">
import Tooltip from '/dist/module.esm.js'

document.addEventListener('alpine:initializing', () => {
window.Alpine.plugin(
Tooltip
.defaultProps({
theme: 'material'
})
)
})
</script>
<script src="//unpkg.com/alpinejs" defer></script>
</head>

<body x-data="{ content: 'Hello!' }">
<button x-tooltip.on.click.placement.left.no-flip="content">
Click me!
</button>

<input type="text" x-model="content">

<button x-tooltip.raw="Hello, world!">
Raw tooltip
</button>
</body>
</html>
9 changes: 9 additions & 0 deletions src/buildConfigFromModifiers.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,14 @@ export const buildConfigFromModifiers = modifiers => {
config.placement = getModifierArgument('placement')
}

const popperOptions = {}

if (modifiers.includes('no-flip')) {
popperOptions.modifiers ||= [];
popperOptions.modifiers.push({ name: 'flip', enabled: false });
}

config.popperOptions = popperOptions;

return config
}

0 comments on commit d63fb36

Please sign in to comment.