Explorar o código

began with ui.colors command to change the look

Rodja Trappe %!s(int64=3) %!d(string=hai) anos
pai
achega
03404252dc
Modificáronse 3 ficheiros con 42 adicións e 0 borrados
  1. 12 0
      nicegui/elements/colors.js
  2. 29 0
      nicegui/elements/colors.py
  3. 1 0
      nicegui/ui.py

+ 12 - 0
nicegui/elements/colors.js

@@ -0,0 +1,12 @@
+Vue.component("colors", {
+  template: `<span v-bind:id="jp_props.id" :class="jp_props.classes" :style="jp_props.style"></span>`,
+  mounted() {
+    var colors = this.$props.jp_props.options;
+    for (var color in colors) {
+      document.body.style.setProperty("--q-color-" + color, colors[color]);
+    }
+  },
+  props: {
+    jp_props: Object,
+  },
+});

+ 29 - 0
nicegui/elements/colors.py

@@ -0,0 +1,29 @@
+from operator import neg
+from turtle import pos
+from .custom_view import CustomView
+from .element import Element
+
+class ColorsView(CustomView):
+
+    def __init__(self, primary, secondary, accent, positive, negative, info, warning):
+        super().__init__('colors', __file__,
+                         primary=primary,
+                         secondary=secondary,
+                         accent=accent,
+                         positive=positive,
+                         negative=negative,
+                         info=info,
+                         warning=warning)
+        self.initialize(temp=False)
+
+class Colors(Element):
+
+    def __init__(self, *,
+                 primary='#1976d2',
+                 secondary='#26a69a',
+                 accent='#9c27b0',
+                 positive='#21ba45',
+                 negative='#c10015',
+                 info='#31ccec',
+                 warning='#f2c037'):
+        super().__init__(ColorsView(primary, secondary, accent, positive, negative, info, warning))

+ 1 - 0
nicegui/ui.py

@@ -30,6 +30,7 @@ class Ui:
     from .elements.switch import Switch as switch
     from .elements.toggle import Toggle as toggle
     from .elements.upload import Upload as upload
+    from .elements.colors import Colors as colors
 
     from .elements.plot import Plot as plot
     from .elements.line_plot import LinePlot as line_plot