Skip to content

Commit

Permalink
Merge pull request #26 from pyiron/node_colors_themes
Browse files Browse the repository at this point in the history
Node colors themes
  • Loading branch information
jan-janssen authored Oct 21, 2024
2 parents b0429b7 + 7351a9f commit 6b57239
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pyironflow/reactflow.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from pyiron_workflow import Workflow
from pyiron_workflow.channels import NotData
from pyironflow.themes import get_color

import anywidget
import pathlib
Expand Down Expand Up @@ -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': get_color(node=node, theme='light'),
'borderRadius': '10px',
'width': f'{node_width}px'},
'targetPosition': 'left',
Expand Down
29 changes: 29 additions & 0 deletions pyironflow/themes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import typing

from pyiron_workflow.nodes.function import Function
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']):

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):
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

0 comments on commit 6b57239

Please sign in to comment.