Skip to content

Commit

Permalink
fix(html): fix toopltip text display
Browse files Browse the repository at this point in the history
  • Loading branch information
fu050409 committed Mar 6, 2024
1 parent 3653ea2 commit 73e7a8c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 25 deletions.
4 changes: 2 additions & 2 deletions src/diceutils/renderer/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
/* Position the tooltip text */
position: absolute;
z-index: 1;
bottom: 125%;
left: 50%;
bottom: calc(100% + 5px);
left: calc(50% + 50px);
margin-left: -60px;
/* Fade in tooltip */
Expand Down
50 changes: 27 additions & 23 deletions tests/test_renderer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from diceutils.renderer import Renderer, Messages, Role
from diceutils.renderer.html import HTMLRenderer

import datetime


def test_render():
messages = Messages()
Expand All @@ -14,32 +16,14 @@ def test_render():
"text": "男人最终还是跟了上来,只是嘴里连连念叨着:“我是美国公民,我是美国公民……”"
},
},
{"type": "image", "data": {"url": "http://a.com/2.png"}},
]
msg_content_3 = [
{
"type": "text",
"data": {
"text": ".rd10*5"
}
}
]
msg_content_3 = [{"type": "text", "data": {"text": ".rd10*5"}}]
msg_content_4 = [
{
"type": "text",
"data": {
"text": "[苏向夜]掷骰: 1D10*5={10}*5=50"
}
}
{"type": "text", "data": {"text": "[苏向夜]掷骰: 1D10*5={10}*5=50"}}
]

msg_content_5 = [
{
"type": "text",
"data": {
"text": "苏说道:”我们去毁灭人类吧。“Test,“hi"
}
}
{"type": "text", "data": {"text": "苏说道:”我们去毁灭人类吧。“Test,“hi"}}
]
messages.add_message("230234235", Role.GM, "苏向夜", "date", msg_content_1)
messages.add_message("130324324", Role.PL, "少年狐", "date", msg_content_1)
Expand All @@ -51,11 +35,31 @@ def test_render():
"130232542",
Role.OB,
"简律纯",
"datetime.datetime.now()",
str(datetime.datetime.now()),
[
{"type": "text", "data": {"text": "谴责!"}},
{
"type": "image",
"data": {
"url": "https://th.bing.com/th/id/OIP.ZTTJgCn_iXE4sM52RK2x7gAAAA?rs=1&pid=ImgDetMain"
},
},
],
)
messages.add_message(
"130232542",
Role.OB,
"简律纯",
str(datetime.datetime.now()),
[
{
"type": "image",
"data": {
"url": "https://th.bing.com/th/id/OIP.ZTTJgCn_iXE4sM52RK2x7gAAAA?rs=1&pid=ImgDetMain"
},
},
],
)

renderer = Renderer.render(messages, HTMLRenderer())
renderer.export("测试")
renderer.export("测试")

0 comments on commit 73e7a8c

Please sign in to comment.