IconsHelper can support NotStr icons

This commit is contained in:
2026-02-24 22:38:08 +01:00
parent 5dc4fbae25
commit b383b1bc8b
2 changed files with 5 additions and 39 deletions

View File

@@ -153,43 +153,6 @@ class HierarchicalCanvasGraph(MultipleInstance):
""" """
return self._state return self._state
# def get_selected_id(self) -> Optional[str]:
# """Get the currently selected node ID.
#
# Returns:
# str or None: The selected node ID, or None if no selection
# """
# return self._state.ns_selected_id
#
# def set_collapsed(self, node_ids: set):
# """Set the collapsed state of nodes.
#
# Args:
# node_ids: Set of node IDs to mark as collapsed
# """
# self._state.collapsed = list(node_ids)
# logger.debug(f"set_collapsed: {len(node_ids)} nodes collapsed")
#
# def toggle_node(self, node_id: str):
# """Toggle the collapsed state of a node.
#
# Args:
# node_id: The ID of the node to toggle
#
# Returns:
# self: For chaining
# """
# collapsed_set = set(self._state.collapsed)
# if node_id in collapsed_set:
# collapsed_set.remove(node_id)
# logger.debug(f"toggle_node: expanded {node_id}")
# else:
# collapsed_set.add(node_id)
# logger.debug(f"toggle_node: collapsed {node_id}")
#
# self._state.collapsed = list(collapsed_set)
# return self
def handle_update_view_state(self, transform: Optional[dict] = None, layout_mode: Optional[str] = None): def handle_update_view_state(self, transform: Optional[dict] = None, layout_mode: Optional[str] = None):
"""Internal handler to update view state from client. """Internal handler to update view state from client.

View File

@@ -1,6 +1,7 @@
import pandas as pd import pandas as pd
from fasthtml.components import * from fasthtml.components import *
from myfasthtml.controls.IconsHelper import IconsHelper
from myfasthtml.core.bindings import Binding from myfasthtml.core.bindings import Binding
from myfasthtml.core.commands import Command, CommandTemplate from myfasthtml.core.commands import Command, CommandTemplate
from myfasthtml.core.constants import ColumnType from myfasthtml.core.constants import ColumnType
@@ -48,7 +49,7 @@ class mk:
) )
@staticmethod @staticmethod
def icon(icon, def icon(icon=None,
size=20, size=20,
can_select=True, can_select=True,
can_hover=False, can_hover=False,
@@ -83,12 +84,14 @@ class mk:
'flex items-center justify-center', 'flex items-center justify-center',
cls, cls,
kwargs) kwargs)
icon_to_use = icon or (command.icon if command else IconsHelper.get("QuestionMark"))
tooltip = tooltip or (command.description if command else None)
if tooltip: if tooltip:
merged_cls = merge_classes(merged_cls, "mf-tooltip") merged_cls = merge_classes(merged_cls, "mf-tooltip")
kwargs["data-tooltip"] = tooltip kwargs["data-tooltip"] = tooltip
return mk.mk(Div(icon, cls=merged_cls, **kwargs), command=command, binding=binding) return mk.mk(Div(icon_to_use, cls=merged_cls, **kwargs), command=command, binding=binding)
@staticmethod @staticmethod
def label(text: str, def label(text: str,