Skip to content

Commit

Permalink
code review
Browse files Browse the repository at this point in the history
  • Loading branch information
falkoschindler committed Oct 2, 2023
1 parent adf4dd1 commit 2d753eb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
3 changes: 1 addition & 2 deletions nicegui/elements/icon.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Optional

from .mixins.name_element import NameElement
from .mixins.color_elements import TextColorElement
from .mixins.name_element import NameElement


class Icon(NameElement, TextColorElement):
Expand All @@ -23,7 +23,6 @@ def __init__(self,
:param color: icon color (either a Quasar, Tailwind, or CSS color or `None`, default: `None`)
"""
super().__init__(tag='q-icon', name=name, text_color=color)
self._props['name'] = name

if size:
self._props['size'] = size
10 changes: 3 additions & 7 deletions nicegui/elements/mixins/name_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ class NameElement(Element):

def __init__(self, *, name: str, **kwargs: Any) -> None:
super().__init__(**kwargs)
self.name = name
self._props['name'] = name
self._name_to_model_name(name)

def bind_name_to(self,
target_object: Any,
Expand Down Expand Up @@ -69,16 +69,12 @@ def set_name(self, name: str) -> None:
:param name: The new name.
"""
self._props['name'] = name
self.update()
self.name = name

def on_name_change(self, name: str) -> None:
"""Called when the name of this element changes.
:param name: The new name.
"""
self._name_to_model_name(name)
self.update()

def _name_to_model_name(self, name: str) -> None:
self._props['name'] = name
self.update()

0 comments on commit 2d753eb

Please sign in to comment.