UCS2014 commited on
Commit
fdd7e80
·
verified ·
1 Parent(s): 3fc666d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +84 -43
app.py CHANGED
@@ -9,12 +9,16 @@ 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 = 120 # px (breathing room above hero; raise if the logo looks "trimmed")
13
- CARD_WIDTH = 300 # px (fixed width per card on desktop)
14
- CARD_THUMB_HEIGHT = 180 # px (image area inside each card)
15
- GRID_GAP = 100 # px (space between the cards)
16
  BUTTON_TEXT = "Click to Run APP"
17
- OPEN_IN_NEW_TAB = False # True = open links in a new tab
 
 
 
 
18
 
19
  # ========= BRAND / APPS =========
20
  COMPANY_NAME = "Smart Thinking - Logging"
@@ -25,23 +29,23 @@ APP1 = {
25
  "url": "https://smart-thinking-gr.hf.space/",
26
  "thumb": ASSETS / "app1.png",
27
  "blurb": "Real-Time GR Logging Prediction",
28
- "bg": "#F7FBFF", # very light blue
29
- "border":"#713F12", # accent border
30
  }
31
  APP2 = {
32
  "title": "ST_Log_Sonic (Ts)",
33
  "url": "https://smart-thinking-sonic-ts.hf.space",
34
  "thumb": ASSETS / "app2.png",
35
  "blurb": "Real-Time Shear Slowness Logging Prediction",
36
- "bg": "#F6FFF7", # very light green
37
  "border":"#713F12",
38
  }
39
  APP3 = {
40
  "title": "ST_Log_Sonic (Tc)",
41
- "url": "https://smart-thinking-sonic-tc.hf.space", # <-- replace with your Space URL
42
- "thumb": ASSETS / "app3.png", # <-- upload this image
43
  "blurb": "Real-Time Compression Slowness Logging Prediction",
44
- "bg": "#F9F6FF", # very light purple
45
  "border":"#713F12",
46
  }
47
 
@@ -51,7 +55,60 @@ LOGO_PATH = ASSETS / "logo.png"
51
  page_icon = str(LOGO_PATH) if LOGO_PATH.exists() else "🧭"
52
  st.set_page_config(page_title=f"{COMPANY_NAME} — Apps", page_icon=page_icon, layout="wide")
53
 
54
- # ========= CSS (fits one screen on desktop; centered titles & buttons) =========
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  st.markdown(
56
  f"""
57
  <style>
@@ -59,8 +116,8 @@ st.markdown(
59
  --top-spacer: {TOP_SPACER}px;
60
  --card-width: {CARD_WIDTH}px;
61
  --grid-gap: {GRID_GAP}px;
62
- --tagline-gap: 0px; /* distance between H1 and tagline */
63
- --grid-top-space: 20px; /* space above the cards */
64
  }}
65
 
66
  html, body, [data-testid="stAppViewContainer"] {{ height: 100%; }}
@@ -83,10 +140,11 @@ st.markdown(
83
  }}
84
  .hero h1 {{ font-size: 2.3rem; margin: .2rem 0 0; }}
85
  .hero p {{
86
- color: #5a5f6a;
87
  margin: var(--tagline-gap) auto 0;
88
  max-width: 720px;
89
  font-style: italic;
 
90
  }}
91
 
92
  /* GRID */
@@ -95,7 +153,7 @@ st.markdown(
95
  gap: var(--grid-gap);
96
  justify-content: center;
97
  align-items: stretch;
98
- flex-wrap: nowrap; /* keep three across on desktop */
99
  margin-top: var(--grid-top-space);
100
  }}
101
  @media (max-width: calc(3 * var(--card-width) + 2 * var(--grid-gap) + 64px)) {{
@@ -107,59 +165,42 @@ st.markdown(
107
  background: var(--card-bg, #fff);
108
  border: 1px solid var(--card-border, rgba(0,0,0,.06));
109
  border-radius:16px; padding:14px;
110
- box-shadow:0 4px 18px rgba(0,0,0,.05);
111
  transition:transform .12s ease, box-shadow .12s ease;
112
  text-align:center; display:flex; flex-direction:column; gap:10px;
113
- align-items: center; /* center children horizontally */
 
114
  }}
115
- .card:hover {{ transform: translateY(-2px); box-shadow: 0 10px 28px rgba(0,0,0,.08); }}
116
 
117
  .thumb {{
118
  width: 100%;
119
  height: {CARD_THUMB_HEIGHT}px;
120
  border-radius:14px;
121
  border:1px solid rgba(0,0,0,.06);
122
- object-fit: contain; /* show full image */
123
  background:#fff;
124
  }}
125
 
126
- .card h3, .card p {{
127
- text-align: center; /* center text */
128
- width: 100%;
129
- }}
130
  .card p {{ color:#5a5f6a; min-height:30px; margin:0 8px 2px; }}
131
 
132
- /* Light button with dark text — centered */
133
  .btn {{
134
  display:inline-block; padding:10px 14px; border-radius:12px;
135
  border:1px solid #e5e7eb; text-decoration:none;
136
  background:#f3f4f6; color:#111827; font-weight:500;
137
- margin: 2px auto 0; /* center via auto margins */
138
- align-self: center; /* and ensure flex centering */
139
  }}
140
  .btn:hover {{ background:#e5e7eb; }}
141
 
142
- .footer {{ text-align:center; color:#6b7280; font-size:1.0em; margin-top: 6px; }}
143
  .footer hr {{ margin: 6px 0; }}
144
  </style>
145
  """,
146
  unsafe_allow_html=True,
147
  )
