sebastrh commited on
Commit
e87a7ea
·
verified ·
1 Parent(s): 38fb341

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +130 -83
app.py CHANGED
@@ -3,74 +3,104 @@ import pandas as pd
3
  from google.oauth2.service_account import Credentials
4
  import gspread
5
  from urllib.parse import quote_plus
 
 
6
 
7
- # --- 1. CONFIGURACIÓN ---
8
  st.set_page_config(page_title="ARZON STUDIOS", layout="wide", initial_sidebar_state="collapsed")
9
 
10
- # --- 2. ICONOS INCORPORADOS (BASE64 DIRECTO PARA CERO TEMBLOR) ---
11
- # Estos códigos son la imagen real. Al estar aquí, el navegador no tiene que "buscar" archivos.
12
- ICONS = {
13
- "menu": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAACXBIWXMAAAsTAAALEwEAmpwYAAAANElEQVR4nO3PQQ0AIBDAsMl/ZxsG97AABySbdms8VfXvBwAAAAAAAAAAAABAnS3pXvAB8XkCH96mYp0AAAAASUVORK5CYII=",
14
- "search": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAW0lEQVR4nO3asQ2AMBBDUf9mYAtYf6Sio6SAnSByS65AnFvSUnvE0X090pP7946UkiS7AnH2X8/9X999O9eS9AnE+fMFAAAAAAAAAAAAALiX8ub+vSNtSfcCAAnKIX+T2yVvAAAAAElFTkSuQmCC",
15
- "wish": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAXElEQVR4nO3asQ2AMBBDUf9mYAtYf6Sio6SAnSByS65AnFvSUnvE0X090pP7946UkiS7AnH2X8/9X999O9eS9AnE+fMFAAAAAAAAAAAAALiX8ub+vSNtSfcCAAnKIX+T2yVvAAAAAElFTkSuQmCC",
16
- "bag": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAW0lEQVR4nO3asQ2AMBBDUf9mYAtYf6Sio6SAnSByS65AnFvSUnvE0X090pP7946UkiS7AnH2X8/9X999O9eS9AnE+fMFAAAAAAAAAAAAALiX8ub+vSNtSfcCAAnKIX+T2yVvAAAAAElFTkSuQmCC"
17
- }
 
 
 
18
 
19
- # --- 3. CSS MAESTRO (FIX DE TEMBLOR Y BOTONES) ---
20
  st.markdown(f"""
21
  <style>
22
  @import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;500&family=Inter:wght@300;400;600&display=swap');
23
 
24
- /* Forzar Blanco y quitar basura */
25
- .stApp {{ background-color: white !important; }}
26
  header, footer, #MainMenu {{ display: none !important; }}
27
  [data-testid="stSidebar"] {{ background-color: white !important; border-right: 1px solid #eee; }}
 
 
 
 
 
 
 
 
 
 
28
 
29
- /* ESTRUCTURA FIJA DEL HEADER (Evita el temblor) */
30
- .nav-btn button {{
31
- background-color: transparent !important;
32
- border: none !important;
33
- width: 35px !important;
34
- height: 35px !important;
35
- background-size: 24px !important;
36
- background-repeat: no-repeat !important;
37
- background-position: center !important;
38
- color: transparent !important;
39
- box-shadow: none !important;
40
- margin: 0 auto !important;
41
- display: block !important;
42
- cursor: pointer !important;
43
  }}
44
-
45
- /* Inyección de Iconos */
46
- .btn-m button {{ background-image: url('{ICONS["menu"]}') !important; }}
47
- .btn-s button {{ background-image: url('{ICONS["search"]}') !important; }}
48
- .btn-w button {{ background-image: url('{ICONS["wish"]}') !important; }}
49
- .btn-b button {{ background-image: url('{ICONS["bag"]}') !important; }}
50
-
51
- .brand-logo {{
52
  font-family: 'Playfair Display', serif;
53
- font-size: 38px;
54
- text-align: center;
55
- letter-spacing: 4px;
56
  text-transform: uppercase;
57
  color: black;
58
- margin-top: -10px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  }}
60
 
61
- /* Estilo botones tienda */
62
- button[kind="primary"] {{
63
- background-color: black !important; color: white !important; border-radius: 0 !important;
64
- text-transform: uppercase; padding: 15px !important; width: 100%; border: none;
 
 
 
 
 
 
 
 
65
  }}
66
- button[kind="secondary"] {{
67
- background-color: white !important; color: black !important; border-radius: 0 !important;
68
- text-transform: uppercase; border: 1px solid #ddd !important; width: 100%;
 
 
 
 
 
 
 
 
69
  }}
70
  </style>
71
  """, unsafe_allow_html=True)
