-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathsample.py
66 lines (58 loc) · 1.72 KB
/
sample.py
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
import streamlit as st
from streamlit_sortables import sort_items
st.title('Sortables')
st.write('Sort items in a single container.')
items = ['item1', 'item2', 'item3']
sorted_items = sort_items(items)
st.write(sorted_items)
st.write('----')
st.write('Sort items in multiple containers.')
items = [
{'header': 'container1', 'items': ['item1', 'item2', 'item3']},
{'header': 'container2', 'items': ['item4', 'item5', 'item6']},
]
sorted_items = sort_items(items, multi_containers=True)
st.write(sorted_items)
st.write('----')
st.write('Lots of items in a single container.')
items = [
{'header': 'header1', 'items': ['item1', 'item2', 'item3', 'item4', 'item5', 'item6', 'item7', 'item8', 'item9', 'item10', 'item11', 'item12', 'item13']},
]
sorted_items = sort_items(items, multi_containers=True)
st.write(sorted_items)
st.write('----')
st.write('Custom style.')
original_items = [
{'header': 'first container', 'items': ['A', 'B', 'C']},
{'header': 'second container', 'items': ['D', 'E', 'F']}
]
custom_style = """
.sortable-component {
border: 3px solid #6495ED;
border-radius: 10px;
padding: 5px;
}
.sortable-container {
background-color: #F0F0F0;
counter-reset: item;
}
.sortable-container-header {
background-color: #FFBFDF;
padding-left: 1rem;
}
.sortable-container-body {
background-color: #F0F0F0;
}
.sortable-item, .sortable-item:hover {
background-color: #6495ED;
font-color: #FFFFFF;
font-weight: bold;
}
.sortable-item::before {
content: counter(item) ". ";
counter-increment: item;
}
"""
sorted_items = sort_items(original_items, multi_containers=True, custom_style=custom_style)
st.write(f'original_items: {original_items}')
st.write(f'sorted_items: {sorted_items}')