|
| 1 | +import dash |
| 2 | +import dash_bootstrap_components as dbc |
| 3 | +from dash.dependencies import Input, Output, State |
| 4 | + |
| 5 | +from .alert import alerts |
| 6 | +from .badge import badges |
| 7 | +from .button import buttons |
| 8 | +from .card import cards |
| 9 | +from .collapse import collapse |
| 10 | +from .fade import fade |
| 11 | +from .form import form |
| 12 | +from .input import checklist_items, input_, input_group, radio_items |
| 13 | +from .jumbotron import jumbotron |
| 14 | +from .list_group import list_group |
| 15 | +from .modal import modal |
| 16 | +from .navbar import navbar |
| 17 | +from .popover import popover |
| 18 | +from .progress import progress |
| 19 | +from .spinner import spinner |
| 20 | +from .table import table |
| 21 | +from .tabs import tabs |
| 22 | +from .toast import toast |
| 23 | +from .tooltip import tooltip |
| 24 | + |
| 25 | +FONT_AWESOME = "https://use.fontawesome.com/releases/v5.10.2/css/all.css" |
| 26 | +app = dash.Dash(external_stylesheets=[dbc.themes.BOOTSTRAP, FONT_AWESOME]) |
| 27 | + |
| 28 | +app.layout = dbc.Container( |
| 29 | + [ |
| 30 | + alerts, |
| 31 | + badges, |
| 32 | + buttons, |
| 33 | + cards, |
| 34 | + collapse, |
| 35 | + fade, |
| 36 | + dbc.Row( |
| 37 | + [ |
| 38 | + dbc.Col([form, input_group], xs=12, md=6), |
| 39 | + dbc.Col([input_], xs=12, md=6), |
| 40 | + ] |
| 41 | + ), |
| 42 | + dbc.Row( |
| 43 | + [ |
| 44 | + dbc.Col([checklist_items], xs=12, md=6), |
| 45 | + dbc.Col([radio_items], xs=12, md=6), |
| 46 | + ] |
| 47 | + ), |
| 48 | + jumbotron, |
| 49 | + list_group, |
| 50 | + modal, |
| 51 | + navbar, |
| 52 | + popover, |
| 53 | + progress, |
| 54 | + spinner, |
| 55 | + table, |
| 56 | + tabs, |
| 57 | + toast, |
| 58 | + tooltip, |
| 59 | + ], |
| 60 | + fluid=True, |
| 61 | + className="px-4", |
| 62 | +) |
| 63 | + |
| 64 | + |
| 65 | +@app.callback( |
| 66 | + Output("collapse", "is_open"), |
| 67 | + [Input("collapse-button", "n_clicks")], |
| 68 | + [State("collapse", "is_open")], |
| 69 | +) |
| 70 | +def toggle_collapse(n, is_open): |
| 71 | + if n: |
| 72 | + return not is_open |
| 73 | + return is_open |
| 74 | + |
| 75 | + |
| 76 | +@app.callback( |
| 77 | + Output("fade", "is_in"), |
| 78 | + [Input("fade-button", "n_clicks")], |
| 79 | + [State("fade", "is_in")], |
| 80 | +) |
| 81 | +def toggle_fade(n, is_in): |
| 82 | + if n: |
| 83 | + return not is_in |
| 84 | + return is_in |
| 85 | + |
| 86 | + |
| 87 | +@app.callback( |
| 88 | + Output("popover", "is_open"), |
| 89 | + [Input("popover-target", "n_clicks")], |
| 90 | + [State("popover", "is_open")], |
| 91 | +) |
| 92 | +def toggle_popover(n, is_open): |
| 93 | + if n: |
| 94 | + return not is_open |
| 95 | + return is_open |
| 96 | + |
| 97 | + |
| 98 | +@app.callback( |
| 99 | + Output("modal", "is_open"), |
| 100 | + [Input("button", "n_clicks")], |
| 101 | + [State("modal", "is_open")], |
| 102 | +) |
| 103 | +def toggle_modal(n, is_open): |
| 104 | + if n: |
| 105 | + return not is_open |
| 106 | + return is_open |
| 107 | + |
| 108 | + |
| 109 | +@app.callback( |
| 110 | + Output("auto-toast", "is_open"), [Input("auto-toast-toggle", "n_clicks")] |
| 111 | +) |
| 112 | +def open_toast(_): |
| 113 | + return True |
| 114 | + |
| 115 | + |
| 116 | +if __name__ == "__main__": |
| 117 | + app.run_server(debug=True) |
0 commit comments