Skip to content

Commit 0b6db5e

Browse files
committed
Add Ticker state
1 parent c966de7 commit 0b6db5e

File tree

12 files changed

+34
-13
lines changed

12 files changed

+34
-13
lines changed

src/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import streamlit as st
22

3-
from components import sidebar, container
3+
from ui.components import sidebar, container
44

55
st.set_page_config(
66
page_title="Stock Analysis Dashboard",

src/components/sidebar.py

Lines changed: 0 additions & 9 deletions
This file was deleted.
File renamed without changes.

src/ui/components/__init__.py

Whitespace-only changes.
File renamed without changes.
Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
import streamlit as st
12
import streamlit_shadcn_ui as ui
23

34
from .balance_sheet_tab import render as balance_sheet
45
from .cashflow_tab import render as cashflow
56
from .income_stmt_tab import render as income_stmt
67
from .overview_tab import render as overview
8+
from ..state import Ticker
79

810
tab_content = {
911
"Overview": overview,
@@ -14,7 +16,13 @@
1416

1517

1618
def render():
17-
options = list(tab_content.keys())
18-
current_tab = ui.tabs(options, default_value=options[0], key="current_tab")
19+
ticker_name = Ticker()
1920

20-
return tab_content[current_tab]()
21+
if ticker_name.is_available():
22+
options = list(tab_content.keys())
23+
current_tab = ui.tabs(options, default_value=options[0], key="current_tab")
24+
return tab_content[current_tab]()
25+
26+
else:
27+
st.write("welcome page")
28+
st.write("Write a valid ticker to start your analysis!")
File renamed without changes.

src/ui/components/sidebar.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import streamlit as st
2+
3+
4+
def render():
5+
with st.sidebar:
6+
st.title("Dashboard")
7+
st.text_input("Write a valid Ticker", key="ticker", type="default")

src/ui/state/Ticker.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import streamlit as st
2+
3+
4+
class Ticker:
5+
def __init__(self):
6+
if "ticker" not in st.session_state:
7+
st.session_state["ticker"] = ""
8+
self.name = st.session_state["ticker"]
9+
10+
def get_ticker(self):
11+
return self.name
12+
13+
def is_available(self):
14+
return self.name != ""

src/ui/state/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .Ticker import Ticker as Ticker

0 commit comments

Comments
 (0)