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

Allow bulma-collapsible to work out of the box #81

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Documentation: https://bulma-collapsible.netlify.app/javascript/

window.addEventListener("load", () => {
if (typeof bulmaCollapsible === "undefined") {
throw new Error(
"The bulma-collapsible extension is not enabled, enable it to use the runner."
);
}
bulmaCollapsible.attach();
});
12 changes: 12 additions & 0 deletions django_simple_bulma/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
fontawesome_token = ""

simple_bulma_path = Path(__file__).resolve().parent
collapsible_runner_path = (
simple_bulma_path / "extensions"
"/bulma-collapsible-runner/dist/js/bulma-collapsible-runner.js"
)

# (Path, str) pairs describing a relative path in an extension and a glob pattern to search for
sass_files_searches = (
Expand All @@ -52,6 +56,7 @@ def is_enabled(extension: Union[Path, str]) -> bool:
def get_js_files() -> Generator[str, None, None]:
"""Yield all the js files that are needed for the users selected extensions."""
# For every extension...
extensions = []
for ext in (simple_bulma_path / "extensions").iterdir():
# ...check if it is enabled...
if is_enabled(ext):
Expand All @@ -67,6 +72,13 @@ def get_js_files() -> Generator[str, None, None]:
if js_file:
yield js_file.relative_to(simple_bulma_path).as_posix()

# Add the name of the extension to the list of enabled extensions
extensions.append(ext.name)

# If we've got only bulma-collapsible, we need the runner, too.
if "bulma-collapsible" in extensions and "bulma-collapsible-runner" not in extensions:
yield collapsible_runner_path


def get_sass_files(ext: Path) -> List[Path]:
"""Given the path to an extension, find and yield all files that should be imported."""
Expand Down