From b478fd075aa8ea890abe52aa9b51e529b8d227cb Mon Sep 17 00:00:00 2001 From: maxchristlmck Date: Fri, 29 Sep 2023 14:37:38 +0200 Subject: [PATCH 1/3] added text component --- vizro-core/src/vizro/models/_controls/text.py | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 vizro-core/src/vizro/models/_controls/text.py diff --git a/vizro-core/src/vizro/models/_controls/text.py b/vizro-core/src/vizro/models/_controls/text.py new file mode 100644 index 000000000..6b92dcb3e --- /dev/null +++ b/vizro-core/src/vizro/models/_controls/text.py @@ -0,0 +1,32 @@ +from typing import Literal + +from dash import dcc, html + +from vizro.models import VizroBaseModel +from vizro.models._models_utils import _log_call + + +class Text(VizroBaseModel): + """Creates a text utilizing `dcc.Markdown` as text component. + + Args: + type (Literal["text"]): Defaults to `"text"`. + text (str): Markdown string to create text that should adhere to the CommonMark Spec. + """ + + type: Literal["text"] = "text" + text: str + + @_log_call + def build(self): + text = dcc.Markdown( + self.text, + className="text", + dangerously_allow_html=False, + id=self.id, + ) + return html.Div( + text, + className="text_container", + id=f"{self.id}_outer", + ) From 776ecdc3d3dc28d81bd60f7ae1dec76a68491aa6 Mon Sep 17 00:00:00 2001 From: maxchristlmck Date: Fri, 29 Sep 2023 15:03:38 +0200 Subject: [PATCH 2/3] added divider component --- .../src/vizro/models/_controls/divider.py | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 vizro-core/src/vizro/models/_controls/divider.py diff --git a/vizro-core/src/vizro/models/_controls/divider.py b/vizro-core/src/vizro/models/_controls/divider.py new file mode 100644 index 000000000..9b19f697c --- /dev/null +++ b/vizro-core/src/vizro/models/_controls/divider.py @@ -0,0 +1,32 @@ +from typing import Dict, Literal + +from dash import html + +from vizro.models import VizroBaseModel +from vizro.models._models_utils import _log_call + + +class Divider(VizroBaseModel): + """Creates a divider utilizing dash html component. + + Args: + type (Literal["divider"]): Defaults to `"divider"`. + style (Dict[str, str]): Style dictionary to pass to html component. Default to + a solid gray line with 100% width. + """ + + type: Literal["divider"] = "divider" + style: Dict[str, str] = { + "borderWidth": "0.1vh", + "width": "100%", + "borderColor": "#33353f", + "borderStyle": "solid", + } + + @_log_call + def build(self): + return html.Hr( + style=self.style, + className="divider_container", + id=f"{self.id}_outer", + ) From 23bcc28e4f13c5e0d05e48247cad5515d467b5bb Mon Sep 17 00:00:00 2001 From: maxchristlmck Date: Fri, 29 Sep 2023 15:03:55 +0200 Subject: [PATCH 3/3] updated ControlType --- vizro-core/src/vizro/models/types.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vizro-core/src/vizro/models/types.py b/vizro-core/src/vizro/models/types.py index 6ba038e05..9e6785df2 100644 --- a/vizro-core/src/vizro/models/types.py +++ b/vizro-core/src/vizro/models/types.py @@ -255,7 +255,7 @@ class OptionsDictType(TypedDict): ] ControlType = Annotated[ - Union["Filter", "Parameter"], + Union["Divider", "Filter", "Parameter", "Text"], Field( discriminator="type", description="Control that affects components on the page.",