Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Tidy] Replace dmc.Tabs with dbc.Tabs #895

Merged
merged 69 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from 65 commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
81eeb60
Add changes
huong-li-nguyen Nov 18, 2024
5f0e020
Update latest CSS file
huong-li-nguyen Nov 19, 2024
fff42a1
Remove CSS for tooltip
huong-li-nguyen Nov 19, 2024
07d8929
Update vizro-bootstrap.min.css
huong-li-nguyen Nov 19, 2024
0a7ff33
Create 20241119_155853_huong_li_nguyen_add_bs_tooltip_styling.md
huong-li-nguyen Nov 19, 2024
7abbbbf
Merge branch 'main' into tidy/add-bs-tooltip-styling
huong-li-nguyen Nov 19, 2024
480914d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 19, 2024
4a598a2
Remove all CSS variables
huong-li-nguyen Nov 19, 2024
39032be
Rename variables with vizro-bs equivalent
huong-li-nguyen Nov 19, 2024
1ca73f8
Replace with rem units
huong-li-nguyen Nov 19, 2024
610a188
Hardcode values where suitable
huong-li-nguyen Nov 19, 2024
96464d6
Add back selected variables
huong-li-nguyen Nov 19, 2024
e35fe36
Replace matched values
huong-li-nguyen Nov 19, 2024
3404355
Replace remaining values
huong-li-nguyen Nov 19, 2024
4d07ec0
Create 20241119_173819_huong_li_nguyen_remove_variables.md
huong-li-nguyen Nov 19, 2024
5a47f97
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 19, 2024
e7cdc9b
Merge branch 'tidy/add-bs-tooltip-styling' into tidy/remove-variables
huong-li-nguyen Nov 19, 2024
1277f11
Merge branch 'tidy/remove-variables' of https://github.com/mckinsey/v…
huong-li-nguyen Nov 19, 2024
b52fb72
Fix collapse bg color
huong-li-nguyen Nov 20, 2024
42bdb3a
Update color
huong-li-nguyen Nov 20, 2024
0742dc8
Fix renaming of border
huong-li-nguyen Nov 20, 2024
ba273f7
Replace remaining variable mentions
huong-li-nguyen Nov 20, 2024
307ce5c
Merge branch 'main' into tidy/remove-variables
huong-li-nguyen Nov 20, 2024
84d5d73
Update CSS variables outside of static folder
huong-li-nguyen Nov 21, 2024
2ec7c6e
Revert demo changes
huong-li-nguyen Nov 21, 2024
4fac651
Update changelog
huong-li-nguyen Nov 21, 2024
c77fd12
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 21, 2024
f9bba27
Update table
huong-li-nguyen Nov 21, 2024
bf90f2c
Merge branch 'main' into tidy/remove-variables
huong-li-nguyen Nov 21, 2024
e0c9f20
Fix tabs
huong-li-nguyen Nov 21, 2024
96fcd96
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 21, 2024
790ccb4
Replace dash-mantine with dbc
huong-li-nguyen Nov 21, 2024
5ddd50a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 21, 2024
43eca2f
Tidy
huong-li-nguyen Nov 21, 2024
33cef8a
Merge branch 'tidy/replace-tabs' of https://github.com/mckinsey/vizro…
huong-li-nguyen Nov 21, 2024
31fb84b
Add preliminary bootstrap css
huong-li-nguyen Nov 21, 2024
2d911ad
Update CSS
huong-li-nguyen Nov 21, 2024
42b67b8
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 21, 2024
4600223
Merge branch 'main' into tidy/remove-variables
huong-li-nguyen Nov 25, 2024
de7781e
Clarify comment
huong-li-nguyen Nov 25, 2024
bfb64ff
Update vizro-bootstrap.min.css
huong-li-nguyen Nov 25, 2024
303f9e4
Update vizro-bootstrap.min.css
huong-li-nguyen Nov 25, 2024
085f64a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 25, 2024
3a6f665
Tidy
huong-li-nguyen Nov 25, 2024
0a720c3
Merge branch 'tidy/replace-tabs' of https://github.com/mckinsey/vizro…
huong-li-nguyen Nov 25, 2024
367f396
Add new bootstrap file and fix scrolling issue
huong-li-nguyen Nov 25, 2024
6373542
Merge branch 'tidy/remove-variables' into tidy/replace-tabs
huong-li-nguyen Nov 25, 2024
21010a8
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 25, 2024
84036b3
Merge branch 'tidy/replace-tabs' of https://github.com/mckinsey/vizro…
huong-li-nguyen Nov 25, 2024
f77fb2f
Tidy
huong-li-nguyen Nov 25, 2024
e21d2ee
Add changelog entry
huong-li-nguyen Nov 25, 2024
e14a080
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 25, 2024
7b3e2e3
Add comment
huong-li-nguyen Nov 25, 2024
3fd9728
Merge branch 'tidy/remove-variables' into tidy/replace-tabs
huong-li-nguyen Nov 25, 2024
b9e25c6
Add comment
huong-li-nguyen Nov 26, 2024
9358742
Update docs
huong-li-nguyen Nov 26, 2024
e9be97e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 26, 2024
c18f942
Lint
huong-li-nguyen Nov 26, 2024
a9dd04d
Merge branch 'tidy/remove-variables' of https://github.com/mckinsey/v…
huong-li-nguyen Nov 26, 2024
aaf8426
Merge branch 'tidy/remove-variables' into tidy/replace-tabs
huong-li-nguyen Nov 26, 2024
26046be
Update
huong-li-nguyen Nov 26, 2024
e30bf6c
Merge branch 'tidy/remove-variables' into tidy/replace-tabs
huong-li-nguyen Nov 26, 2024
bf1a006
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 26, 2024
aaf36a3
Fix typo
huong-li-nguyen Nov 26, 2024
09ae02b
Merge branch 'tidy/remove-variables' into tidy/replace-tabs
huong-li-nguyen Nov 26, 2024
bb3a9ee
Merge branch 'main' into tidy/replace-tabs
huong-li-nguyen Nov 26, 2024
06cd5fc
Revert change
huong-li-nguyen Nov 26, 2024
2a89c16
Simplify unit tests
huong-li-nguyen Nov 26, 2024
5665ff4
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<!--
A new scriv changelog fragment.

