Skip to content

Commit 35a7218

Browse files
committed
fix better system color + Swiper (not in ui.ALL)
1 parent d946840 commit 35a7218

File tree

9 files changed

+178
-23
lines changed

9 files changed

+178
-23
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,22 @@ This component should be embbeded in an element which have a constraint on its h
336336

337337
Note that the list is a list of lambda (`List[Callable[[], Tag]]`) to create the rendering on-demand.
338338

339+
340+
## Object Swipper
341+
342+
**IMPORTANT** : not included in default (`ui.ALL`). If you want to use it, you must include it, like that `imports=ui.ALL + [ui.Swiper] ` (because +170ko). TODO: need to find a clever soluce ;-)
343+
344+
A component to use a Swiper (https://swiperjs.com/).
345+
346+
```python
347+
348+
ll=[lambda i=i: MyObject(i) for i in range(1,200_000)] # slide created on demand
349+
# or ll=[MyObject(i) for i in range(1,20)] # concrete slides
350+
self <= ui.Swiper(ll, default=0)
351+
352+
```
353+
354+
339355
## utilities methods
340356

341357
### hflex & vflex

htagui/all.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
from .ifields import IText,ITextarea,IRange,IBool,ISelect,IRadios
1818
from .fileupload import FileUpload
1919
from .containers import VScroll,VScrollPager
20-
from .sortables import Sortable
20+
from .sortables import Sortable
21+
from .swipers import Swiper
2122
class App(Tag.body):
2223
_ui=None
2324

@@ -30,5 +31,10 @@ def ui(self):
3031
# global methods
3132
from .flex import hflex,vflex # utilities (Htag contructor methods)
3233

33-
34+
# Swiper not inluded by default !!!!!
35+
# Swiper not inluded by default !!!!! (coz +170ko)
36+
# Swiper not inluded by default !!!!!
3437
ALL=[App,Form,Tabs,Dialog,HSplit,VSplit,IText,ITextarea,IRange,IBool,ISelect,IRadios,FileUpload,Sortable,VScroll,VScrollPager]
38+
# Swiper not inluded by default !!!!!
39+
# Swiper not inluded by default !!!!!
40+
# Swiper not inluded by default !!!!!

htagui/basics/bases.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
.menu > div {
7878
padding:8px;
7979
cursor:pointer;
80-
background:white;
80+
background:Canvas;
8181
}
8282
.menu > div:hover {
8383
filter: brightness(0.95);
@@ -88,7 +88,7 @@
8888
border:0px;
8989
cursor:pointer;
9090
margin:2px;
91-
background:white;
91+
background:Canvas;
9292
padding:8px;
9393
font-family: ubuntu,'Helvetica';
9494
}
@@ -294,16 +294,16 @@ def init(self,metatag,obj):
294294
self["style"].set("right","0px")
295295
self["style"].set("left","0px")
296296
self["style"].set("z-index","500")
297-
self["style"].set("background","white")
297+
self["style"].set("background","Canvas")
298298
self <= obj
299299

300300

301301
class ModalAlert(ModalBlock):
302302
def __init__(self,metatag,obj,wsize:float=None):
303303
if wsize is None: wsize=0.6
304304
pwidth=f"{int(wsize*100)}%"
305-
bc = Tag.button("X",_onclick=metatag.stepevent(),_style="float:right;border-radius:50%;border:0px;cursor:pointer;background:white")
306-
box = Tag.div( [bc,obj],_style=f"width:{pwidth};max-height:80%;background:white;overflow-y: auto;background:white;border-radius:6px;box-shadow: rgba(0, 0, 0, 0.35) 0px 5px 15px;padding:10px",_onmousedown="event.stopPropagation();")
305+
bc = Tag.button("X",_onclick=metatag.stepevent(),_style="float:right;border-radius:50%;border:0px;cursor:pointer;background:Canvas")
306+
box = Tag.div( [bc,obj],_style=f"width:{pwidth};max-height:80%;background:Canvas;overflow-y: auto;border-radius:6px;box-shadow: rgba(0, 0, 0, 0.35) 0px 5px 15px;padding:10px",_onmousedown="event.stopPropagation();")
307307
ModalBlock.__init__(self,metatag,box)
308308
self.childs[1]["onmousedown"]=metatag.stepevent()
309309

@@ -346,7 +346,7 @@ def init(self,metatag,obj,mode:str):
346346
t,r,b,l= ("0px","0px",f"{size}%","0px")
347347

348348
self <= Voile(_onmousedown=metatag.stepevent())
349-
self <= Tag.div( obj ,_style=f"position:fixed;top:{t};bottom:{b};left:{l};right:{r};background:white;border-radius:0px;box-shadow: rgba(0, 0, 0, 0.35) 0px 5px 15px;;z-index:1001;padding:10px")
349+
self <= Tag.div( obj ,_style=f"position:fixed;top:{t};bottom:{b};left:{l};right:{r};background:Canvas;border-radius:0px;box-shadow: rgba(0, 0, 0, 0.35) 0px 5px 15px;;z-index:1001;padding:10px")
350350

351351
class Pop(Tag.div):
352352
def init(self,metatag,obj,xy:tuple):
@@ -369,7 +369,7 @@ def init(self,metatag,obj,xy:tuple):
369369

370370
class Toast(Tag.div):
371371
def init(self,main_non_used,obj,timeout=1000):
372-
self <= Tag.div(obj,_style="position:fixed;right:10px;bottom:10px;z-index:1001;background:white;padding:10px;border:2px solid black;border-radius:10px;min-width:200px")
372+
self <= Tag.div(obj,_style="position:fixed;right:10px;bottom:10px;z-index:1001;background:Canvas;padding:10px;border:2px solid black;border-radius:10px;min-width:200px")
373373
self.js="setTimeout( function() {self.remove()} , %s)" % timeout
374374

375375
######################################################################################

htagui/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class Choose(Tag.div):
9797
def init(self,main):
9898
" all the ui logic goes here "
9999
for i in main.all:
100-
self <= Tag.button(i, _onclick = main.stepevent(select=i),_style="background:white;cursor:pointer;border:1px dotted #CCC")
100+
self <= Tag.button(i, _onclick = main.stepevent(select=i),_style="background:Canvas;cursor:pointer;border:1px dotted #CCC")
101101
class Current(Tag.div):
102102
def init(self,main,val):
103103
" all the ui logic goes here "

htagui/fluent/bases.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
border:0px;
2929
cursor:pointer;
3030
margin:2px;
31-
background:white;
31+
background:Canvas;
3232
padding:8px;
3333
font-family: ubuntu;
3434
}
@@ -138,7 +138,7 @@ def init(self,metatag,obj):
138138
self["style"].set("right","0px")
139139
self["style"].set("left","0px")
140140
self["style"].set("z-index","500")
141-
self["style"].set("background","white")
141+
self["style"].set("background","Canvas")
142142
self <= obj
143143

