Skip to content

Commit

Permalink
docs: update
Browse files Browse the repository at this point in the history
  • Loading branch information
Col0ring committed Dec 10, 2024
1 parent 1e28851 commit 431f3e9
Show file tree
Hide file tree
Showing 38 changed files with 533 additions and 45 deletions.
2 changes: 1 addition & 1 deletion backend/modelscope_studio/components/antd/tag/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class AntdTag(ModelScopeLayoutComponent):

def __init__(
self,
value: str | None = "",
value: str | None = None,
props: dict | None = None,
*,
bordered: bool | None = None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ class AntdTagCheckableTag(ModelScopeDataLayoutComponent):
EVENTS = [
EventListener("change",
callback=lambda block: block._internal.update(
bind_change_event=True))
bind_change_event=True)),
EventListener("click",
callback=lambda block: block._internal.update(
bind_click_event=True))
]

def __init__(
Expand Down
15 changes: 8 additions & 7 deletions backend/modelscope_studio/components/antd/tooltip/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@ class AntdTooltip(ModelScopeLayoutComponent):

def __init__(
self,
title: str | None = "",
title: str | None = None,
props: dict | None = None,
*,
align: dict | None = None,
arrow: bool | dict | None = True,
auto_adjust_overflow: bool = True,
arrow: bool | dict | None = None,
auto_adjust_overflow: bool | None = None,
color: str | None = None,
default_open: bool | None = None,
destroy_tooltip_on_hide: bool | None = None,
fresh: bool | None = None,
get_popup_container: str | None = None,
mouse_enter_delay: float | int = 0.1,
mouse_leave_delay: float | int = 0.1,
mouse_enter_delay: float | int | None = None,
mouse_leave_delay: float | int | None = None,
overlay_class_name: str | None = None,
overlay_style: dict | None = None,
overlay_inner_style: dict | None = None,
Expand All @@ -51,9 +51,10 @@ def __init__(
'leftBottom',
'rightTop',
'rightBottom',
] = 'top',
] | None = None,
trigger: Literal['hover', 'focus', 'click', 'contextMenu']
| list[Literal['hover', 'focus', 'click', 'contextMenu']] = 'hover',
| list[Literal['hover', 'focus', 'click', 'contextMenu']]
| None = None,
open: bool | None = None,
z_index: int | None = None,
root_class_name: str | None = None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def __init__(

@property
def skip_api(self):
return False
return True

def preprocess(self, payload: None) -> None:
return payload
Expand Down
10 changes: 7 additions & 3 deletions backend/modelscope_studio/components/base/div/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from ....utils.dev import ModelScopeLayoutComponent, resolve_frontend_dir
from ...antd.carousel import AntdCarousel
from ...antd.space import AntdSpace
from ...antd.tooltip import AntdTooltip
from ..slot import ModelScopeSlot


Expand Down Expand Up @@ -65,10 +66,13 @@ def __init__(
as_item=as_item,
elem_style=elem_style,
**kwargs)

if self.parent and self._internal and (any(
isinstance(self.parent, component)
for component in [AntdCarousel, AntdSpace, ModelScopeSlot])):
isinstance(self.parent, component) for component in [
AntdCarousel,
AntdSpace,
AntdTooltip,
ModelScopeSlot,
])):
self._internal.update(fragment=True)
self.value = value
self.props = props
Expand Down
9 changes: 7 additions & 2 deletions backend/modelscope_studio/components/base/span/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from ....utils.dev import ModelScopeLayoutComponent, resolve_frontend_dir
from ...antd.carousel import AntdCarousel
from ...antd.space import AntdSpace
from ...antd.tooltip import AntdTooltip
from ..slot import ModelScopeSlot


Expand Down Expand Up @@ -66,8 +67,12 @@ def __init__(
elem_style=elem_style,
**kwargs)
if self.parent and self._internal and (any(
isinstance(self.parent, component)
for component in [AntdCarousel, AntdSpace, ModelScopeSlot])):
isinstance(self.parent, component) for component in [
AntdCarousel,
AntdSpace,
AntdTooltip,
ModelScopeSlot,
])):
self._internal.update(fragment=True)
self.value = value
self.props = props
Expand Down
3 changes: 2 additions & 1 deletion backend/modelscope_studio/components/base/text/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from ....utils.dev import ModelScopeComponent, resolve_frontend_dir
from ...antd.carousel import AntdCarousel
from ...antd.space import AntdSpace
from ...antd.tooltip import AntdTooltip


class ModelScopeText(ModelScopeComponent):
Expand Down Expand Up @@ -38,7 +39,7 @@ def __init__(
**kwargs)
if self.parent and self._internal and (any(
isinstance(self.parent, component)
for component in [AntdCarousel, AntdSpace])):
for component in [AntdCarousel, AntdTooltip, AntdSpace])):
self._internal.update(fragment=True)
self.value = value

Expand Down
7 changes: 7 additions & 0 deletions docs/components/antd/alert/README-zh_CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Alert

