add bg/padding for <li>, fix flex <ul> <ol>

This commit is contained in:
Face
2025-07-31 21:00:59 +03:00
parent c3aff33f46
commit a0c72bd94b
4 changed files with 49 additions and 13 deletions

View File

@@ -80,13 +80,11 @@ var HTML_CONTENT = """<head>
<!-- Recent Activity Log -->
<h2 style="text-center mt-6">📝 Recent Activity</h2>
<div style="w-[80%] mx-auto mt-2">
<ul>
<li style="bg-[#334155] px-4 py-2 rounded mb-1">✅ Task "Update UI" marked as complete</li>
<li style="bg-[#334155] px-4 py-2 rounded mb-1">🔔 New comment on "Bug Fix #224"</li>
<li style="bg-[#334155] px-4 py-2 rounded mb-1">📤 Exported report "Q2 Metrics"</li>
</ul>
</div>
<ul style="w-[80%] mt-2 flex justify-center flex-column gap-2">
<li style="bg-[#334155] px-4 py-2 rounded-xl mb-1">✅ Task "Update UI" marked as complete</li>
<li style="bg-[#334155] px-4 py-2 rounded-xl mb-1">🔔 New comment on "Bug Fix #224"</li>
<li style="bg-[#334155] px-4 py-2 rounded-xl mb-1">📤 Exported report "Q2 Metrics"</li>
</ul>
<separator direction="horizontal" />

View File

@@ -72,7 +72,18 @@ func create_li_node(element: HTMLParser.HTMLElement, list_type: String, index: i
li_container.add_child(marker_label)
li_container.add_child(content_label)
return li_container
var styles = parser.get_element_styles_with_inheritance(element, "", [])
if BackgroundUtils.needs_background_wrapper(styles):
var panel_container = BackgroundUtils.create_panel_container_with_background(styles)
panel_container.name = "Li"
# Get the VBoxContainer inside PanelContainer and replace it with our HBoxContainer
var vbox = panel_container.get_child(0)
panel_container.remove_child(vbox)
vbox.queue_free()
panel_container.add_child(li_container)
return panel_container
else:
return li_container
func get_marker_for_type(list_type: String, index: int) -> String:
match list_type:

View File

@@ -66,7 +66,18 @@ func create_li_node(element: HTMLParser.HTMLElement, list_type: String, marker_w
li_container.add_child(bullet_label)
li_container.add_child(content_label)
return li_container
var styles = parser.get_element_styles_with_inheritance(element, "", [])
if BackgroundUtils.needs_background_wrapper(styles):
var panel_container = BackgroundUtils.create_panel_container_with_background(styles)
panel_container.name = "Li"
# Get the VBoxContainer inside PanelContainer and replace it with our HBoxContainer
var vbox = panel_container.get_child(0)
panel_container.remove_child(vbox)
vbox.queue_free()
panel_container.add_child(li_container)
return panel_container
else:
return li_container
func get_bullet_for_type(list_type: String) -> String:
match list_type:

View File

@@ -49,7 +49,6 @@ func render() -> void:
parser.process_styles()
print("Total elements found: " + str(parse_result.all_elements.size()))
if parse_result.errors.size() > 0:
print("Parse errors: " + str(parse_result.errors))
@@ -148,8 +147,25 @@ func create_element_node(element: HTMLParser.HTMLElement, parser: HTMLParser) ->
final_node = AUTO_SIZING_FLEX_CONTAINER.new()
final_node.name = "Flex_" + element.tag_name
container_for_children = final_node
# For FLEX ul/ol elements, we need to create the li children directly in the flex container
if element.tag_name == "ul" or element.tag_name == "ol":
final_node.flex_direction = FlexContainer.FlexDirection.Column
website_container.add_child(final_node)
var temp_list = UL.instantiate() if element.tag_name == "ul" else OL.instantiate()
website_container.add_child(temp_list)
await temp_list.init(element, parser)
for child in temp_list.get_children():
temp_list.remove_child(child)
container_for_children.add_child(child)
website_container.remove_child(temp_list)
temp_list.queue_free()
# If the element itself has text (like <span style="flex">TEXT</span>)
if not element.text_content.is_empty():
elif not element.text_content.is_empty():
var new_node = await create_element_node_internal(element, parser)
container_for_children.add_child(new_node)
else:
@@ -248,12 +264,12 @@ func create_element_node_internal(element: HTMLParser.HTMLElement, parser: HTMLP
"ul":
node = UL.instantiate()
website_container.add_child(node)
await node.init(element)
await node.init(element, parser)
return node
"ol":
node = OL.instantiate()
website_container.add_child(node)
await node.init(element)
await node.init(element, parser)
return node
"li":
node = LI.instantiate()