Skip to content

Commit

Permalink
Show tooltip with emote's name when hovering over it
Browse files Browse the repository at this point in the history
  • Loading branch information
douglascdev committed Dec 12, 2023
1 parent aaa35d0 commit dd81651
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Changes:
* Render global 7tv emotes
* Show tooltip with emote's name when hovering over it

17 changes: 12 additions & 5 deletions hasherino/components/chat_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,15 @@ async def on_font_size_changed(self, new_font_size: int):
self.height = new_font_size


class ChatEmote(ft.Image, FontSizeSubscriber):
class ChatEmote(ft.Container, FontSizeSubscriber):
def __init__(self, *args, **kwargs):
self.emote: Emote | None = kwargs.pop("emote", None)
super().__init__(
content=ft.Image(
tooltip=self.emote.name if self.emote else "", *args, **kwargs
),
)

async def on_font_size_changed(self, new_font_size: int):
self.height = new_font_size * 2

Expand Down Expand Up @@ -61,13 +69,12 @@ def add_control_elements(self, message):
)

for element in message.elements:
if type(element) == str:
if type(element) is str:
color = message.user.chat_color if message.me else ""
result = ChatText(element, color, self.font_size)
elif type(element) == Emote:
elif type(element) is Emote:
result = ChatEmote(
src=element.url,
height=self.font_size * 2,
emote=element, src=element.url, height=self.font_size * 2
)
else:
raise TypeError
Expand Down
2 changes: 1 addition & 1 deletion hasherino/components/tabs.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ async def load_emotes(self):

emotes[user.login] = {
emote_name: Emote(
emote_id,
emote_name,
emote_id,
f"https://cdn.7tv.app/emote/{emote_id}/2x.webp",
)
for emote_name, emote_id in seventv_emotes.items()
Expand Down

0 comments on commit dd81651

Please sign in to comment.