-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.py
110 lines (95 loc) · 2.39 KB
/
utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import streamlit as st
import toml
from PIL import Image
from datetime import datetime
@st.cache_data(ttl=3600)
def load_config(config_readme_path: str):
"""Loads information files"""
config_readme = toml.load(config_readme_path)
return dict(config_readme)
@st.cache_data(ttl=3600)
def load_image(image_path: str):
"""Loads an image"""
return Image.open(image_path)
def display_links(repo_link, other_link) -> None:
"""Displays a repository and other link"""
col1, col2 = st.sidebar.columns(2)
col1.markdown(
f"<a style='display: block; text-align: center;' href={repo_link}>Source code</a>",
unsafe_allow_html=True,
)
col2.markdown(
f"<a style='display: block; text-align: center;' href={other_link}>App introduction</a>",
unsafe_allow_html=True,
)
def is_daytime():
# Get the current local time
now = datetime.now()
# Set the hours during which it's considered daytime (e.g., 6 AM to 6 PM)
daytime_start = now.replace(hour=6, minute=0, second=0)
daytime_end = now.replace(hour=18, minute=0, second=0)
# Check if the current time is within the daytime range
return daytime_start <= now <= daytime_end
general_parameters = [
"um025",
"humidity",
"pressure",
"um050",
"temperature",
"um003",
"um005",
"pm1",
"pm10",
"um100",
"pm25",
"um010",
"voc",
"pm4",
"no",
"no2",
"o3",
"so2",
"co",
]
custom_markers = {
"humidity": "💧", # Humidity - Raindrop Emoji
"others": "▲",
}
custom_css = """
<style>
.card {
padding: 20px;
border: 1px solid #ccc;
border-radius: 10px;
box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.1);
}
.card-title {
font-size: 24px;
font-weight: bold;
margin-bottom: 10px;
}
.card-content {
font-size: 16px;
color: white;
}
</style>
"""
def create_custom_markdown_card(text):
# Apply custom CSS styles to the card
st.markdown(custom_css, unsafe_allow_html=True)
# Create the card
st.markdown(
"""
<div class="card">
<div class="card-title">Information</div>
<div class="card-content">
"""
+ text
+ """
</div>
""",
unsafe_allow_html=True,
)
st.write("")
st.write("")
st.write("")