Skip to content
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
9 changes: 8 additions & 1 deletion assets/docs/components/avatar.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ class AvatarImage(CoreComponent):
@classmethod
def create(cls, **props) -> rx.Component:
custom_classes = props.pop("class_name", "")
user_on_mount = props.pop("on_mount", None)
props["data-slot"] = "avatar-image"

img_id = props.get("id") or f"avatar-img-{uuid.uuid4().hex[:8]}"
Expand All @@ -147,7 +148,13 @@ class AvatarImage(CoreComponent):
}})()
"""

props["on_mount"] = rx.call_script(js)
mount_handlers = [rx.call_script(js)]
if user_on_mount is not None:
if isinstance(user_on_mount, list):
mount_handlers.extend(user_on_mount)
else:
mount_handlers.append(user_on_mount)
props["on_mount"] = mount_handlers

cls.set_class_name(cn(ClassNames.IMAGE, custom_classes), props)
return rx.el.img(**props)
Expand Down
9 changes: 8 additions & 1 deletion components/ui/avatar.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class AvatarImage(CoreComponent):
@classmethod
def create(cls, **props) -> rx.Component:
custom_classes = props.pop("class_name", "")
user_on_mount = props.pop("on_mount", None)
props["data-slot"] = "avatar-image"

img_id = props.get("id") or f"avatar-img-{uuid.uuid4().hex[:8]}"
Expand All @@ -83,7 +84,13 @@ def create(cls, **props) -> rx.Component:
}})()
"""

props["on_mount"] = rx.call_script(js)
mount_handlers = [rx.call_script(js)]
if user_on_mount is not None:
if isinstance(user_on_mount, list):
mount_handlers.extend(user_on_mount)
else:
mount_handlers.append(user_on_mount)
props["on_mount"] = mount_handlers

cls.set_class_name(cn(ClassNames.IMAGE, custom_classes), props)
return rx.el.img(**props)
Expand Down