PythonMindset commited on
Commit
a88b0ec
·
1 Parent(s): 1910208

Fix: Pure HTML projects page + sticky sidebar

Browse files
Files changed (2) hide show
  1. pages/2_Projects.py +26 -47
  2. styles.css +9 -0
pages/2_Projects.py CHANGED
@@ -3,63 +3,42 @@ from config import PROJECTS
3
 
4
  st.set_page_config(page_title="Projets", page_icon="💼", layout="wide")
5
 
6
- # Charger CSS
7
  with open("styles.css", encoding="utf-8") as f:
8
  st.markdown(f"<style>{f.read()}</style>", unsafe_allow_html=True)
9
 
10
- st.markdown('<h1 style="color: #00D9FF; text-align: center; margin-bottom: 3rem; font-weight: 800;">💼 Mes Projets Data Science</h1>', unsafe_allow_html=True)
11
 
12
  for idx, proj in enumerate(PROJECTS):
13
- clean_title = proj['titre'].replace(proj['icon'], '').strip()
 
 
14
 
15
- badge_html = '<span class="card-badge">✓ Déployé</span>' if proj['statut'] == "Déployé" else '<span class="card-badge" style="background: #667EEA;">✓ Complet</span>'
 
 
16
 
17
- st.markdown(f'''
18
- <div class="project-card">
19
- <h2 class="project-title">{proj["icon"]} {clean_title} {badge_html}</h2>
20
- <p style="color: #D5DAE1; font-size: 1.05rem; line-height: 1.8; margin: 1rem 0 1.5rem 0;">
21
- {proj["description"]}
22
- </p>
23
- </div>
24
- ''', unsafe_allow_html=True)
25
 
26
- # Technologies
27
- st.markdown("**Technologies :**")
28
- tech_cols = st.columns(len(proj['technologies']))
29
- for i, tech in enumerate(proj['technologies']):
30
- with tech_cols[i]:
31
- st.markdown(f'<span class="tech-pill">{tech}</span>', unsafe_allow_html=True)
32
 
33
- # Images
34
- st.markdown('<h3 style="color: #00D9FF; margin: 2rem 0 1rem 0;">📸 Aperçu</h3>', unsafe_allow_html=True)
 
 
35
 
36
- col1, col2 = st.columns(2)
 
37
 
38
- if idx == 0:
39
- images = [f"images/projects/dakar_{i}.png" for i in range(1, 5)]
40
- elif idx == 1:
41
- images = [f"images/projects/tidianeflix_{i}.png" for i in range(1, 5)]
42
- elif idx == 2:
43
- images = [f"images/projects/sentimentscope_{i}.png" for i in range(1, 5)]
44
- elif idx == 3:
45
- images = [f"images/projects/climate_change{i}.png" for i in range(1, 5)]
46
-
47
- for i, img_path in enumerate(images):
48
- try:
49
- with col1 if i % 2 == 0 else col2:
50
- st.image(img_path, use_container_width=True)
51
- except:
52
- pass
53
-
54
- # Liens avec VRAIS BOUTONS
55
- st.markdown('<h3 style="color: #00D9FF; margin: 2rem 0 1rem 0;">🔗 Liens du projet</h3>', unsafe_allow_html=True)
56
-
57
- cols = st.columns(len(proj['liens']))
58
- label_map = {"github": "💻 GitHub", "demo": "🌐 Démo en direct", "notebook": "📓 Carnet"}
59
-
60
- for i, (key, url) in enumerate(proj['liens'].items()):
61
- with cols[i]:
62
- st.link_button(label_map.get(key, key.title()), url, use_container_width=True)
63
 
 
64
  if idx < len(PROJECTS) - 1:
65
- st.markdown("---")
 
 
 
3
 
4
  st.set_page_config(page_title="Projets", page_icon="💼", layout="wide")
5
 
 
6
  with open("styles.css", encoding="utf-8") as f:
7
  st.markdown(f"<style>{f.read()}</style>", unsafe_allow_html=True)
8
 
9
+ html = '<h1 style="color: #00D9FF; text-align: center; margin-bottom: 3rem; font-weight: 800;">💼 Mes Projets Data Science</h1>'
10
 
11
  for idx, proj in enumerate(PROJECTS):
12
+ clean_title = proj["titre"].replace(proj["icon"], "").strip()
13
+ badge_style = "" if proj["statut"] == "Déployé" else 'style="background: #667EEA;"'
14
+ badge_text = "✓ Déployé" if proj["statut"] == "Déployé" else "✓ Complet"
15
 
16
+ html += f'<div class="project-card" style="margin: 2rem 0;">'
17
+ html += f'<h2 class="project-title">{proj["icon"]} {clean_title} <span class="card-badge" {badge_style}>{badge_text}</span></h2>'
18
+ html += f'<p style="color: #D5DAE1; font-size: 1.05rem; line-height: 1.8;">{proj["description"]}</p>'
19
 
20
+ html += '<div style="margin: 1rem 0;"><strong style="color: #00D9FF;">Technologies:</strong><br/>'
21
+ for tech in proj["technologies"]:
22
+ html += f'<span class="tech-pill">{tech}</span>'
23
+ html += '</div>'
 
 
 
 
24
 
25
+ html += '<h3 style="color: #00D9FF; margin: 1.5rem 0 1rem;">📸 Aperçu</h3>'
26
+ html += '<div style="display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem;">'
 
 
 
 
27
 
28
+ prefix = ["dakar", "tidianeflix", "sentimentscope", "climate_change"][idx]
29
+ for i in range(1, 5):
30
+ suffix = f"_{i}" if idx < 3 else str(i)
31
+ html += f'<img src="app/static/images/projects/{prefix}{suffix}.png" style="width: 100%; border-radius: 8px; border: 2px solid rgba(0,217,255,0.3);">'
32
 
33
+ html += '</div><h3 style="color: #00D9FF; margin: 1.5rem 0 1rem;">🔗 Liens du projet</h3>'
34
+ html += '<div style="display: flex; gap: 1rem;">'
35
 
36
+ labels = {"github": "💻 GitHub", "demo": "🌐 Démo en direct", "notebook": "📓 Carnet"}
37
+ for key, url in proj["liens"].items():
38
+ html += f'<a href="{url}" target="_blank" class="stButton"><span>{labels.get(key, key)}</span></a>'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
 
40
+ html += '</div></div>'
41
  if idx < len(PROJECTS) - 1:
42
+ html += '<hr style="margin: 3rem 0; border: 1px solid rgba(0,217,255,0.2);">'
43
+
44
+ st.markdown(html, unsafe_allow_html=True)
styles.css CHANGED
@@ -313,3 +313,12 @@ header[data-testid="stHeader"] {
313
  #MainMenu, footer {
314
  visibility: hidden;
315
  }
 
 
 
 
 
 
 
 
 
 
313
  #MainMenu, footer {
314
  visibility: hidden;
315
  }
316
+
317
+
318
+ /* ============ SIDEBAR STICKY ============ */
319
+ [data-testid="stSidebar"] > div:first-child {
320
+ position: sticky !important;
321
+ top: 0 !important;
322
+ height: 100vh !important;
323
+ overflow-y: auto !important;
324
+ }