Skip to content

Commit

Permalink
add color class and ui changes (#170)
Browse files Browse the repository at this point in the history
  • Loading branch information
khaxis committed May 27, 2023
1 parent 59d8325 commit bb1323c
Show file tree
Hide file tree
Showing 13 changed files with 244 additions and 12 deletions.
2 changes: 2 additions & 0 deletions plynx/constants/parameter_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ class ParameterTypes:
LIST_INT: str = 'list_int'
LIST_NODE: str = 'list_node'
CODE: str = 'code'
COLOR: str = 'color'


PRIMITIVE_TYPES = {
ParameterTypes.BOOL,
ParameterTypes.FLOAT,
ParameterTypes.INT,
ParameterTypes.STR,
ParameterTypes.COLOR,
}
2 changes: 2 additions & 0 deletions plynx/db/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,8 @@ def _get_default_by_type(parameter_type: str):
return ParameterListOfNodes()
elif parameter_type == ParameterTypes.CODE:
return ParameterCode()
elif parameter_type == ParameterTypes.COLOR:
return '#FF0000'
else:
return None

Expand Down
12 changes: 12 additions & 0 deletions plynx/demo/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def print_any(value):
@plynx.node.output(name='dict', var_type=dict)
@plynx.node.output(name='float', var_type=float)
@plynx.node.output(name='bool', var_type=bool)
@plynx.node.output(name='color', var_type="color")
@plynx.node.operation(
title="All types",
description="Echo all types",
Expand All @@ -27,6 +28,7 @@ def all_types():
"dict": {"foo": "woo"},
"float": math.pi,
"bool": True,
"color": "#FF0000",
}


Expand Down Expand Up @@ -75,6 +77,15 @@ def print_bool(value):
print_any(value)


@plynx.node.input(name='value', var_type="color")
@plynx.node.operation(
title="Print Color value",
)
def print_color(value):
"""Print input value."""
print_any(value)


@plynx.node.input(name='value', var_type="py-json-file")
@plynx.node.output(name='value', var_type=dict)
@plynx.node.operation(
Expand Down Expand Up @@ -108,6 +119,7 @@ def dict_to_file(value):
print_dict,
print_float,
print_bool,
print_color,
file_to_dict,
dict_to_file,
]
Expand Down
15 changes: 11 additions & 4 deletions plynx/plugins/resources/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,33 @@ class Raw(resource.BaseResource):
DISPLAY_RAW: bool = True


class RawInt(resource.BaseResource):
class RawInt(Raw):
"""Raw Resource that will store an integer in the Node."""
DISPLAY_RAW: bool = True

@staticmethod
def preprocess_input(value: Any) -> int:
"""Resource_id to an object"""
return int(value)


class RawFloat(resource.BaseResource):
class RawFloat(Raw):
"""Raw Resource that will store an integer in the Node."""
DISPLAY_RAW: bool = True

@staticmethod
def preprocess_input(value: Any) -> float:
"""Resource_id to an object"""
return float(value)


class RawColor(Raw):
"""Raw Resource that will store an integer in the Node."""

@staticmethod
def preprocess_input(value: Any) -> str:
"""Resource_id to an object"""
return str(value)


class File(resource.BaseResource):
"""Raw Resource that will be stored in the file format in the Node."""

Expand Down
92 changes: 92 additions & 0 deletions ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"react-alert-template-basic": "^1.0.2",
"react-beautiful-dnd": "^13.1.1",
"react-cache-buster": "^0.1.8",
"react-color": "^2.19.3",
"react-cookie": "^4.1.1",
"react-cookies": "^0.1.1",
"react-dev-utils": "^12.0.1",
Expand Down
4 changes: 4 additions & 0 deletions ui/src/components/Common/ParameterItem.css
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@
font-style: italic;
}

.ParameterValueCell > .input-button {
margin-left: 2pt;
}

.properties-list .option-block {
display: flex;
}
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {CODE_LANGUAGES, CODE_THEMES} from '../../constants';
import 'brace/ext/language_tools';
import 'brace/ext/searchbox';

import './CodeItem.css';
import './ValueCodeItem.css';

// Init react-ace

Expand All @@ -20,7 +20,7 @@ CODE_THEMES.forEach(theme => {

// Finish react-ace

export default class EnumItem extends Component {
export default class CodeItem extends Component {
static propTypes = {
name: PropTypes.string.isRequired,
readOnly: PropTypes.bool.isRequired,
Expand Down

0 comments on commit bb1323c

Please sign in to comment.