UCS2014 commited on
Commit
e2645b8
·
verified ·
1 Parent(s): c83a766

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +120 -87
app.py CHANGED
@@ -8,45 +8,50 @@ BASE_DIR = Path(__file__).parent # -> Landing_Page/
8
  ASSETS = BASE_DIR / "assets" # -> Landing_Page/assets/
9
 
10
  # ========= CONTROLS (tweak these) =========
11
- HERO_LOGO_SIZE = 180 # px (top company logo size)
12
- TOP_SPACER = 160 # px
13
- CARD_WIDTH = 300 # px
14
- CARD_THUMB_HEIGHT = 180 # px
15
- GRID_GAP = 100 # px
16
- BUTTON_TEXT = "Click to Run APP"
17
  OPEN_IN_NEW_TAB = False
18
 
19
- # NEW: Background image controls
20
- BACKGROUND_IMAGE = ASSETS / "bg.png" # <-- put your background image here
21
- BACKGROUND_OPACITY = 0.3 # 0.0 (invisible) ... 1.0 (fully opaque)
 
22
 
23
  # ========= BRAND / APPS =========
24
  COMPANY_NAME = "Smart Thinking - Logging"
25
  TAGLINE = "We Deliver Smart AI-Based Solutions For O&G Industry"
26
 
 
 
 
 
27
  APP1 = {
28
  "title": "ST_Log_GR",
29
  "url": "https://smart-thinking-gr.hf.space/",
30
  "thumb": ASSETS / "app1.png",
31
- "blurb": "Real-Time GR Logging Prediction",
32
- "bg": "#F7FBFF",
33
- "border":"#713F12",
34
  }
35
  APP2 = {
36
  "title": "ST_Log_Sonic (Ts)",
37
  "url": "https://smart-thinking-sonic-ts.hf.space",
38
  "thumb": ASSETS / "app2.png",
39
- "blurb": "Real-Time Shear Slowness Logging Prediction",
40
- "bg": "#F6FFF7",
41
- "border":"#713F12",
42
  }
43
  APP3 = {
44
  "title": "ST_Log_Sonic (Tc)",
45
  "url": "https://smart-thinking-sonic-tc.hf.space",
46
  "thumb": ASSETS / "app3.png",
47
- "blurb": "Real-Time Compression Slowness Logging Prediction",
48
- "bg": "#F9F6FF",
49
- "border":"#713F12",
50
  }
51
 
52
  LOGO_PATH = ASSETS / "logo.png"
@@ -67,157 +72,184 @@ def img_tag(path: Path, alt: str, cls: str) -> str:
67
  uri = data_uri(path)
68
  if uri:
69
  return f'<img class="{cls}" src="{uri}" alt="{escape(alt)}" />'
 
70
  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>'
71
 
72
- # ========= NEW: BACKGROUND INJECTION =========
73
- def inject_background(image_path: Path, opacity: float = 0.12) -> None:
74
- """
75
- Paint a page-wide background image with adjustable opacity.
76
- Works across Streamlit versions by targeting .stApp and the view container.
77
- """
78
  uri = data_uri(image_path)
79
  if not uri:
80
- # Optional: small on-screen hint to confirm path issues
81
  st.caption(f"Background image not found: {image_path}")
82
  return
83
-
84
  st.markdown(f"""
85
  <style>
86
  :root {{
87
  --bg-opacity: {max(0.0, min(opacity, 1.0))};
88
  }}
89
 
90
- /* Make sure the app root can host a positioned overlay */
91
  .stApp {{
92
  position: relative !important;
93
  background: transparent !important;
94
  }}
95
-
96
- /* Some Streamlit builds still use this container; keep it transparent */
97
- [data-testid="stAppViewContainer"] {{
98
- background: transparent !important;
99
- }}
100
-
101
- /* Main content area should not paint over the background */
102
- [data-testid="stAppViewContainer"] > .main {{
103
- background: transparent !important;
104
- }}
105
-
106
  html, body {{
107
  background: transparent !important;
108
  }}
109
 
110
- /* Background overlay inside .stApp so it always sits behind content */
111
  .stApp::before {{
112
  content: "";
113
- position: fixed; /* fixed to viewport */
114
  inset: 0;
115
- z-index: 0; /* below all content we'll raise to 1 */
116
  background-image: url('{uri}');
117
  background-size: cover;
118
  background-position: center;
119
  background-repeat: no-repeat;
120
  opacity: var(--bg-opacity);
121
- filter: saturate(0.9) brightness(1.05); /* add blur(2px) if desired */
122
- pointer-events: none; /* never intercept clicks */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123
  }}
124
 
125
- /* Ensure all Streamlit content stacks above the bg */
126
  .stApp > * {{ position: relative; z-index: 1; }}
127
  </style>
128
  """, unsafe_allow_html=True)
