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] Add vizro-bootstrap stylesheet and remove custom CSS #384

Merged
merged 60 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
522dff0
Add vizro-bootstrap CSS files
huong-li-nguyen Mar 25, 2024
e92a6f1
Remove CSS code for `Accordion`
huong-li-nguyen Mar 25, 2024
84e9da8
Remove CSS for `Card`
huong-li-nguyen Mar 25, 2024
00fc1fd
Ignore Bootstrap files and lint
huong-li-nguyen Mar 25, 2024
63385ff
Remove CSS for `Button`
huong-li-nguyen Mar 25, 2024
8129702
Add newest CSS file
huong-li-nguyen Mar 25, 2024
b1368e8
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 25, 2024
8ecdffd
Remove redundant files
huong-li-nguyen Mar 25, 2024
07f5c24
Tidy and lint
huong-li-nguyen Mar 25, 2024
533a9f0
Fix unit tests
huong-li-nguyen Mar 25, 2024
0ef547c
Merge branch 'tidy/replace_css_bootstrap' of https://github.com/mckin…
huong-li-nguyen Mar 25, 2024
db3d0c2
Merge branch 'main' into tidy/replace_css_bootstrap
huong-li-nguyen Mar 26, 2024
63cca69
Update CSS files
huong-li-nguyen Mar 26, 2024
22e2d2e
Refactor `NavBar`
huong-li-nguyen Mar 26, 2024
7dd3a65
Merge branch 'main' into tidy/replace_css_bootstrap
huong-li-nguyen Mar 26, 2024
bb02055
Lint
huong-li-nguyen Mar 26, 2024
f191fc3
Fix unit tests
huong-li-nguyen Mar 26, 2024
b04dc7f
Replace `html.Div` with `dbc.Nav` or `dbc.Navbar`
huong-li-nguyen Mar 27, 2024
3bbb973
Create 20240327_104803_huong_li_nguyen_improve_semantics_nav.md
huong-li-nguyen Mar 27, 2024
74031d6
Replace `hidden` argument with `className`
huong-li-nguyen Mar 27, 2024
9c506b8
Overwrite CSS temporarily
huong-li-nguyen Mar 27, 2024
9926932
Lint
huong-li-nguyen Mar 27, 2024
45a4aba
Merge branch 'main' into tidy/improve_semantics_nav
huong-li-nguyen Mar 27, 2024
5eee94e
Merge branch 'tidy/improve_semantics_nav' into tidy/replace_css_boots…
huong-li-nguyen Mar 27, 2024
8682c3e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 27, 2024
87dcaa3
Merge branch 'main' into tidy/replace_css_bootstrap
huong-li-nguyen Apr 9, 2024
5e972d2
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 9, 2024
c234b91
Merge branch 'main' into tidy/replace_css_bootstrap
huong-li-nguyen Apr 9, 2024
5b4036a
Add relevant code for RadioItems
huong-li-nguyen Apr 9, 2024
f9dcc0f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 9, 2024
80992f1
Update classNames
huong-li-nguyen Apr 9, 2024
25701b9
Merge branch 'tidy/replace_css_bootstrap' of https://github.com/mckin…
huong-li-nguyen Apr 9, 2024
90b5003
Add CSS file without radio
huong-li-nguyen Apr 9, 2024
4b11fc9
Revert changes on RadioItem
huong-li-nguyen Apr 9, 2024
8771ca7
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 9, 2024
bd149b4
Remove custom CSS for NavBar
huong-li-nguyen Apr 9, 2024
d250f40
Update letter spacing
huong-li-nguyen Apr 9, 2024
c2f8313
Merge branch 'main' into tidy/replace_css_bootstrap
huong-li-nguyen Apr 9, 2024
7d7ae28
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 9, 2024
a0bdc47
Tidy NavBar
huong-li-nguyen Apr 9, 2024
5060a4d
Merge branch 'tidy/replace_css_bootstrap' of https://github.com/mckin…
huong-li-nguyen Apr 9, 2024
dec7037
Fix unit tests
huong-li-nguyen Apr 9, 2024
5ee7cb3
Remove redundant className
huong-li-nguyen Apr 9, 2024
2274596
Fix unit tests
huong-li-nguyen Apr 9, 2024
c590deb
Update vizro bootstrap css
pruthvip15 Apr 10, 2024
1f612e6
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 10, 2024
af94fc9
Merge remote-tracking branch 'origin/main' into tidy/replace_css_boot…
pruthvip15 Apr 10, 2024
2095111
Rename map file
pruthvip15 Apr 10, 2024
b7ca78a
Rename map file
pruthvip15 Apr 10, 2024
312c520
Merge remote-tracking branch 'origin/tidy/replace_css_bootstrap' into…
pruthvip15 Apr 10, 2024
280d48a
Ensure vizro-bootstrap is loaded in first
huong-li-nguyen Apr 10, 2024
b879c69
Update ignore statement for codespell
huong-li-nguyen Apr 10, 2024
51d1aae
Update file names to min.css.map
pruthvip15 Apr 11, 2024
8782f8a
Merge remote-tracking branch 'origin/tidy/replace_css_bootstrap' into…
pruthvip15 Apr 11, 2024
d20cdd0
Add map file to be ignored by codespell
pruthvip15 Apr 11, 2024
6b0cc5a
Remove `CardBody`
huong-li-nguyen Apr 11, 2024
67ae9aa
Merge branch 'main' into tidy/replace_css_bootstrap
huong-li-nguyen Apr 11, 2024
0064c90
Update changelog
huong-li-nguyen Apr 12, 2024
04eba58
Merge branch 'main' into tidy/replace_css_bootstrap
huong-li-nguyen Apr 12, 2024
62de61a
Bring over latest changes from v-b PR
huong-li-nguyen Apr 12, 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
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ repos:
rev: v2.2.6
hooks:
- id: codespell
args: ["--skip=*.min.css.map, *.min.css"]
huong-li-nguyen marked this conversation as resolved.
Show resolved Hide resolved
additional_dependencies:
- tomli

