Skip to content

Commit

Permalink
style: re-format with larger line length
Browse files Browse the repository at this point in the history
  • Loading branch information
maartenbreddels committed Mar 21, 2024
1 parent bf661ec commit b8841ed
Show file tree
Hide file tree
Showing 10 changed files with 300 additions and 955 deletions.
3 changes: 3 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"printWidth": 140
}
99 changes: 18 additions & 81 deletions examples/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,11 @@ def report_click(event_data=None):
menu_items = [
dict(
key="1",
label=ipyreact.Widget.element(
_type="div", children=["Click me 1"], events={"onClick": report_click}
),
label=ipyreact.Widget.element(_type="div", children=["Click me 1"], events={"onClick": report_click}),
),
dict(
key="2",
label=ipyreact.Widget.element(
_type="div", children=["Click me 2"], events={"onClick": report_click}
),
label=ipyreact.Widget.element(_type="div", children=["Click me 2"], events={"onClick": report_click}),
),
]
text = """Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Expand All @@ -64,87 +60,37 @@ def Page():
# buttons
with antd.Col(props=dict(span=8, style={"boxSizing": "border-box"})):
with ipyreact.Widget.element(_type="div"):
antd.Button(
children=["Button"],
props=dict(type="primary"),
events={"onClick": report_click},
)
antd.Button(children=["Button"], props=dict(type="primary"), events={"onClick": report_click})
antd.Button(children=["Button"])
with antd.Col(props=dict(span=8)):
antd.Button(
children=["Button"], props=dict(type="primary", shape="round")
)
antd.Button(
props=dict(
type="primary",
shape="circle",
icon=icons.Icon("SearchOutlined"),
)
)
antd.Button(
props=dict(shape="circle", icon=icons.Icon("SearchOutlined"))
)
antd.Button(children=["Button"], props=dict(type="primary", shape="round"))
antd.Button(props=dict(type="primary", shape="circle", icon=icons.Icon("SearchOutlined")))
antd.Button(props=dict(shape="circle", icon=icons.Icon("SearchOutlined")))
with antd.Col(props=dict(span=8)):
antd.Button(children=["Button"], props=dict(type="text"))
with antd.Col(props=dict(span=8)):
antd.Button(
children=["Button"], props=dict(type="primary", size="small")
)
antd.Button(children=["Button"], props=dict(type="primary", size="small"))
antd.Button(children=["Button"], props=dict(size="small"))
with antd.Col(props=dict(span=8)):
antd.Button(
children=["Button"],
props=dict(type="primary", shape="round", size="small"),
)
antd.Button(
props=dict(
type="primary",
shape="circle",
icon=icons.Icon("SearchOutlined"),
size="small",
)
)
antd.Button(
props=dict(
shape="circle", icon=icons.Icon("SearchOutlined"), size="small"
)
)
antd.Button(children=["Button"], props=dict(type="primary", shape="round", size="small"))
antd.Button(props=dict(type="primary", shape="circle", icon=icons.Icon("SearchOutlined"), size="small"))
antd.Button(props=dict(shape="circle", icon=icons.Icon("SearchOutlined"), size="small"))
with antd.Col(props=dict(span=8)):
antd.Button(children=["Button"], props=dict(type="text", size="small"))

# sliders
with antd.Col(props=dict(span=8)):
antd.Slider(
value=slider.value, on_value=slider.set, props=dict(min=0, max=100)
)
antd.Slider(value=slider.value, on_value=slider.set, props=dict(min=0, max=100))
with antd.Col(props=dict(span=8)):
antd.Slider(
value=slider_range.value,
on_value=slider_range.set,
props=dict(min=0, max=100, range=True),
)
antd.Slider(value=slider_range.value, on_value=slider_range.set, props=dict(min=0, max=100, range=True))
with antd.Col(props=dict(span=8)):
antd.Slider(
value=slider.value,
on_value=slider.set,
props=dict(min=0, max=100, tooltip=dict(open=True)),
)
antd.Slider(value=slider.value, on_value=slider.set, props=dict(min=0, max=100, tooltip=dict(open=True)))

# select
with antd.Col(props=dict(span=8)):
antd.Select(
value=select.value,
on_value=select.set,
props=dict(options=options, style=dict(width="120px")),
)
antd.Select(value=select.value, on_value=select.set, props=dict(options=options, style=dict(width="120px")))
with antd.Col(props=dict(span=8)):
antd.Select(
value=multi_select.value,
on_value=multi_select.set,
props=dict(
options=options, style=dict(width="220px"), mode="multiple"
),
)
antd.Select(value=multi_select.value, on_value=multi_select.set, props=dict(options=options, style=dict(width="220px"), mode="multiple"))
with antd.Col(props=dict(span=8)):
pass
# only supported in 5.31+
Expand All @@ -154,21 +100,12 @@ def Page():
with antd.Col(props=dict(span=8)):
antd.Switch(value=switch.value, on_value=switch.set)
with antd.Col(props=dict(span=8)):
with antd.Dropdown(
props=dict(menu=dict(items=menu_items), trigger=["click"])
):
with antd.Dropdown(props=dict(menu=dict(items=menu_items), trigger=["click"])):
ipyreact.Widget.element(_type="span", children=["Menu"])
with antd.Col(props=dict(span=8)):
with antd.Modal(
value=dialog.value,
events={"onOk": dialog_close, "onCancel": dialog_close},
):
with antd.Modal(value=dialog.value, events={"onOk": dialog_close, "onCancel": dialog_close}):
ipyreact.Widget.element(_type="div", children=[text])
antd.Button(
children=["Dialog"],
props=dict(type="primary"),
events={"onClick": dialog_open},
)
antd.Button(children=["Dialog"], props=dict(type="primary"), events={"onClick": dialog_open})

solara.Preformatted(f"message: {message.value or ''}")
solara.Preformatted(f"slider: {slider.value}")
Expand Down
21 changes: 7 additions & 14 deletions generate/generate-schema.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,7 @@ async function extractPropsAndSaveToFile(inputFilePath, outputFilePath) {
}
const outputFilePath = "./generate/propslist.json"; // Replace with your desired output file path

const propsList = await extractPropsAndSaveToFile(
inputFilePath,
outputFilePath,
);
const propsList = await extractPropsAndSaveToFile(inputFilePath, outputFilePath);

// We can either get the schema for one file and one type...
// const schema = TJS.generateSchema(program, propsList, settings);
Expand All @@ -72,16 +69,12 @@ propsList.forEach((props) => {
});
const schema = generator.getSchemaForSymbols(propsList);

await fs.writeFile(
"./generate/schema.json",
JSON.stringify(schema, undefined, 4),
function (err) {
if (err) {
return console.log(err);
}
console.log("The file was saved!");
},
);
await fs.writeFile("./generate/schema.json", JSON.stringify(schema, undefined, 4), function (err) {
if (err) {
return console.log(err);
}
console.log("The file was saved!");
});

// // ... or a generator that lets us incrementally get more schemas

Expand Down
4 changes: 1 addition & 3 deletions generate/polish-schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,7 @@ def remove_unsupported(obj):
events[name].add(prop_name)
definition["properties"].pop(prop_name)
if events[name]:
definition["properties"]["events"] = {
"$ref": "#/definitions/" + name + "Events"
}
definition["properties"]["events"] = {"$ref": "#/definitions/" + name + "Events"}

all_events = set()
for name, event_set in events.items():
Expand Down
10 changes: 1 addition & 9 deletions ipyantd/assets/antd-jupyter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,5 @@ export function ModalStatefull({ value, setValue, ...rest }) {
rest.onCancel();
}
};
return (
<antd.Modal
open={value}
afterOpenChange={onOpenChange}
onOk={handleOk}
onCancel={handleCancel}
{...rest}
/>
);
return <antd.Modal open={value} afterOpenChange={onOpenChange} onOk={handleOk} onCancel={handleCancel} {...rest} />;
}
32 changes: 8 additions & 24 deletions ipyantd/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ def Button(
):
widget_cls = widgets.Button
comp = reacton.core.ComponentWidget(widget=widget_cls)
return reacton.core.Element(
comp, kwargs={"props": props, "events": events, "children": children}
)
return reacton.core.Element(comp, kwargs={"props": props, "events": events, "children": children})


def Slider(
Expand All @@ -59,14 +57,10 @@ def Slider(
events: SliderSinglePropsEvents = {},
children: ChildrenType = [],
):
return widgets.Slider.element(
value=value, on_value=on_value, props=props, events=events, children=children
)
return widgets.Slider.element(value=value, on_value=on_value, props=props, events=events, children=children)


def Flex(
props: FlexProps = {}, events: FlexPropsEvents = {}, children: ChildrenType = []
):
def Flex(props: FlexProps = {}, events: FlexPropsEvents = {}, children: ChildrenType = []):
widget_cls = widgets.Flex
comp = reacton.core.ComponentWidget(widget=widget_cls)
return reacton.core.Element(comp, kwargs={"props": props, "children": children})
Expand All @@ -75,17 +69,13 @@ def Flex(
def Row(props: RowProps = {}, events: RowPropsEvents = {}, children: ChildrenType = []):
widget_cls = widgets.Row
comp = reacton.core.ComponentWidget(widget=widget_cls)
return reacton.core.Element(
comp, kwargs={"props": props, "events": events, "children": children}
)
return reacton.core.Element(comp, kwargs={"props": props, "events": events, "children": children})


def Col(props: ColProps = {}, events: ColPropsEvents = {}, children: ChildrenType = []):
widget_cls = widgets.Col
comp = reacton.core.ComponentWidget(widget=widget_cls)
return reacton.core.Element(
comp, kwargs={"props": props, "events": events, "children": children}
)
return reacton.core.Element(comp, kwargs={"props": props, "events": events, "children": children})


def Select(
Expand Down Expand Up @@ -194,12 +184,8 @@ def DatePicker(


def ColorPicker(
value: Optional[
Union[ColorModel, RGB1, RGBA1, HSB, HSBA, Union[str, float]]
] = None,
on_value: Optional[
Callable[[Union[ColorModel, RGB1, RGBA1, HSB, HSBA, Union[str, float]]], None]
] = None,
value: Optional[Union[ColorModel, RGB1, RGBA1, HSB, HSBA, Union[str, float]]] = None,
on_value: Optional[Callable[[Union[ColorModel, RGB1, RGBA1, HSB, HSBA, Union[str, float]]], None]] = None,
props: ColorPickerProps = {},
events: ColorPickerPropsEvents = {},
children: ChildrenType = [],
Expand Down Expand Up @@ -238,9 +224,7 @@ def pick(*data):
DatePicker(onChange=pick, value=date)
else:
DatePicker(onChange=pick)
Button(
children=["Hi1 " + str(count)], props=dict(type="primary"), onClick=click
)
Button(children=["Hi1 " + str(count)], props=dict(type="primary"), onClick=click)
Button(
children=["Hi2 " + str(date)],
type="primary",
Expand Down
Loading

0 comments on commit b8841ed

Please sign in to comment.