129
 
130
- # Apply background (safe no-op if image is missing)
131
- inject_background(BACKGROUND_IMAGE, BACKGROUND_OPACITY)
132
 
133
- # ========= CSS (layout & components) =========
134
  st.markdown(
135
  f"""
136
  <style>
137
  :root {{
138
  --top-spacer: {TOP_SPACER}px;
139
- --card-width: {CARD_WIDTH}px;
140
  --grid-gap: {GRID_GAP}px;
141
- --tagline-gap: 0px;
142
- --grid-top-space: 20px;
143
  }}
144
 
145
  html, body, [data-testid="stAppViewContainer"] {{ height: 100%; }}
146
  [data-testid="stAppViewContainer"] > .main {{ padding-top: 0 !important; padding-bottom: 0 !important; }}
 
147
  .block-container {{
148
- max-width: 1120px;
149
  min-height: 100vh;
150
  display: flex; flex-direction: column;
151
- justify-content: center;
152
- gap: 10px;
153
- padding: var(--top-spacer) 0 8px !important;
154
  }}
155
 
156
  /* HERO */
157
- .hero {{ text-align:center; margin: 0 0 8px; }}
158
  .hero img {{
159
  width: {HERO_LOGO_SIZE}px; max-width: 95vw; height: auto;
160
  display:block; margin: 0 auto 8px;
161
- filter: drop-shadow(0 2px 8px rgba(0,0,0,.12));
 
 
 
 
 
 
162
  }}
163
- .hero h1 {{ font-size: 2.3rem; margin: .2rem 0 0; }}
164
  .hero p {{
165
- color: #2b2f36;
166
- margin: var(--tagline-gap) auto 0;
167
  max-width: 720px;
168
  font-style: italic;
169
- text-shadow: 0 1px 2px rgba(255,255,255,0.35); /* slight lift over bg */
170
  }}
171
 
172
  /* GRID */
173
  .grid {{
174
- display: flex;
175
- gap: var(--grid-gap);
 
176
  justify-content: center;
177
  align-items: stretch;
178
- flex-wrap: nowrap;
179
  margin-top: var(--grid-top-space);
180
  }}
181
- @media (max-width: calc(3 * var(--card-width) + 2 * var(--grid-gap) + 64px)) {{
182
- .grid {{ flex-wrap: wrap; }}
 
 
 
183
  }}
184
 
185
  .card {{
186
- width: var(--card-width);
187
- background: var(--card-bg, #fff);
188
- border: 1px solid var(--card-border, rgba(0,0,0,.06));
189
- border-radius:16px; padding:14px;
190
- box-shadow:0 4px 18px rgba(0,0,0,.08);
191
- transition:transform .12s ease, box-shadow .12s ease;
192
  text-align:center; display:flex; flex-direction:column; gap:10px;
193
  align-items: center;
194
- backdrop-filter: none; /* set to blur(2px) if you want frosted cards */
 
 
 
 
 
195
  }}
196
- .card:hover {{ transform: translateY(-2px); box-shadow: 0 10px 28px rgba(0,0,0,.12); }}
197
 
198
  .thumb {{
199
  width: 100%;
200
  height: {CARD_THUMB_HEIGHT}px;
201
  border-radius:14px;
202
- border:1px solid rgba(0,0,0,.06);
203
  object-fit: contain;
204
  background:#fff;
205
  }}
206
 
207
- .card h3, .card p {{ text-align: center; width: 100%; }}
208
- .card p {{ color:#5a5f6a; min-height:30px; margin:0 8px 2px; }}
 
 
 
 
 
 
 
 
 
 
 
209
 
 
210
  .btn {{
211
- display:inline-block; padding:10px 14px; border-radius:12px;
212
- border:1px solid #e5e7eb; text-decoration:none;
213
- background:#f3f4f6; color:#111827; font-weight:500;
214
- margin: 2px auto 0;
215
- align-self: center;
 
 
 
 
 
 
216
  }}
217
- .btn:hover {{ background:#e5e7eb; }}
218
 
219
- .footer {{ text-align:center; color:#374151; font-size:1.0em; margin-top: 6px; }}
220
- .footer hr {{ margin: 6px 0; }}
221
  </style>
222
  """,
223
  unsafe_allow_html=True,
@@ -237,12 +269,13 @@ st.markdown(
237
  def app_card(app: dict) -> str:
238
  target = "_blank" if OPEN_IN_NEW_TAB else "_self"
239
  style = f"--card-bg:{app.get('bg','#fff')}; --card-border:{app.get('border','rgba(0,0,0,.06)')};"
 
240
  return (
241
  f"<div class='card' style='{style}'>"
242
- + img_tag(app["thumb"], app["title"], "thumb")
243
  + f"<h3>{escape(app['title'])}</h3>"
244
  + f"<p>{escape(app['blurb'])}</p>"
245
- + f"<a class='btn' href='{escape(app['url'])}' target='{target}'>{escape(BUTTON_TEXT)}</a>"
246
  + "</div>"
247
  )
248
 
@@ -258,4 +291,4 @@ st.markdown(
258
  </div>
259
  """,
260
  unsafe_allow_html=True,
261
- )
 
8
  ASSETS = BASE_DIR / "assets" # -> Landing_Page/assets/
9
 
10
  # ========= CONTROLS (tweak these) =========
11
+ HERO_LOGO_SIZE = 172 # px
12
+ TOP_SPACER = 140 # px (more breathing room at top)
13
+ CARD_WIDTH = 260 # px (leaner cards)
14
+ CARD_THUMB_HEIGHT = 120 # px (smaller thumbs)
15
+ GRID_GAP = 48 # px (more but tighter than 100 when cards are smaller)
16
+ BUTTON_TEXT = "Open App"
17
  OPEN_IN_NEW_TAB = False
18
 
19
+ # Background image
20
+ BACKGROUND_IMAGE = ASSETS / "bg.png"
21
+ BACKGROUND_OPACITY = 0.18 # keep subtle; text stays readable
22
+ BACKGROUND_BLUR_PX = 3 # add slight blur to reduce busyness
23
 
24
  # ========= BRAND / APPS =========
25
  COMPANY_NAME = "Smart Thinking - Logging"
26
  TAGLINE = "We Deliver Smart AI-Based Solutions For O&G Industry"
27
 
28
+ # Accent color (brand)
29
+ ACCENT = "#0E7490" # teal-ish
30
+ ACCENT_SOFT = "rgba(14,116,144,0.12)"
31
+
32
  APP1 = {
33
  "title": "ST_Log_GR",
34
  "url": "https://smart-thinking-gr.hf.space/",
35
  "thumb": ASSETS / "app1.png",
36
+ "blurb": "Real-time gamma ray log prediction.",
37
+ "bg": "#FBFDFE",
38
+ "border":"#D6EAF0",
39
  }
40
  APP2 = {
41
  "title": "ST_Log_Sonic (Ts)",
42
  "url": "https://smart-thinking-sonic-ts.hf.space",
43
  "thumb": ASSETS / "app2.png",
44
+ "blurb": "Predict shear slowness (ΔtS) in real time.",
45
+ "bg": "#FAFFFB",
46
+ "border":"#DAF0D9",
47
  }
48
  APP3 = {
49
  "title": "ST_Log_Sonic (Tc)",
50
  "url": "https://smart-thinking-sonic-tc.hf.space",
51
  "thumb": ASSETS / "app3.png",
52
+ "blurb": "Predict compressional slowness (ΔtC) in real time.",
53
+ "bg": "#FCFBFF",
54
+ "border":"#E4DAF0",
55
  }
56
 
57
  LOGO_PATH = ASSETS / "logo.png"
 
72
  uri = data_uri(path)
73
  if uri:
74
  return f'<img class="{cls}" src="{uri}" alt="{escape(alt)}" />'
75
+ # graceful fallback box if missing
76
  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>'
77
 
78
+ # ========= BACKGROUND (robust) =========
79
+ def inject_background(image_path: Path, opacity: float = 0.15, blur_px: int = 0) -> None:
 
 
 
 
80
  uri = data_uri(image_path)
81
  if not uri:
 
82
  st.caption(f"Background image not found: {image_path}")
83
  return
 
84
  st.markdown(f"""
85
  <style>
86
  :root {{
87
  --bg-opacity: {max(0.0, min(opacity, 1.0))};
88
  }}
89
 
 
90
  .stApp {{
91
  position: relative !important;
92
  background: transparent !important;
93
  }}
94
+ [data-testid="stAppViewContainer"],
95
+ [data-testid="stAppViewContainer"] > .main,
 
 
 
 
 
 
 
 
 
96
  html, body {{
97
  background: transparent !important;
98
  }}
99
 
100
+ /* background layer */
101
  .stApp::before {{
102
  content: "";
103
+ position: fixed;
104
  inset: 0;
105
+ z-index: 0;
106
  background-image: url('{uri}');
107
  background-size: cover;
108
  background-position: center;
109
  background-repeat: no-repeat;
110
  opacity: var(--bg-opacity);
111
+ filter: blur({int(blur_px)}px) saturate(0.9) brightness(1.02);
112
+ pointer-events: none;
113
+ }}
114
+
115
+ /* gradient veil for better readability */
116
+ .stApp::after {{
117
+ content: "";
118
+ position: fixed;
119
+ inset: 0;
120
+ z-index: 0;
121
+ background: radial-gradient(ellipse at center,
122
+ rgba(255,255,255,0.75) 0%,
123
+ rgba(255,255,255,0.55) 40%,
124
+ rgba(255,255,255,0.35) 70%,
125
+ rgba(255,255,255,0.15) 100%);
126
+ pointer-events: none;
127
  }}
128
 
129
+ /* Ensure all content is above the bg */
130
  .stApp > * {{ position: relative; z-index: 1; }}
131
  </style>
132
  """, unsafe_allow_html=True)
133
 
134
+ inject_background(BACKGROUND_IMAGE, BACKGROUND_OPACITY, BACKGROUND_BLUR_PX)
 
135
 
136
+ # ========= CORE CSS =========
137
  st.markdown(
138
  f"""
139
  <style>
140
  :root {{
141
  --top-spacer: {TOP_SPACER}px;
142
+ --card-width: {CARD_WIDTH}px; /* we'll override to fixed 260 below */
143
  --grid-gap: {GRID_GAP}px;
144
+ --grid-top-space: 28px;
145
+ --brand: {ACCENT};
146
  }}
147
 
148
  html, body, [data-testid="stAppViewContainer"] {{ height: 100%; }}
149
  [data-testid="stAppViewContainer"] > .main {{ padding-top: 0 !important; padding-bottom: 0 !important; }}
150
+
151
  .block-container {{
152
+ max-width: 1080px;
153
  min-height: 100vh;
154
  display: flex; flex-direction: column;
155
+ justify-content: flex-start;
156
+ gap: 14px;
157
+ padding: var(--top-spacer) 0 16px !important;
158
  }}
159
 
160
  /* HERO */
161
+ .hero {{ text-align:center; margin: 0 0 18px; }}
162
  .hero img {{
163
  width: {HERO_LOGO_SIZE}px; max-width: 95vw; height: auto;
164
  display:block; margin: 0 auto 8px;
165
+ filter: drop-shadow(0 4px 14px rgba(0,0,0,.10));
166
+ }}
167
+ .hero h1 {{
168
+ font-size: 2.6rem; line-height: 1.15; margin: .25rem 0 .25rem;
169
+ letter-spacing: .3px;
170
+ color: #0F172A;
171
+ text-shadow: 0 1px 0 rgba(255,255,255,.65);
172
  }}
 
173
  .hero p {{
174
+ color: #364152;
175
+ margin: 6px auto 0;
176
  max-width: 720px;
177
  font-style: italic;
 
178
  }}
179
 
180
  /* GRID */
181
  .grid {{
182
+ display: grid;
183
+ grid-template-columns: repeat(3, 260px);
184
+ gap: 48px;
185
  justify-content: center;
186
  align-items: stretch;
 
187
  margin-top: var(--grid-top-space);
188
  }}
189
+ @media (max-width: 1024px) {{
190
+ .grid {{ grid-template-columns: repeat(2, 260px); gap: 36px; }}
191
+ }}
192
+ @media (max-width: 620px) {{
193
+ .grid {{ grid-template-columns: 1fr; }}
194
  }}
195
 
196
  .card {{
197
+ width: 260px;
198
+ background: color-mix(in oklab, white 88%, #f6fafe 12%);
199
+ border: 1px solid rgba(0,0,0,.06);
200
+ border-radius:18px; padding:16px 14px;
201
+ box-shadow: 0 6px 28px rgba(2,20,35,.06);
202
+ transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
203
  text-align:center; display:flex; flex-direction:column; gap:10px;
204
  align-items: center;
205
+ backdrop-filter: saturate(1.1) blur(2px);
206
+ }}
207
+ .card:hover {{
208
+ transform: translateY(-4px);
209
+ box-shadow: 0 14px 40px rgba(2,20,35,.12);
210
+ border-color: {ACCENT_SOFT};
211
  }}
 
212
 
213
  .thumb {{
214
  width: 100%;
215
  height: {CARD_THUMB_HEIGHT}px;
216
  border-radius:14px;
217
+ border:1px solid rgba(0,0,0,.04);
218
  object-fit: contain;
219
  background:#fff;
220
  }}
221
 
222
+ .card h3 {{
223
+ margin: 6px 0 0;
224
+ font-size: 1.05rem;
225
+ font-weight: 700;
226
+ letter-spacing: .2px;
227
+ color: #0b1220;
228
+ }}
229
+ .card p {{
230
+ color:#495464;
231
+ min-height: 34px;
232
+ margin: 4px 8px 0;
233
+ font-size: .95rem;
234
+ }}
235
 
236
+ /* Brand gradient button */
237
  .btn {{
238
+ display:inline-block; padding:10px 16px; border-radius:12px;
239
+ border:1px solid rgba(14,116,144,0.25); text-decoration:none;
240
+ background: linear-gradient(90deg, {ACCENT} 0%, #14B8A6 100%);
241
+ color: white; font-weight: 600; letter-spacing:.2px;
242
+ margin: 8px auto 0;
243
+ box-shadow: 0 6px 18px rgba(20,184,166,.28);
244
+ }}
245
+ .btn:hover {{
246
+ filter: brightness(0.98) saturate(1.05);
247
+ transform: translateY(-1px);
248
+ box-shadow: 0 10px 26px rgba(20,184,166,.35);
249
  }}
 
250
 
251
+ .footer {{ text-align:center; color:#334155; font-size:0.98em; margin-top: 18px; }}
252
+ .footer hr {{ margin: 10px 0; border-color: rgba(0,0,0,.08); }}
253
  </style>
254
  """,
255
  unsafe_allow_html=True,
 
269
  def app_card(app: dict) -> str:
270
  target = "_blank" if OPEN_IN_NEW_TAB else "_self"
271
  style = f"--card-bg:{app.get('bg','#fff')}; --card-border:{app.get('border','rgba(0,0,0,.06)')};"
272
+ # Leaner cards: keep thumb (icon) but smaller; concise description
273
  return (
274
  f"<div class='card' style='{style}'>"
275
+ + img_tag(app['thumb'], app['title'], "thumb")
276
  + f"<h3>{escape(app['title'])}</h3>"
277
  + f"<p>{escape(app['blurb'])}</p>"
278
+ + f"<a class='btn' href='{escape(app['url'])}' target='{target}' rel='noopener'>{escape(BUTTON_TEXT)}</a>"
279
  + "</div>"
280
  )
281
 
 
291
  </div>
292
  """,
293
  unsafe_allow_html=True,
294
+ )