Skip to content

Commit

Permalink
Updated examples based on latest code changes
Browse files Browse the repository at this point in the history
  • Loading branch information
idling-mind committed Jan 2, 2024
1 parent bee2224 commit 8dab65c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
8 changes: 5 additions & 3 deletions examples/pandas_table.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
from dash import Dash
from html2dash import html2dash, settings
from html2dash import html2dash
import dash_mantine_components as dmc
import pandas as pd

settings["element-map"]["table"] = dmc.Table
element_map = {
"table": dmc.Table,
}

df = pd.read_csv("https://raw.githubusercontent.com/datasciencedojo/datasets/master/titanic.csv")
app = Dash()

pandas_table = html2dash(df.head(50).to_html(index=False))
pandas_table = html2dash(df.head(50).to_html(index=False), element_map=element_map)
pandas_table.children[0].striped = True
pandas_table.children[0].withBorder = True
app.layout = dmc.Container(pandas_table)
Expand Down
19 changes: 11 additions & 8 deletions examples/tabler.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
from pathlib import Path
from dash import Dash
from html2dash import html2dash, settings
from dash import Dash, html, dcc
from html2dash import html2dash
import dash_mantine_components as dmc
from dash_iconify import DashIconify

settings["modules"].append(dmc)
settings["element-map"]["icon"] = DashIconify
settings["element-map"]["rprogress"] = dmc.RingProgress
settings["element-map"]["lprogress"] = dmc.Progress
modules = [html, dcc, dmc]
element_map = {}
element_map["icon"] = DashIconify
element_map["rprogress"] = dmc.RingProgress
element_map["lprogress"] = dmc.Progress

app = Dash(
__name__,
Expand All @@ -17,10 +18,12 @@
external_stylesheets=[
"https://cdn.jsdelivr.net/npm/@tabler/[email protected]/dist/css/tabler.min.css",
"https://rsms.me/inter/inter.css",
]
],
)

app.layout = html2dash(Path("tabler.html").read_text())
app.layout = html2dash(
Path("tabler.html").read_text(), module_list=modules, element_map=element_map
)

if __name__ == "__main__":
app.run_server(debug=True)

0 comments on commit 8dab65c

Please sign in to comment.