Skip to content

Commit da546e7

Browse files
committed
Refactor component paths in sync_components.py for improved structure. Update card and textarea components for better styling and layout. Enhance tooltip component with animation frame scheduling for smoother interactions.
1 parent 95d27bf commit da546e7

File tree

4 files changed

+26
-11
lines changed

4 files changed

+26
-11
lines changed

scripts/sync_components.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ def __init__(self, workspace_root: str = "/Users/dakixr/dev"):
4343

4444
# Component directories
4545
self.uikit_components = self.uikit_path / "src" / "htpy_uikit" / "components"
46-
self.ionisium_components = self.ionisium_path / "templates" / "components"
47-
self.costcompiler_components = self.costcompiler_path / "templates" / "components"
46+
self.ionisium_components = self.ionisium_path / "components"
47+
self.costcompiler_components = self.costcompiler_path / "components"
4848

4949
# Projects mapping
5050
self.projects = {

src/htpy_uikit/components/card.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def card(
9191
nodes.append(header(class_=header_classes)[*header_children])
9292

9393
# Section
94-
sec_classes = ""
94+
sec_classes = "flex flex-col gap-6"
9595
if section_class:
9696
sec_classes = f"{sec_classes} {section_class}"
9797
nodes.append(section(class_=sec_classes)[children])

src/htpy_uikit/components/textarea.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def textarea_component(
5353
"border-input placeholder:text-muted-foreground focus-visible:border-ring "
5454
"focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 "
5555
"dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive "
56-
"dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md "
56+
"dark:bg-input/30 flex min-h-16 w-full rounded-md field-sizing-content"
5757
"border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] "
5858
"outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm"
5959
)

src/htpy_uikit/components/tooltip.py

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from htpy import Node
22
from htpy import Renderable
33
from htpy import span
4+
from htpy import template
45
from htpy import with_children
56
from markupsafe import Markup
67
from sourcetypes import js
@@ -50,6 +51,19 @@ def tooltip(
5051
style: '',
5152
side: '{side}',
5253
align: '{align}',
54+
_raf: null,
55+
schedule() {{
56+
cancelAnimationFrame(this._raf || 0);
57+
this._raf = requestAnimationFrame(() => {{
58+
this.update();
59+
// Run a second time next frame to account for late layout/teleport
60+
this._raf = requestAnimationFrame(() => this.update());
61+
}});
62+
}},
63+
cancel() {{
64+
cancelAnimationFrame(this._raf || 0);
65+
this._raf = null;
66+
}},
5367
update() {{
5468
const trigger = this.$refs.trigger;
5569
const bubble = this.$refs.bubble;
@@ -96,12 +110,12 @@ def tooltip(
96110
"class_": merge_classes("relative inline-block w-fit", class_),
97111
"x-ref": "trigger",
98112
"x-data": Markup(x_data),
99-
"@mouseenter": "open = true; $nextTick(() => update())",
100-
"@mouseleave": "open = false",
101-
"@focus": "open = true; $nextTick(() => update())",
102-
"@blur": "open = false",
103-
"@resize.window": "open && update()",
104-
"@scroll.window": "open && update()",
113+
"@mouseenter": "open = true; $nextTick(() => schedule())",
114+
"@mouseleave": "open = false; cancel()",
115+
"@focus": "open = true; $nextTick(() => schedule())",
116+
"@blur": "open = false; cancel()",
117+
"@resize.window": "open && schedule()",
118+
"@scroll.window": "open && schedule()",
105119
"tabindex": "0",
106120
"aria-describedby": "",
107121
}
@@ -124,5 +138,6 @@ def tooltip(
124138

125139
# Create elements
126140
bubble = span(**bubble_attrs, **attrs)[content]
141+
teleported = template(x_teleport="body")[bubble]
127142

128-
return span(**wrapper_attrs)[children, bubble]
143+
return span(**wrapper_attrs)[children, teleported]

0 commit comments

Comments
 (0)