Reactions
Slack-style emoji reactions with live-updating counts.
Preview
Arguments
reactions(options=['', '👍', '🎉', '❤️'], counts={'👍': 3, '🎉': 1, '❤️': 0}, active=['👍'])Usage
views.py
python
from djust import LiveView
from djust.decorators import event_handler
from djust.components import Reactions
class MyView(LiveView):
template_name = "my_template.html"
def mount(self, request, **kwargs):
self.component = Reactions(options=['', '👍', '🎉', '❤️'], counts={'👍': 3, '🎉': 1, '❤️': 0}, active=['👍'])
@event_handler()
def react(self, **kwargs):
self.component.active = ... # `toggle_member` — see this component's docsmy_template.html
django
{{ component }}Events this component sends to the view: react.
Parameters
| Name | Type | Default |
|---|---|---|
| options | List[str] | None | None |
| counts | Dict[str, int] | None | None |
| event | str — renames the event; identity is `name` | 'react' |
| active | List[str] | None | None |
| custom_class | str | '' |
| **kwargs | — passed to `Component.__init__`: `name=` identifies the instance in the events it sends, `id=` sets `component.id`, and any other keyword is kept as state | — |
Source & styles
| File | Path | Notes |
|---|---|---|
| module | djust.components.components.reactions | Subclass it, or pass custom_class, to change how it renders. |
| css | djust_components/components.css | Defines 5 of this component's classes at line 2268, 2269, 2271, 2272, 2273. Override those rules, or the custom properties they read, in a stylesheet loaded after it. |