Skip to content

Commit bb4001a

Browse files
committed
fix: antdx docs
1 parent a962e0a commit bb4001a

88 files changed

Lines changed: 1409 additions & 304 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,5 @@ yalc.lock
6161
.stylelintcache
6262
.DS_Store
6363
.pytest_cache
64+
65+
.qoder

backend/modelscope_studio/components/antd/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@
7272
from .list.item.meta import AntdListItemMeta as ListItemMeta
7373
from .mentions import AntdMentions as Mentions
7474
from .mentions.option import AntdMentionsOption as MentionsOption
75+
from .masonry import AntdMasonry as Masonry
76+
from .masonry.item import AntdMasonryItem as MasonryItem
7577
from .menu import AntdMenu as Menu
7678
from .menu.item import AntdMenuItem as MenuItem
7779
from .message import AntdMessage as Message

backend/modelscope_studio/components/antd/components.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@
6767
from .list import AntdList
6868
from .list.item import AntdListItem
6969
from .list.item.meta import AntdListItemMeta
70+
from .masonry import AntdMasonry
71+
from .masonry.item import AntdMasonryItem
7072
from .mentions import AntdMentions
7173
from .mentions.option import AntdMentionsOption
7274
from .menu import AntdMenu
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
from __future__ import annotations
2+
3+
from typing import Any
4+
from gradio.events import EventListener
5+
6+
from ....utils.dev import ModelScopeLayoutComponent, resolve_frontend_dir
7+
from .item import AntdMasonryItem
8+
9+
10+
class AntdMasonry(ModelScopeLayoutComponent):
11+
"""
12+
Ant Design: https://ant.design/components/masonry
13+
14+
A masonry layout component for displaying content with different heights.
15+
16+
When to use:
17+
- When displaying images or cards with irregular heights
18+
- When content needs to be evenly distributed in columns
19+
- When column count needs to be responsive
20+
"""
21+
Item = AntdMasonryItem
22+
23+
EVENTS = [
24+
EventListener("layout_change",
25+
callback=lambda block: block._internal.update(
26+
bind_layoutChange_event=True)),
27+
]
28+
SLOTS = ['items', 'itemRender']
29+
30+
def __init__(
31+
self,
32+
additional_props: dict | None = None,
33+
*,
34+
columns: int | dict | None = None,
35+
gutter: int | tuple[int | dict, int | dict] | dict | None = None,
36+
fresh: bool | None = None,
37+
items: list[dict] | None = None,
38+
item_render: str | None = None,
39+
class_names: dict | None = None,
40+
styles: dict | None = None,
41+
as_item: str | None = None,
42+
_internal: None = None,
43+
# gradio properties
44+
visible: bool = True,
45+
elem_id: str | None = None,
46+
elem_classes: list[str] | str | None = None,
47+
elem_style: dict | None = None,
48+
render: bool = True,
49+
**kwargs):
50+
super().__init__(visible=visible,
51+
elem_id=elem_id,
52+
elem_classes=elem_classes,
53+
render=render,
54+
as_item=as_item,
55+
elem_style=elem_style,
56+
**kwargs)
57+
self.additional_props = additional_props
58+
self.columns = columns
59+
self.gutter = gutter
60+
self.fresh = fresh
61+
self.items = items
62+
self.item_render = item_render
63+
self.class_names = class_names
64+
self.styles = styles
65+
66+
FRONTEND_DIR = resolve_frontend_dir("masonry")
67+
68+
@property
69+
def skip_api(self):
70+
return True
71+
72+
def preprocess(self, payload: None) -> None:
73+
return payload
74+
75+
def postprocess(self, value: None) -> None:
76+
return value
77+
78+
def example_payload(self) -> Any:
79+
return None
80+
81+
def example_value(self) -> Any:
82+
return None
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
from __future__ import annotations
2+
3+
from typing import Any
4+
5+
from .....utils.dev import ModelScopeLayoutComponent, resolve_frontend_dir
6+
7+
8+
class AntdMasonryItem(ModelScopeLayoutComponent):
9+
"""
10+
Ant Design: https://ant.design/components/masonry
11+
"""
12+
13+
EVENTS = []
14+
15+
# supported slots
16+
SLOTS = []
17+
18+
def __init__(
19+
self,
20+
key: str | float | int | None = None,
21+
*,
22+
column: int | None = None,
23+
data: Any | None = None,
24+
height: int | float | None = None,
25+
additional_props: dict | None = None,
26+
as_item: str | None = None,
27+
_internal: None = None,
28+
# gradio properties
29+
visible: bool = True,
30+
elem_id: str | None = None,
31+
elem_classes: list[str] | str | None = None,
32+
elem_style: dict | None = None,
33+
render: bool = True,
34+
**kwargs):
35+
super().__init__(visible=visible,
36+
elem_id=elem_id,
37+
elem_classes=elem_classes,
38+
render=render,
39+
as_item=as_item,
40+
elem_style=elem_style,
41+
**kwargs)
42+
self.additional_props = additional_props
43+
self.key = key
44+
self.column = column
45+
self.data = data
46+
self.height = height
47+
48+
FRONTEND_DIR = resolve_frontend_dir("masonry", "item")
49+
50+
@property
51+
def skip_api(self):
52+
return True
53+
54+
def preprocess(self, payload: None) -> None:
55+
return payload
56+
57+
def postprocess(self, value: None) -> None:
58+
return value
59+
60+
def example_payload(self) -> Any:
61+
return None
62+
63+
def example_value(self) -> Any:
64+
return None

