Skip to content

Commit 5b0b9b3

Browse files
committed
docs: Write documentation about the * special content action, #17
1 parent be80605 commit 5b0b9b3

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

README.md

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ yarn add @untemps/svelte-use-tooltip
128128

129129
### Content Actions
130130

131-
The `contentActions` prop allow handling interactions within the tooltip content.
131+
The `contentActions` prop allows to handle interactions within the tooltip content.
132132

133133
Each element inside the content parent may configure its own action since it can be queried using the key-selector.
134134

@@ -147,13 +147,13 @@ One event by element is possible so far as elements are referenced by selector.
147147
eventType: 'mouseenter',
148148
callback: (arg) => console.log(arg),
149149
callbackParams: ['Haha you\'re hovering the button 1'],
150-
closeOnCallback: true
150+
closeOnCallback: false
151151
},
152152
'#button2': {
153153
eventType: 'click',
154154
callback: (arg1, arg2) => console.log(arg1, arg2),
155155
callbackParams: ['Haha you\'ve clicked the', 'button 2'],
156-
closeOnCallback: false
156+
closeOnCallback: true
157157
},
158158
}
159159
}}>Hover me</div>
@@ -170,6 +170,30 @@ One event by element is possible so far as elements are referenced by selector.
170170
| `callbackParams` | array | null | List of arguments to pass to the event handler in. |
171171
| `closeOnCallback` | boolean | false | Flag to automatically close the tooltip when the event handler is triggered. |
172172

173+
#### `*` selector
174+
175+
If you need the whole tooltip content to be interactive, you can use the special `*` key:
176+
177+
```svelte
178+
<script>
179+
import { useTooltip } from '@untemps/svelte-use-tooltip'
180+
</script>
181+
182+
<div use:useTooltip={{
183+
content: 'Foo',
184+
contentActions: {
185+
'*': {
186+
eventType: 'click',
187+
callback: (arg) => console.log(arg),
188+
callbackParams: ['Haha you clicked the tooltip'],
189+
closeOnCallback: true
190+
}
191+
}
192+
}}>Hover me</div>
193+
```
194+
195+
If you combine the `*` selector with other events, its callback will be triggered along with the other ones.
196+
173197
## Development
174198

175199
The component can be served for development purpose on `http://localhost:5000/` running:

0 commit comments

Comments
 (0)