-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: sub index for Each & Radio value mapping
- Loading branch information
Showing
17 changed files
with
472 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Flex | ||
|
||
A flex layout container for alignment. See [Ant Design](https://ant.design/components/flex/) for more information. | ||
|
||
## Examples | ||
|
||
<demo name="basic"></demo> | ||
<demo name="align"></demo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Flex | ||
|
||
A flex layout container for alignment. See [Ant Design](https://ant.design/components/flex/) for more information. | ||
|
||
## Examples | ||
|
||
<demo name="basic"></demo> | ||
<demo name="align"></demo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from helper.Docs import Docs | ||
|
||
docs = Docs(__file__) | ||
|
||
if __name__ == "__main__": | ||
docs.render().queue().launch() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import gradio as gr | ||
|
||
import modelscope_studio.components.antd as antd | ||
import modelscope_studio.components.base as ms | ||
|
||
with gr.Blocks() as demo: | ||
with ms.Application(): | ||
with antd.ConfigProvider(): | ||
with antd.Flex(gap="middle", align="start", vertical=True): | ||
ms.Div("Select justify:") | ||
justify_segmented = antd.Segmented('flex-start', | ||
options=[ | ||
'flex-start', | ||
'center', | ||
'flex-end', | ||
'space-between', | ||
'space-around', | ||
'space-evenly', | ||
]) | ||
ms.Div("Select align:") | ||
align_segmented = antd.Segmented( | ||
'flex-start', options=['flex-start', 'center', 'flex-end']) | ||
with antd.Flex(elem_style=dict( | ||
width='100%', | ||
height=120, | ||
borderRadius=6, | ||
border='1px solid #40a9ff', | ||
), | ||
justify="flex-start", | ||
align="flex-start") as flex: | ||
antd.Button("Primary", type="primary") | ||
antd.Button("Primary", type="primary") | ||
antd.Button("Primary", type="primary") | ||
antd.Button("Primary", type="primary") | ||
justify_segmented.change(fn=lambda _justify_segmented: gr. | ||
update(justify=_justify_segmented), | ||
inputs=[justify_segmented], | ||
outputs=[flex]) | ||
align_segmented.change(fn=lambda _align_segmented: gr.update( | ||
align=_align_segmented), | ||
inputs=[align_segmented], | ||
outputs=[flex]) | ||
|
||
if __name__ == "__main__": | ||
demo.queue().launch() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import gradio as gr | ||
|
||
import modelscope_studio.components.antd as antd | ||
import modelscope_studio.components.base as ms | ||
|
||
with gr.Blocks() as demo: | ||
with ms.Application(): | ||
with antd.ConfigProvider(): | ||
with antd.Flex(gap="middle", vertical=True): | ||
with antd.Radio.Group("horizontal") as radio_group: | ||
with antd.Radio("horizontal"): | ||
ms.Text("horizontal") | ||
with antd.Radio("vertical"): | ||
ms.Text("vertical") | ||
with antd.Flex(vertical=False) as flex: | ||
for i in range(4): | ||
ms.Div(elem_style=dict(height=54, | ||
width="25%", | ||
backgroundColor='#1677ff' if i % | ||
2 else '#1677ffbf')) | ||
radio_group.change(fn=lambda _radio_group: gr.update( | ||
vertical=True if _radio_group == "vertical" else False), | ||
inputs=[radio_group], | ||
outputs=[flex]) | ||
if __name__ == "__main__": | ||
demo.queue().launch() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Grid | ||
|
||
24 Grids System. See [Ant Design](https://ant.design/components/grid/) for more information. | ||
|
||
## Examples | ||
|
||
<demo name="basic"></demo> | ||
<demo name="playground" title="Playground"></demo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Grid | ||
|
||
24 Grids System. See [Ant Design](https://ant.design/components/grid/) for more information. | ||
|
||
## Examples | ||
|
||
<demo name="basic"></demo> | ||
<demo name="playground" title="Playground"></demo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from helper.Docs import Docs | ||
|
||
docs = Docs(__file__) | ||
|
||
if __name__ == "__main__": | ||
docs.render().queue().launch() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import json | ||
|
||
import gradio as gr | ||
|
||
import modelscope_studio.components.antd as antd | ||
import modelscope_studio.components.base as ms | ||
|
||
with gr.Blocks() as demo: | ||
with ms.Application(): | ||
with antd.ConfigProvider(): | ||
with antd.Row(gutter=[6, 10]): | ||
with antd.Col(span=6): | ||
ms.Text("Col-6") | ||
with antd.Col(span=12): | ||
ms.Text("Col-12") | ||
with antd.Col(span=6): | ||
ms.Text("Col-6") | ||
with antd.Col(span=6): | ||
ms.Text("Col-6") | ||
with antd.Col(span=12): | ||
ms.Text("Col-12") | ||
with antd.Col(span=6): | ||
ms.Text("Col-6") | ||
if __name__ == "__main__": | ||
demo.queue().launch() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import json | ||
|
||
import gradio as gr | ||
|
||
import modelscope_studio.components.antd as antd | ||
import modelscope_studio.components.base as ms | ||
|
||
gutters = {} | ||
vgutters = {} | ||
col_counts = {} | ||
|
||
for i, v in enumerate([8, 16, 24, 32, 40, 48]): | ||
gutters[str(i)] = vgutters[str(i)] = v | ||
|
||
for i, v in enumerate([2, 3, 4, 6, 8, 12]): | ||
col_counts[str(i)] = v | ||
|
||
with gr.Blocks() as demo: | ||
with ms.Application(): | ||
with antd.ConfigProvider(): | ||
ms.Span("Horizontal Gutter (px): ") | ||
with ms.Div(elem_style=dict(width="50%")): | ||
horizontal_slider = antd.Slider( | ||
value=1, | ||
min=0, | ||
max=len(gutters) - 1, | ||
marks=gutters, | ||
step=None, | ||
tooltip=dict( | ||
formatter=f"(value) => ({json.dumps(gutters)}[value])") | ||
) | ||
ms.Span("Vertical Gutter (px): ") | ||
with ms.Div(elem_style=dict(width="50%")): | ||
vertical_slider = antd.Slider( | ||
value=1, | ||
min=0, | ||
max=len(vgutters) - 1, | ||
marks=vgutters, | ||
step=None, | ||
tooltip=dict( | ||
formatter=f"(value) => ({json.dumps(vgutters)}[value])" | ||
)) | ||
ms.Span("Column Count: ") | ||
with ms.Div(elem_style=dict(width="50%", marginBottom=48)): | ||
count_slider = antd.Slider( | ||
value=1, | ||
min=0, | ||
max=len(col_counts) - 1, | ||
marks=col_counts, | ||
step=None, | ||
tooltip=dict( | ||
formatter= | ||
f"(value) => ({json.dumps(col_counts)}[value])")) | ||
with antd.Row(gutter=[gutters["1"], vgutters["1"]]) as row: | ||
with ms.Each(value=[{ | ||
"span": 8 | ||
}, { | ||
"span": 8 | ||
}, { | ||
"span": 8 | ||
}] * 2) as cols: | ||
with antd.Col(elem_style=dict(background="transparent", | ||
border=0)): | ||
ms.Div("Column", | ||
elem_style=dict(height=120, | ||
fontSize=14, | ||
lineHeight='120px', | ||
background="#0092ff", | ||
borderRadius=4, | ||
color="#fff", | ||
textAlign='center')) | ||
|
||
def on_change(_horizontal_slider, _vertical_slider, _count_slider): | ||
return gr.update(gutter=[ | ||
gutters[str(_horizontal_slider)], vgutters[str( | ||
_vertical_slider)] | ||
]), gr.update( | ||
value=[{ | ||
"span": int(24 / col_counts[str(_count_slider)]) | ||
} for _ in range(col_counts[str(_count_slider)])] * 2) | ||
|
||
gr.on([ | ||
horizontal_slider.change, vertical_slider.change, | ||
count_slider.change | ||
], | ||
fn=on_change, | ||
inputs=[horizontal_slider, vertical_slider, count_slider], | ||
outputs=[row, cols]) | ||
if __name__ == "__main__": | ||
demo.queue().launch() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.