ecodev-front 0.0.4__tar.gz → 0.0.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ecodev-front
3
- Version: 0.0.4
3
+ Version: 0.0.6
4
4
  Summary: Dash component helpers
5
5
  License: MIT
6
6
  Author: Amaury Salles
@@ -7,6 +7,7 @@ from ecodev_front.card import card_title
7
7
  from ecodev_front.card import macro_info
8
8
  from ecodev_front.data_table import data_table
9
9
  from ecodev_front.display_utils import number_formatting
10
+ from ecodev_front.footer_style import footer_style
10
11
  from ecodev_front.graph import graph_box
11
12
  from ecodev_front.nav_items import navbar_action_item
12
13
  from ecodev_front.nav_items import navbar_divider
@@ -26,4 +27,5 @@ from ecodev_front.upload_box import upload_box
26
27
  __all__ = ['app_logo', 'app_title', 'navbar_header', 'navbar_menu', 'data_table', 'navbar_divider',
27
28
  'navbar_action_item', 'navbar_login', 'navbar_menu_item', 'upload_box', 'card_section',
28
29
  'card_title', 'macro_info', 'number_formatting', 'background_card', 'search_bar',
29
- 'graph_box', 'LOGIN_USERNAME_INPUT_ID', 'LOGIN_PASSWORD_INPUT_ID', 'LOGIN_BTN_ID']
30
+ 'graph_box', 'LOGIN_USERNAME_INPUT_ID', 'LOGIN_PASSWORD_INPUT_ID', 'LOGIN_BTN_ID',
31
+ 'footer_style']
@@ -8,18 +8,19 @@ from typing import Optional
8
8
  import dash_mantine_components as dmc
9
9
  from dash import html
10
10
 
11
+ DEFAULT_STYLE = {'padding': '2%',
12
+ 'position': 'flex',
13
+ 'justifyContent': 'center',
14
+ 'alignItems': 'center',
15
+ 'textAlign': 'center'}
16
+
11
17
 
12
18
  def background_card(children: List[dmc.CardSection],
13
19
  style: Optional[Dict[str, str]] = None) -> dmc.Card:
14
20
  """
15
21
  Returns a formatted dmc.Card
16
22
  """
17
- return dmc.Card(children, radius='md', shadow='sm', p=0,
18
- style={'padding': '2%',
19
- 'position': 'flex',
20
- 'justifyContent': 'center',
21
- 'alignItems': 'center',
22
- 'textAlign': 'center'})
23
+ return dmc.Card(children, radius='md', shadow='sm', p=0, style=style or DEFAULT_STYLE)
23
24
 
24
25
 
