From 369184129b8c8d1f6c56d231795ace97e9110446 Mon Sep 17 00:00:00 2001 From: Chris Modzelewski Date: Tue, 15 Aug 2023 12:19:54 -0400 Subject: [PATCH 1/2] Fixed missing properties in NavigationBase. Closes #95 --- .../options/navigation/__init__.py | 85 ++++++++++++++++++- tests/input_files/navigation/navigation/01.js | 20 ++++- tests/options/navigation/test_navigation.py | 5 +- 3 files changed, 107 insertions(+), 3 deletions(-) diff --git a/highcharts_core/options/navigation/__init__.py b/highcharts_core/options/navigation/__init__.py index 099718a5..abb6f5ef 100644 --- a/highcharts_core/options/navigation/__init__.py +++ b/highcharts_core/options/navigation/__init__.py @@ -23,6 +23,9 @@ def __init__(self, **kwargs): self._button_options = None self._events = None self._icons_url = None + self._menu_item_hover_style = None + self._menu_item_style = None + self._menu_style = None self.annotation_options = kwargs.get('annotation_options', None) self.bindings = kwargs.get('bindings', None) @@ -30,6 +33,9 @@ def __init__(self, **kwargs): self.button_options = kwargs.get('button_options', None) self.events = kwargs.get('events', None) self.icons_url = kwargs.get('icons_url', None) + self.menu_item_hover_style = kwargs.get('menu_item_hover_style', None) + self.menu_item_style = kwargs.get('menu_item_style', None) + self.menu_style = kwargs.get('menu_style', None) super().__init__(**kwargs) @@ -118,6 +124,74 @@ def icons_url(self) -> Optional[str]: def icons_url(self, value): self._icons_url = validators.string(value, allow_empty = True) + @property + def menu_item_hover_style(self) -> Optional[str | dict]: + """CSS styles for the individual items within the popup menu when the user's mouse hovers over them. + + .. note:: + + Font size defaults to 11px on desktop and 14px on touch devices. + + Defaults to: + ``{"background": "#f2f2f2" }``. + + :rtype: :class:`str ` or :class:`dict ` or :obj:`None ` + """ + return self._menu_item_hover_style + + @menu_item_hover_style.setter + def menu_item_hover_style(self, value): + try: + self._menu_item_hover_style = validators.dict(value, allow_empty = True) + except (ValueError, TypeError): + self._menu_item_hover_style = validators.string(value, + allow_empty = True, + coerce_value = True) + + @property + def menu_item_style(self) -> Optional[str | dict]: + """CSS styles for the individual items within the popup menu. + + .. note:: + + Font size defaults to 11px on desktop and 14px on touch devices. + + Defaults to: + ``{"padding": "0.5em", "color": "#333333", "background": "none", "borderRadius": "3px", "fontSize": "0.8em", "transition": "background 250ms, color 250ms"}``. + + :rtype: :class:`str ` or :class:`dict ` or :obj:`None ` + """ + return self._menu_item_style + + @menu_item_style.setter + def menu_item_style(self, value): + try: + self._menu_item_style = validators.dict(value, allow_empty = True) + except (ValueError, TypeError): + self._menu_item_style = validators.string(value, + allow_empty = True, + coerce_value = True) + + @property + def menu_style(self) -> Optional[str | dict]: + """CSS styles for the popup menu appearing when the popup button is clicked. + + Defaults to: + ``{"background": "#ffffff", "borderRadius": "3px", "padding": "0.5em"}``. + + :rtype: :class:`str ` or :class:`dict ` or :obj:`None ` + """ + return self._menu_style + + @menu_style.setter + def menu_style(self, value): + try: + self._menu_style = validators.dict(value, allow_empty = True) + except (ValueError, TypeError): + self._menu_style = validators.string(value, + allow_empty = True, + coerce_value = True) + @classmethod def _get_kwargs_from_dict(cls, as_dict): kwargs = { @@ -127,6 +201,9 @@ def _get_kwargs_from_dict(cls, as_dict): 'button_options': as_dict.get('buttonOptions', None), 'events': as_dict.get('events', None), 'icons_url': as_dict.get('iconsURL', None), + 'menu_item_hover_style': as_dict.get('menuItemHoverStyle', None), + 'menu_item_style': as_dict.get('menuItemStyle', None), + 'menu_style': as_dict.get('menuStyle', None), } return kwargs @@ -138,7 +215,10 @@ def _to_untrimmed_dict(self, in_cls = None) -> dict: 'bindingsClassName': self.bindings_class_name, 'buttonOptions': self.button_options, 'events': self.events, - 'iconsURL': self.icons_url + 'iconsURL': self.icons_url, + 'menuItemHoverStyle': self.menu_item_hover_style, + 'menuItemStyle': self.menu_item_style, + 'menuStyle': self.menu_style, } return untrimmed @@ -194,6 +274,9 @@ def _get_kwargs_from_dict(cls, as_dict): 'button_options': as_dict.get('buttonOptions', None), 'events': as_dict.get('events', None), 'icons_url': as_dict.get('iconsURL', None), + 'menu_item_hover_style': as_dict.get('menuItemHoverStyle', None), + 'menu_item_style': as_dict.get('menuItemStyle', None), + 'menu_style': as_dict.get('menuStyle', None), 'breadcrumbs': as_dict.get('breadcrumbs', None), } diff --git a/tests/input_files/navigation/navigation/01.js b/tests/input_files/navigation/navigation/01.js index 48e679dd..55d994c1 100644 --- a/tests/input_files/navigation/navigation/01.js +++ b/tests/input_files/navigation/navigation/01.js @@ -36,5 +36,23 @@ selectButton: function (event) {return true;}, showPopup: function(event) {return true;} }, - iconsURL: 'https://www.somewhere.com/' + iconsURL: 'https://www.somewhere.com/', + menuItemHoverStyle: { + 'color': '#5f5e5e', + 'fontFamily': 'Roboto', + 'fontSize': '12px', + 'fontWeight': '400' + }, + menuItemStyle: { + 'color': '#5f5e5e', + 'fontFamily': 'Roboto', + 'fontSize': '12px', + 'fontWeight': '400' + }, + menuStyle: { + 'color': '#5f5e5e', + 'fontFamily': 'Roboto', + 'fontSize': '12px', + 'fontWeight': '400' + } } diff --git a/tests/options/navigation/test_navigation.py b/tests/options/navigation/test_navigation.py index c2604e0a..9f330f67 100644 --- a/tests/options/navigation/test_navigation.py +++ b/tests/options/navigation/test_navigation.py @@ -93,7 +93,10 @@ 'selectButton': """function (event) {return true;}""", 'showPopup': """function(event) {return true;}""" }, - 'icons_url': 'https://www.somewhere.com/' + 'icons_url': 'https://www.somewhere.com/', + 'menu_item_style': {"fontWeight": "bold", "fontSize": "12px"}, + 'menu_item_hover_style': {"fontWeight": "bold", "fontSize": "12px"}, + 'menu_style': {"border-width": "1px"} }, None), ] From f38969ad8fd0e2bf0851e84e1b7084da1a82ac10 Mon Sep 17 00:00:00 2001 From: Chris Modzelewski Date: Tue, 15 Aug 2023 12:21:40 -0400 Subject: [PATCH 2/2] Bumped version number and updated changelog. --- CHANGES.rst | 7 +++++++ highcharts_core/__version__.py | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index d1754e43..e11f0e8a 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,4 +1,11 @@ +Release 1.3.6 +========================================= + +* **BUGFIX:** Adding missing ``menu...Style`` properties to `Navigation` class (#95). + +--------------------- + Release 1.3.5 ========================================= diff --git a/highcharts_core/__version__.py b/highcharts_core/__version__.py index 09d50a09..2686689d 100644 --- a/highcharts_core/__version__.py +++ b/highcharts_core/__version__.py @@ -1 +1 @@ -__version__ = '1.3.5' \ No newline at end of file +__version__ = '1.3.6' \ No newline at end of file