Skip to content

Commit 057a3a5

Browse files
committed
Update component landing page (#677)
* Update component landing page * Fix issues in R snippet
1 parent c80ad50 commit 057a3a5

File tree

10 files changed

+59
-70
lines changed

10 files changed

+59
-70
lines changed

docs/components_page/__init__.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ def _get_label(slug):
8888
return "InputGroup"
8989
if slug == "list_group":
9090
return "ListGroup"
91+
if slug == "index":
92+
return "Components"
9193
return slug.capitalize()
9294

9395

@@ -110,7 +112,7 @@ def register_apps():
110112
"jumbotron": {"markdown_path": COMPONENTS / "jumbotron.md"},
111113
"layout": {"markdown_path": COMPONENTS / "layout.md"},
112114
"list_group": {"markdown_path": COMPONENTS / "list_group.md"},
113-
"main": {"markdown_path": COMPONENTS / "main.md"},
115+
"index": {"markdown_path": COMPONENTS / "index.md"},
114116
"modal": {
115117
"markdown_path": COMPONENTS / "modal.md",
116118
"extra_env_vars": {"LOREM": LOREM},
@@ -163,7 +165,7 @@ def register_apps():
163165
"label": _get_label(slug),
164166
}
165167
for slug in component_bodies
166-
if _get_label(slug) != "Main"
168+
if slug != "index"
167169
],
168170
},
169171
]
@@ -173,9 +175,14 @@ def register_apps():
173175
template = env.from_string(INDEX_STRING_TEMPLATE)
174176

175177
for slug, kwargs in component_bodies.items():
178+
requests_pathname_prefix = (
179+
f"/docs/components/{slug}/"
180+
if slug != "index"
181+
else "/docs/components/"
182+
)
176183
app = dash.Dash(
177184
external_stylesheets=["/static/loading.css"],
178-
requests_pathname_prefix=f"/docs/components/{slug}/",
185+
requests_pathname_prefix=requests_pathname_prefix,
179186
suppress_callback_exceptions=True,
180187
serve_locally=SERVE_LOCALLY,
181188
index_string=template.render(
@@ -197,6 +204,9 @@ def register_apps():
197204
)
198205
else:
199206
app.layout = parse(app, **kwargs)
200-
routes[f"/docs/components/{slug}"] = app
207+
if slug == "index":
208+
routes["/docs/components"] = app
209+
else:
210+
routes[f"/docs/components/{slug}"] = app
201211

202212
return routes
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
title: Components
3+
lead: Usage examples for all components in dash-bootstrap-components
4+
---
5+
6+
The component documentation for _dash-bootstrap-components_ contains many snippets showing example usage, as well as api documentation for each component explaining the different props that you can set.
7+
8+
Example snippets for the different components will look something like this, with tabs to switch between R or Julia versions of the examples.
9+
10+
{{example:components/index/simple.py:layout}}
11+
12+
## Adding the snippets to your app
13+
14+
Note that the contents of each snippet **do not by themselves constitute a working app**. We generally omit boilerplate code such as standard imports and instantiation of the app. In the above example you would additionally need to:
15+
16+
1. import Dash
17+
2. create a Dash app instance (making sure to link a Bootstrap stylesheet, see the [themes documentation](/docs/themes/) for details)
18+
3. assign `layout` to the app layout
19+
4. start the Dash server.
20+
21+
If any of the above steps are unclear, please take a look at the [Quickstart](/docs/quickstart/) instructions for creating a basic app, the [examples](https://github.com/facultyai/dash-bootstrap-components/tree/main/examples) in our GitHub repository, or refer to the official Dash documentation for [Python](https://dash.plotly.com/), [R](https://dashr.plotly.com/), or [Julia](https://dash-julia.plotly.com/).
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
library(dashBootstrapComponents)
2+
library(dashHtmlComponents)
3+
4+
layout <- dbcAlert(
5+
paste(
6+
"This is an example of a component being used in the wild.",
7+
"Below me, you can find the code used to create me."
8+
),
9+
color = "info"
10+
)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
using DashBootstrapComponents, DashHtmlComponents
2+
3+
layout = dbc_alert(
4+
"This is an example of a component being used in the wild. " *
5+
"Below me, you can find the code used to create me.",
6+
color = "info",
7+
)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import dash_bootstrap_components as dbc
2+
3+
layout = dbc.Alert(
4+
"This is an example of a component being used in the wild. "
5+
"Below me, you can find the code used to create me.",
6+
color="info",
7+
)

docs/components_page/components/main.md

Lines changed: 0 additions & 17 deletions
This file was deleted.

docs/components_page/components/main/simple.R

Lines changed: 0 additions & 18 deletions
This file was deleted.

docs/components_page/components/main/simple.jl

Lines changed: 0 additions & 12 deletions
This file was deleted.

docs/components_page/components/main/simple.py

Lines changed: 0 additions & 15 deletions
This file was deleted.

docs/server.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,6 @@ def faq():
9292
except TemplateNotFound:
9393
abort(404)
9494

95-
@server.route("/docs/components/")
96-
def components_index():
97-
return redirect("/docs/components/main", 302)
98-
9995
@server.route("/l/components/", defaults={"slug": "main"})
10096
@server.route("/l/components/<slug>/")
10197
def components_redirect(slug):

0 commit comments

Comments
 (0)