docs/app.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,9 @@ def render(self):
224224
}, {
225225
"label": get_text("Layout", "Layout 布局"),
226226
"key": "layout"
227+
}, {
228+
"label": get_text("Masonry", "Masonry 瀑布流"),
229+
"key": "masonry"
227230
}, {
228231
"label": get_text("Space", "Space 间距"),
229232
"key": "space"
@@ -451,6 +454,9 @@ def render(self):
451454
}, {
452455
"label": get_text("Conversations", "Conversations 管理对话"),
453456
"key": "conversations"
457+
}, {
458+
"label": get_text("Notification", "Notification 系统通知"),
459+
"key": "notification"
454460
}]
455461
}, {
456462
"label":
@@ -485,6 +491,9 @@ def render(self):
485491
"type":
486492
"group",
487493
"children": [{
494+
"label": get_text("Think", "Think 思考过程"),
495+
"key": "think"
496+
}, {
488497
"label": get_text("ThoughtChain", "ThoughtChain 思考链"),
489498
"key": "thought_chain"
490499
}]
@@ -496,6 +505,21 @@ def render(self):
496505
"children": [{
497506
"label": get_text("Actions", "Actions 操作列表"),
498507
"key": "actions"
508+
}, {
509+
"label": get_text("CodeHighlighter", "CodeHighlighter 代码高亮"),
510+
"key": "code_highlighter"
511+
}, {
512+
"label": get_text("FileCard", "FileCard 文件卡片"),
513+
"key": "file_card"
514+
}, {
515+
"label": get_text("Folder", "Folder 文件夹"),
516+
"key": "folder"
517+
}, {
518+
"label": get_text("Mermaid", "Mermaid 图表工具"),
519+
"key": "mermaid"
520+
}, {
521+
"label": get_text("Sources", "Sources 来源引用"),
522+
"key": "sources"
499523
}]
500524
}, {
501525
"label":
@@ -587,8 +611,8 @@ def more_components():
587611
default_active_tab=default_active_tab,
588612
logo=logo)
589613

590-
demo = site.render()
614+
demo, css = site.render()
591615

592616
if __name__ == "__main__":
593617
demo.queue(default_concurrency_limit=100,
594-
max_size=100).launch(ssr_mode=False, max_threads=100)
618+
max_size=100).launch(css=css, ssr_mode=False, max_threads=100)

docs/components/antd/config_provider/demos/basic.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
with antd.ConfigProvider(
1111
locale=default_locale,
1212
direction=default_direction,
13-
theme=dict(token=dict(
13+
theme_config=dict(token=dict(
1414
colorPrimary=default_color))) as config_provider:
1515
with antd.Card():
1616
with ms.Div(elem_style=dict(marginBottom=16)):
@@ -61,7 +61,7 @@
6161
outputs=[config_provider])
6262
gr.on(
6363
[theme.change, color.change],
64-
fn=lambda _theme, _color: gr.update(theme=dict(
64+
fn=lambda _theme, _color: gr.update(theme_config=dict(
6565
token=dict(colorPrimary=_color) if _color else None,
6666
algorithm=dict(dark=True
6767
if _theme and 'dark' in _theme else False,
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Masonry
2+
3+
A masonry/waterfall layout component for displaying content with different heights. See [Ant Design](https://ant.design/components/masonry/) for more information.
4+
5+
## Examples
6+
7+
<demo name="basic"></demo>
8+
<demo name="columns" title="Custom Columns"></demo>
9+
<demo name="responsive" title="Responsive Layout"></demo>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Masonry
2+
3+
A masonry/waterfall layout component for displaying content with different heights. See [Ant Design](https://ant.design/components/masonry/) for more information.
4+
5+
## Examples
6+
7+
<demo name="basic"></demo>
8+
<demo name="columns" title="Custom Columns"></demo>
9+
<demo name="responsive" title="Responsive Layout"></demo>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from helper.Docs import Docs
2+
3+
docs = Docs(__file__)
4+
5+
if __name__ == "__main__":
6+
docs.render().queue().launch()

0 commit comments

Comments
 (0)