148
 
149
- # ========= IMAGE HELPERS =========
150
- def data_uri(path: Path) -> str | None:
151
- if not path.exists(): return None
152
- mime, _ = mimetypes.guess_type(path.name)
153
- if not mime: mime = "image/png"
154
- b64 = base64.b64encode(path.read_bytes()).decode("utf-8")
155
- return f"data:{mime};base64,{b64}"
156
-
157
- def img_tag(path: Path, alt: str, cls: str) -> str:
158
- uri = data_uri(path)
159
- if uri:
160
- return f'<img class="{cls}" src="{uri}" alt="{escape(alt)}" />'
161
- 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>'
162
-
163
  # ========= HERO =========
164
  st.markdown(
165
  '<div class="hero">'
@@ -195,4 +236,4 @@ st.markdown(
195
  </div>
196
  """,
197
  unsafe_allow_html=True,
198
- )
 
9
 
10
  # ========= CONTROLS (tweak these) =========
11
  HERO_LOGO_SIZE = 180 # px (top company logo size)
12
+ TOP_SPACER = 120 # 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.jpg" # <-- put your background image here
21
+ BACKGROUND_OPACITY = 0.12 # 0.0 (invisible) ... 1.0 (fully opaque)
22
 
23
  # ========= BRAND / APPS =========
24
  COMPANY_NAME = "Smart Thinking - Logging"
 
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
 
 
55
  page_icon = str(LOGO_PATH) if LOGO_PATH.exists() else "🧭"
56
  st.set_page_config(page_title=f"{COMPANY_NAME} — Apps", page_icon=page_icon, layout="wide")
57
 
58
+ # ========= IMAGE HELPERS =========
59
+ def data_uri(path: Path) -> str | None:
60
+ if not path.exists(): return None
61
+ mime, _ = mimetypes.guess_type(path.name)
62
+ if not mime: mime = "image/png"
63
+ b64 = base64.b64encode(path.read_bytes()).decode("utf-8")
64
+ return f"data:{mime};base64,{b64}"
65
+
66
+ 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
+ Uses a ::before layer attached to the Streamlit app container.
77
+ """
78
+ uri = data_uri(image_path)
79
+ if not uri:
80
+ return
81
+ # Tip: tweak filter() to taste (e.g., blur or desaturate for readability)
82
+ st.markdown(f"""
83
+ <style>
84
+ :root {{
85
+ --bg-opacity: {max(0.0, min(opacity, 1.0))};
86
+ }}
87
+ /* Full-page fixed background behind all content */
88
+ [data-testid="stAppViewContainer"]::before {{
89
+ content: "";
90
+ position: fixed;
91
+ inset: 0;
92
+ z-index: -1;
93
+ background-image: url('{uri}');
94
+ background-size: cover;
95
+ background-position: center;
96
+ background-repeat: no-repeat;
97
+ opacity: var(--bg-opacity);
98
+ filter: saturate(0.9) brightness(1.05); /* add blur(2px) if you want */
99
+ }}
100
+
101
+ /* Keep main container transparent to let the bg show through the gaps */
102
+ [data-testid="stAppViewContainer"] > .main {{
103
+ background: transparent !important;
104
+ }}
105
+ </style>
106
+ """, unsafe_allow_html=True)
107
+
108
+ # Apply background (safe no-op if image is missing)
109
+ inject_background(BACKGROUND_IMAGE, BACKGROUND_OPACITY)
110
+
111
+ # ========= CSS (layout & components) =========
112
  st.markdown(
113
  f"""
114
  <style>
 
116
  --top-spacer: {TOP_SPACER}px;
117
  --card-width: {CARD_WIDTH}px;
118
  --grid-gap: {GRID_GAP}px;
119
+ --tagline-gap: 0px;
120
+ --grid-top-space: 20px;
121
  }}
122
 
123
  html, body, [data-testid="stAppViewContainer"] {{ height: 100%; }}
 
140
  }}
141
  .hero h1 {{ font-size: 2.3rem; margin: .2rem 0 0; }}
142
  .hero p {{
143
+ color: #2b2f36;
144
  margin: var(--tagline-gap) auto 0;
145
  max-width: 720px;
146
  font-style: italic;
147
+ text-shadow: 0 1px 2px rgba(255,255,255,0.35); /* slight lift over bg */
148
  }}
149
 
150
  /* GRID */
 
153
  gap: var(--grid-gap);
154
  justify-content: center;
155
  align-items: stretch;
156
+ flex-wrap: nowrap;
157
  margin-top: var(--grid-top-space);
158
  }}
159
  @media (max-width: calc(3 * var(--card-width) + 2 * var(--grid-gap) + 64px)) {{
 
165
  background: var(--card-bg, #fff);
166
  border: 1px solid var(--card-border, rgba(0,0,0,.06));
167
  border-radius:16px; padding:14px;
168
+ box-shadow:0 4px 18px rgba(0,0,0,.08);
169
  transition:transform .12s ease, box-shadow .12s ease;
170
  text-align:center; display:flex; flex-direction:column; gap:10px;
171
+ align-items: center;
172
+ backdrop-filter: none; /* set to blur(2px) if you want frosted cards */
173
  }}
174
+ .card:hover {{ transform: translateY(-2px); box-shadow: 0 10px 28px rgba(0,0,0,.12); }}
175
 
176
  .thumb {{
177
  width: 100%;
178
  height: {CARD_THUMB_HEIGHT}px;
179
  border-radius:14px;
180
  border:1px solid rgba(0,0,0,.06);
181
+ object-fit: contain;
182
  background:#fff;
183
  }}
184
 
185
+ .card h3, .card p {{ text-align: center; width: 100%; }}
 
 
 
186
  .card p {{ color:#5a5f6a; min-height:30px; margin:0 8px 2px; }}
187
 
 
188
  .btn {{
189
  display:inline-block; padding:10px 14px; border-radius:12px;
190
  border:1px solid #e5e7eb; text-decoration:none;
191
  background:#f3f4f6; color:#111827; font-weight:500;
192
+ margin: 2px auto 0;
193
+ align-self: center;
194
  }}
195
  .btn:hover {{ background:#e5e7eb; }}
196
 
197
+ .footer {{ text-align:center; color:#374151; font-size:1.0em; margin-top: 6px; }}
198
  .footer hr {{ margin: 6px 0; }}
199
  </style>
200
  """,
201
  unsafe_allow_html=True,
202
  )
203
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
204
  # ========= HERO =========
205
  st.markdown(
206
  '<div class="hero">'
 
236
  </div>
237
  """,
238
  unsafe_allow_html=True,
239
+ )