25
26
  def card_title(title: str,
@@ -4,6 +4,7 @@ Module implementing a generic Dash AG Grid table
4
4
  from typing import Any
5
5
  from typing import Dict
6
6
  from typing import List
7
+ from typing import Union
7
8
 
8
9
  import dash_ag_grid as dag
9
10
  from pydantic_settings import BaseSettings
@@ -24,12 +25,12 @@ DAG_ENTERPRISE_AUTH = DashAgGridEnterprise()
24
25
 
25
26
  def data_table(id: str,
26
27
  df,
27
- column_defs: List[Dict[Any, Any]] = None,
28
- default_col_def: Dict = None,
29
- style: Dict = None,
28
+ column_defs: Union[List[Dict[Any, Any]], None] = None,
29
+ default_col_def: Union[Dict, None] = None,
30
+ style: Union[Dict, None] = None,
30
31
  row_alternating_color='#f5f5f5',
31
- row_style: Dict = None,
32
- dashGridOptions: Dict = None
32
+ row_style: Union[Dict, None] = None,
33
+ dash_grid_options: Union[Dict, None] = None
33
34
  ) -> dag.AgGrid:
34
35
  """
35
36
  Generic Dash AG Grid table
@@ -61,7 +62,7 @@ def data_table(id: str,
61
62
  ]
62
63
  }
63
64
 
64
- dashGridOptions = dashGridOptions or {
65
+ dash_grid_options = dash_grid_options or {
65
66
  'colResizeDefault': 'shift',
66
67
  'rowSelection': 'single',
67
68
  'headerHeight': 30,
@@ -78,5 +79,5 @@ def data_table(id: str,
78
79
  style=style,
79
80
  getRowStyle=row_style,
80
81
  columnSize='responsiveSizeToFit',
81
- dashGridOptions=dashGridOptions
82
+ dashGridOptions=dash_grid_options
82
83
  )
@@ -0,0 +1,26 @@
1
+ """
2
+ BLA
3
+ """
4
+ from typing import Dict
5
+ from typing import Union
6
+
7
+
8
+ def footer_style(
9
+ color: str = '#0066A1', height: str = '5vh', display: str = 'flex'
10
+ ) -> Dict[str, Union[str, int]]:
11
+ """
12
+ Main app footer style
13
+ """
14
+ return {
15
+ 'position': 'fixed',
16
+ 'bottom': 0,
17
+ 'height': height,
18
+ 'width': '100vw',
19
+ 'paddingBottom': '10px',
20
+ 'backgroundColor': color,
21
+ 'color': 'white',
22
+ 'display': display,
23
+ 'textAlign': 'center',
24
+ 'alignContent': 'center',
25
+ 'justifyContent': 'center',
26
+ }
@@ -0,0 +1,29 @@
1
+ """
2
+ BLA
3
+ """
4
+ from typing import Optional
5
+
6
+ import dash_mantine_components as dmc
7
+ from dash import html
8
+
9
+ from ecodev_front.display_utils import number_formatting
10
+
11
+
12
+ def report_value(title: str, value: str | int, unit: Optional[str] = None) -> html.Div:
13
+ """
14
+ BLA
15
+ """
16
+ if isinstance(value, (int, float)):
17
+ value = number_formatting(value)
18
+ elif value.isnumeric():
19
+ value = number_formatting(float(value))
20
+
21
+ return html.Div(
22
+ dmc.Group(
23
+ [
24
+ dmc.Text(title, weight=700, size='16px', color='grey'),
25
+ dmc.Text(value, weight=700, size='16px'),
26
+ dmc.Text(unit, size='14px', italic=True),
27
+ ]
28
+ )
29
+ )
@@ -4,6 +4,7 @@ Component to search something in databases.
4
4
  Note: Typically only used as the main search bar on a page.
5
5
  """
6
6
  from typing import Dict
7
+ from typing import Union
7
8
 
8
9
  import dash_mantine_components as dmc
9
10
  from dash import html
@@ -14,7 +15,7 @@ def search_bar(id: str,
14
15
  label: str,
15
16
  helper: str,
16
17
  helper_text_color: str = 'gray',
17
- style: Dict[str, str] = None,
18
+ style: Union[Dict[str, str], None] = None,
18
19
  icon: str = 'quill:search',
19
20
  debounce: int = 750) -> html.Div:
20
21
  """
@@ -2,6 +2,7 @@
2
2
  Component which allows document upload.
3
3
  """
4
4
  from typing import Dict
5
+ from typing import Union
5
6
 
6
7
  from dash import dcc
7
8
  from dash import html
@@ -20,12 +21,12 @@ DEFAULT_STYLE = {'height': '30vh',
20
21
  def upload_box(id: str,
21
22
  label: str,
22
23
  multiple: bool,
23
- style: Dict[str, str] = DEFAULT_STYLE
24
+ style: Union[Dict[str, str], None] = None
24
25
  ) -> dcc.Upload:
25
26
  """
26
27
  BLA
27
28
  """
28
- return dcc.Upload(id=id, multiple=multiple, style=style,
29
+ return dcc.Upload(id=id, multiple=multiple, style=style or DEFAULT_STYLE,
29
30
  children=html.H5(label, style={'display': 'flex',
30
31
  'justifyContent': 'center',
31
32
  'alignItems': 'center',
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "ecodev-front"
3
- version = "0.0.4"
3
+ version = "0.0.6"
4
4
  description = "Dash component helpers"
5
5
  authors = ["Amaury Salles <amaury.salles@gmail.com>",
6
6
  "Yoann Diep <yoann.diep@hotmail.fr>",
File without changes