From ec0de08fd01755bba59faf9e8b1ee2c1992c40da Mon Sep 17 00:00:00 2001 From: Don Armstrong Date: Tue, 19 Mar 2024 08:55:00 -0700 Subject: [PATCH] add bootstrap css --- Makefile | 16 +++++++++ assets/.gitignore | 2 ++ src/ptouch_web/dashapp.py | 71 ++++++++++++++++++++++++++++++++------- 3 files changed, 77 insertions(+), 12 deletions(-) create mode 100644 Makefile create mode 100644 assets/.gitignore diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..6eeac00 --- /dev/null +++ b/Makefile @@ -0,0 +1,16 @@ +#!/usr/bin/make -f + +all: assets/bootstrap.min.css assets/bootstrap.bundle.min.js + +BOOTSTRAP_VERSION=5 +BOOTSWATCH_VERSION=5 + +assets/bootstrap.min.css: + curl -o "$@" "https://cdn.jsdelivr.net/npm/bootswatch@${BOOTSWATCH_VERSION}/dist/darkly/bootstrap.min.css" + +assets/bootstrap.bundle.min.js: + curl -o "$@" "https://cdn.jsdelivr.net/npm/bootstrap@${BOOTSTRAP_VERSION}/dist/js/bootstrap.bundle.min.js" + + +clean: + rm -f assets/bootstrap.* diff --git a/assets/.gitignore b/assets/.gitignore new file mode 100644 index 0000000..6cdde6a --- /dev/null +++ b/assets/.gitignore @@ -0,0 +1,2 @@ +bootstrap.bundle.min.js +bootstrap.min.css diff --git a/src/ptouch_web/dashapp.py b/src/ptouch_web/dashapp.py index c3ff627..9b3b11d 100644 --- a/src/ptouch_web/dashapp.py +++ b/src/ptouch_web/dashapp.py @@ -1,25 +1,72 @@ from dash import Dash, html, dcc, Input, Output, State, ctx import requests -app = Dash(__name__, requests_pathname_prefix="/app/") +app = Dash( + __name__, + requests_pathname_prefix="/app/", + external_stylesheets=["/app/assets/bootstrap.min.css"], + assets_folder="../../assets/", +) app.layout = html.Div( [ html.Div( + className="mb-3", children=[ - html.Label("Text input"), - dcc.Textarea( - id="label-text", - style={"width": "100%"}, - placeholder="Text for label", + html.Div( + className="mb-3", + children=[ + html.Label("Label Text", className="form-label"), + dcc.Textarea( + id="label-text", + style={"width": "100%"}, + className="form-control", + placeholder="Text for label", + ), + html.Div( + id="label-help", + className="form-text", + children=["Multiple lines print as shown"], + ), + ], + ), + html.Div( + className="mb-3", + children=[ + html.Label("Font size", className="form-label"), + dcc.Input( + id="font-size", + className="form-control", + type="number", + min=0, + max=100, + ), + html.Div( + id="emailHelp", + className="form-text", + children=["Leave blank for auto font size"], + ), + ], + ), + html.Div( + className="mb-3", + children=[ + html.Label("Copies", className="form-label"), + dcc.Input( + id="copies", + className="form-control", + value=1, + type="number", + min=0, + max=100, + ), + ], + ), + html.Button( + "Print", name="print", id="print", className="btn btn-primary" ), - html.Label("Font size"), - dcc.Input(id="font-size", type="number", min=0, max=100), - html.Label("Copies"), - dcc.Input(id="copies", value=1, type="number", min=0, max=100), - html.Button("Print", name="print", id="print"), html.Div(id="print-result"), - ] + ], ), ] ) -- 2.39.5