144144

@@ -147,8 +147,8 @@ def init(self,metatag,obj,wsize:float=None):
147147
if wsize is not None:
148148
self["style"].set("--dialog-width",f"{int(wsize*100)}%")
149149
self["style"].set("--dialog-height","auto")
150-
bc = Tag.button("X",_onclick=metatag.stepevent(),_style="float:right;border-radius:50%;border:0px;cursor:pointer;background:white")
151-
box = Tag.div( obj,_style=f"background:white;overflow-y:auto;background:white;margin:10px;",_onmousedown="event.stopPropagation();")
150+
bc = Tag.button("X",_onclick=metatag.stepevent(),_style="float:right;border-radius:50%;border:0px;cursor:pointer;background:Canvas")
151+
box = Tag.div( obj,_style=f"background:Canvas;overflow-y:auto;margin:10px;",_onmousedown="event.stopPropagation();")
152152
self <= bc+box
153153

154154
#~ self.childs[1]["onmousedown"]=metatag.stepevent()
@@ -197,7 +197,7 @@ def init(self,metatag,obj,mode:str):
197197
t,r,b,l= ("0px","0px",f"{size}%","0px")
198198

199199
self <= Voile(_onmousedown=metatag.stepevent())
200-
self <= Tag.div( obj ,_style=f"position:fixed;top:{t};bottom:{b};left:{l};right:{r};background:white;border-radius:0px;box-shadow: rgba(0, 0, 0, 0.35) 0px 5px 15px;;z-index:1001;padding:10px")
200+
self <= Tag.div( obj ,_style=f"position:fixed;top:{t};bottom:{b};left:{l};right:{r};background:Canvas;border-radius:0px;box-shadow: rgba(0, 0, 0, 0.35) 0px 5px 15px;;z-index:1001;padding:10px")
201201

202202

203203
class Pop(Tag.div):
@@ -222,7 +222,7 @@ def init(self,metatag,obj,xy:tuple):
222222

223223
class Toast(Tag.div):
224224
def init(self,main_non_used,obj,timeout=1000):
225-
self <= Tag.div(obj,_style="position:fixed;right:10px;bottom:10px;z-index:1001;background:white;padding:10px;border:2px solid black;border-radius:10px;min-width:200px")
225+
self <= Tag.div(obj,_style="position:fixed;right:10px;bottom:10px;z-index:1001;background:Canvas;padding:10px;border:2px solid black;border-radius:10px;min-width:200px")
226226
self.js="setTimeout( function() {self.remove()} , %s)" % timeout
227227

228228
######################################################################################

htagui/md/bases.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ def init(self,metatag,obj):
215215
self["style"].set("right","0px")
216216
self["style"].set("left","0px")
217217
self["style"].set("z-index","500")
218-
self["style"].set("background","white")
218+
self["style"].set("background","Canvas")
219219
self <= obj
220220

