Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@

Release 1.3.6
=========================================

* **BUGFIX:** Adding missing ``menu...Style`` properties to `Navigation` class (#95).

---------------------

Release 1.3.5
=========================================

Expand Down
2 changes: 1 addition & 1 deletion highcharts_core/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.3.5'
__version__ = '1.3.6'
85 changes: 84 additions & 1 deletion highcharts_core/options/navigation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,19 @@ 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)
self.bindings_class_name = kwargs.get('bindings_class_name', None)
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)

Expand Down Expand Up @@ -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 <python:str>` or :class:`dict <python:dict>` or :obj:`None <python: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 <python:str>` or :class:`dict <python:dict>` or :obj:`None <python: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 <python:str>` or :class:`dict <python:dict>` or :obj:`None <python: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 = {
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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),
}
Expand Down
20 changes: 19 additions & 1 deletion tests/input_files/navigation/navigation/01.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
}
5 changes: 4 additions & 1 deletion tests/options/navigation/test_navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
]

Expand Down