Skip to content

Commit 3637bc1

Browse files
committed
Adding layout components
1 parent 61899f3 commit 3637bc1

File tree

3 files changed

+48
-2
lines changed

3 files changed

+48
-2
lines changed

js/src/index.js

+19
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ import TextField from '@mui/material/TextField';
55
import Checkbox from '@mui/material/Checkbox';
66
import Select from '@mui/material/Select';
77
import MenuItem from '@mui/material/MenuItem';
8+
9+
import Box from '@mui/material/Box';
810
import Grid from '@mui/material/Grid';
11+
import Container from '@mui/material/Container';
912

1013
import React from "react";
1114
import ReactDOM from "react-dom";
@@ -60,4 +63,20 @@ export function MDGrid({ children, ...attrs}) {
6063
{children}
6164
</Grid>
6265
);
66+
}
67+
68+
export function MDContainer({ children, ...attrs}) {
69+
return (
70+
<Container {...attrs}>
71+
{children}
72+
</Container>
73+
);
74+
}
75+
76+
export function MDBox({ children, ...attrs}) {
77+
return (
78+
<Box {...attrs}>
79+
{children}
80+
</Box>
81+
);
6382
}

reactpy_material/__init__.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
__version__ = "0.0.1"
22

33
from .core.components import button, button_group, autocomplete, checkbox, select
4-
from .core.layout import grid
4+
from .core.layout import grid, container, box
55

66
__all__ = [
77
"button",
88
"button_group",
99
"autocomplete",
1010
"checkbox",
1111
"select",
12-
"grid"
12+
"grid",
13+
"container",
14+
"box"
1315
]

reactpy_material/core/layout.py

+25
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
)
1313

1414
md_grid = export(_js_module, "MDGrid")
15+
md_container = export(_js_module, "MDContainer")
16+
md_box = export(_js_module, "MDBox")
1517

1618
@component
1719
def grid(*children: VdomChild, attrs: Any = {}):
@@ -23,3 +25,26 @@ def grid(*children: VdomChild, attrs: Any = {}):
2325
children_items += (c, )
2426

2527
return md_grid(attrs, children_items)
28+
29+
@component
30+
def container(*children: VdomChild, attrs: Any = {}):
31+
children_items = ()
32+
for c in children:
33+
if isinstance(c, Component):
34+
children_items += (c.render(), )
35+
else:
36+
children_items += (c, )
37+
38+
return md_container(attrs, children_items)
39+
40+
@component
41+
def box(*children: VdomChild, attrs: Any = {}):
42+
children_items = ()
43+
for c in children:
44+
if isinstance(c, Component):
45+
children_items += (c.render(), )
46+
else:
47+
children_items += (c, )
48+
49+
return md_box(attrs, children_items)
50+

0 commit comments

Comments
 (0)