Browse Source

allow async for documentation

Rodja Trappe 2 năm trước cách đây
mục cha
commit
f3bbfa8a14
2 tập tin đã thay đổi với 22 bổ sung1 xóa
  1. 1 1
      website/demo.py
  2. 21 0
      website/more_documentation/icon_documentation.py

+ 1 - 1
website/demo.py

@@ -27,7 +27,7 @@ class demo:
     def __call__(self, f: Callable) -> Callable:
         with ui.column().classes('w-full items-stretch gap-8 no-wrap min-[1500px]:flex-row'):
             code = inspect.getsource(f).split('# END OF DEMO')[0].strip().splitlines()
-            while not code[0].strip().startswith('def'):
+            while not code[0].strip().startswith('def') and not code[0].strip().startswith('async def'):
                 del code[0]
             del code[0]
             indentation = len(code[0]) - len(code[0].lstrip())

+ 21 - 0
website/more_documentation/icon_documentation.py

@@ -1,5 +1,26 @@
 from nicegui import ui
+from website.documentation_tools import text_demo
 
 
 def main_demo() -> None:
     ui.icon('thumb_up')
+
+
+def more() -> None:
+    ui.add_head_html('<script src="https://unpkg.com/eva-icons"></script>')
+
+    @text_demo('Eva icons', '''
+        You can use [Eva icons](https://akveo.github.io/eva-icons/#/) in your app.
+    ''')
+    async def eva_icons():
+        from nicegui import Client
+
+        # @ui.page('/')
+        # async def main(client: Client):
+        #     ui.add_head_html('<script src="https://unpkg.com/eva-icons"></script>')
+        #     ui.element('i').props('data-eva="github"')
+        #     await client.connected()
+        #     await ui.run_javascript('eva.replace();', respond=False)
+        # END OF DEMO
+        ui.element('i').props('data-eva="github"')
+        await ui.run_javascript('eva.replace();', respond=False)