Expand Down
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
**/docs/
**/.devcontainer/devcontainer.json
**/static/css/vizro-bootstrap.min.css
**/static/css/vizro-bootstrap.min.css.map
2 changes: 2 additions & 0 deletions .stylelintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
**/static/css/vizro-bootstrap.min.css
**/static/css/vizro-bootstrap.min.css.map
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

- 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 default bootstrap stylesheet with `vizro-bootstrap` stylesheet. ([#384](https://github.com/mckinsey/vizro/pull/384))
- Refactor code and remove custom classNames from `Button`, `Card`, `NavBar` and `NavLink`. ([#384](https://github.com/mckinsey/vizro/pull/384))

<!--
### 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))

-->
8 changes: 4 additions & 4 deletions vizro-core/src/vizro/_vizro.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from typing import List

import dash
import dash_bootstrap_components as dbc
import flask
from flask_caching import SimpleCache

Expand All @@ -30,9 +29,6 @@ def __init__(self, **kwargs):
self.dash.config.external_stylesheets.extend(
huong-li-nguyen marked this conversation as resolved.
Show resolved Hide resolved
[
"https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined",
# Bootstrap theme has no effect on styling as it gets overwritten by our CSS. However, it is
# necessary to add a default theme here so that added dbc components work properly.
dbc.themes.BOOTSTRAP,
]
)

Expand All @@ -41,6 +37,10 @@ def __init__(self, **kwargs):
vizro_assets_folder = Path(__file__).with_name("static")
requests_pathname_prefix = self.dash.config.requests_pathname_prefix
vizro_css = [requests_pathname_prefix + path for path in self._get_external_assets(vizro_assets_folder, "css")]

# Ensure vizro-bootstrap.min.css is loaded in first to allow overwrites
vizro_css.sort(key=lambda x: not x.endswith("vizro-bootstrap.min.css"))
huong-li-nguyen marked this conversation as resolved.
Show resolved Hide resolved

huong-li-nguyen marked this conversation as resolved.
Show resolved Hide resolved
vizro_js = [
{"src": requests_pathname_prefix + path, "type": "module"}
for path in self._get_external_assets(vizro_assets_folder, "js")
Expand Down
7 changes: 1 addition & 6 deletions vizro-core/src/vizro/models/_components/button.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from typing import List, Literal

import dash_bootstrap_components as dbc
from dash import html

try:
from pydantic.v1 import Field
Expand Down Expand Up @@ -32,8 +31,4 @@ class Button(VizroBaseModel):

@_log_call
def build(self):
return html.Div(
dbc.Button(id=self.id, children=self.text, className="button_primary"),
className="button_container",
id=f"{self.id}_outer",
)
return dbc.Button(id=self.id, children=self.text)
huong-li-nguyen marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 2 additions & 2 deletions vizro-core/src/vizro/models/_components/card.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ class Card(VizroBaseModel):

@_log_call
def build(self):
text = dcc.Markdown(self.text, className="card_text", dangerously_allow_html=False, id=self.id)
text = dcc.Markdown(self.text, dangerously_allow_html=False, id=self.id)
card_content = (
dbc.NavLink(
text,
href=get_relative_path(self.href) if self.href.startswith("/") else self.href,
className="card-link",
)
if self.href
else text
)

card_class = "nav-card" if self.href else "card"
return dbc.Card(card_content, className=card_class, id=f"{self.id}_outer")
2 changes: 1 addition & 1 deletion vizro-core/src/vizro/models/_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def _make_page_404_layout():
],
className="error_text_container",
),
dbc.Button("Take me home", href=get_relative_path("/"), className="button_primary"),
dbc.Button("Take me home", href=get_relative_path("/")),
],
className="error_content_container",
),
Expand Down
6 changes: 4 additions & 2 deletions vizro-core/src/vizro/models/_navigation/nav_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
from collections.abc import Mapping
from typing import Dict, List, Literal

import dash_bootstrap_components as dbc
from dash import html

try:
from pydantic.v1 import Field, validator
except ImportError: # pragma: no cov
from pydantic import Field, validator

import dash_bootstrap_components as dbc

from vizro.models import VizroBaseModel
from vizro.models._models_utils import _log_call
Expand Down Expand Up @@ -75,4 +75,6 @@ def build(self, *, active_page_id=None) -> _NavBuildType:
# Active page is not in navigation at all, so hide navigation panel.
nav_panel = dbc.Nav(id="nav-panel", className="d-none invisible")

return html.Div([dbc.Navbar(nav_links, id="nav-bar"), nav_panel])
# `flex-column` ensures that we return a vertical NavBar. In the future, we could use that className
# to create a horizontal NavBar.
return html.Div([dbc.Navbar(nav_links, id="nav-bar", className="flex-column"), nav_panel])
1 change: 0 additions & 1 deletion vizro-core/src/vizro/models/_navigation/nav_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ def build(self, *, active_page_id=None):
),
],
id=self.id,
className="nav-bar-icon-link",
href=get_relative_path(first_page.path),
# `active` is required to keep the icon highlighted when navigating through different pages inside
# the nested accordion
Expand Down
122 changes: 0 additions & 122 deletions vizro-core/src/vizro/static/css/accordion.css

