From 2c9724571349efdbe5f2f95b04822f490527ad20 Mon Sep 17 00:00:00 2001 From: tlakshmi Date: Mon, 21 Oct 2024 13:39:21 +0200 Subject: [PATCH 1/8] refactoring node colors --- pyironflow/reactflow.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyironflow/reactflow.py b/pyironflow/reactflow.py index f067e54..b9a7104 100644 --- a/pyironflow/reactflow.py +++ b/pyironflow/reactflow.py @@ -1,5 +1,6 @@ from pyiron_workflow import Workflow from pyiron_workflow.channels import NotData +from pyironflow.themes import node_color import anywidget import pathlib @@ -145,7 +146,7 @@ def get_node_dict(node, id_num, key=None): 'type': 'customNode', 'style': {'border': '1px black solid', 'padding': 5, - 'background': '#1999', # node.gui_color, # This requires Tara's branch of pyiron_workflow + 'background': node_color(node=node, theme='light'), 'borderRadius': '10px', 'width': f'{node_width}px'}, 'targetPosition': 'left', From 4065b45d620467a5b3af8fe097287bd42b54dce3 Mon Sep 17 00:00:00 2001 From: tlakshmi Date: Mon, 21 Oct 2024 13:40:10 +0200 Subject: [PATCH 2/8] add themes.py --- pyironflow/themes.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 pyironflow/themes.py diff --git a/pyironflow/themes.py b/pyironflow/themes.py new file mode 100644 index 0000000..e586516 --- /dev/null +++ b/pyironflow/themes.py @@ -0,0 +1,22 @@ +from pyiron_workflow.nodes.function import Function +from pyiron_workflow.nodes.macro import Macro +from pyiron_workflow.nodes.transform import DataclassNode + + +def node_color(node, theme): + + if theme == 'light': + return light_mode(node) + +def light_mode(node): + if isinstance(node, Function): + color_light_green = "#a2ea9f" + return color_light_green + elif isinstance(node, Macro): + color_light_orange = "#eacf9f" + return color_light_orange + elif isinstance(node, DataclassNode): + color_light_purple = "#cb9fea" + return color_light_purple + else: + return node.color From 0dd4fa34b384e58f5748083c6e71f22716b400e4 Mon Sep 17 00:00:00 2001 From: Tarakeshwar Lakshmipathy <87063936+Tara-Lakshmipathy@users.noreply.github.com> Date: Mon, 21 Oct 2024 15:13:18 +0200 Subject: [PATCH 3/8] Update pyironflow/themes.py Co-authored-by: Liam Huber --- pyironflow/themes.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyironflow/themes.py b/pyironflow/themes.py index e586516..da75598 100644 --- a/pyironflow/themes.py +++ b/pyironflow/themes.py @@ -1,3 +1,5 @@ +import typing + from pyiron_workflow.nodes.function import Function from pyiron_workflow.nodes.macro import Macro from pyiron_workflow.nodes.transform import DataclassNode From b61584166826e1e0ef736adedab5bc4f1a587af7 Mon Sep 17 00:00:00 2001 From: Tarakeshwar Lakshmipathy <87063936+Tara-Lakshmipathy@users.noreply.github.com> Date: Mon, 21 Oct 2024 15:13:30 +0200 Subject: [PATCH 4/8] Update pyironflow/themes.py Co-authored-by: Liam Huber --- pyironflow/themes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyironflow/themes.py b/pyironflow/themes.py index da75598..1927494 100644 --- a/pyironflow/themes.py +++ b/pyironflow/themes.py @@ -10,7 +10,7 @@ def node_color(node, theme): if theme == 'light': return light_mode(node) -def light_mode(node): +def light_mode(node: Node): if isinstance(node, Function): color_light_green = "#a2ea9f" return color_light_green From c85ef1a09c996eb1dc3f565ab87a7a65d9c120cb Mon Sep 17 00:00:00 2001 From: Tarakeshwar Lakshmipathy <87063936+Tara-Lakshmipathy@users.noreply.github.com> Date: Mon, 21 Oct 2024 15:14:21 +0200 Subject: [PATCH 5/8] Update pyironflow/themes.py Co-authored-by: Liam Huber --- pyironflow/themes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyironflow/themes.py b/pyironflow/themes.py index 1927494..cefabe5 100644 --- a/pyironflow/themes.py +++ b/pyironflow/themes.py @@ -5,7 +5,7 @@ from pyiron_workflow.nodes.transform import DataclassNode -def node_color(node, theme): +def get_color(node: Node, theme: typing.Literal['light']): if theme == 'light': return light_mode(node) From 48b15b37d3668c7fb00168e557d80435a75ee59b Mon Sep 17 00:00:00 2001 From: Tarakeshwar Lakshmipathy <87063936+Tara-Lakshmipathy@users.noreply.github.com> Date: Mon, 21 Oct 2024 15:14:29 +0200 Subject: [PATCH 6/8] Update pyironflow/themes.py Co-authored-by: Liam Huber --- pyironflow/themes.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pyironflow/themes.py b/pyironflow/themes.py index cefabe5..510c20e 100644 --- a/pyironflow/themes.py +++ b/pyironflow/themes.py @@ -4,6 +4,9 @@ from pyiron_workflow.nodes.macro import Macro from pyiron_workflow.nodes.transform import DataclassNode +if typing.TYPE_CHECKING: + from pyiron_workflow.node import Node + def get_color(node: Node, theme: typing.Literal['light']): From bfe48ca995ea4195f46cfed5fa001b69b03c7a69 Mon Sep 17 00:00:00 2001 From: Tarakeshwar Lakshmipathy <87063936+Tara-Lakshmipathy@users.noreply.github.com> Date: Mon, 21 Oct 2024 15:14:41 +0200 Subject: [PATCH 7/8] Update pyironflow/themes.py Co-authored-by: Liam Huber --- pyironflow/themes.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyironflow/themes.py b/pyironflow/themes.py index 510c20e..cf18916 100644 --- a/pyironflow/themes.py +++ b/pyironflow/themes.py @@ -12,6 +12,8 @@ def get_color(node: Node, theme: typing.Literal['light']): if theme == 'light': return light_mode(node) + else: + raise ValueError(f'Theme must be one of ("light",) but got {theme}') def light_mode(node: Node): if isinstance(node, Function): From 7351a9fc04c53b2d1faa0b1719c5f5363a45b21e Mon Sep 17 00:00:00 2001 From: Tarakeshwar Lakshmipathy <87063936+Tara-Lakshmipathy@users.noreply.github.com> Date: Mon, 21 Oct 2024 15:16:42 +0200 Subject: [PATCH 8/8] Update reactflow.py --- pyironflow/reactflow.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyironflow/reactflow.py b/pyironflow/reactflow.py index b9a7104..91c9e5a 100644 --- a/pyironflow/reactflow.py +++ b/pyironflow/reactflow.py @@ -1,6 +1,6 @@ from pyiron_workflow import Workflow from pyiron_workflow.channels import NotData -from pyironflow.themes import node_color +from pyironflow.themes import get_color import anywidget import pathlib @@ -146,7 +146,7 @@ def get_node_dict(node, id_num, key=None): 'type': 'customNode', 'style': {'border': '1px black solid', 'padding': 5, - 'background': node_color(node=node, theme='light'), + 'background': get_color(node=node, theme='light'), 'borderRadius': '10px', 'width': f'{node_width}px'}, 'targetPosition': 'left',