Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2 clicks were needed to show the combobox
- Loading branch information
1 parent
8280a50
commit bd4e533
Showing
3 changed files
with
119 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,47 @@ | ||
<title>Popover with custom Trigger</title> | ||
<tip>If you have special needs simply use `slot-scope`. This gives you access to the `toggle`-function and the current `visibility`. The second button is using this in order to customize the trigger event and styling.</tip> | ||
<docs> | ||
**Implementation Details** | ||
|
||
There are three different ways a trigger control can be rendered. | ||
|
||
1. `$slots.control`: If there is a slot called `control` we simply render that. This control should emit `click`-events. | ||
2. `$scopedSlots.control`: If there is a scoped slot `control` we assume that the popover consumer (**you**) has some kind of special needs. Thus, when rendering the scoped slot, we pass a little bit of context to the consumer. | ||
|
||
**The context looks like this:**: | ||
|
||
```javascript | ||
{ | ||
// Calling this will toggle the popover. | ||
toggle: () => (void); | ||
// whether the popover is currently visible. | ||
visible: boolean; | ||
} | ||
``` | ||
|
||
Because of the fact that we assume that the consumer has special needs, we do not show the popover automatically. The consumer has to call `toggle` for example by binding it to `@click`/`@click.native` of some kind of control or by using `v-model`. | ||
|
||
3. If there is no (scoped) control-slot we simply render a standard button on behalf of the consumer. | ||
</docs> | ||
<template><div> | ||
<FdPopover> | ||
<FdButton styling="emphasized" type="positive" slot="control">Custom Popover Trigger Control (automatic popover visibility)</FdButton> | ||
<FdMenuItem>Option 1</FdMenuItem> | ||
<FdMenuItem>Option 2</FdMenuItem> | ||
<FdMenuItem>Option 3</FdMenuItem> | ||
</FdPopover> | ||
|
||
<br /><br /> | ||
|
||
<template> | ||
<!-- div is needed: otherwise the popover will not be positioned correctly --> | ||
<div> | ||
<FdPopover> | ||
<FdButton styling="emphasized" type="positive" slot="control">Custom Popover Trigger Control</FdButton> | ||
<FdButton | ||
slot-scope="popover" | ||
slot="control" | ||
:type="popover.visible ? 'negative' : 'warning'" | ||
@click="popover.toggle" | ||
>Custom Popover Trigger Control (manual popover visibility)</FdButton> | ||
<FdMenuItem>Option 1</FdMenuItem> | ||
<FdMenuItem>Option 2</FdMenuItem> | ||
<FdMenuItem>Option 3</FdMenuItem> | ||
<FdMenuItem>Option 4</FdMenuItem> | ||
</FdPopover> | ||
</div> | ||
</template> | ||
</div></template> |