justheuristic commited on
Commit
2c1b6a1
1 Parent(s): 94f41cc
Files changed (3) hide show
  1. app.py +2 -34
  2. st_helpers.py +7 -20
  3. static/tabs.html +36 -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, draw_tab_selector
10
  from charts import draw_current_progress
11
 
12
  st.set_page_config(page_title="Training Transformers Together", layout="centered")
@@ -64,39 +64,7 @@ content_text("<b> TODO </b> General Story That Weaves Together Three Tabs Below
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()
 
6
  import streamlit as st
7
 
8
 
9
+ from st_helpers import make_header, content_text, content_title, cite, make_footer, make_tabs
10
  from charts import draw_current_progress
11
 
12
  st.set_page_config(page_title="Training Transformers Together", layout="centered")
 
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
+ make_tabs()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
 
69
  content_text("<b> TODO UPDATE")
70
  make_footer()
st_helpers.py CHANGED
@@ -13,6 +13,8 @@ with open("static/content_style.css", 'r', encoding='utf-8') as f:
13
  content_style_css = f.read()
14
  with open("static/meta.html", 'r', encoding='utf-8') as f:
15
  meta_html = f.read()
 
 
16
  with open("static/footer.html", 'r', encoding='utf-8') as f:
17
  footer_html = f.read()
18
 
@@ -27,8 +29,12 @@ def make_header():
27
  )
28
 
29
 
 
 
 
 
30
  def make_footer():
31
- components.html(f"<style>{embeds_style_css}</style>{footer_html}", height=110)
32
 
33
 
34
  def content_title(title: str, vspace_before: int = 0, vspace_after: int = 0):
@@ -51,22 +57,3 @@ CITATIONS = {}
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)
 
13
  content_style_css = f.read()
14
  with open("static/meta.html", 'r', encoding='utf-8') as f:
15
  meta_html = f.read()
16
+ with open("static/tabs.html", 'r', encoding='utf-8') as f:
17
+ tabs_html = f.read()
18
  with open("static/footer.html", 'r', encoding='utf-8') as f:
19
  footer_html = f.read()
20
 
 
29
  )
30
 
31
 
32
+ def make_tabs():
33
+ components.html(f"<style>{content_style_css}</style>{tabs_html}", height=400)
34
+
35
+
36
  def make_footer():
37
+ components.html(f"<style>{content_style_css}</style>{footer_html}", height=110)
38
 
39
 
40
  def content_title(title: str, vspace_before: int = 0, vspace_after: int = 0):
 
57
  def cite(tag):
58
  CITATIONS.setdefault(tag, len(CITATIONS) + 1)
59
  return f"&nbsp;[{CITATIONS[tag]}]"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
static/tabs.html ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <html lang="en">
2
+ <head>
3
+ <title>Bootstrap Example</title>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
7
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
8
+ <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
9
+ </head>
10
+ <body>
11
+
12
+ <div id="tabs" style="width: 100%; margin:0 auto;">
13
+ <div>
14
+ <!-- Nav tabs -->
15
+ <ul class="nav nav-tabs" role="tablist">
16
+ <li role="presentation" class="active"><a href="#home" aria-controls="home" role="tab" data-toggle="tab">"Efficient Training"</a></li>
17
+ <li role="presentation"><a href="#profile" aria-controls="profile" role="tab" data-toggle="tab">Security & Privacy</a></li>
18
+ <li role="presentation"><a href="#messages" aria-controls="messages" role="tab" data-toggle="tab">Make Your Own (TBU)</a></li>
19
+ </ul>
20
+
21
+ <!-- Tab panes -->
22
+ <div class="tab-content">
23
+ <div role="tabpanel" class="tab-pane active" id="home">
24
+ <b> TODO 1</b> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
25
+ </div>
26
+ <div role="tabpanel" class="tab-pane" id="profile">
27
+ <b> TODO 2</b> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
28
+ </div>
29
+ <div role="tabpanel" class="tab-pane" id="messages">
30
+ <b> TODO 3</b> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
31
+ </div>
32
+ </div>
33
+
34
+ </div>
35
+ </div>
36
+ </body>