-
Notifications
You must be signed in to change notification settings - Fork 56
Expand file tree
/
Copy pathapp.py
More file actions
125 lines (119 loc) · 3.9 KB
/
app.py
File metadata and controls
125 lines (119 loc) · 3.9 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/usr/bin/env python
# _*_coding:utf-8_*_
"""
@Time : 2023/5/26 22:14
@Author : ji hao ran
@File : app.py
@Project : StreamlitAntdComponents
@Software : PyCharm
"""
from demo.demo import DEMO
from demo.overview import overview
from demo.callback import callback_usage
from demo.session_state import session_usage
from demo.icon import icon
from demo.utils import *
st.set_page_config(layout='wide', page_title='streamlit-antd-components')
st.markdown(f'''
<style>
.stApp .main .block-container{{
padding:30px 50px
}}
.stApp [data-testid='stSidebar']>div:nth-child(1)>div:nth-child(2){{
padding-top:50px
}}
iframe{{
display:block;
}}
.stRadio div[role='radiogroup']>label{{
margin-right:5px
}}
</style>
''', unsafe_allow_html=True)
with st.sidebar.container():
# tag
modified = sac.Tag('Modified', color='blue', bordered=False)
new = sac.Tag('New', color='green', bordered=False)
deprecated = sac.Tag('Deprecated', color='orange', bordered=False)
redesign = sac.Tag('Redesign', color='purple', bordered=False)
# title
st.subheader(f'Streamlit-antd-components')
# menu
menu = sac.menu(
items=[
sac.MenuItem('overview'),
sac.MenuItem('icon', tag=new),
sac.MenuItem('general', type='group', children=[
sac.MenuItem('buttons')
]),
sac.MenuItem('layout', type='group', children=[sac.MenuItem('divider')]),
sac.MenuItem(
label='navigation', type='group', children=[
sac.MenuItem('menu', tag=modified),
sac.MenuItem('pagination'),
'steps'
]
),
sac.MenuItem(
label='data entry', type='group',
children=[
sac.MenuItem('cascader'),
sac.MenuItem('checkbox'),
sac.MenuItem('chip'),
'rate',
sac.MenuItem('switch'),
sac.MenuItem('transfer')
]
),
sac.MenuItem(
label='data display', type='group',
children=[
sac.MenuItem('segmented'),
sac.MenuItem('tabs', tag=modified),
sac.MenuItem('tree'),
sac.MenuItem('tags'),
],
),
sac.MenuItem(
label='feedback', type='group', children=[
sac.MenuItem('alert', tag=modified),
sac.MenuItem('result')
]
),
sac.MenuItem(label='Advanced Usage', type='group', children=[
sac.MenuItem('session state'),
sac.MenuItem('callback'),
]),
],
key='menu',
open_all=True, indent=20,
format_func='title',
)
sac.divider('Environment', color='gray')
sac.tags(
[sac.Tag(f'streamlit=={st.__version__}', size='xs', color='cyan'),
sac.Tag(f'streamlit-antd-components=={sac.__VERSION__}', size='xs', color='blue')])
with st.container():
if menu == 'overview':
overview()
elif menu == 'callback':
callback_usage()
elif menu == 'session state':
session_usage()
elif menu == 'icon':
icon()
else:
com_ = DEMO.get(menu)
# component introduce
st.subheader(menu.title(), anchor=False)
st.write(com_.get('doc'))
# component demo and api
tabs = sac.tabs([sac.TabsItem('Demo', icon='easel'), sac.TabsItem('Api', icon='cursor')], size='sm')
if tabs == 'Demo':
col = st.columns([2.2, 1])
with col[-1].expander(f"{menu} params", True):
kw = com_.get('params')(key=menu)
with col[0]:
com_.get('main')(kw)
else:
com_.get('api')()