File size: 2,520 Bytes
e841ba5
 
 
 
 
1969c22
 
 
e841ba5
 
 
 
1969c22
 
 
 
e841ba5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1969c22
e841ba5
 
 
 
 
 
1969c22
 
e841ba5
 
 
 
1969c22
e841ba5
1969c22
 
 
 
e841ba5
 
 
 
 
1969c22
 
e841ba5
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import gradio as gr
import modelscope_studio.components.antd as antd
import modelscope_studio.components.base as ms

data = [{
    'avatar': {
        "src": f'https://api.dicebear.com/7.x/miniavs/svg?seed={i}'
    },
    "link": {
        "href": "https://ant.design",
        "value": f"ant design part {i}"
    },
    "img": {
        "src":
        "https://gw.alipayobjects.com/zos/rmsportal/mqaQswcyDLcXyDKnZfES.png"
    },
    "meta": {
        'description':
        'Ant Design, a design language for background applications, is refined by Ant UED Team.',
    },
    'content':
    'We supply a series of design principles, practical patterns and high quality design resources (Sketch and Axure), to help people create their product prototypes beautifully and efficiently.'
} for i in range(10)]

page_size = 3


def IconText(icon: str, text: str):
    with antd.Space():
        antd.Icon(icon)
        ms.Text(text)


with gr.Blocks() as demo:
    with ms.Application():
        with antd.ConfigProvider():
            with antd.List(item_layout="vertical",
                           size="large",
                           data_source=data,
                           pagination=dict(total=len(data),
                                           pageSize=page_size)) as list:
                with ms.Slot("footer"):
                    with ms.Div():
                        antd.Typography.Text('ant design', strong=True)
                        ms.Text("footer part")
                with ms.Slot("renderItem",
                             params_mapping="""(item) => item"""):
                    with antd.List.Item():
                        with ms.Slot("actions"):
                            IconText('StarOutlined', 156)
                            IconText('LikeOutlined', 156)
                            IconText('MessageOutlined', 3)
                        with ms.Slot("extra"):
                            antd.Image(preview=False,
                                       alt="logo",
                                       width=272,
                                       as_item="img")
                        with antd.List.Item.Meta(as_item="meta"):
                            with ms.Slot("avatar"):
                                antd.Avatar(as_item="avatar")
                            with ms.Slot("title"):
                                antd.Typography.Link(as_item="link")
                        ms.Span(as_item="content")

if __name__ == "__main__":
    demo.queue().launch()