Skip to content

Dangers of Mutability Docs #549

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

Merged
merged 14 commits into from
Jan 5, 2022
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
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# IDOM · [![Tests](https://github.com/idom-team/idom/workflows/Test/badge.svg?event=push)](https://github.com/idom-team/idom/actions?query=workflow%3ATest) [![PyPI Version](https://img.shields.io/pypi/v/idom.svg)](https://pypi.python.org/pypi/idom) [![License](https://img.shields.io/badge/License-MIT-purple.svg)](https://github.com/idom-team/idom/blob/main/LICENSE)

IDOM is a Python package for making user interfaces. These interfaces are built from
small elements of functionality like buttons text and images. IDOM allows you to combine
these elements into reusable "components" that can be composed together to create
complex views.
IDOM is a Python web framework for building **interactive websites without needing a
single line of Javascript**. These sites are built from small elements of functionality
like buttons text and images. IDOM allows you to combine these elements into reusable
"components" that can be composed together to create complex views.

Ecosystem independence is also a core feature of IDOM. It can be added to existing
applications built on a variety of sync and async web servers, as well as integrated
Expand Down
10 changes: 5 additions & 5 deletions docs/examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def load_examples() -> Iterator[tuple[str, Callable[[], ComponentType]]]:

def all_example_names() -> set[str]:
names = set()
for file in _iter_example_files():
for file in _iter_example_files(SOURCE_DIR):
path = file.parent if file.name == "app.py" else file
names.add("/".join(path.relative_to(SOURCE_DIR).with_suffix("").parts))
return names
Expand Down Expand Up @@ -64,12 +64,12 @@ def get_example_files_by_name(
return [path] if path.exists() else []


def _iter_example_files() -> Iterator[Path]:
for path in SOURCE_DIR.iterdir():
def _iter_example_files(root: Path) -> Iterator[Path]:
for path in root.iterdir():
if path.is_dir():
if not path.name.startswith("_") or path.name == "_examples":
yield from path.rglob("*.py")
elif path != CONF_FILE and path.suffix == ".py":
yield from _iter_example_files(path)
elif path.suffix == ".py" and path != CONF_FILE:
yield path


Expand Down
4 changes: 3 additions & 1 deletion docs/source/_custom_js/package-lock.json

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

25 changes: 25 additions & 0 deletions docs/source/_custom_js/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,16 @@ export function mountWidgetExample(
});

const mountEl = document.getElementById(mountID);
let isMounted = false;
triggerIfInViewport(mountEl, () => {
if (!isMounted) {
activateView(mountEl, serverInfo, useActivateButton);
isMounted = true;
}
});
}

function activateView(mountEl, serverInfo, useActivateButton) {
if (!useActivateButton) {
mountWithLayoutServer(mountEl, serverInfo);
return;
Expand Down Expand Up @@ -67,3 +76,19 @@ export function mountWidgetExample(

mountEl.appendChild(enableWidgetButton);
}

function triggerIfInViewport(element, callback) {
const observer = new window.IntersectionObserver(
([entry]) => {
if (entry.isIntersecting) {
callback();
}
},
{
root: null,
threshold: 0.1, // set offset 0.1 means trigger if atleast 10% of element in viewport
}
);

observer.observe(element);
}
4 changes: 4 additions & 0 deletions docs/source/_static/css/sphinx-design-overrides.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ body {
max-height: 700px;
overflow: auto;
}

.sd-card-title .sd-badge {
font-size: 1em;
}

This file was deleted.

This file was deleted.

Loading