Skip to content

Commit 3dd847b

Browse files
committed
CSS load and layout optimization
optimizing css loading by loading the layout css before everything else and loading the iframe for the map separately at the end - optimized the layout with less unnecesarry padding
1 parent e38baa6 commit 3dd847b

File tree

1 file changed

+76
-66
lines changed

1 file changed

+76
-66
lines changed

app.py

Lines changed: 76 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,84 @@
1919
}
2020
)
2121

22+
st.markdown(
23+
"""
24+
<style>
25+
/* Header*/
26+
.css-1avcm0n{
27+
height: 1rem;
28+
}
29+
/* Smooth scrolling*/
30+
.main {
31+
scroll-behavior: smooth;
32+
}
33+
/* main app body with less padding*/
34+
.css-z5fcl4 {
35+
padding-block: 0;
36+
}
37+
38+
/*Sidebar*/
39+
.css-1544g2n {
40+
padding: 0 1rem;
41+
}
42+
43+
/*Sidebar : inside container*/
44+
.css-ge7e53 {
45+
width: fit-content;
46+
}
47+
48+
/*Sidebar : image*/
49+
.css-1kyxreq {
50+
display: block !important;
51+
}
52+
53+
/*Sidebar : Navigation list*/
54+
div.element-container:nth-child(4) > div:nth-child(1) > div:nth-child(1) > ul:nth-child(1) {
55+
margin: 0;
56+
padding: 0;
57+
list-style: none;
58+
}
59+
div.element-container:nth-child(4) > div:nth-child(1) > div:nth-child(1) > ul:nth-child(1) > li {
60+
padding: 0;
61+
margin: 0;
62+
padding: 0;
63+
font-weight: 600;
64+
}
65+
div.element-container:nth-child(4) > div:nth-child(1) > div:nth-child(1) > ul:nth-child(1) > li > a {
66+
text-decoration: none;
67+
}
68+
69+
div.element-container:nth-child(4) > div:nth-child(1) > div:nth-child(1) > ul:nth-child(1) > li > a:hover {
70+
color: rgb(46, 206, 255);
71+
transition: 0.3s ease-in-out;
72+
}
73+
74+
/* Sidebar: socials*/
75+
div.css-rklnmr:nth-child(6) > div:nth-child(1) > div:nth-child(1) > p {
76+
display: flex;
77+
flex-direction: row;
78+
gap: 1rem;
79+
}
80+
81+
/* Upload info box */
82+
/*Upload button*/
83+
.css-1erivf3.e1b2p2ww15 {
84+
display: flex;
85+
flex-direction: column;
86+
align-items: inherit;
87+
font-size: 14px;
88+
}
89+
.css-u8hs99.eqdbnj014{
90+
display: flex;
91+
flex-direction: row;
92+
margin-inline: 0;
93+
}
94+
</style>
95+
""", unsafe_allow_html=True)
96+
2297
# Initializing the Earth Engine library
2398
# Use ee.Initialize() only on local machine! Comment back before deployement (Unusable on deployment > use geemap init+auth bellow)
24-
#ee.Initialize()
99+
ee.Initialize()
25100
# geemap auth + initialization for cloud deployment
26101
@st.cache_data(persist=True)
27102
def ee_authenticate(token_name="EARTHENGINE_TOKEN"):
@@ -401,71 +476,6 @@ def getNDVI(collection):
401476
st.markdown(
402477
"""
403478
<style>
404-
/* Smooth scrolling*/
405-
.main {
406-
scroll-behavior: smooth;
407-
}
408-
/* main app body with less padding*/
409-
.css-z5fcl4 {
410-
padding-block: 1rem;
411-
}
412-
413-
/*Upload button*/
414-
.css-1erivf3.e1b2p2ww15 {
415-
display: flex;
416-
flex-direction: column;
417-
align-items: inherit;
418-
font-size: 14px;
419-
}
420-
.css-u8hs99.eqdbnj014{
421-
display: flex;
422-
flex-direction: row;
423-
margin-inline: 0;
424-
}
425-
426-
/*Sidebar*/
427-
.css-1544g2n {
428-
padding: 0 1rem;
429-
}
430-
431-
/*Sidebar : inside container*/
432-
.css-ge7e53 {
433-
width: fit-content;
434-
}
435-
436-
/*Sidebar : image*/
437-
.css-1kyxreq {
438-
display: block !important;
439-
}
440-
441-
/*Sidebar : Navigation list*/
442-
div.element-container:nth-child(4) > div:nth-child(1) > div:nth-child(1) > ul:nth-child(1) {
443-
margin: 0;
444-
padding: 0;
445-
list-style: none;
446-
}
447-
div.element-container:nth-child(4) > div:nth-child(1) > div:nth-child(1) > ul:nth-child(1) > li {
448-
padding: 0;
449-
margin: 0;
450-
padding: 0;
451-
font-weight: 600;
452-
}
453-
div.element-container:nth-child(4) > div:nth-child(1) > div:nth-child(1) > ul:nth-child(1) > li > a {
454-
text-decoration: none;
455-
}
456-
457-
div.element-container:nth-child(4) > div:nth-child(1) > div:nth-child(1) > ul:nth-child(1) > li > a:hover {
458-
color: rgb(46, 206, 255);
459-
transition: 0.3s ease-in-out;
460-
}
461-
462-
/* Sidebar: socials*/
463-
div.css-rklnmr:nth-child(6) > div:nth-child(1) > div:nth-child(1) > p {
464-
display: flex;
465-
flex-direction: row;
466-
gap: 1rem;
467-
}
468-
469479
/*Map iframe*/
470480
iframe {
471481
width: 100%;

0 commit comments

Comments
 (0)