Skip to content

Commit

Permalink
add Grid Object
Browse files Browse the repository at this point in the history
  • Loading branch information
manatlan committed Sep 21, 2024
1 parent 9c1818e commit 821f87f
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,4 @@ cython_debug/
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
poetry.lock
htagui/swipers2.py
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,20 @@ self <= ui.Button("p1", _onclick = lambda ev: v.go( Tag.div("p1") ))
self <= ui.Button("p2", _onclick = lambda ev: v.go( Tag.div("p2") ))
self <= v
```
## Object Grid

signature : Grid(format,vformat="auto",gap="1px",**a)

A simple grid container

example:
```python

g = Grid("1fr 1fr 2fr")
g <= Tag.div( "2colums",_style="grid-column:1 / 3")
g <= Tag.div( "1column")

```


## utilities methods
Expand Down
4 changes: 2 additions & 2 deletions htagui/all.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from .splitters import HSplit, VSplit
from .ifields import IText,ITextarea,IRange,IBool,ISelect,IRadios
from .fileupload import FileUpload
from .containers import VScroll,VScrollPager, View
from .containers import VScroll,VScrollPager, View, Grid
from .sortables import Sortable
from .swipers import Swiper
from .javascripts import JSKEYABLE
Expand All @@ -34,5 +34,5 @@ def ui(self):

# Swiper not inluded by default !!!!!

ALL=[JSKEYABLE, App,Form,Tabs,Dialog,HSplit,VSplit,IText,ITextarea,IRange,IBool,ISelect,IRadios,FileUpload,Sortable,VScroll,VScrollPager,View]
ALL=[JSKEYABLE, App,Form,Tabs,Dialog,HSplit,VSplit,IText,ITextarea,IRange,IBool,ISelect,IRadios,FileUpload,Sortable,VScroll,VScrollPager,View,Grid]
FULL=ALL+[Swiper] # Swiper not inluded by default !!!!! (coz +170ko)
11 changes: 11 additions & 0 deletions htagui/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,14 @@ def go(self,tag,anchor=None):
self._refs[f'#{anchor}'] = tag
self.call( f"document.location=`#{anchor}`")

class Grid(Tag.div):
"""
g = Grid("2fr 1fr 1fr")
g <= Tag.div( "2colums",_style="grid-column:1 / 3")
g <= Tag.div( "1column")
"""
def init(self,format,vformat="auto",gap="1px",**a): # format= "2fr 1fr 1fr"
self["style"].set("display","grid")
self["style"].set("grid-template-columns",format)
self["style"].set("grid-template-rows",vformat)
self["style"].set("gap",gap)

0 comments on commit 821f87f

Please sign in to comment.