72
 
73
  # --- 4. CONEXIÓN DATOS ---
 
74
  secret_dict = {
75
  "type": "service_account",
76
  "project_id": "trhhats",
@@ -101,49 +131,66 @@ df = cargar_catalogo()
101
 
102
  # --- 5. ESTADO ---
103
  if 'page' not in st.session_state: st.session_state.page = 'home'
 
104
  if 'cart' not in st.session_state: st.session_state.cart = []
105
- if 'category' not in st.session_state: st.session_state.category = "VIEW ALL"
106
-
107
- # --- 6. HEADER ---
108
- c1, c2, c3, c4, c5, c6 = st.columns([0.5, 0.5, 3, 0.1, 0.5, 0.5])
109
-
110
- with c1:
111
- st.markdown('<div class="nav-btn btn-m">', unsafe_allow_html=True)
112
- if st.button(" ", key="m"): st.sidebar.write("Menú Abierto")
113
- st.markdown('</div>', unsafe_allow_html=True)
114
-
115
- with c2:
116
- st.markdown('<div class="nav-btn btn-s">', unsafe_allow_html=True)
117
- if st.button(" ", key="s"): st.toast("Buscador")
118
- st.markdown('</div>', unsafe_allow_html=True)
119
-
120
- with c3:
121
- st.markdown('<div class="brand-logo">ARZON STUDIOS</div>', unsafe_allow_html=True)
122
- # Botón invisible sobre logo para Home
123
- st.markdown('<div style="position:relative; height:40px; margin-top:-40px;">', unsafe_allow_html=True)
124
- if st.button("logo", key="l", use_container_width=True):
125
- st.session_state.page = 'home'; st.rerun()
126
- st.markdown('</div>', unsafe_allow_html=True)
127
-
128
- with c5:
129
- st.markdown('<div class="nav-btn btn-w">', unsafe_allow_html=True)
130
- if st.button(" ", key="w"): st.session_state.page = 'wishlist'; st.rerun()
131
- st.markdown('</div>', unsafe_allow_html=True)
132
 
133
- with c6:
134
- st.markdown('<div class="nav-btn btn-b">', unsafe_allow_html=True)
135
- if st.button(" ", key="b"): st.toast("Carrito")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
136
  st.markdown('</div>', unsafe_allow_html=True)
137
 
138
- # --- 7. CONTENIDO ---
139
  if st.session_state.page == 'home':
140
  st.markdown("<br>", unsafe_allow_html=True)
141
- cols = st.columns(3, gap="large")
142
  if not df.empty:
143
- for idx, row in df.iterrows():
144
- with cols[idx % 3]:
 
145
  st.image(row['Imagen'], use_container_width=True)
146
- st.markdown(f"<div style='text-align:center; font-weight:bold;'>{row['Producto']}</div>", unsafe_allow_html=True)
147
- st.markdown(f"<div style='text-align:center;'>${row['Precio']} MXN</div>", unsafe_allow_html=True)
148
- if st.button("SHOP NOW", key=f"btn_{idx}", use_container_width=True):
149
- st.toast(f"Agregado {row['Producto']}")
 
 
 
 
 
 
 
 
3
  from google.oauth2.service_account import Credentials
4
  import gspread
5
  from urllib.parse import quote_plus
6
+ import base64
7
+ import os
8
 
9
+ # --- 1. CONFIGURACIÓN DE PÁGINA ---
10
  st.set_page_config(page_title="ARZON STUDIOS", layout="wide", initial_sidebar_state="collapsed")
11
 
12
+ # --- 2. CARGA DE ICONOS (BASE64 PARA EVITAR PARPADEO) ---
13
+ def get_base64(file):
14
+ if os.path.exists(file):
15
+ with open(file, "rb") as f:
16
+ return base64.b64encode(f.read()).decode()
17
+ return ""
18
+
19
+ ico_menu = get_base64("menu.png")
20
+ ico_search = get_base64("search.png")
21
+ ico_wish = get_base64("wish.png")
22
+ ico_bag = get_base64("bag.png")
23
 
24
+ # --- 3. CSS MAESTRO (POSICIONAMIENTO AMIRI) ---
25
  st.markdown(f"""
26
  <style>
27
  @import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;500&family=Inter:wght@300;400;600&display=swap');
28
 
29
+ /* Fondo Blanco y Limpieza de Interfaz */
30
+ [data-testid="stAppViewContainer"] {{ background-color: white !important; }}
31
  header, footer, #MainMenu {{ display: none !important; }}
32
  [data-testid="stSidebar"] {{ background-color: white !important; border-right: 1px solid #eee; }}
33
+ [data-testid="stSidebar"] button[kind="header"] {{ display: none; }}
34
+
35
+ /* CONTENEDOR DE NAVEGACIÓN */
36
+ .nav-container {{
37
+ display: flex;
38
+ align-items: center;
39
+ justify-content: center;
40
+ height: 60px;
41
+ position: relative;
42
+ }}
43
 
44
+ .nav-icon {{
45
+ width: 22px;
46
+ height: 22px;
47
+ object-fit: contain;
 
 
 
 
 
 
 
 
 
 
48
  }}
49
+
50
+ .brand-text {{
 
 
 
 
 
 
51
  font-family: 'Playfair Display', serif;
52
+ font-size: 35px;
53
+ letter-spacing: 5px;
 
54
  text-transform: uppercase;
55
  color: black;
56
+ text-align: center;
57
+ }}
58
+
59
+ /* BOTONES FANTASMA (EL TRUCO FINAL) */
60
+ /* Hacemos que los botones de Streamlit sean invisibles y floten sobre los iconos */
61
+ div[data-testid="column"] .stButton button {{
62
+ position: absolute;
63
+ top: 0;
64
+ left: 0;
65
+ width: 100% !important;
66
+ height: 50px !important;
67
+ opacity: 0 !important; /* Totalmente invisible */
68
+ border: none !important;
69
+ background: transparent !important;
70
+ z-index: 10;
71
+ cursor: pointer;
72
  }}
73
 
74
+ /* BOTONES VISIBLES DE LA TIENDA */
75
+ .shop-btn button {{
76
+ opacity: 1 !important;
77
+ background-color: transparent !important;
78
+ border: 1px solid #ddd !important;
79
+ text-transform: uppercase;
80
+ font-size: 11px !important;
81
+ letter-spacing: 1px;
82
+ border-radius: 0 !important;
83
+ color: black !important;
84
+ position: relative !important; /* No flotan */
85
+ height: auto !important;
86
  }}
87
+ .shop-btn button:hover {{ border-color: black !important; }}
88
+
89
+ .black-btn button {{
90
+ opacity: 1 !important;
91
+ background-color: black !important;
92
+ color: white !important;
93
+ border: none !important;
94
+ font-weight: 600;
95
+ padding: 15px !important;
96
+ border-radius: 0 !important;
97
+ position: relative !important;
98
  }}
99
  </style>
100
  """, unsafe_allow_html=True)
101
 
102
  # --- 4. CONEXIÓN DATOS ---
103
+ # (Copia aquí tu lógica de cargar_catalogo() con tus credenciales secret_dict)
104
  secret_dict = {
105
  "type": "service_account",
106
  "project_id": "trhhats",
 
131
 
132
  # --- 5. ESTADO ---
133
  if 'page' not in st.session_state: st.session_state.page = 'home'
134
+ if 'search_open' not in st.session_state: st.session_state.search_open = False
135
  if 'cart' not in st.session_state: st.session_state.cart = []
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
136
 
137
+ # --- 6. HEADER (LA ESTRUCTURA FIJA) ---
138
+ # Usamos una sola fila de columnas para el header
139
+ h_col = st.columns([0.5, 0.5, 4, 0.5, 0.5])
140
+
141
+ with h_col[0]: # MENU
142
+ st.markdown(f'<div class="nav-container"><img src="data:image/png;base64,{ico_menu}" class="nav-icon"></div>', unsafe_allow_html=True)
143
+ if st.button(" ", key="btn_menu"):
144
+ st.session_state.search_open = False
145
+ st.toast("Abriendo menú...")
146
+
147
+ with h_col[1]: # SEARCH
148
+ st.markdown(f'<div class="nav-container"><img src="data:image/png;base64,{ico_search}" class="nav-icon"></div>', unsafe_allow_html=True)
149
+ if st.button(" ", key="btn_search"):
150
+ st.session_state.search_open = not st.session_state.search_open
151
+ st.rerun()
152
+
153
+ with h_col[2]: # LOGO TEXTO
154
+ st.markdown('<div class="brand-text">ARZON STUDIOS</div>', unsafe_allow_html=True)
155
+ if st.button(" ", key="btn_logo"):
156
+ st.session_state.page = 'home'
157
+ st.session_state.search_open = False
158
+ st.rerun()
159
+
160
+ with h_col[3]: # WISH
161
+ st.markdown(f'<div class="nav-container"><img src="data:image/png;base64,{ico_wish}" class="nav-icon"></div>', unsafe_allow_html=True)
162
+ if st.button(" ", key="btn_wish"):
163
+ st.session_state.page = 'wishlist'
164
+ st.rerun()
165
+
166
+ with h_col[4]: # BAG
167
+ st.markdown(f'<div class="nav-container"><img src="data:image/png;base64,{ico_bag}" class="nav-icon"></div>', unsafe_allow_html=True)
168
+ if st.button(" ", key="btn_bag"):
169
+ st.toast("Carrito")
170
+
171
+ # --- 7. BUSCADOR DESPLEGABLE ---
172
+ if st.session_state.search_open:
173
+ st.markdown('<div style="border-bottom: 1px solid #000; padding: 20px 0; margin-bottom: 40px;">', unsafe_allow_html=True)
174
+ st.text_input("SEARCH", placeholder="Type to search...", label_visibility="collapsed")
175
+ st.caption("POPULAR SEARCHES: NEW ARRIVALS, ACCESSORIES")
176
  st.markdown('</div>', unsafe_allow_html=True)
177
 
178
+ # --- 8. CONTENIDO PRINCIPAL ---
179
  if st.session_state.page == 'home':
180
  st.markdown("<br>", unsafe_allow_html=True)
 
181
  if not df.empty:
182
+ cols = st.columns(3, gap="large")
183
+ for i, row in df.iterrows():
184
+ with cols[i % 3]:
185
  st.image(row['Imagen'], use_container_width=True)
186
+ st.markdown(f"<div style='text-align:center; font-weight:600; margin-top:10px;'>{row['Producto']}</div>", unsafe_allow_html=True)
187
+ st.markdown(f"<div style='text-align:center; margin-bottom:10px;'>${row['Precio']} MXN</div>", unsafe_allow_html=True)
188
+ st.markdown('<div class="shop-btn">', unsafe_allow_html=True)
189
+ if st.button("SHOP NOW", key=f"s_{i}"):
190
+ st.toast(f"Ver {row['Producto']}")
191
+ st.markdown('</div>', unsafe_allow_html=True)
192
+ st.write("")
193
+
194
+ elif st.session_state.page == 'wishlist':
195
+ st.markdown("<h3 style='text-align:center; letter-spacing:2px;'>WISHLIST</h3>", unsafe_allow_html=True)
196
+ st.info("Tu lista está vacía.")