|
1 | 1 | import dash_bootstrap_components as dbc |
2 | | -from dash import dcc, html |
3 | | - |
4 | | -_FORM_ELEMENT_STYLE = { |
5 | | - "display": "block", |
6 | | - "width": "200px", |
7 | | - # "margin": "0 20px 20px 20px", |
8 | | - "verticalAlign": "middle", |
9 | | - "justifyContent": "center", |
10 | | -} |
| 2 | +from dash import html |
11 | 3 |
|
| 4 | +# Create your form components |
| 5 | +group_input = dbc.Select( |
| 6 | + id="search-form-group-input", |
| 7 | + options=[ |
| 8 | + {"label": "node", "value": "node"}, |
| 9 | + {"label": "line", "value": "line"}, |
| 10 | + {"label": "link", "value": "link"}, |
| 11 | + {"label": "transformer", "value": "transformer"}, |
| 12 | + {"label": "branch", "value": "branch"}, |
| 13 | + ], |
| 14 | + value="node", # Default value |
| 15 | + style={"width": "150px", "display": "inline-block"} |
| 16 | +) |
12 | 17 |
|
13 | | -SEARCH_FORM_HTML = html.Div( |
14 | | - [ |
15 | | - html.Div( |
16 | | - dcc.RadioItems(["node", "line", "link", "transformer", "branch"], "node", id="search-form-group-input"), |
17 | | - style=_FORM_ELEMENT_STYLE, |
18 | | - ), |
19 | | - html.Div(dcc.Dropdown(["id"], "id", id="search-form-column-input"), style=_FORM_ELEMENT_STYLE), |
20 | | - html.Div( |
21 | | - dcc.Input(placeholder="Enter value to mark", id="search-form-value-input"), |
22 | | - style=_FORM_ELEMENT_STYLE, |
23 | | - ), |
24 | | - ] |
| 18 | +column_input = dbc.Select( |
| 19 | + id="search-form-column-input", |
| 20 | + options=[{"label": "id", "value": "id"}], |
| 21 | + value="id", # Default value |
| 22 | + style={"width": "150px", "display": "inline-block"} |
25 | 23 | ) |
26 | 24 |
|
27 | | -SEARCH_FORM_TOGGLE = html.Div( |
28 | | - dbc.Button( |
29 | | - "Search", |
30 | | - id="collapse-button", |
31 | | - className="mb-3", |
32 | | - color="primary", |
33 | | - n_clicks=0, |
34 | | - ), |
35 | | - style={"margin": "20px"}, |
| 25 | +value_input = dbc.Input( |
| 26 | + id="search-form-value-input", |
| 27 | + placeholder="Enter value", |
| 28 | + type="text", |
| 29 | + style={"width": "150px", "display": "inline-block"} |
36 | 30 | ) |
37 | 31 |
|
38 | | -HEADER_HTML = html.Div( |
| 32 | +# Arrange as a sentence |
| 33 | +SEARCH_FORM_HTML = html.Div( |
39 | 34 | [ |
40 | | - SEARCH_FORM_TOGGLE, |
41 | | - dbc.Collapse( |
42 | | - SEARCH_FORM_HTML, |
43 | | - id="collapse", |
44 | | - is_open=False, |
45 | | - ), |
46 | | - ] |
| 35 | + html.Span("Search ", className="mr-2", style={"margin-right": "8px"}), |
| 36 | + group_input, |
| 37 | + html.Span(" with ", className="mx-2", style={"margin": "0 8px"}), |
| 38 | + column_input, |
| 39 | + html.Span(" == ", className="mx-2", style={"margin": "0 8px"}), |
| 40 | + value_input, |
| 41 | + ], |
| 42 | +style={ |
| 43 | + "display": "flex", |
| 44 | + "align-items": "center", |
| 45 | + "justify-content": "center", # Centers items horizontally |
| 46 | + "padding": "10px", |
| 47 | + "margin": "0 auto", # Centers the container itself |
| 48 | + "width": "100%" # Ensures the container takes full width |
| 49 | + } |
47 | 50 | ) |
0 commit comments