Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
54 changes: 20 additions & 34 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,74 +127,60 @@ license your work under the terms of the [Apache 2.0 License](../LICENSE).

## Code guidelines

### Python
We use [`uv`](https://docs.astral.sh/uv/) to manage the Python project, and [`just`](https://github.com/casey/just) as a task runner. See their resepctive documentation for details on how to install. To manage the JavaScript package you will also need to install [NodeJS](https://nodejs.org/)

We use [`nox`](https://nox.thea.codes/en/stable/) to test and lint Python code.
Python code is linted using `ruff`, JavaScript code is linted using `prettier`. Run the linters with

```sh
pip install nox
just lint
```

Code is linted using `black`, `flake8`, and `isort`. Run the linters with
You can alternatively lint just the Python or JavaScript source with

```sh
nox -s lint
just lint-py
just lint-js
```

Many formatting issues can be fixed automatically by `black` and `isort`. Run
them with
Many formatting issues can be fixed automatically by `ruff` or `prettier` respectively. Run them with

```sh
nox -s format
just format
```

Finally you can run the Python tests locally for a particular version of Python
with

```sh
nox -s test-3.8
just python_version=3.10 test-py
```

and similarly for other versions.
and similarly for other versions. Run the JavaScript unit tests with

### JS

Prettier to format JavaScript code as configured in `.prettierrc`. You can lint
your code with

```bash
npm run lint
```sh
npm test
# or
just test-js
```

and format it automatically with
Run all tests with

```bash
npm run format
```sh
just test
```

### Run tests

Run `npm run test` before committing to ensure your changes pass our tests.

## Building dash-bootstrap-components locally

To build _dash-bootstrap-components_ locally, first install the Python
development dependencies

```sh
python -m pip install -r requirements-dev.txt
```

Then install JavaScript dependencies
First install JavaScript dependencies

```sh
npm install
```

You can now build Python, R and Julia packages with
Then build with

```sh
npm run build
just build
```

## License
Expand Down
63 changes: 29 additions & 34 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,32 @@ jobs:
- id: get-version
run: echo "version=$(echo ${{ github.head_ref }} | sed 's|release/||')" >> "$GITHUB_OUTPUT"

- name: Use Node 16
- name: Use Node 22
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 22

- name: Install dependencies
run: npm ci
- name: Set up Python 3.12
uses: actions/setup-python@v5
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v3
with:
python-version: '3.12'
version: 'latest'

- name: Install just
uses: extractions/setup-just@v2

- name: Install Python dependencies
run: python -m pip install -r requirements-dev.txt
- name: Install JS dependencies
run: npm ci

- name: Update docs requirements
run: invoke set-documentation-version ${{ steps.get-version.outputs.version }}
run: just _set-docs-version ${{ steps.get-version.outputs.version }}

- name: Build dash-bootstrap-components
run: just build

- uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}

- name: Clean dist/
run: rm -rf dist/dash_bootstrap_components.min.js

- name: Build dash-bootstrap-components
run: python -m build --sdist --wheel --outdir dist/

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@v1.4.2
with:
Expand All @@ -71,7 +69,7 @@ jobs:
prerelease: false

- name: Post-release cleanup
run: invoke postrelease ${{ steps.get-version.outputs.version }}
run: just postrelease ${{ steps.get-version.outputs.version }}

- uses: stefanzweifel/git-auto-commit-action@v4
with:
Expand All @@ -92,32 +90,29 @@ jobs:
- id: get-version
run: echo "version=$(echo ${{ github.head_ref }} | sed 's|prerelease/||')" >> "$GITHUB_OUTPUT"

- name: Use Node 16
- name: Use Node 22
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 22

- name: Install dependencies
run: npm ci

- name: Set up Python 3.12
uses: actions/setup-python@v5
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v3
with:
python-version: '3.12'
version: 'latest'

- name: Install just
uses: extractions/setup-just@v2

- name: Install JS dependencies
run: npm ci

- name: Install Python dependencies
run: python -m pip install -r requirements-dev.txt
- name: Build dash-bootstrap-components
run: just build

- uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}

- name: Clean dist/
run: rm -rf dist/dash_bootstrap_components.min.js

- name: Build dash-bootstrap-components
run: python -m build --sdist --wheel --outdir dist/

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@v1.4.2
with:
Expand All @@ -143,7 +138,7 @@ jobs:
prerelease: true

- name: Post-release cleanup
run: invoke postrelease ${{ steps.get-version.outputs.version }}
run: just postrelease ${{ steps.get-version.outputs.version }}

