justheuristic commited on
Commit
94f41cc
1 Parent(s): 28f4b4e

tabs prototype

Browse files
Files changed (2) hide show
  1. app.py +41 -1
  2. st_helpers.py +25 -0
app.py CHANGED
@@ -6,7 +6,7 @@ If you're not a hedgehog, you shouldn't reuse this code. Use this instead: https
6
  import streamlit as st
7
 
8
 
9
- from st_helpers import make_header, content_text, content_title, cite, make_footer
10
  from charts import draw_current_progress
11
 
12
  st.set_page_config(page_title="Training Transformers Together", layout="centered")
@@ -57,6 +57,46 @@ Please note that we currently limit the number of colab participants to <b>TODO<
57
  with other users. If there are too many active peers, take a look at alternative starter kits here <b>TODO</b>
58
  """)
59
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
 
61
  content_text("<b> TODO UPDATE")
62
  make_footer()
 
6
  import streamlit as st
7
 
8
 
9
+ from st_helpers import make_header, content_text, content_title, cite, make_footer, draw_tab_selector
10
  from charts import draw_current_progress
11
 
12
  st.set_page_config(page_title="Training Transformers Together", layout="centered")
 
57
  with other users. If there are too many active peers, take a look at alternative starter kits here <b>TODO</b>
58
  """)
59
 
60
+ content_title("But how does it work?")
61
+ content_text("<b> TODO </b> General Story That Weaves Together Three Tabs Below . Lorem ipsum dolor sit amet, "
62
+ "consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim"
63
+ " ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. "
64
+ "Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. "
65
+ "Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.")
66
+
67
+ query_params = st.experimental_get_query_params()
68
+ tabs = ["Efficient Training", "Security & Privacy", "Make Your Own (TBU)"]
69
+ active_tab = query_params["tab"][0] if "tab" in query_params else tabs[0]
70
+ if active_tab not in tabs:
71
+ st.experimental_set_query_params(tab=tabs[0])
72
+ active_tab = tabs[0]
73
+
74
+ draw_tab_selector(tabs, active_tab)
75
+
76
+ if active_tab == tabs[0]:
77
+ content_text("<b> TODO 1</b> Lorem ipsum dolor sit amet, "
78
+ "consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim"
79
+ " ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. "
80
+ "Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. "
81
+ "Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.")
82
+
83
+ elif active_tab == tabs[1]:
84
+ content_text("<b> TODO 2</b> Lorem ipsum dolor sit amet, "
85
+ "consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim"
86
+ " ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. "
87
+ "Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. "
88
+ "Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.")
89
+
90
+ elif active_tab == tabs[2]:
91
+ content_text("<b> TODO 3</b> Lorem ipsum dolor sit amet, "
92
+ "consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim"
93
+ " ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. "
94
+ "Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. "
95
+ "Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.")
96
+
97
+ else:
98
+ st.error("Something has gone terribly wrong. Please keep your fingers crossed while reloading the page.")
99
+
100
 
101
  content_text("<b> TODO UPDATE")
102
  make_footer()
st_helpers.py CHANGED
@@ -1,3 +1,5 @@
 
 
1
  import streamlit as st
2
  import streamlit.components.v1 as components
3
 
@@ -19,6 +21,10 @@ def make_header():
19
  components.html(f"<style>{embeds_style_css}</style>{header_html}<script>{header_animate_js}</script>", height=260)
20
  st.markdown(meta_html, unsafe_allow_html=True)
21
  st.markdown(f"<style>{content_style_css}</style>", unsafe_allow_html=True) # apply css to the rest of the document
 
 
 
 
22
 
23
 
24
  def make_footer():
@@ -45,3 +51,22 @@ CITATIONS = {}
45
  def cite(tag):
46
  CITATIONS.setdefault(tag, len(CITATIONS) + 1)
47
  return f"&nbsp;[{CITATIONS[tag]}]"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Sequence
2
+
3
  import streamlit as st
4
  import streamlit.components.v1 as components
5
 
 
21
  components.html(f"<style>{embeds_style_css}</style>{header_html}<script>{header_animate_js}</script>", height=260)
22
  st.markdown(meta_html, unsafe_allow_html=True)
23
  st.markdown(f"<style>{content_style_css}</style>", unsafe_allow_html=True) # apply css to the rest of the document
24
+ st.markdown(
25
+ '<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">',
26
+ unsafe_allow_html=True,
27
+ )
28
 
29
 
30
  def make_footer():
 
51
  def cite(tag):
52
  CITATIONS.setdefault(tag, len(CITATIONS) + 1)
53
  return f"&nbsp;[{CITATIONS[tag]}]"
54
+
55
+
56
+ def draw_tab_selector(tabs: Sequence[str], active_tab: str):
57
+ li_items = "".join(
58
+ f"""
59
+ <li class="nav-item">
60
+ <a class="nav-link{' active' if t == active_tab else ''}" href="/?tab={t}">{t}</a>
61
+ </li>
62
+ """
63
+ for t in tabs
64
+ )
65
+ tabs_html = f"""
66
+ <ul class="nav nav-tabs">
67
+ {li_items}
68
+ </ul>
69
+ """
70
+
71
+ st.markdown(tabs_html, unsafe_allow_html=True)
72
+ st.markdown("<br>", unsafe_allow_html=True)