Skip to content

Commit 168c372

Browse files
committed
add ui.Input types : password, search, color
1 parent 0751667 commit 168c372

File tree

6 files changed

+25
-10
lines changed

6 files changed

+25
-10
lines changed

htagui/basics/bases.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
filter: brightness(0.95);
3636
}
3737
38-
.input[type="text"] {
38+
.input[type="text"],.input[type="search"],.input[type="password"] {
3939
font-family: ubuntu,'Helvetica';
4040
font-size: 1em;
4141
padding:6px;

htagui/bulma/bases.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def init(self,**a):
2424
if "type" not in self.attrs:
2525
self.attrs["type"]="text"
2626

27-
if self.attrs.get("type")=="text":
27+
if self.attrs.get("type") in ["text","search","password"]:
2828
self["class"].add("input")
2929

3030
self["placeholder"] = self.attrs.get("label")

htagui/fluent/bases.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,22 @@
3939
"""),
4040
]
4141

42-
4342
class Input(Tag.input):
4443
statics= STATICS
4544
def init(self,*a,**k):
46-
type=self.attrs.get("type")
47-
if type is None or type=="text":
45+
type=self.attrs.get("type") or "text"
46+
if type in ["text","search","password"]:
4847
self.tag = "fluent-text-field"
48+
self["type"]=type
4949
elif type=="checkbox":
5050
self.tag = "fluent-switch"
5151
elif type=="radio":
5252
self.tag = "fluent-radio"
5353
elif type=="range":
5454
self.tag = "fluent-slider"
5555

56+
self["placeholder"] = self.attrs.get("label")
57+
5658
class Textarea(Tag.fluent_text_area):
5759
statics=STATICS
5860
def init(self,txt:str,**a):

htagui/md/bases.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,11 @@ def init(self,**a):
7575
class Input(Tag.input):
7676
statics= STATICS
7777
def init(self,*a,**k):
78-
type=self.attrs.get("type")
79-
if type is None or type=="text":
78+
type=self.attrs.get("type") or "text"
79+
if type in ["text","search","password"]:
8080
self.tag = "md-filled-text-field"
8181
self["style"].set("width","calc(100% - 16px)")
82+
self["type"]=type
8283
elif type=="checkbox":
8384
self.tag = "md-switch"
8485
elif type=="radio":

htagui/shoelace/bases.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,10 @@
3838
class Input(Tag.input):
3939
statics= STATICS
4040
def init(self,*a,**k):
41-
type=self.attrs.get("type")
42-
if type is None or type=="text":
41+
type=self.attrs.get("type") or "text"
42+
if type in ["text","search","password"]:
4343
self.tag = "sl-input"
44+
self["type"]=type
4445
elif type=="checkbox":
4546
self.tag = "sl-switch"
4647
# self.tag = "sl-checkbox"

manual_tests.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,24 @@ def init(self, root, dynamic=False):
4444
ui.IRadios(3,OPTS, onchange=self.onchange_dynamic),
4545
]
4646
else:
47-
self.objects=[ # _onchange can't work sith shoelace !!!!
47+
self.objects=[
4848
ui.Input(_value="input", _onchange=self.bind( self.onchange_static, b"this.value"),_name="myinput",_label="myinput"),
4949
ui.Textarea("textarea", _onchange=self.bind( self.onchange_static, b"this.value"),_name="mytextarea" ,_label="mytextarea"),
5050
ui.Input(_type="checkbox",_checked=True, _onchange=self.bind( self.onchange_static, b"this.checked || this.selected"),_name="mycheckbox"), # selected for "MD" !!!!
5151
ui.Input(_type="range",_value=42, _onchange=self.bind( self.onchange_static, b"this.value"),_name="myrange"),
5252
ui.Select(OPTS,_value=2, _onchange=self.bind( self.onchange_static, b"this.value"),_name="myselect"),
5353
ui.Radios(OPTS,_value=2, _onchange=self.bind( self.onchange_static, b"this.value"),_name="myradios"),
54+
55+
56+
# more Specialized input types
57+
ui.Input(_type="search",_onchange=self.bind( self.onchange_static, b"this.value"),_name="mysearch",_label="mysearch"),
58+
ui.Input(_type="password",_onchange=self.bind( self.onchange_static, b"this.value"),_name="mypassword",_label="mypassword"),
59+
ui.Input(_type="color",_onchange=self.bind( self.onchange_static, b"this.value"),_name="mycolor"),
60+
# ui.Input(_type="date",_name="mydate"),
61+
# ui.Input(_type="month",_name="mymonth"),
62+
# ui.Input(_type="time",_name="mytime"),
63+
# ui.Input(_type="week",_name="myweek"),
64+
5465
]
5566

5667
self.omain=Tag.div()

0 commit comments

Comments
 (0)