algomancy-content 0.3.12__py3-none-any.whl

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.
@@ -0,0 +1,426 @@
1
+ from datetime import date
2
+
3
+ from dash import html, dcc
4
+ import dash_bootstrap_components as dbc
5
+ import dash_daq as daq
6
+
7
+
8
+ class ShowcaseHomePage:
9
+ @staticmethod
10
+ def register_callbacks():
11
+ pass
12
+
13
+ @staticmethod
14
+ def create_content():
15
+ """
16
+ Creates a div containing a broad set of common HTML UI elements for CSS styling checks.
17
+
18
+ Returns:
19
+ html.Div: A container with examples of default/common elements.
20
+ """
21
+ # Top section: default text elements
22
+ left_text, right_text = default_text_elements()
23
+ top_section = html.Div(
24
+ [
25
+ dbc.Row(
26
+ [
27
+ dbc.Col(left_text, width=6, md=6),
28
+ dbc.Col(right_text, width=6, md=6),
29
+ ]
30
+ ),
31
+ html.Hr(),
32
+ ],
33
+ className="mb-3",
34
+ )
35
+
36
+ # Left column controls (use dcc/dbc components)
37
+ left_controls = [
38
+ dbc.Row(
39
+ [
40
+ dbc.Col(
41
+ html.Div(
42
+ [
43
+ dbc.Label("Text input"),
44
+ dbc.Input(
45
+ type="text",
46
+ placeholder="Enter text",
47
+ id="text-input",
48
+ ),
49
+ ],
50
+ className="mb-3",
51
+ ),
52
+ width=6,
53
+ ),
54
+ dbc.Col(
55
+ html.Div(
56
+ [
57
+ dbc.Label("Password"),
58
+ dbc.Input(
59
+ type="password",
60
+ placeholder="Enter password",
61
+ id="password-input",
62
+ ),
63
+ ],
64
+ className="mb-3",
65
+ ),
66
+ ),
67
+ dbc.Col(
68
+ html.Div(
69
+ [
70
+ dbc.Label("Email"),
71
+ dbc.Input(
72
+ type="email",
73
+ placeholder="name@example.com",
74
+ id="email-input",
75
+ ),
76
+ ],
77
+ className="mb-3",
78
+ ),
79
+ width=6,
80
+ ),
81
+ dbc.Col(
82
+ html.Div(
83
+ [
84
+ dbc.Label("URL"),
85
+ dbc.Input(
86
+ type="url",
87
+ placeholder="https://example.com",
88
+ id="url-input",
89
+ ),
90
+ ],
91
+ className="mb-3",
92
+ ),
93
+ width=6,
94
+ ),
95
+ ]
96
+ ),
97
+ dbc.Row(
98
+ [
99
+ dbc.Col(
100
+ html.Div(
101
+ [
102
+ dbc.Label("Search"),
103
+ dbc.Input(
104
+ type="search",
105
+ placeholder="Search...",
106
+ id="search-input",
107
+ ),
108
+ ],
109
+ className="mb-3",
110
+ ),
111
+ width=6,
112
+ ),
113
+ dbc.Col(
114
+ html.Div(
115
+ [
116
+ dbc.Label("Number"),
117
+ dbc.Input(
118
+ type="number",
119
+ min=0,
120
+ max=10,
121
+ step=1,
122
+ value=5,
123
+ id="number-input",
124
+ ),
125
+ ],
126
+ className="mb-3",
127
+ ),
128
+ ),
129
+ dbc.Col(
130
+ html.Div(
131
+ [
132
+ dbc.Label("Range"),
133
+ dcc.Slider(
134
+ min=0,
135
+ max=100,
136
+ value=50,
137
+ step=1,
138
+ marks={
139
+ 0: "0",
140
+ 25: "25",
141
+ 50: "50",
142
+ 75: "75",
143
+ 100: "100",
144
+ },
145
+ id="range-slider",
146
+ ),
147
+ ],
148
+ className="mb-4",
149
+ ),
150
+ width=6,
151
+ ),
152
+ dbc.Col(
153
+ html.Div(
154
+ [
155
+ dbc.Label("Date ", style={"margin-right": "10px"}),
156
+ dcc.DatePickerSingle(
157
+ id="my-date-picker", date=date(2025, 1, 1)
158
+ ),
159
+ dcc.DatePickerRange(
160
+ id="range-datepicker",
161
+ start_date=date(2025, 1, 1),
162
+ end_date=date(2025, 1, 8),
163
+ ),
164
+ ],
165
+ className="mb-3",
166
+ ),
167
+ width=6,
168
+ ),
169
+ ]
170
+ ),
171
+ html.Div(
172
+ [
173
+ dbc.Label("Boolean switch"),
174
+ daq.BooleanSwitch(id="my-boolean-switch", on=False),
175
+ ],
176
+ className="mb-3",
177
+ ),
178
+ # html.Div([
179
+ # dbc.Label("Color"),
180
+ # daq.ColorPicker(
181
+ # id='my-color-picker-1',
182
+ # label='Color Picker',
183
+ # value=dict(hex='#119DFF')
184
+ # ),
185
+ # html.Div(id='color-picker-output-1'),
186
+ # ], className="mb-3"),
187
+ ]
188
+
189
+ # Right column controls
190
+ right_controls = [
191
+ dbc.Row(
192
+ [
193
+ dbc.Col(
194
+ html.Div(
195
+ [
196
+ dbc.Label("Choose one"),
197
+ dbc.RadioItems(
198
+ options=[
199
+ {"label": "Option 1", "value": 1},
200
+ {"label": "Option 2", "value": 2},
201
+ {
202
+ "label": "Disabled Option",
203
+ "value": 3,
204
+ "disabled": True,
205
+ },
206
+ ],
207
+ value=1,
208
+ id="radioitems-input",
209
+ ),
210
+ ],
211
+ className="mb-3",
212
+ ),
213
+ width=4,
214
+ ),
215
+ dbc.Col(
216
+ html.Div(
217
+ [
218
+ dbc.Label("Choose a bunch"),
219
+ dbc.Checklist(
220
+ options=[
221
+ {"label": "Option 1", "value": 1},
222
+ {"label": "Option 2", "value": 2},
223
+ {
224
+ "label": "Disabled Option",
225
+ "value": 3,
226
+ "disabled": True,
227
+ },
228
+ ],
229
+ value=[1],
230
+ id="checklist-input",
231
+ ),
232
+ ],
233
+ className="mb-3",
234
+ ),
235
+ width=4,
236
+ ),
237
+ dbc.Col(
238
+ html.Div(
239
+ [
240
+ dbc.Label("Toggle a bunch"),
241
+ dbc.Checklist(
242
+ options=[
243
+ {"label": "Option 1", "value": 1},
244
+ {"label": "Option 2", "value": 2},
245
+ {
246
+ "label": "Disabled Option",
247
+ "value": 3,
248
+ "disabled": True,
249
+ },
250
+ ],
251
+ value=[1],
252
+ id="switches-input",
253
+ switch=True,
254
+ ),
255
+ ],
256
+ className="mb-3",
257
+ ),
258
+ width=4,
259
+ ),
260
+ ]
261
+ ),
262
+ html.Div(
263
+ [
264
+ dbc.Label("Textarea"),
265
+ dbc.Textarea(
266
+ placeholder="Enter multi-line text", rows=3, id="textarea-input"
267
+ ),
268
+ ],
269
+ className="mb-3",
270
+ ),
271
+ html.Div(
272
+ [
273
+ dbc.Label("Select"),
274
+ dcc.Dropdown(
275
+ id="select-dropdown",
276
+ options=[
277
+ {"label": "Option 1", "value": "1"},
278
+ {"label": "Option 2", "value": "2"},
279
+ {"label": "Option 3", "value": "3"},
280
+ ],
281
+ placeholder="Select an option",
282
+ clearable=True,
283
+ ),
284
+ ],
285
+ className="mb-3",
286
+ ),
287
+ html.Div(
288
+ [
289
+ dbc.Label("Multi Select"),
290
+ dcc.Dropdown(
291
+ id="select-dropdown",
292
+ options=[
293
+ {"label": "Option 1", "value": "1"},
294
+ {"label": "Option 2", "value": "2"},
295
+ {"label": "Option 3", "value": "3"},
296
+ ],
297
+ placeholder="Select one or more options",
298
+ multi=True,
299
+ clearable=True,
300
+ ),
301
+ ],
302
+ className="mb-3",
303
+ ),
304
+ dbc.Tooltip(
305
+ [
306
+ html.P("Select one or more options"),
307
+ html.P("this is a second line"),
308
+ ],
309
+ id="tooltip",
310
+ target="example-button",
311
+ ),
312
+ dbc.Button("Click me", color="primary", id="example-button"),
313
+ ]
314
+
315
+ # Table and image row
316
+ table_component = dbc.Table(
317
+ [
318
+ html.Thead(
319
+ html.Tr(
320
+ [
321
+ html.Th("Header 1"),
322
+ html.Th("Header 2"),
323
+ html.Th("Header 3"),
324
+ ]
325
+ )
326
+ ),
327
+ html.Tbody(
328
+ [
329
+ html.Tr(
330
+ [
331
+ html.Td("Row 1, Col 1"),
332
+ html.Td("Row 1, Col 2"),
333
+ html.Td("Row 1, Col 3"),
334
+ ]
335
+ ),
336
+ html.Tr(
337
+ [
338
+ html.Td("Row 2, Col 1"),
339
+ html.Td("Row 2, Col 2"),
340
+ html.Td("Row 2, Col 3"),
341
+ ]
342
+ ),
343
+ ]
344
+ ),
345
+ ],
346
+ bordered=True,
347
+ striped=True,
348
+ hover=True,
349
+ responsive=True,
350
+ )
351
+
352
+ media_component = html.Div(
353
+ [
354
+ dbc.Label("Image", style={"margin-right": "10px"}),
355
+ html.Img(
356
+ src="assets/pepsi_girl.jpeg",
357
+ alt="Placeholder image",
358
+ style={"maxWidth": "45%"},
359
+ ),
360
+ ]
361
+ )
362
+
363
+ content = dbc.Container(
364
+ [
365
+ top_section,
366
+ dbc.Row(
367
+ [
368
+ dbc.Col(left_controls, md=6),
369
+ dbc.Col(right_controls, md=6),
370
+ ],
371
+ className="gy-3",
372
+ ),
373
+ html.Hr(),
374
+ dbc.Row(
375
+ [
376
+ dbc.Col(table_component, md=8),
377
+ dbc.Col(media_component, md=4),
378
+ ],
379
+ className="gy-3",
380
+ ),
381
+ ],
382
+ id="default-elements-showcase",
383
+ fluid=True,
384
+ )
385
+ return content
386
+
387
+
388
+ def default_text_elements():
389
+ return [
390
+ html.H1("Heading 1"),
391
+ html.H2("Heading 2"),
392
+ html.H3("Heading 3"),
393
+ html.H4("Heading 4"),
394
+ html.H5("Heading 5"),
395
+ html.H6("Heading 6"),
396
+ html.P(
397
+ [
398
+ "This is a paragraph with a ",
399
+ html.A("link", href="#"),
400
+ ", some ",
401
+ html.B("bold"),
402
+ ", ",
403
+ html.I("italic"),
404
+ ", and ",
405
+ html.Code("inline code"),
406
+ ".",
407
+ ]
408
+ ),
409
+ ], [
410
+ html.Blockquote("A sample blockquote to test default styling."),
411
+ html.Ul(
412
+ [
413
+ html.Li("Unordered item 1"),
414
+ html.Li("Unordered item 2"),
415
+ html.Li("Unordered item 3"),
416
+ ]
417
+ ),
418
+ html.Ol(
419
+ [
420
+ html.Li("Ordered item 1"),
421
+ html.Li("Ordered item 2"),
422
+ html.Li("Ordered item 3"),
423
+ ]
424
+ ),
425
+ html.Pre('def example():\n return "sample preformatted text"'),
426
+ ]
@@ -0,0 +1,56 @@
1
+ import dash_bootstrap_components as dbc
2
+ import pandas as pd
3
+ from dash import html, dash_table
4
+
5
+
6
+ class StandardDataPage:
7
+ PAGE_SIZE = 10
8
+
9
+ @staticmethod
10
+ def create_content(data):
11
+ assert hasattr(
12
+ data, "tables"
13
+ ), "Standard data page works on the data.tables dictionary"
14
+ assert isinstance(
15
+ data.tables, dict
16
+ ), "Standard data page works on the data.tables dictionary"
17
+
18
+ acc_items = []
19
+ for key, table in data.tables.items():
20
+ title = f"{key} data"
21
+ acc_items.append(
22
+ dbc.AccordionItem(
23
+ StandardDataPage._create_table(table, key), title=title
24
+ )
25
+ )
26
+
27
+ return html.Div(
28
+ [
29
+ html.H4("Data view"),
30
+ dbc.Accordion(
31
+ acc_items,
32
+ id="raw-data-view",
33
+ always_open=True,
34
+ start_collapsed=True,
35
+ ),
36
+ ]
37
+ )
38
+
39
+ @staticmethod
40
+ def _create_table(tabledata: pd.DataFrame, key: str) -> html.Div:
41
+ return html.Div(
42
+ [
43
+ dash_table.DataTable(
44
+ id=f"data_table_{key}",
45
+ columns=[{"name": i, "id": i} for i in sorted(tabledata.columns)],
46
+ data=tabledata.to_dict("records"),
47
+ page_current=0,
48
+ page_size=StandardDataPage.PAGE_SIZE,
49
+ page_action="native",
50
+ ),
51
+ ]
52
+ )
53
+
54
+ @staticmethod
55
+ def register_callbacks():
56
+ pass