Skip to content
Open
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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dependencies = [
"django-ace-overlay",
"django-bitfield==2.2.0",
"django-bootstrap-icons==0.9.0",
"django-bootstrap5==22.2",
"django-bootstrap5==25.1",
"django-celery-beat==2.8.1",
"django-cors-headers==3.13.0",
"django-countries==7.6.1",
Expand Down
13 changes: 7 additions & 6 deletions scss/base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
@import "superuser";

// Add imports to adjust default colors and theme maps
@import "bootstrap-5.2.0/scss/functions";
@import "bootstrap-5.3.3/scss/functions";
@import "custom-variables";
@import "bootstrap-5.2.0/scss/variables";
@import "bootstrap-5.3.3/scss/variables";
@import "custom-maps";

// import study-responses after custom variables because it uses a color variable
@import "study-responses";

// Add all bootstrap features
@import "bootstrap-5.2.0/scss/bootstrap";
@import "bootstrap-5.3.3/scss/bootstrap";


.empty-text {
Expand All @@ -36,7 +36,7 @@

// Screen widths xs to lg
.home-title-text {
font-size: calc(1.325rem + 0.9vw) !important; // fs-2
font-size: calc(1.325rem + 0.9vw) !important; // fs-2
}

.home-subtitle-text {
Expand All @@ -46,15 +46,16 @@
// Screen widths xl and xxl
@include media-breakpoint-up(xl) {
.home-title-text {
font-size: calc(1.375rem + 1.5vw) !important; // fs-1
font-size: calc(1.375rem + 1.5vw) !important; // fs-1
}

.home-subtitle-text {
font-size: calc(1.3rem + 0.6vw) !important; // fs-3
}
}

.img-hover:hover, .img-hover:focus {
.img-hover:hover,
.img-hover:focus {
color: #636464;
background-color: #e5e5e5;
}
Expand Down
8 changes: 4 additions & 4 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 26 additions & 18 deletions web/management/commands/custom_bootstrap5.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import hashlib
import os
import shutil
import urllib.request
import zipfile
from pathlib import Path
from urllib.parse import urlparse

import sass
from django.core.management.base import BaseCommand, CommandError
Expand All @@ -25,37 +28,42 @@ def handle(self, *args, **kwargs):
js_url = get_bootstrap_setting("javascript_url").get("url")
bs5_version = js_url.split("/")[4].split("@")[1]

# download BS5 scss from https://getbootstrap.com/docs/5.2/getting-started/download/
bs5_url = f"https://github.com/twbs/bootstrap/archive/v{bs5_version}.zip"
bs5_filename = bs5_url.split("/")[-1]
# download BS5 scss
bs5_url = urlparse(
f"https://github.com/twbs/bootstrap/archive/v{bs5_version}.zip"
)

bs5_filename = os.path.basename(bs5_url.path)

# the known root directory of the BS5 archive zip file
zip_root_dir = Path("bootstrap-5.2.0")
zip_root_dir = Path(f"bootstrap-{bs5_version}")

# get the hash of the exisiting compiled css file
css_hash = self.get_css_hash()

# when the root directory doesn't exists, download and extract file
if not zip_root_dir.exists():
print(f"Downloading bootstrap v{bs5_version}....")
urllib.request.urlretrieve(bs5_url, bs5_filename)
# download and extract file
print(f"Downloading bootstrap v{bs5_version}.")
urllib.request.urlretrieve(bs5_url.geturl(), bs5_filename)

print("Unzip bootstrap file...")
with zipfile.ZipFile(bs5_filename) as zip_ref:
zip_ref.extractall("./")
print("Unzip bootstrap file.")
with zipfile.ZipFile(bs5_filename) as zip_ref:
zip_ref.extractall("./")

print("Remove downloaded compressed file...")
Path(bs5_filename).unlink()
print("Remove downloaded compressed file.")
Path(bs5_filename).unlink()

if not zip_root_dir.exists():
raise CommandError(
f'Expected directory "{zip_root_dir}" was not found after unzip.'
)
if not zip_root_dir.exists():
raise CommandError(
f'Expected directory "{zip_root_dir}" was not found after unzip.'
)

print("Compile sass to css...")
print("Compile sass to css.")
with open(self.output_css, "w") as fp:
fp.write(sass.compile(filename="scss/base.scss"))

print("Remove bootstrap directory.")
shutil.rmtree(zip_root_dir)

if self.get_css_hash() != css_hash:
raise CommandError("The custom bootstrap 5 css file has been updated.")
else:
Expand Down
Loading