Uncomment the section that is right (remove the HTML comment wrapper).
-->

<!--
### Highlights ✨

- A bullet item for the Highlights ✨ category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX. ([#1](https://github.com/mckinsey/vizro/pull/1))

-->

### Removed

- Removed all CSS variables from `variables.css` and `token_names.css`, replacing them with CSS variables from `vizro-bootstrap.min.css`.
Refer to [`vizro-bootstrap.min.css](https://github.com/mckinsey/vizro/blob/main/vizro-core/src/vizro/static/css/vizro-bootstrap.min.css) for the updated CSS variables. ([#886](https://github.com/mckinsey/vizro/pull/886))

<!--
### Added

- A bullet item for the Added category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX. ([#1](https://github.com/mckinsey/vizro/pull/1))

-->
<!--
### Changed

- A bullet item for the Changed category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX. ([#1](https://github.com/mckinsey/vizro/pull/1))

-->
<!--
### Deprecated

- A bullet item for the Deprecated category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX. ([#1](https://github.com/mckinsey/vizro/pull/1))

-->
<!--
### Fixed

- A bullet item for the Fixed category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX. ([#1](https://github.com/mckinsey/vizro/pull/1))

-->
<!--
### Security

- A bullet item for the Security category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX. ([#1](https://github.com/mckinsey/vizro/pull/1))

-->
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<!--
A new scriv changelog fragment.

Uncomment the section that is right (remove the HTML comment wrapper).
-->

<!--
### Highlights ✨

- A bullet item for the Highlights ✨ category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX. ([#1](https://github.com/mckinsey/vizro/pull/1))

-->
<!--
### Removed

- A bullet item for the Removed category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX. ([#1](https://github.com/mckinsey/vizro/pull/1))

-->
<!--
### Added

- A bullet item for the Added category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX. ([#1](https://github.com/mckinsey/vizro/pull/1))

-->

### Changed

- Replace `dmc.Tabs` with `dbc.Tabs` and change CSS selectors accordingly. ([#895](https://github.com/mckinsey/vizro/pull/895))

<!--
### Deprecated

- A bullet item for the Deprecated category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX. ([#1](https://github.com/mckinsey/vizro/pull/1))

-->
<!--
### Fixed

- A bullet item for the Fixed category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX. ([#1](https://github.com/mckinsey/vizro/pull/1))

-->
<!--
### Security

- A bullet item for the Security category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX. ([#1](https://github.com/mckinsey/vizro/pull/1))

-->
20 changes: 19 additions & 1 deletion vizro-core/docs/pages/user-guides/custom-css.md
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,14 @@ It's essential to understand the relationship between the targeted CSS class or

## Common examples

### Make your CSS responsive to theme switches with variables
To ensure your CSS adapts to theme changes, we recommend using CSS variables (`var`) whenever possible. For a
comprehensive list of available variable names, refer to the
[Bootstrap documentation](https://getbootstrap.com/docs/5.3/customize/css-variables/). Note that our
Bootstrap stylesheet is still under development, so not all Bootstrap variables are currently available.
Additionally, you can define your own CSS variables, as demonstrated in the example on
[changing the container background color](#change-the-styling-of-a-container).

### Turn off page title
See the example above on [hiding the page title on selected pages](#overwrite-css-for-selected-pages).

Expand Down Expand Up @@ -380,8 +388,18 @@ To do this, you need to change the container's CSS class. Using the DevTool, as
!!! example "Style a container"
=== "custom.css"
```css
/* Assign a variable to the dark and light theme */
[data-bs-theme="dark"] {
--container-bg-color: #232632;
}

[data-bs-theme="light"] {
--container-bg-color: #F5F6F6;
}

/* Use the custom variable var(--container-bg-color) */
.page-component-container {
background: var(--surfaces-bg-card);
background: var(--container-bg-color);
padding: 12px;
}
```
Expand Down
6 changes: 3 additions & 3 deletions vizro-core/docs/pages/user-guides/custom-tables.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ The following examples show a possible version of a custom table. In this case t
columns = [{"name": i, "id": i} for i in chosen_columns]
defaults = {
"style_as_list_view": True,
"style_data": {"border_bottom": "1px solid var(--border-subtle-alpha-01)", "height": "40px"},
"style_data": {"border_bottom": "1px solid var(--border-subtleAlpha01)", "height": "40px"},
"style_header": {
"border_bottom": "1px solid var(--state-overlays-selected-hover)",
"border_top": "1px solid var(--main-container-bg-color)",
"border_bottom": "1px solid var(--stateOverlays-selectedHover)",
"border_top": "1px solid var(--right-side-bg)",
"height": "32px",
},
}
Expand Down
77 changes: 43 additions & 34 deletions vizro-core/examples/scratch_dev/app.py
Original file line number Diff line number Diff line change
@@ -1,46 +1,55 @@
"""Dev app to try things out."""

import pandas as pd
import vizro.models as vm
import vizro.plotly.express as px
from vizro import Vizro
from vizro._themes._color_values import COLORS
import dash_bootstrap_components as dbc
from dash import html

from typing import Literal

from dash import html

import vizro.models as vm
from vizro import Vizro


class Tooltip(vm.VizroBaseModel):
type: Literal["tooltip"] = "tooltip"
text: str = "This is a tooltip"

def build(self):
return html.Div(
[
dbc.Button("Button", id=f"{self.id}-tooltip-target"),
dbc.Tooltip(
self.text,
target=f"{self.id}-tooltip-target",
is_open=True,
),
]
)


vm.Page.add_type("components", Tooltip)
gapminder_2007 = px.data.gapminder().query("year == 2007")

page = vm.Page(
title="Custom Component",
title="Tabs",
components=[
Tooltip(text="Tooltip label"),
Tooltip(
text="Max. width of tooltip should not exceed 180px - this instance should be used for multiple lines of text for increased legibility."
vm.Tabs(
tabs=[
vm.Container(
title="Tab I",
components=[
vm.Graph(
title="Graph I",
figure=px.bar(
gapminder_2007,
x="continent",
y="lifeExp",
color="continent",
),
),
vm.Graph(
title="Graph II",
figure=px.box(
gapminder_2007,
x="continent",
y="lifeExp",
color="continent",
),
),
],
),
vm.Container(
title="Tab II",
components=[
vm.Graph(
title="Graph III",
figure=px.scatter(
gapminder_2007,
x="gdpPercap",
y="lifeExp",
size="pop",
color="continent",
),
),
],
),
],
),
],
)
Expand Down
19 changes: 3 additions & 16 deletions vizro-core/src/vizro/models/_components/tabs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

from typing import TYPE_CHECKING, Literal

import dash_mantine_components as dmc
from dash import html
import dash_bootstrap_components as dbc

try:
from pydantic.v1 import validator
Expand Down Expand Up @@ -33,21 +32,9 @@ class Tabs(VizroBaseModel):

@_log_call
def build(self):
tabs_list = dmc.TabsList(
[dmc.Tab(tab.title, value=tab.id, className="tab-title") for tab in self.tabs],
className="tabs-list",
)

tabs_panels = [
dmc.TabsPanel(html.Div([tab.build()], className="tab-content"), value=tab.id, className="tabs-panel")
for tab in self.tabs
]

return dmc.Tabs(
return dbc.Tabs(
id=self.id,
value=self.tabs[0].id,
children=[tabs_list, *tabs_panels],
children=[dbc.Tab(tab.build(), label=tab.title) for tab in self.tabs],
persistence=True,
persistence_type="session",
className="tabs",
)
Loading