-
Notifications
You must be signed in to change notification settings - Fork 0
/
design.py
103 lines (77 loc) · 2.71 KB
/
design.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
"""
This module is for specifying the design system and design of the quantified
self application. The typography, colors, and other design elements are defined
here. Several standard components are also defined here, such as buttons,
cards, and forms. Styling is done with Tailwind CSS classes.
This is a separate module from main.py to keep the main module clean and focused
on the application logic.
"""
# =============================================================================
# MARK: imports
# =============================================================================
# Standard library imports
import os
import logging
from contextlib import contextmanager
# Third party imports
from dotenv import load_dotenv
from nicegui import ui
# Local imports
# import logging_config # noqa: F401, pylint: disable=unused-import
# =============================================================================
# MARK: Preamble
# =============================================================================
load_dotenv()
ENV = os.environ.get("ENVI").strip().lower()
# Setup logging
logger = logging.getLogger(__name__)
# =============================================================================
# MARK: Design
# =============================================================================
color_palette = {
"primary": "#006A8A",
"secondary": "#08415C",
"accent": "#cf3965",
"positive": "#3fa63f",
"negative": "#ee5f5b",
"warning": "#FFBD00",
}
# =============================================================================
# MARK: Components
# =============================================================================
class message(ui.label):
def __init__(self, text: str) -> None:
super().__init__(text)
self.classes("text-h4 text-grey-8")
@contextmanager
def frame(page_title: str):
"""
Custom page frame to share the same styling and behavior across all
pages.
"""
ui.colors(
primary=color_palette["primary"],
secondary=color_palette["secondary"],
accent=color_palette["accent"],
positive=color_palette["positive"],
negative=color_palette["negative"],
warning=color_palette["warning"],
)
yield
@contextmanager
def left_drawer():
"""
Custom left_drawer frame
"""
with ui.left_drawer() as drawer:
yield
# =============================================================================
# MARK: main()
# =============================================================================
def main() -> None:
"""Main function for the design module."""
logger.warning(
"The design module was ran as a script. This is not the intended behavior."
)
if __name__ == "__main__":
main()