Sfoglia il codice sorgente

experimental introduction of design enum to not apply default styling

Rodja Trappe 3 anni fa
parent
commit
e27b26c6c7
3 ha cambiato i file con 18 aggiunte e 2 eliminazioni
  1. 12 2
      nicegui/elements/card.py
  2. 5 0
      nicegui/elements/element.py
  3. 1 0
      nicegui/ui.py

+ 12 - 2
nicegui/elements/card.py

@@ -1,8 +1,18 @@
+from nicegui.elements.element import Design
 import justpy as jp
 from .group import Group
 
 class Card(Group):
-    def __init__(self):
-        view = jp.QCard(classes='column items-start q-pa-md', style='gap: 1em', delete_flag=False)
+    def __init__(self, design: Design = Design.default):
+        if design == design.default:
+            view = jp.QCard(classes='column items-start q-pa-md', style='gap: 1em', delete_flag=False)
+        elif design == design.plain:
+            view = jp.QCard(delete_flag=False)
+        else:
+            raise Exception(f'unsupported design: {design}')
+        super().__init__(view)
 
+class CardSection(Group):
+    def __init__(self):
+        view = jp.QCardSection(delete_flag=False)
         super().__init__(view)

+ 5 - 0
nicegui/elements/element.py

@@ -1,3 +1,4 @@
+from enum import Enum
 import justpy as jp
 from binding.binding import BindableProperty
 
@@ -74,3 +75,7 @@ class Element:
                 setattr(self.view, prop, True)
 
         return self
+
+class Design(Enum):
+    default = 1
+    plain = 2

+ 1 - 0
nicegui/ui.py

@@ -34,6 +34,7 @@ class Ui:
     from .elements.row import Row as row
     from .elements.column import Column as column
     from .elements.card import Card as card
+    from .elements.card import CardSection as card_section
 
     from .timer import Timer as timer