Skip to content

Commit f99495a

Browse files
delsimdelsim
andauthored
Extend demos (#441)
* Add updated demo templates * Add mantine component example * Fix file header --------- Co-authored-by: delsim <[email protected]>
1 parent 6621196 commit f99495a

File tree

7 files changed

+88
-4
lines changed

7 files changed

+88
-4
lines changed

demo/demo/mantine_example.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
'''
2+
Dash apps for the demonstration of functionality
3+
4+
Copyright (c) 2023 Gibbs Consulting and others - see CONTRIBUTIONS.md
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
SOFTWARE.
23+
'''
24+
25+
from dash import dcc, html
26+
from django_plotly_dash import DjangoDash
27+
28+
import dash_mantine_components as dmc
29+
30+
31+
mantine_example = DjangoDash("MantineExample")
32+
33+
34+
mantine_example.layout = dmc.Alert(
35+
"Hi from Dash Mantine Components. You can create some great looking dashboards using me!",
36+
title="Welcome!",
37+
color="violet",
38+
)

demo/demo/plotly_apps.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,3 +461,5 @@ def pattern_match(values):
461461
[dash.dependencies.Input({"_type": "div", "_id": ALL}, 'children')])
462462
def pattern_all(values):
463463
return str(values)
464+
465+

demo/demo/scaffold.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55

66
from demo.plotly_apps import multiple_callbacks, flexible_expanded_callbacks
77

8+
89
def stateless_app_loader(app_name):
910

1011
# Load a stateless app
1112
return import_string("demo.scaffold." + app_name)
1213

13-
demo_app = DjangoDash(name="name_of_demo_app")
1414

15+
demo_app = DjangoDash(name="name_of_demo_app")

demo/demo/templates/demo_eleven.html

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{%extends "base.html"%}
2+
{%load plotly_dash%}
3+
4+
{%block title%}Demo Eleven - Dash Mantine Components{%endblock%}
5+
6+
{%block content%}
7+
<h1>Dash Mantine Components</h1>
8+
<p>
9+
This example demonstrates serving Dash Mantine Components within a Dash app.
10+
</p>
11+
<p></p>
12+
<div class="card bg-light border-dark">
13+
<div class="card-body">
14+
<p><span>{</span>% load plotly_dash %}</p>
15+
<p>&lt;div class="<span>{</span>% plotly_class name="MantineExample"%}">
16+
<p class="ml-3"><span>{</span>% plotly_app name="MantineExample" ratio=0.3 %}</p>
17+
<p>&lt;\div>
18+
</div>
19+
</div>
20+
<p></p>
21+
<div class="card border-dark">
22+
<div class="card-body">
23+
<div class="{%plotly_class name="MantineExample"%}">
24+
{%plotly_app name="MantineExample" ratio=0.3 %}
25+
</div>
26+
</div>
27+
</div>
28+
{%endblock%}

demo/demo/templates/demo_ten.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,10 @@ <h1>Multiple Callback Values</h1>
3535
</div>
3636
</div>
3737
<p></p>
38+
<div class="card border-dark">
39+
<div class="card-body">
40+
{%plotly_app name="FlexibleExpandedCallbacks" ratio=0.2 %}
41+
</div>
42+
</div>
43+
<p></p>
3844
{%endblock%}

demo/demo/templates/index.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ <h1>Demonstration Application</h1>
4848
<td><a class="btn btn-primary btn-block" href="{%url "demo-ten"%}">Demo Ten</a></td>
4949
<td>Callback with multiple return values</td>
5050
</tr>
51+
<tr>
52+
<td><a class="btn btn-primary btn-block" href="{%url "demo-eleven"%}">Demo Eleven</a></td>
53+
<td>Dash Mantine Components</td>
54+
</tr>
5155
</tbody>
5256
</table>
5357
{%endblock%}

demo/demo/urls.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,17 @@
2626
from django.conf.urls.static import static
2727

2828
# Load demo plotly apps - this triggers their registration
29-
import demo.plotly_apps # pylint: disable=unused-import
30-
import demo.dash_apps # pylint: disable=unused-import
31-
import demo.bootstrap_app # pylint: disable=unused-import
29+
import demo.plotly_apps # pylint: disable=unused-import
30+
import demo.dash_apps # pylint: disable=unused-import
31+
import demo.bootstrap_app # pylint: disable=unused-import
32+
import demo.mantine_example # pylint: disable=unused-import
33+
3234

3335
from django_plotly_dash.views import add_to_session
3436

3537
from .views import dash_example_1_view, session_state_view
3638

39+
3740
urlpatterns = [
3841
path('', TemplateView.as_view(template_name='index.html'), name="home"),
3942
path('demo-one', TemplateView.as_view(template_name='demo_one.html'), name="demo-one"),
@@ -46,12 +49,14 @@
4649
path('demo-eight', session_state_view, {'template_name':'demo_eight.html'}, name="demo-eight"),
4750
path('demo-nine', TemplateView.as_view(template_name='demo_nine.html'), name="demo-nine"),
4851
path('demo-ten', TemplateView.as_view(template_name='demo_ten.html'), name="demo-ten"),
52+
path('demo-eleven', TemplateView.as_view(template_name='demo_eleven.html'), name="demo-eleven"),
4953
path('admin/', admin.site.urls),
5054
path('django_plotly_dash/', include('django_plotly_dash.urls')),
5155

5256
path('demo-session-var', add_to_session, name="session-variable-example"),
5357
]
5458

59+
5560
# Add in static routes so daphne can serve files; these should
5661
# be masked eg with nginx for production use
5762

0 commit comments

Comments
 (0)