Skip to content

Commit 7669746

Browse files
committed
Add box-sizing and z-index to Style
1 parent 2169f29 commit 7669746

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

mesop/component_helpers/style.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ class Style:
118118
border: Defines the border properties for each side of the component. See [MDN doc](https://developer.mozilla.org/en-US/docs/Web/CSS/border).
119119
border_radius: Defines the border radius. See [MDN doc](https://developer.mozilla.org/en-US/docs/Web/CSS/border-radius).
120120
box_shadow: Defines the box shadow. See [MDN doc](https://developer.mozilla.org/en-US/docs/Web/CSS/box-shadow).
121+
box_sizing: Defines the box sizing. See [MDN doc](https://developer.mozilla.org/en-US/docs/Web/CSS/box-sizing).
121122
color: Sets the color of the text inside the component. See [MDN doc](https://developer.mozilla.org/en-US/docs/Web/CSS/color).
122123
column_gap: Sets the gap between columns. See [MDN doc](https://developer.mozilla.org/en-US/docs/Web/CSS/column-gap).
123124
columns: Specifies the number of columns in a multi-column element. See [MDN doc](https://developer.mozilla.org/en-US/docs/Web/CSS/columns).
@@ -157,6 +158,7 @@ class Style:
157158
text_overflow: Specifies how overflowed content that is not displayed should be signaled to the user. See [MDN doc](https://developer.mozilla.org/en-US/docs/Web/CSS/text-overflow).
158159
white_space: Specifies how white space inside an element is handled. See [MDN doc](https://developer.mozilla.org/en-US/docs/Web/CSS/white-space).
159160
width: Sets the width of the component. See [MDN doc](https://developer.mozilla.org/en-US/docs/Web/CSS/width).
161+
z-index: Sets the z-index of the component. See [MDN doc](https://developer.mozilla.org/en-US/docs/Web/CSS/z-index).
160162
"""
161163

162164
# For literal properties, make the most commonly used option the first literal
@@ -168,6 +170,7 @@ class Style:
168170
border: Border | None = None
169171
border_radius: int | str | None = None
170172
box_shadow: str | None = None
173+
box_sizing: str | None = None
171174
color: str | None = None
172175
column_gap: int | str | None = None
173176
columns: int | None = None
@@ -256,6 +259,7 @@ class Style:
256259
"break-spaces",
257260
] | None = None
258261
width: int | str | None = None
262+
z_index: int | None = None
259263

260264

261265
def to_style_proto(s: Style) -> pb.Style:
@@ -266,6 +270,7 @@ def to_style_proto(s: Style) -> pb.Style:
266270
border=_map_border(s.border),
267271
border_radius=_px_str(s.border_radius),
268272
box_shadow=s.box_shadow,
273+
box_sizing=s.box_sizing,
269274
color=s.color,
270275
column_gap=_px_str(s.column_gap),
271276
columns=s.columns,
@@ -306,6 +311,7 @@ def to_style_proto(s: Style) -> pb.Style:
306311
text_overflow=s.text_overflow,
307312
white_space=s.white_space,
308313
width=_px_str(s.width),
314+
z_index=s.z_index,
309315
)
310316

311317

mesop/protos/ui.proto

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,14 +217,15 @@ message UserDefinedType {
217217
repeated Arg args = 1;
218218
}
219219

220-
// Next id: 47
220+
// Next id: 49
221221
message Style {
222222
optional string align_content = 32;
223223
optional string align_items = 1;
224224
optional string background = 2;
225225
optional Border border = 3;
226226
optional string border_radius = 28;
227227
optional string box_shadow = 29;
228+
optional string box_sizing = 47;
228229
optional string color = 4;
229230
optional string column_gap = 33;
230231
optional int32 columns = 5;
@@ -265,6 +266,7 @@ message Style {
265266
optional string text_overflow = 25;
266267
optional string white_space = 26;
267268
optional string width = 27;
269+
optional int32 z_index = 48;
268270
}
269271

270272
message EdgeInsets {

mesop/web/src/utils/styles.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ export function formatStyle(styleObj: Style): string {
4040
if (styleObj.getBoxShadow()) {
4141
style += `box-shadow: ${styleObj.getBoxShadow()};`;
4242
}
43+
if (styleObj.getBoxSizing()) {
44+
style += `box-sizing: ${styleObj.getBoxSizing()};`;
45+
}
4346
if (styleObj.getColor()) {
4447
style += `color: ${styleObj.getColor()};`;
4548
}
@@ -169,5 +172,8 @@ export function formatStyle(styleObj: Style): string {
169172
if (styleObj.getWidth()) {
170173
style += `width: ${styleObj.getWidth()};`;
171174
}
175+
if (styleObj.getZIndex()) {
176+
style += `z-index: ${styleObj.getZIndex()};`;
177+
}
172178
return style;
173179
}

0 commit comments

Comments
 (0)