From aa4ee1b93ccf6ffff0af382bd6193351c65f8079 Mon Sep 17 00:00:00 2001 From: Face <69168154+face-hh@users.noreply.github.com> Date: Fri, 1 Aug 2025 21:16:48 +0300 Subject: [PATCH] border styles --- README.md | 1 + Scripts/B9/CSSParser.gd | 80 ++++++++++++++++++++++++++ Scripts/Constants.gd | 39 +++++++++++-- Scripts/StyleManager.gd | 20 ++++++- Scripts/Utils/BackgroundUtils.gd | 56 +++++++++++++++++- Scripts/Utils/UtilityClassValidator.gd | 10 ++++ Scripts/main.gd | 32 +++++++++-- 7 files changed, 223 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index afe4251..0a68646 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ TODO: 9. Installer should register **gurt://** as a valid protocol thru the registry. 10. < input type=**datetime** />, essentially a type "date" but with a vertical separator, then `mm | ss | FORMAT` layout for time. 11. **< table >** component. [🔗 Related Godot proposal](https://github.com/godotengine/godot-proposals/issues/97) +12. **< canvas >** component should be theoretically impossible by exposing Godot `_draw()` APIs to Lua. Issues: 1. **< br />** counts as 1 element in **WebsiteContainer**, therefore despite being (0,0) in size, it counts as double in spacing diff --git a/Scripts/B9/CSSParser.gd b/Scripts/B9/CSSParser.gd index 9a2edb8..b89e75c 100644 --- a/Scripts/B9/CSSParser.gd +++ b/Scripts/B9/CSSParser.gd @@ -508,6 +508,86 @@ static func parse_utility_class_internal(rule: CSSRule, utility_name: String) -> rule.properties["my-auto"] = true return + # Apply border properties + var apply_border = func(side: String, width: String = "", color = null, style: String = "solid"): + var prefix = "border" + ("-" + side if side != "" else "") + if width != "": + rule.properties[prefix + "-width"] = width + if color != null: + rule.properties[prefix + "-color"] = color + if style != "": + rule.properties[prefix + "-style"] = style + + # Handle border utilities + if utility_name == "border": + apply_border.call("", "1px", Color.BLACK) + return + + if utility_name == "border-none": + rule.properties["border-style"] = "none" + return + + # Individual border sides - pattern: border-{side}-{value} + var border_sides = ["t", "r", "b", "l"] + var side_map = {"t": "top", "r": "right", "b": "bottom", "l": "left"} + + for side in border_sides: + var short_side = side + var full_side = side_map[side] + + # Basic side border (e.g., border-t) + if utility_name == "border-" + short_side: + apply_border.call(full_side, "1px") + return + + # Side with value (e.g., border-t-2, border-t-red-500) + if utility_name.begins_with("border-" + short_side + "-"): + var val = utility_name.substr(9) # after "border-X-" + + # Check for bracket notation first + if utility_name.begins_with("border-" + short_side + "-[") and utility_name.ends_with("]"): + var value = SizeUtils.extract_bracket_content(utility_name, 9) + if value.begins_with("#") or ColorUtils.parse_color(value) != null: + apply_border.call(full_side, "", ColorUtils.parse_color(value)) + else: + apply_border.call(full_side, value) + return + + # Check if it's a numeric width + if val.is_valid_int(): + apply_border.call(full_side, str(int(val)) + "px") + return + + # Check if it's a color + var color = ColorUtils.get_color(val) + if color != null: + apply_border.call(full_side, "", color) + return + + # General border width (e.g., border-2) + if utility_name.begins_with("border-"): + var val = utility_name.substr(7) + + # Custom border width like border-[2px] + if utility_name.begins_with("border-[") and utility_name.ends_with("]"): + var value = SizeUtils.extract_bracket_content(utility_name, 7) + if value.begins_with("#"): + apply_border.call("", "", ColorUtils.parse_color(value)) + else: + apply_border.call("", value) + return + + # Numeric width + if val.is_valid_int(): + apply_border.call("", str(int(val)) + "px") + return + + # Color name + var color = ColorUtils.get_color(val) + if color != null: + apply_border.call("", "", color) + return + # Handle more utility classes as needed # Add more cases here for other utilities diff --git a/Scripts/Constants.gd b/Scripts/Constants.gd index cc45d31..27d5f12 100644 --- a/Scripts/Constants.gd +++ b/Scripts/Constants.gd @@ -24,7 +24,7 @@ pre { text-xl font-mono } button { bg-[#1b1b1b] rounded-md text-white hover:bg-[#2a2a2a] active:bg-[#101010] } """ -var HTML_CONTENT = """ +var HTML_CONTENT2 = """ My Custom Dashboard @@ -99,7 +99,7 @@ var HTML_CONTENT = """ """.to_utf8_buffer() -var HTML_CONTENT2 = """ +var HTML_CONTENT = """ My cool web @@ -141,7 +141,7 @@ var HTML_CONTENT2 = """ this is code THIS IS A SPAN AND SHOULDNT BE ANY DIFFERENT

- Hello gang + Hello gang

@@ -152,9 +152,36 @@ both      spaces and
 line breaks
 	
-

-So -

+

+ So +

+ + +
border
+
border-2
+
border-4
+
border-2 border-red-500
+
border-solid
+
border-dashed
+
border-dotted
+
border-none
+
border-t
+
border-r
+
border-b
+
border-l
+
border-t-4
+
border-b-2
+
border-l-6
+
border-t-3 border-green-500
+
border-white
+
border-black
+
border-transparent
+
border-gray-400
+
border-slate-700
+
border-red-500
+
border-green-600
+
border-blue-400
+
border-yellow-300