Просмотр исходного кода

experimental introduction of design enum to not apply default styling

Rodja Trappe 3 лет назад
Родитель
Сommit
e27b26c6c7
3 измененных файлов с 18 добавлено и 2 удалено
  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
 import justpy as jp
 from .group import Group
 from .group import Group
 
 
 class Card(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)
         super().__init__(view)

+ 5 - 0
nicegui/elements/element.py

@@ -1,3 +1,4 @@
+from enum import Enum
 import justpy as jp
 import justpy as jp
 from binding.binding import BindableProperty
 from binding.binding import BindableProperty
 
 
@@ -74,3 +75,7 @@ class Element:
                 setattr(self.view, prop, True)
                 setattr(self.view, prop, True)
 
 
         return self
         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.row import Row as row
     from .elements.column import Column as column
     from .elements.column import Column as column
     from .elements.card import Card as card
     from .elements.card import Card as card
+    from .elements.card import CardSection as card_section
 
 
     from .timer import Timer as timer
     from .timer import Timer as timer