UCS2014 commited on
Commit
674b03f
·
verified ·
1 Parent(s): 41d63dd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +45 -51
app.py CHANGED
@@ -3,17 +3,17 @@ from html import escape
3
  from pathlib import Path
4
  import streamlit as st
5
 
6
- # ---------- PATHS (subfolder-safe) ----------
7
  BASE_DIR = Path(__file__).parent # -> Landing_Page/
8
  ASSETS = BASE_DIR / "assets" # -> Landing_Page/assets/
9
 
10
- # ---------- CONTROLS (easy knobs) ----------
11
- HERO_LOGO_SIZE = 140 # px (company logo in the hero)
12
- CARD_THUMB_HEIGHT = 180 # px (image area inside each card)
13
  BUTTON_TEXT = "Click to Run APP"
14
- OPEN_IN_NEW_TAB = False # set True to open links in a new browser tab
15
 
16
- # ---------- CONFIG ----------
17
  COMPANY_NAME = "Smart Thinking"
18
  TAGLINE = "We Deliver Smart AI-Based Solutions For O&G Industry"
19
 
@@ -31,40 +31,41 @@ APP2 = {
31
  }
32
  LOGO_PATH = ASSETS / "logo.png"
33
 
34
- # ---------- PAGE META ----------
35
  page_icon = str(LOGO_PATH) if LOGO_PATH.exists() else "🧭"
36
  st.set_page_config(page_title=f"{COMPANY_NAME} — Apps", page_icon=page_icon, layout="wide")
37
 
38
- # ---------- CSS (fit to 1 screen on desktop, center content) ----------
39
  st.markdown(
40
  f"""
41
  <style>
42
  html, body, [data-testid="stAppViewContainer"] {{ height: 100%; }}
43
- [data-testid="stAppViewContainer"] > .main {{
44
- min-height: 100vh;
45
- }}
46
  .block-container {{
47
- max-width: 1100px;
48
  min-height: 100vh;
49
- display: flex; flex-direction: column; justify-content: center;
50
- padding-top: 12px !important; padding-bottom: 12px !important;
 
 
51
  }}
52
 
53
- .hero {{ text-align:center; margin: 4px 0 16px; }}
 
54
  .hero img {{
55
  width: {HERO_LOGO_SIZE}px; max-width: 95vw; height: auto;
56
- display: block; margin: 0 auto;
57
  filter: drop-shadow(0 2px 8px rgba(0,0,0,.12));
58
  }}
59
- .hero h1 {{ font-size: 2.2rem; margin: .75rem 0 .25rem; }}
60
  .hero p {{ color: #5a5f6a; margin: 0 auto; max-width: 720px; }}
61
 
62
- /* Cards layout: 2 columns on desktop, stack on small screens */
63
- @media (min-width: 901px) {{
64
- .two-cols {{ display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }}
65
- }}
66
- @media (max-width: 900px) {{
67
- .two-cols {{ display: grid; grid-template-columns: 1fr; gap: 16px; }}
68
  }}
69
 
70
  .card {{
@@ -72,7 +73,7 @@ st.markdown(
72
  border: 1px solid rgba(0,0,0,.06);
73
  box-shadow: 0 4px 18px rgba(0,0,0,.05);
74
  transition: transform .12s ease, box-shadow .12s ease;
75
- text-align: center; /* center everything */
76
  }}
77
  .card:hover {{ transform: translateY(-2px); box-shadow: 0 10px 28px rgba(0,0,0,.08); }}
78
 
@@ -81,27 +82,27 @@ st.markdown(
81
  height: {CARD_THUMB_HEIGHT}px;
82
  border-radius: 14px;
83
  border: 1px solid rgba(0,0,0,.06);
84
- object-fit: contain; /* show full image, no crop */
85
  background: #fff;
86
  }}
87
 
88
  .card h3 {{ margin: 12px 0 6px; }}
89
  .card p {{ color: #5a5f6a; min-height: 36px; margin-bottom: 10px; }}
90
 
91
- /* Light button, dark text */
92
  .btn {{
93
  display:inline-block; padding: 10px 14px; border-radius: 12px;
94
  border: 1px solid #e5e7eb; text-decoration:none;
95
  background: #f3f4f6; color: #111827; font-weight: 500;
96
  }}
97
  .btn:hover {{ background:#e5e7eb; }}
98
- .footer {{ text-align:center; color:#8a9099; font-size: 0.9rem; margin-top: 8px; }}
99
  </style>
100
  """,
101
  unsafe_allow_html=True,
102
  )
