File size: 3,628 Bytes
d52ae5a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
from dotenv import load_dotenv
from streamlit_extras.stylable_container import stylable_container
from PIL import Image
from ui.article_recommendation import main as article_recommendor_main
from ui.research_paper import main as research_article_suggester_main
from ui.til_feedback import main as feedback_main

load_dotenv()


st.set_page_config(page_title='Multi-Page App', page_icon='📰', layout='wide')

def load_css(file_name):
    with open(file_name) as f:
        return f.read()

def main():

    if 'page' not in st.session_state:
        st.session_state.page = "main"

    if st.session_state.page == "main":
        show_main_page()
    elif st.session_state.page == "article_recommendor":
        article_recommendor_main()
    elif st.session_state.page == "research_article_suggester":
        research_article_suggester_main()
    elif st.session_state.page == "feedback":
        feedback_main()

def show_main_page():

    css = load_css("ui/main.css")
    st.markdown(f"<style>{css}</style>", unsafe_allow_html=True)

    st.markdown('<div class="main-title">Welcome to the Multi-Page App!</div>', unsafe_allow_html=True)
    st.markdown("---")
    st.markdown('<div class="sub-header">Navigate to Specific Pages:</div>', unsafe_allow_html=True)

    card_info = [
        {"title": "Article Recommendor", "description": "Discover articles tailored to your interests.", "key": "article_recommendor"},
        {"title": "Recent Article Suggester", "description": "Get suggestions for recent research articles.", "key": "research_article_suggester"},
        {"title": "Feedback", "description": "Provide your valuable feedback.", "key": "feedback"},
    ]

    num_cols = 3
    num_rows = (len(card_info) + num_cols - 1) // num_cols

    with stylable_container(
        key="container_with_border",
        css_styles="""
            {
                display: flex;
                align-items: center;
                flex-wrap: wrap;
            }
            """,
    ):
        for row in range(num_rows):
            cols = st.columns(num_cols)
            for col in range(num_cols):
                index = row * num_cols + col
                if index < len(card_info):
                    card = card_info[index]
                    with cols[col]:
                        with stylable_container(
                            key="inside_container_with_border",
                            css_styles="""
                                {
                                    height: 500px;
                                    background-color: #f8f9fa;
                                    border-radius: 10px;
                                    box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.1);
                                    display: flex;
                                    justify-content: center;
                                    align-items: center;
                                    flex-wrap: wrap;
                                    padding:10px;
                                """,
                        ):
                            st.markdown(
                                f'''
                                <div class="card">
                                    <h2>{card["title"]}</h2>
                                    <p>{card["description"]}</p>
                                </div>
                                ''', unsafe_allow_html=True)
                            if st.button(f"Go to {card['title']}", key=card["key"]):
                                st.session_state.page = card["key"]

if __name__ == '__main__':
    main()