Display warning messages that require attention. See [Ant Design](https://ant.design/components/alert/) for more information.

## Examples

<demo name="basic"></demo>
7 changes: 7 additions & 0 deletions docs/components/antd/alert/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Alert

Display warning messages that require attention. See [Ant Design](https://ant.design/components/alert/) for more information.

## Examples

<demo name="basic"></demo>
6 changes: 6 additions & 0 deletions docs/components/antd/alert/app.py
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()
40 changes: 40 additions & 0 deletions docs/components/antd/alert/demos/basic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import gradio as gr

import modelscope_studio.components.antd as antd
import modelscope_studio.components.base as ms

data = [{
"message": "Success Text",
"description":
"Success Description Success Description Success Description Success Description",
"type": "success"
}, {
"message": "Info Text",
"description":
"Info Description Info Description Info Description Info Description",
"type": "info"
}, {
"message": "Warning Text",
"description":
"Warning Description Warning Description Warning Description Warning Description",
"type": "warning"
}, {
"message": "Error Text",
"description":
"Error Description Error Description Error Description Error Description",
"type": "error"
}]

with gr.Blocks() as demo:
with ms.Application():
with antd.ConfigProvider():
with antd.Space(direction="vertical"):
for item in data:
antd.Alert(message=item["message"],
description=item["description"],
type=item["type"],
closable=True,
show_icon=True)

if __name__ == "__main__":
demo.queue().launch()
26 changes: 6 additions & 20 deletions docs/components/antd/table/demos/pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,12 @@
import modelscope_studio.components.antd as antd
import modelscope_studio.components.base as ms

data = [
{
"key": '1',
"name": 'Mike',
"age": 32,
"address": '10 Downing Street',
},
{
"key": '2',
"name": 'John',
"age": 42,
"address": '10 Downing Street',
},
{
"key": '3',
"name": 'Joe',
"age": 32,
"address": '10 Downing Street',
},
] * 10
data = [{
"key": f"{i}",
"name": f'Item {i}',
"age": 32,
"address": '10 Downing Street',
} for i in range(20)]


def on_change(e: gr.EventData):
Expand Down
8 changes: 8 additions & 0 deletions docs/components/antd/tabs/README-zh_CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Tabs

Tabs make it easy to explore and switch between different views. See [Ant Design](https://ant.design/components/tabs/) for more information.

## Examples

<demo name="basic"></demo>
<demo name="position" title="Position"></demo>
8 changes: 8 additions & 0 deletions docs/components/antd/tabs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Tabs

Tabs make it easy to explore and switch between different views. See [Ant Design](https://ant.design/components/tabs/) for more information.

## Examples

<demo name="basic"></demo>
<demo name="position" title="Position"></demo>
6 changes: 6 additions & 0 deletions docs/components/antd/tabs/app.py
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()
32 changes: 32 additions & 0 deletions docs/components/antd/tabs/demos/basic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
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.Tabs(default_active_key='1'):
with antd.Tabs.Item(key="1", label="Tab1"):
ms.Text("Tab 1")
with antd.Tabs.Item(key="2", label="Tab2", disabled=True):
ms.Text("Tab 2")
with antd.Tabs.Item(key="3", label="Tab3"):
ms.Text("Tab 3")
with ms.Slot("icon"):
antd.Icon("AndroidOutlined")
antd.Divider("Extra content")
with antd.Tabs(default_active_key='1'):
with ms.Slot("tabBarExtraContent.left"):
antd.Button("Left Extra Action")
with ms.Slot("tabBarExtraContent.right"):
antd.Button("Right Extra Action")
with antd.Tabs.Item(key="1", label="Tab1"):
ms.Text("Tab 1")
with antd.Tabs.Item(key="2", label="Tab2"):
ms.Text("Tab 2")
with antd.Tabs.Item(key="3", label="Tab3"):
ms.Text("Tab 3")

if __name__ == "__main__":
demo.queue().launch()
29 changes: 29 additions & 0 deletions docs/components/antd/tabs/demos/position.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import gradio as gr

import modelscope_studio.components.antd as antd
import modelscope_studio.components.base as ms

default_position = "top"

with gr.Blocks() as demo:
with ms.Application():
with antd.ConfigProvider():
with antd.Space():
ms.Text("Tab position")
position = antd.Radio.Group(
value=default_position,
option_type="button",
options=["top", "left", "right", "bottom"])
with antd.Tabs(default_active_key='1') as tabs:
with antd.Tabs.Item(key="1", label="Tab1"):
ms.Text("Tab 1")
with antd.Tabs.Item(key="2", label="Tab2"):
ms.Text("Tab 2")
with antd.Tabs.Item(key="3", label="Tab3"):
ms.Text("Tab 3")
position.change(fn=lambda x: gr.update(tab_position=x),
inputs=[position],
outputs=[tabs])

if __name__ == "__main__":
demo.queue().launch()
8 changes: 8 additions & 0 deletions docs/components/antd/tag/README-zh_CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Tag

Used for marking and categorization. See [Ant Design](https://ant.design/components/tag/) for more information.

## Examples

<demo name="basic"></demo>
<demo name="checkable_tag" title="Checkable Tag"></demo>
8 changes: 8 additions & 0 deletions docs/components/antd/tag/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Tag

Used for marking and categorization. See [Ant Design](https://ant.design/components/tag/) for more information.

## Examples

<demo name="basic"></demo>
<demo name="checkable_tag" title="Checkable Tag"></demo>
6 changes: 6 additions & 0 deletions docs/components/antd/tag/app.py
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()
Loading

0 comments on commit 431f3e9

Please sign in to comment.