- uses: stefanzweifel/git-auto-commit-action@v4
with:
Expand Down
47 changes: 21 additions & 26 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,37 @@ jobs:
runs-on: 'ubuntu-latest'
steps:
- uses: actions/checkout@v1
- name: Use Node 16
- name: Install just
uses: extractions/setup-just@v2
- name: Use Node 22
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 22
- name: Install dependencies
run: npm ci
- name: Lint source
run: npm run lint
run: just lint-js
- name: Run tests
run: npm run test
- name: Run demo test
run: npm run test:demo
run: just test-js
build:
name: Build package
runs-on: 'ubuntu-latest'
steps:
- uses: actions/checkout@v1
- name: Use Node 16
- name: Install just
uses: extractions/setup-just@v2
- name: Use Node 22
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 22
- name: Install dependencies
run: npm ci
- name: Set up Python 3.12
uses: actions/setup-python@v5
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v3
with:
python-version: '3.12'
- name: Install Dash
run: python -m pip install -r requirements-dev.txt
version: 'latest'
- name: Build dash-bootstrap-components
run: npm run build
run: just build
- name: Upload generated files
uses: actions/upload-artifact@v4
with:
Expand All @@ -62,23 +62,18 @@ jobs:
HUB_PORT: 4444
steps:
- uses: actions/checkout@v1
- name: Set up Python 3.12
uses: actions/setup-python@v5
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v3
with:
python-version: '3.12'
- name: Set up Python ${{ matrix.python-version }}
if: matrix.python-version != '3.12'
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install nox
run: python3.12 -m pip install -U nox
version: 'latest'
- name: Install just
uses: extractions/setup-just@v2
- name: Lint Python source
if: matrix.python-version == '3.12'
run: nox -s lint
run: just lint-py
- uses: actions/download-artifact@v4
with:
name: dash-bootstrap-components
path: dash_bootstrap_components/_components
- name: Test Python module
run: nox -s test-${{ matrix.python-version }}
run: just python_version=${{ matrix.python-version }} test-py
6 changes: 4 additions & 2 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"tabWidth": 2,
"singleQuote": true,
"bracketSpacing": false
}
"bracketSpacing": false,
"arrowParens": "avoid",
"trailingComma": "none"
}
3 changes: 0 additions & 3 deletions MANIFEST.in

This file was deleted.

4 changes: 1 addition & 3 deletions dash_bootstrap_components/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@

_js_dist = [
{
"relative_package_path": (
"_components/dash_bootstrap_components.min.js"
),
"relative_package_path": ("_components/dash_bootstrap_components.min.js"),
"external_url": (
f"https://unpkg.com/dash-bootstrap-components@{__version__}"
"/dist/dash_bootstrap_components.min.js"
Expand Down
9 changes: 3 additions & 6 deletions dash_bootstrap_components/_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def _generate_table_from_df(
index=False,
index_label=None,
date_format=None,
**table_kwargs
**table_kwargs,
):
"""
Generate a Table component from a dataframe.
Expand Down Expand Up @@ -78,8 +78,7 @@ def _generate_table_from_df(
# Get the actual headers
n_levels = df.columns.nlevels
header_values = [
list(df.columns.get_level_values(level))
for level in range(n_levels)
list(df.columns.get_level_values(level)) for level in range(n_levels)
]

# The sizes of consecutive header groups at each level
Expand Down Expand Up @@ -134,9 +133,7 @@ def _generate_table_from_df(
table.append(
html.Tbody(
[
html.Tr(
[html.Td(df.iloc[i, j]) for j in range(len(df.columns))]
)
html.Tr([html.Td(df.iloc[i, j]) for j in range(len(df.columns))])
for i in range(len(df))
]
)
Expand Down
3 changes: 1 addition & 2 deletions dash_bootstrap_components/icons.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
BOOTSTRAP = (
"https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.3/"
"font/bootstrap-icons.css"
"https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.3/" "font/bootstrap-icons.css"
)
FONT_AWESOME = "https://use.fontawesome.com/releases/v6.3.0/css/all.css"
4 changes: 1 addition & 3 deletions dash_bootstrap_components/themes.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
BOOTSTRAP = (
"https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css"
)
BOOTSTRAP = "https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css"

GRID = "https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap-grid.min.css" # noqa

Expand Down
12 changes: 3 additions & 9 deletions docs/components_page/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,7 @@ def register_apps():

for slug, kwargs in component_bodies.items():
requests_pathname_prefix = (
f"/docs/components/{slug}/"
if slug != "index"
else "/docs/components/"
f"/docs/components/{slug}/" if slug != "index" else "/docs/components/"
)
app = dash.Dash(
external_stylesheets=["/static/loading.css"],
Expand All @@ -162,13 +160,9 @@ def register_apps():
app.title = f"{_get_label(slug)} - dbc docs"

if slug == "layout":
app.layout = html.Div(
parse(app, **kwargs), className="layout-demo"
)
app.layout = html.Div(parse(app, **kwargs), className="layout-demo")
elif slug == "button_group":
app.layout = html.Div(
parse(app, **kwargs), className="button-group-demo"
)
app.layout = html.Div(parse(app, **kwargs), className="button-group-demo")
else:
app.layout = parse(app, **kwargs)
if slug == "index":
Expand Down
Loading
Loading