This file was deleted.

26 changes: 26 additions & 0 deletions vizro-core/src/vizro/static/css/aggrid.css
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,29 @@
#page-container .ag-floating-filter-input input[class^="ag-"][type="text"] {
padding-left: 0;
}

/* Buttons */
#dashboard-container .ag-standard-button {
background: var(--fill-active);
border: none;
border-radius: 0;
box-shadow: var(--box-shadow-elevation-0);
color: var(--text-contrast-primary);
font-size: var(--text-size-02);
font-weight: var(--text-weight-semibold);
height: 32px;
letter-spacing: var(--letter-spacing-body-link-02);
line-height: var(--text-size-05);
padding: var(--spacing-01) var(--spacing-03);
text-transform: none;
}

#dashboard-container .ag-standard-button:hover {
background: linear-gradient(
var(--state-overlays-contrast-hover),
var(--state-overlays-contrast-hover)
),
var(--fill-active);
color: var(--text-contrast-primary);
text-decoration-line: underline;
}
7 changes: 5 additions & 2 deletions vizro-core/src/vizro/static/css/bootstrap_overwrites.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
.form-label {
margin-bottom: 0;
/* This file contains overwrites, which we want to have as defaults for vizro
but do not want to take over to `vizro-bootstrap` as these settings might not be generic enough. */

.card .nav-link {
height: 100%;
}
43 changes: 0 additions & 43 deletions vizro-core/src/vizro/static/css/button.css

This file was deleted.

Loading
Loading