221221

@@ -290,7 +290,7 @@ def init(self,metatag,obj,mode:str):
290290
t,r,b,l= ("0px","0px",f"{size}%","0px")
291291

292292
self <= Voile(_onmousedown=metatag.stepevent())
293-
self <= Tag.div( obj ,_style=f"position:fixed;top:{t};bottom:{b};left:{l};right:{r};background:white;border-radius:0px;box-shadow: rgba(0, 0, 0, 0.35) 0px 5px 15px;;z-index:1001;padding:10px")
293+
self <= Tag.div( obj ,_style=f"position:fixed;top:{t};bottom:{b};left:{l};right:{r};background:Canvas;border-radius:0px;box-shadow: rgba(0, 0, 0, 0.35) 0px 5px 15px;;z-index:1001;padding:10px")
294294

295295
class Pop(Tag.div):
296296
def init(self,metatag,obj,xy:tuple):
@@ -306,14 +306,14 @@ def init(self,metatag,obj,xy:tuple):
306306
let h=tag.clientHeight;
307307
if(x+w > bw) x=bw-w;
308308
if(y+h > bh) y=bh-h;
309-
tag.style="position:fixed;z-index:2001;padding:2px;left:"+x+"px;top:"+y+"px;background:white";
309+
tag.style="position:fixed;z-index:2001;padding:2px;left:"+x+"px;top:"+y+"px;background:Canvas";
310310
},0);
311311
})(self,%s,%s)""" % (x,y)
312312

313313
self <= Tag.div( obj ,js=js)
314314
class Toast(Tag.div):
315315
def init(self,main_non_used,obj,timeout=1000):
316-
self["style"]="position:fixed;right:10px;bottom:10px;z-index:1001;border:2px solid black;background:white;padding:10px";
316+
self["style"]="position:fixed;right:10px;bottom:10px;z-index:1001;border:2px solid black;background:Canvas;padding:10px";
317317
self <= obj
318318
self.js="setTimeout( function() {self.remove()} , %s)" % timeout
319319

htagui/shoelace/bases.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def init(self,metatag,obj):
141141
self["style"].set("right","0px")
142142
self["style"].set("left","0px")
143143
self["style"].set("z-index","500")
144-
self["style"].set("background","white")
144+
self["style"].set("background","Canvas")
145145
self <= obj
146146

147147
class ModalAlert(Tag.sl_dialog):
@@ -162,7 +162,7 @@ def init(self,metatag,obj,closable=True,wsize:float=None):
162162
%s;
163163
});""" % metatag.bind.step()
164164
if closable:
165-
bc=Tag.button("X",_onclick = self.close,_style="float:right;border-radius:50%;border:0px;cursor:pointer;background:white")
165+
bc=Tag.button("X",_onclick = self.close,_style="float:right;border-radius:50%;border:0px;cursor:pointer;background:Canvas")
166166
self <= [bc,obj]
167167
else:
168168
self <= obj

htagui/swipers.py

Lines changed: 116 additions & 0 deletions
Large diffs are not rendered by default.

manual_tests.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,22 @@ def init(self,x):
263263
self <= Tag.div(_style="height:200px; border:1px solid red;" ) <= ui.VScrollPager([lambda i=i: O(i) for i in range(1,200)])
264264

265265

266+
class TestSwiper(Tag.div):
267+
def init(self,root):
268+
self.output=root.output
269+
270+
class Item(Tag.img):
271+
def init(self,i):
272+
self["src"]=f"https://loremflickr.com/400/400/colors?random={i}"
273+
self["style"]="width:100px;height:100px"
274+
self["onclick"] = self.cc
275+
276+
def cc(self,ev):
277+
print(ev)
278+
279+
self<= ui.Swiper([Item(i) for i in range(50)])
280+
self<= ui.Swiper([lambda i=i: Item(i) for i in range(50)])
281+
266282

267283
class App(ui.App):
268284
statics="""
@@ -271,7 +287,7 @@ class App(ui.App):
271287
hr {padding:0px !important;margin:4px !important;}
272288
"""
273289

274-
imports=ui.ALL
290+
imports=ui.ALL + [ui.Swiper]
275291
def init(self):
276292
self["class"]="content" # for bulma
277293

@@ -299,6 +315,7 @@ def setter(o,testobject):
299315
menu <= Tag.my("others",_onclick=lambda ev: setter(ev.target,TestOthers(self)) )
300316
menu <= Tag.my("Sortable",_onclick=lambda ev: setter(ev.target,TestSortable(self)) )
301317
menu <= Tag.my("VScroll",_onclick=lambda ev: setter(ev.target,TestVscroll(self)) )
318+
menu <= Tag.my("Swiper",_onclick=lambda ev: setter(ev.target,TestSwiper(self)) )
302319
self <= menu
303320
self <= Tag.hr()
304321
self <= self.omain

0 commit comments

Comments
 (0)