Преглед изворни кода

#439 add documentation for ui.element

Falko Schindler пре 2 година
родитељ
комит
49f73eda79
3 измењених фајлова са 10 додато и 3 уклоњено
  1. 3 3
      nicegui/element.py
  2. 1 0
      website/documentation.py
  3. 6 0
      website/more_documentation/element_documentation.py

+ 3 - 3
nicegui/element.py

@@ -1,7 +1,6 @@
 from __future__ import annotations
 
 import re
-from abc import ABC
 from copy import deepcopy
 from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional, Union
 
@@ -20,12 +19,13 @@ if TYPE_CHECKING:
 PROPS_PATTERN = re.compile(r'([\w\-]+)(?:=(?:("[^"\\]*(?:\\.[^"\\]*)*")|([\w\-.%:\/]+)))?(?:$|\s)')
 
 
-class Element(ABC, Visibility):
+class Element(Visibility):
 
     def __init__(self, tag: str, *, _client: Optional[Client] = None) -> None:
         """Generic Element
 
-        This class is also the base class for all other elements.
+        This class is the base class for all other UI elements.
+        But you can use it to create elements with arbitrary HTML tags.
 
         :param tag: HTML tag of the element
         :param _client: client for this element (for internal use only)

+ 1 - 0
website/documentation.py

@@ -79,6 +79,7 @@ def create_full(menu: ui.element) -> None:
     load_demo(ui.date)
     load_demo(ui.time)
     load_demo(ui.upload)
+    load_demo(ui.element)
 
     heading('Markdown and HTML')
 

+ 6 - 0
website/more_documentation/element_documentation.py

@@ -0,0 +1,6 @@
+from nicegui import ui
+
+
+def main_demo() -> None:
+    with ui.element('div').classes('p-2 bg-blue-100'):
+        ui.label('inside a colored div')