103
 
104
- # ---------- IMAGE HELPERS ----------
105
  def data_uri(path: Path) -> str | None:
106
  if not path.exists(): return None
107
  mime, _ = mimetypes.guess_type(path.name)
@@ -113,10 +114,10 @@ def img_tag(path: Path, alt: str, cls: str) -> str:
113
  uri = data_uri(path)
114
  if uri:
115
  return f'<img class="{cls}" src="{uri}" alt="{escape(alt)}" />'
116
- # graceful placeholder
117
  return f'<div class="{cls}" style="display:flex;align-items:center;justify-content:center;color:#50545c;background:linear-gradient(180deg,#f6f7fb,#eceff4);">{escape(alt)}</div>'
118
 
119
- # ---------- HERO ----------
120
  st.markdown(
121
  '<div class="hero">'
122
  + (img_tag(LOGO_PATH, "logo", "") if LOGO_PATH.exists() else "")
@@ -126,29 +127,22 @@ st.markdown(
126
  unsafe_allow_html=True,
127
  )
128
 
129
- # ---------- CARD HTML ----------
130
  def app_card(app: dict) -> str:
131
  target = "_blank" if OPEN_IN_NEW_TAB else "_self"
132
- return f"""
133
- <div class="card">
134
- {img_tag(app['thumb'], app['title'], "thumb")}
135
- <h3>{escape(app['title'])}</h3>
136
- <p>{escape(app['blurb'])}</p>
137
- <a class="btn" href="{escape(app['url'])}" target="{target}">{escape(BUTTON_TEXT)}</a>
138
- </div>
139
- """
140
-
141
- # Render as two separate markdown blocks (prevents partial escaping issues)
142
- left = app_card(APP1)
143
- right = app_card(APP2)
144
-
145
- st.markdown('<div class="two-cols">', unsafe_allow_html=True)
146
- st.markdown(left, unsafe_allow_html=True)
147
- st.markdown(right, unsafe_allow_html=True)
148
- st.markdown('</div>', unsafe_allow_html=True)
149
-
150
- # Footer
151
- # =========================
152
  st.markdown("""
153
  <br><br><br>
154
  <hr>
 
3
  from pathlib import Path
4
  import streamlit as st
5
 
6
+ # ========= PATHS (subfolder-safe) =========
7
  BASE_DIR = Path(__file__).parent # -> Landing_Page/
8
  ASSETS = BASE_DIR / "assets" # -> Landing_Page/assets/
9
 
10
+ # ========= CONTROLS (tweak these) =========
11
+ HERO_LOGO_SIZE = 160 # px (company logo size)
12
+ CARD_THUMB_HEIGHT = 170 # px (image height inside each card)
13
  BUTTON_TEXT = "Click to Run APP"
14
+ OPEN_IN_NEW_TAB = False # True = open links in a new tab
15
 
16
+ # ========= BRAND / APPS =========
17
  COMPANY_NAME = "Smart Thinking"
18
  TAGLINE = "We Deliver Smart AI-Based Solutions For O&G Industry"
19
 
 
31
  }
32
  LOGO_PATH = ASSETS / "logo.png"
33
 
34
+ # ========= PAGE META =========
35
  page_icon = str(LOGO_PATH) if LOGO_PATH.exists() else "🧭"
36
  st.set_page_config(page_title=f"{COMPANY_NAME} — Apps", page_icon=page_icon, layout="wide")
37
 
38
+ # ========= CSS (one-screen desktop, original layout) =========
39
  st.markdown(
40
  f"""
41
  <style>
42
  html, body, [data-testid="stAppViewContainer"] {{ height: 100%; }}
43
+ [data-testid="stAppViewContainer"] > .main {{ min-height: 100vh; }}
 
 
44
  .block-container {{
45
+ max-width: 1120px;
46
  min-height: 100vh;
47
+ display: flex; flex-direction: column;
48
+ justify-content: center; /* center vertically on desktop */
49
+ padding-top: 14px !important;
50
+ padding-bottom: 10px !important;
51
  }}
52
 
53
+ /* HERO */
54
+ .hero {{ text-align:center; margin: 10px 0 16px; }}
55
  .hero img {{
56
  width: {HERO_LOGO_SIZE}px; max-width: 95vw; height: auto;
57
+ display:block; margin: 10px auto 6px; /* top margin avoids visual "trim" */
58
  filter: drop-shadow(0 2px 8px rgba(0,0,0,.12));
59
  }}
60
+ .hero h1 {{ font-size: 2.3rem; margin: .6rem 0 .2rem; }}
61
  .hero p {{ color: #5a5f6a; margin: 0 auto; max-width: 720px; }}
62
 
63
+ /* CARDS GRID: keep 2 columns on desktop */
64
+ .grid {{ display:grid; grid-template-columns: 1fr 1fr; gap: 18px; }}
65
+ @media (max-width: 980px) {{
66
+ /* On small screens we allow stacking (scroll may appear) */
67
+ .grid {{ grid-template-columns: 1fr; }}
68
+ .block-container {{ justify-content: flex-start; }}
69
  }}
70
 
71
  .card {{
 
73
  border: 1px solid rgba(0,0,0,.06);
74
  box-shadow: 0 4px 18px rgba(0,0,0,.05);
75
  transition: transform .12s ease, box-shadow .12s ease;
76
+ text-align: center;
77
  }}
78
  .card:hover {{ transform: translateY(-2px); box-shadow: 0 10px 28px rgba(0,0,0,.08); }}
79
 
 
82
  height: {CARD_THUMB_HEIGHT}px;
83
  border-radius: 14px;
84
  border: 1px solid rgba(0,0,0,.06);
85
+ object-fit: contain; /* show full image (no crop) */
86
  background: #fff;
87
  }}
88
 
89
  .card h3 {{ margin: 12px 0 6px; }}
90
  .card p {{ color: #5a5f6a; min-height: 36px; margin-bottom: 10px; }}
91
 
92
+ /* Light button with dark text */
93
  .btn {{
94
  display:inline-block; padding: 10px 14px; border-radius: 12px;
95
  border: 1px solid #e5e7eb; text-decoration:none;
96
  background: #f3f4f6; color: #111827; font-weight: 500;
97
  }}
98
  .btn:hover {{ background:#e5e7eb; }}
99
+ .footer {{ text-align:center; color:#8a9099; font-size: 0.9rem; margin-top: 6px; }}
100
  </style>
101
  """,
102
  unsafe_allow_html=True,
103
  )
104
 
105
+ # ========= IMAGE HELPERS =========
106
  def data_uri(path: Path) -> str | None:
107
  if not path.exists(): return None
108
  mime, _ = mimetypes.guess_type(path.name)
 
114
  uri = data_uri(path)
115
  if uri:
116
  return f'<img class="{cls}" src="{uri}" alt="{escape(alt)}" />'
117
+ # Friendly placeholder if missing
118
  return f'<div class="{cls}" style="display:flex;align-items:center;justify-content:center;color:#50545c;background:linear-gradient(180deg,#f6f7fb,#eceff4);">{escape(alt)}</div>'
119
 
120
+ # ========= HERO (logo → name → tagline) =========
121
  st.markdown(
122
  '<div class="hero">'
123
  + (img_tag(LOGO_PATH, "logo", "") if LOGO_PATH.exists() else "")
 
127
  unsafe_allow_html=True,
128
  )
129
 
130
+ # ========= CARD HTML (compact strings to avoid markdown code-blocks) =========
131
  def app_card(app: dict) -> str:
132
  target = "_blank" if OPEN_IN_NEW_TAB else "_self"
133
+ return (
134
+ "<div class='card'>"
135
+ + img_tag(app["thumb"], app["title"], "thumb")
136
+ + f"<h3>{escape(app['title'])}</h3>"
137
+ + f"<p>{escape(app['blurb'])}</p>"
138
+ + f"<a class='btn' href='{escape(app['url'])}' target='{target}'>{escape(BUTTON_TEXT)}</a>"
139
+ + "</div>"
140
+ )
141
+
142
+ grid_html = "<div class='grid'>" + app_card(APP1) + app_card(APP2) + "</div>"
143
+ st.markdown(grid_html, unsafe_allow_html=True)
144
+
145
+ # ========= Footer (as requested) =========
 
 
 
 
 
 
 
146
  st.markdown("""
147
  <br><br><br>
148
  <hr>