+
+```
+
+
+Using `` to pass the extra arguments to other components **WILL NOT WORK**. That is because the components are translated to macros before the page render.
+
+You must pass them as the special argument `_attrs`.
+
+```html+jinja
+{#--- WRONG 😵 ---#}
+
+
+{#--- GOOD 👍 ---#}
+
+
+```
+
+
+#### `.set(name=value, ...)`
+
+Sets an attribute or property
+
+- Pass a name and a value to set an attribute (e.g. `type="text"`)
+- Use `True` as a value to set a property (e.g. `disabled`)
+- Use `False` to remove an attribute or property
+- If the attribute is "class", the new classes are appended to
+ the old ones (if not repeated) instead of replacing them.
+- The underscores in the names will be translated automatically to dashes,
+ so `aria_selected` becomes the attribute `aria-selected`.
+
+```html+jinja title="Adding attributes/properties"
+{% do attrs.set(
+ id="loremipsum",
+ disabled=True,
+ data_test="foobar",
+ class="m-2 p-4",
+) %}
+```
+
+```html+jinja title="Removing attributes/properties"
+{% do attrs.set(
+ title=False,
+ disabled=False,
+ data_test=False,
+ class=False,
+) %}
+```
+
+#### `.setdefault(name=value, ...)`
+
+Adds an attribute, but only if it's not already present.
+
+The underscores in the names will be translated automatically to dashes, so `aria_selected`
+becomes the attribute `aria-selected`.
+
+```html+jinja
+{% do attrs.setdefault(
+ aria_label="Products"
+) %}
+```
+
+#### `.add_class(name1, name2, ...)`
+
+Adds one or more classes to the list of classes, if not already present.
+
+```html+jinja
+{% do attrs.add_class("hidden") %}
+{% do attrs.add_class("active", "animated") %}
+```
+
+#### `.remove_class(name1, name2, ...)`
+
+Removes one or more classes from the list of classes.
+
+```html+jinja
+{% do attrs.remove_class("hidden") %}
+{% do attrs.remove_class("active", "animated") %}
+```
+
+#### `.get(name, default=None)`
+
+Returns the value of the attribute or property,
+or the default value if it doesn't exist.
+
+```html+jinja
+{%- set role = attrs.get("role", "tab") %}
+```
+
+...
\ No newline at end of file
diff --git a/docs/content/guide/css_and_js.md b/docs/content/guide/css_and_js.md
new file mode 100644
index 0000000..8e296e2
--- /dev/null
+++ b/docs/content/guide/css_and_js.md
@@ -0,0 +1,230 @@
+---
+title: Adding CSS and JS
+description: Your components might need custom styles or custom JavaScript for many reasons.
+---
+
+
+Your components might need custom styles or custom JavaScript for many reasons.
+
+Instead of using global stylesheet or script files, writing assets for each individual component has several advantages:
+
+- **Portability**: You can copy a component from one project to another, knowing it will keep working as expected.
+- **Performance**: Only load the CSS and JS that you need on each page. Additionally, the browser will have already cached the assets of the components for other pages that use them.
+- **Simple testing**: You can test the JS of a component independently from others.
+
+## Auto-loading assets
+
+JinjaX searches for `.css` and `.js` files with the same name as your component in the same folder and automatically adds them to the list of assets included on the page. For example, if your component is `components/common/Form.jinja`, both `components/common/Form.css` and `components/common/Form.js` will be added to the list, but only if those files exist.
+
+## Manually declaring assets
+
+In addition to auto-loading assets, the CSS and/or JS of a component can be declared in the metadata header with `{#css ... #}` and `{#js ... #}`.
+
+```html
+{#css lorem.css, ipsum.css #}
+{#js foo.js, bar.js #}
+```
+
+- The file paths must be relative to the root of your components catalog (e.g., `components/form.js`) or absolute (e.g., `http://example.com/styles.css`).
+- Multiple assets must be separated by commas.
+- Only **one** `{#css ... #}` and **one** `{#js ... #}` tag is allowed per component at most, but both are optional.
+
+### Global assets
+
+The best practice is to store both CSS and JS files of the component within the same folder. Doing this has several advantages, including easier component reuse in other projects, improved code readability, and simplified debugging.
+
+However, there are instances when you may need to rely on global CSS or JS files, such as third-party libraries. In such cases, you can specify these dependencies in the component's metadata using URLs that start with either "/", "http://," or "https://."
+
+When you do this, JinjaX will render them as is, instead of prepending them with the component's prefix like it normally does.
+
+For example, this code:
+
+```html+jinja
+{#css foo.css, bar.css, /static/bootstrap.min.css #}
+{#js http://example.com/cdn/moment.js, bar.js #}
+
+{{ catalog.render_assets() }}
+```
+
+will be rendered as this HTML output:
+
+```html
+
+
+
+
+
+```
+
+## Including assets in your pages
+
+The catalog will collect all CSS and JS file paths from the components used on a "page" render on the `catalog.collected_css` and `catalog.collected_js` lists.
+
+For example, after rendering this component:
+
+```html+jinja title="components/MyPage.jinja"
+{#css mypage.css #}
+{#js mypage.js #}
+
+
+
+
+ Lizard
+ The Iguana is a type of lizard
+
+
+ Share
+
+
+
+```
+
+Assuming the `Card` and `Button` components declare CSS assets, this will be the state of the `collected_css` list:
+
+```py
+catalog.collected_css
+['mypage.css', 'card.css', 'button.css']
+```
+
+You can add the `
` and `
+
+
+```
+
+## Middleware
+
+The tags above will not work if your application can't return the content of those files. Currently, it can't.
+
+For that reason, JinjaX includes WSGI middleware that will process those URLs if you add it to your application.
+
+```py
+from flask import Flask
+from jinjax import Catalog
+
+app = Flask(__name__)
+
+# Here we add the Flask Jinja globals, filters, etc., like `url_for()`
+catalog = jinjax.Catalog(jinja_env=app.jinja_env)
+
+catalog.add_folder("myapp/components")
+
+app.wsgi_app = catalog.get_middleware(
+ app.wsgi_app,
+ autorefresh=app.debug,
+)
+```
+
+The middleware uses the battle-tested [Whitenoise library](http://whitenoise.evans.io/) and will only respond to the *.css* and *.js* files inside the component(s) folder(s). You can configure it to also return files with other extensions. For example:
+
+```python
+catalog.get_middleware(app, allowed_ext=[".css", .js", .svg", ".png"])
+```
+
+Be aware that if you use this option, `get_middleware()` must be called **after** all folders are added.
+
+## Good practices
+
+### CSS Scoping
+
+The styles of your components will not be auto-scoped. This means the styles of a component can affect other components and likewise, it will be affected by global styles or the styles of other components.
+
+To protect yourself against that, *always* add a custom class to the root element(s) of your component and use it to scope the rest of the component styles.
+
+You can even use this syntax now supported by [all modern web browsers](https://caniuse.com/css-nesting):
+
+```sass
+.Parent {
+ .foo { ... }
+ .bar { ... }
+}
+```
+
+The code above will be interpreted as
+
+```css
+.Parent .foo { ... }
+.Parent .bar { ... }
+```
+
+Example:
+
+```html+jinja title="components/Card.jinja"
+{#css card.css #}
+
+
+
My Card
+ ...
+
+```
+
+```sass title="components/card.css"
+/* 🚫 DO NOT do this */
+h1 { font-size: 2em; }
+h2 { font-size: 1.5em; }
+a { color: blue; }
+
+/* 👍 DO THIS instead */
+.Card {
+ & h1 { font-size: 2em; }
+ & h2 { font-size: 1.5em; }
+ & a { color: blue; }
+}
+
+/* 👍 Or this */
+.Card h1 { font-size: 2em; }
+.Card h2 { font-size: 1.5em; }
+.Card a { color: blue; }
+```
+
+
+Always use a class **instead of** an `id`, or the component will not be usable more than once per page.
+
+
+### JS events
+
+Your components might be inserted in the page on-the-fly, after the JavaScript files have been loaded and executed. So, attaching events to the elements on the page on load will not be enough:
+
+```js title="components/card.js"
+// This will fail for any Card component inserted after page load
+document.querySelectorAll('.Card button.share')
+ .forEach((node) => {
+ node.addEventListener("click", handleClick)
+ })
+
+/* ... etc ... */
+```
+
+A solution can be using event delegation:
+
+```js title="components/card.js"
+// This will work for any Card component inserted after page load
+document.addEventListener("click", (event) => {
+ if (event.target.matches(".Card button.share")) {
+ handleClick(event)
+ }
+})
+```
diff --git a/docs/content/guide/index.md b/docs/content/guide/index.md
new file mode 100644
index 0000000..0c092ea
--- /dev/null
+++ b/docs/content/guide/index.md
@@ -0,0 +1,196 @@
+---
+title: Introduction
+---
+
+
+JinjaX is a Python library for creating reusable "components": encapsulated template snippets that can take arguments and render to HTML. They are similar to React or Vue components, but they render on the server side, not in the browser.
+
+
+Unlike Jinja's `{% include "..." %}` or macros, JinjaX components integrate naturally with the rest of your template code.
+
+```html+jinja
+
+
+ Products
+ {% for product in products %}
+
+ {% endfor %}
+
+
+```
+
+## Features
+
+### Simple
+
+JinjaX components are simple Jinja templates. You use them as if they were HTML tags without having to import them: easy to use and easy to read.
+
+### Encapsulated
+
+They are independent of each other and can link to their own CSS and JS, so you can freely copy and paste components between applications.
+
+### Testable
+
+All components can be unit tested independently of the pages where they are used.
+
+### Composable
+
+A JinjaX component can wrap HTML code or other components with a natural syntax, as if they were another tag.
+
+### Modern
+
+They are a great complement to technologies like [TailwindCSS](https://tailwindcss.com/), [htmx](https://htmx.org/), or [Hotwire](https://hotwired.dev/).
+
+## Usage
+
+#### Install
+
+Install the library using `pip`.
+
+```bash
+pip install jinjax
+```
+
+#### Components folder
+
+Then, create a folder that will contain your components, for example:
+
+```
+└ myapp/
+ ├── app.py
+ ├── components/ 🆕
+ │ └── Card.jinja 🆕
+ ├── static/
+ ├── templates/
+ └── views/
+└─ requirements.txt
+```
+
+#### Catalog
+
+Finally, you must create a "catalog" of components in your app. This is the object that manages the components and their global settings. You then add the path of the folder with your components to the catalog:
+
+```python
+from jinjax import Catalog
+
+catalog = Catalog()
+catalog.add_folder("myapp/components")
+```
+
+#### Render
+
+You will use the catalog to render components from your views.
+
+```python
+def myview():
+ ...
+ return catalog.render(
+ "Page",
+ title="Lorem ipsum",
+ message="Hello",
+ )
+```
+
+In this example, it is a component for the whole page, but you can also render smaller components, even from inside a regular Jinja template if you add the catalog as a global:
+
+```python
+app.jinja_env.globals["catalog"] = catalog
+```
+
+```html+jinja
+{% block content %}
+
+ {{ catalog.irender("LikeButton", title="Like and subscribe!", post=post) }}
+
+
Lorem ipsum
+{{ catalog.irender("CommentForm", post=post) }}
+{% endblock %}
+```
+
+## How It Works
+
+JinjaX uses Jinja to render the component templates. In fact, it currently works as a pre-processor, replacing all:
+
+```html
+
content
+```
+
+with function calls like:
+
+```html+jinja
+{% call catalog.irender("Component", attr="value") %}content{% endcall %}
+```
+
+These calls are evaluated at render time. Each call loads the source of the component file, parses it to extract the names of CSS/JS files, required and/or optional attributes, pre-processes the template (replacing components with function calls, as before), and finally renders the new template.
+
+### Reusing Jinja's Globals, Filters, and Tests
+
+You can add your own global variables and functions, filters, tests, and Jinja extensions when creating the catalog:
+
+```python
+from jinjax import Catalog
+
+catalog = Catalog(
+ globals={ ... },
+ filters={ ... },
+ tests={ ... },
+ extensions=[ ... ],
+)
+```
+
+or afterward.
+
+```python
+catalog.jinja_env.globals.update({ ... })
+catalog.jinja_env.filters.update({ ... })
+catalog.jinja_env.tests.update({ ... })
+catalog.jinja_env.extensions.extend([ ... ])
+```
+
+The ["do" extension](https://jinja.palletsprojects.com/en/3.0.x/extensions/#expression-statement) is enabled by default, so you can write things like:
+
+```html+jinja
+{% do attrs.set(class="btn", disabled=True) %}
+```
+
+### Reusing an Existing Jinja Environment
+
+You can also reuse an existing Jinja Environment, for example:
+
+#### Flask:
+
+```python
+app = Flask(__name__)
+
+# Here we add the Flask Jinja globals, filters, etc., like `url_for()`
+catalog = jinjax.Catalog(jinja_env=app.jinja_env)
+```
+
+#### Django:
+
+First, configure Jinja in `settings.py` and [jinja_env.py](https://docs.djangoproject.com/en/5.0/topics/templates/#django.template.backends.jinja2.Jinja2).
+
+To have a separate "components" folder for shared components and also have "components" subfolders at each Django app level:
+
+```python
+import jinjax
+from jinja2.loaders import FileSystemLoader
+
+def environment(loader: FileSystemLoader, **options):
+ env = Environment(loader=loader, **options)
+
+ ...
+
+ env.add_extension(jinjax.JinjaX)
+ catalog = jinjax.Catalog(jinja_env=env)
+
+ catalog.add_folder("components")
+ for dir in loader.searchpath:
+ catalog.add_folder(os.path.join(dir, "components"))
+
+ return env
+```
+
+#### FastAPI:
+
+TBD
\ No newline at end of file
diff --git a/docs/content/guide/integrations.md b/docs/content/guide/integrations.md
new file mode 100644
index 0000000..0884d22
--- /dev/null
+++ b/docs/content/guide/integrations.md
@@ -0,0 +1,3 @@
+---
+title: Integrations
+---
\ No newline at end of file
diff --git a/docs/content/guide/motivation.md b/docs/content/guide/motivation.md
new file mode 100644
index 0000000..90602b5
--- /dev/null
+++ b/docs/content/guide/motivation.md
@@ -0,0 +1,115 @@
+---
+title: Motivation
+---
+
+An overview of what Jinja is about, and a glimpse into my disjointed decision-making process that got me here.
+
+
+## Components are cool
+
+Despite the complexity of a single-page application, some programmers claim React or Vue offer a better development experience than traditional server-side rendered templates. I believe this is mostly because of the greatest improvement React introduced to web development: components.
+
+
+Components, *as a way to organize template code*. Reactivity is cool too, but unrelated to the main issue.
+
+
+When writing Python, we aim for the code to be easy to understand and test. However, we often forget all of that when writing templates that don't even meet basic standards: long methods, deep conditional nesting, and mysterious variables everywhere.
+
+Components are way cooler than the HTML soup tag of server-side rendered templates. They make it very clear what arguments they take and how they can render. More than anything, components are modular: markup, logic, and relevant styles all in one package. You can copy and paste them between projects, and you can share them with other people.
+
+This means a community has formed around sharing these components. Now you can easily find hundreds of ready-to-use components—some of them very polished—for every common UI widget, even the "complex" ones, like color-pickers. The big problem is that you can only use them with React (and Vue components with Vue, etc.) and in a single-page application.
+
+Jinja is about bringing that innovation back to server-side-rendered applications.
+
+## Not quite there: Jinja macros
+
+An underestimated feature of Jinja is *macros*. Jinja [macros](https://jinja.palletsprojects.com/en/3.0.x/templates/#macros) are template snippets that work like functions: They can have positional or keyword arguments, and when called return the rendered text inside.
+
+```html+jinja
+{% macro input(name, value="", type="text", size=20) -%}
+
+{%- endmacro %}
+
+{% macro button(type="button") -%}
+
+ {{ caller() }}
+
+{%- endmacro %}
+```
+
+You can then import the macro to your template to use it:
+
+```html+jinja
+{% from 'forms.html' import input, button %}
+
+
{{ input("username") }}
+
{{ input("password", type="password") }}
+{% call button("submit") %}Submit{% endcall %}
+```
+You must use the `{% call x %}` to pass the child content to the macro—by using the weird incantation `{{ caller() }}`—otherwise you can just call it like it were a function.
+
+So, can we use macros as components and call it a day? Well... no. This looks terrible:
+
+```html+jinja
+{% call Card(label="Hello") %}
+ {% call MyButton(color="blue", shadowSize=2) %}
+ {{ Icon(name="ok") }} Click Me
+ {% endcall %}
+{% endcall %}
+```
+
+compared to how you would write it with JSX:
+
+```html
+
+
+ Click Me
+
+
+```
+
+But macros are *almost* there. They would be a great foundation if we could adjust the syntax just a little.
+
+## Strong alternative: Mako
+
+At some point, I considered dropping this idea and switching to [Mako](https://www.makotemplates.org/), a template library by Michael Bayer (of SQLAlchemy fame).
+
+It's a hidden gem that doesn't get much attention because of network effects. See how close you can get with it:
+
+```html+mako
+<%def name="layout()"> # <--- A "macro"
+
+
+
+
+
+
+ ${caller.body()}
+
+
+%def>
+
+## calls the layout def <--- Look! Python-style comments
+
+<%self:layout>
+ <%def name="header()"> # <--- This is like a "slot"!
+ I am the header
+ %def>
+ <%def name="sidebar()">
+
+ sidebar 1
+ sidebar 2
+
+ %def>
+ this is the body
+%self:layout>
+```
+
+Mako also has `<% include %>`s with arguments, which is another way of doing components if you don't need to pass content.
+
+However, in the end, the network effects, my familiarity with Jinja, and a little of not-invented-here syndrome tipped the scales to write a Jinja extension.
diff --git a/docs/content/guide/performance.md b/docs/content/guide/performance.md
new file mode 100644
index 0000000..609b952
--- /dev/null
+++ b/docs/content/guide/performance.md
@@ -0,0 +1,3 @@
+---
+title: Performance
+---
diff --git a/docs/content/guide/slots.md b/docs/content/guide/slots.md
new file mode 100644
index 0000000..991f327
--- /dev/null
+++ b/docs/content/guide/slots.md
@@ -0,0 +1,175 @@
+---
+title: Slots / Content
+description: Working with content in components.
+---
+
+
+Besides attributes, components can also accept content to render inside them.
+
+
+Everything between the open and close tags of the components will be rendered and passed to the component as an implicit `content` variable
+
+This is a very common pattern, and it is called a **_slot_**. A slot is a placeholder for content that can be provided by the user of the component. For example, we may have a `
` component that supports usage like this:
+
+```html+jinja
+
+
+ {{ content }}
+
+```
+
+![slot diagram](/static/img/slots-diagram.png)
+
+The `` is responsible for rendering the outer `` (and its fancy styling), while the inner content is provided by the parent component.
+
+A great use case of the `content` is to make layout components:
+
+
+
+
+## Fallback Content
+
+There are cases when it's useful to specify fallback (i.e. default) content for a slot, to be rendered only when no content is provided. For example, in a `` component:
+
+```html+jinja
+
+ {{ content }}
+
+```
+
+We might want the text "Submit" to be rendered inside the `` if the parent didn't provide any slot content. The special "content" variable is just a string like any other, so we can test if it's empty to make "Submit" the fallback content:
+
+```html+jinja
+
+ {% if content %}
+ {{ content }}
+ {% else %}
+ Submit
+ {% endif %}
+
+```
+
+Now when we use `` in a parent component, providing no content for the slot:
+
+```html+jinja
+
+```
+
+
+The `content` of a self-closing component is an empty string.
+
+
+This will render the fallback content, "Submit":
+
+```html
+Submit
+```
+
+But if we provide content:
+
+```html+jinja
+Save
+```
+
+Then the provided content will be rendered instead:
+
+```html
+Save
+```
+
+
+## Multiple content slots (a.k.a. "named slots")
+
+There are cases when a component is complex enough to need multiple content slots. For example, a `` component might need a `header`, a `body`, and a `footer` content.
+
+One way to implement it is using multiple content slots. To do so, instead of rendering `content` as a string, you can also _call_ it with name. Then, the parent component can provide a content _for_ that name.
+
+![_slot variable](/static/img/slots-_slot.png)
+
+Note the `_slot` special variable. This is automatically available in the content in the parent component and contains the named the component has used to call request its content.
+
+The `_slot` variable is scoped to the content of that component, so it's not available outside of it:
+
+```html+jinja hl_lines="2 7 11"
+
+ {% if _slot == "hi" %} {# <--- _slot #}
+ Hello{% endif %}
+
+
+
+ {% if _slot == "hi" %} {# <--- This _slot is a different one #}
+ Sup?{% endif %}
+
+
+{{ _slot }} {# <--- Undefined variable #}
+```
+
+
+## Composability: better than named slots
+
+Named slots are a quick way to have multiple content slots, but are a bit messy beyond some simple cases.
+
+Composability offers a more flexible and idiomatic approach when multiple content slots are needed. The idea is to have separated components for each content slot, and then compose them together. Let's explore this concept using the same example as above.
+
+Consider a `Modal` component that requires three distinct sections: a header, a body, and a footer. Instead of using named slots, we can create separate components for each section and composing them within a `Modal` component wrapper.
+
+```html+jinja
+
+
+
+
+ Hello World!
+
+
+
+ The modal body.
+
+
+
+ Cancel
+ Save
+
+
+
+```
+
+Now, the `Modal` component is responsible for rendering the outer `` and its styling, while the inner content is provided by the child components.
+
+
+
+### Advantages of Composability
+
+- **Flexibility**: You can easily rearrange, omit, or add new sections without modifying the core `Modal` component.
+- **Reusability**: Each section (`ModalHeader`, `ModalBody`, `ModalFooter`) can be used independently or within other components.
+- **Maintainability**: It's easier to update or style individual sections without affecting the others.
+
+
+## Testing components with content
+
+To test a component in isolation, you can manually send a content argument using the special `_content` argument:
+
+```python
+catalog.render("PageLayout", title="Hello world", _content="TEST")
+```
+
diff --git a/docs/content/index.md b/docs/content/index.md
new file mode 100644
index 0000000..69796da
--- /dev/null
+++ b/docs/content/index.md
@@ -0,0 +1,8 @@
+---
+title: Welcome
+component: PageSingle
+description: Super components powers for your Jinja templates
+social_card: SocialCardIndex
+---
+
+
diff --git a/docs/content/ui/accordion.md b/docs/content/ui/accordion.md
new file mode 100644
index 0000000..8676fd5
--- /dev/null
+++ b/docs/content/ui/accordion.md
@@ -0,0 +1,43 @@
+---
+title: Accordion
+description: Component for grouping HTML elements where only one of them can be open at the same time.
+---
+
+
+ Component for grouping details
HTML elements where only one of them can be open at the same time.
+
+
+An accordion is a vertically stacked group of collapsible sections. HTML has already a native element for this, the `` element, but it doesn't support the "only one open at a time" behavior, so we need to add some JS to make it work, and that's what this component does.
+
+If you don't need to ensure only one section is open at a time, you don't need this component at all, just use the `` element directly.
+
+
+
+
+The `Accordion` is a simple wrapper plus some JS logic, so it doesn't uses any arguments and it's as accesible as the `details` element you put inside.
+
+
+## Events
+
+The `Accordion` doesn't emit or listen to any events, but the `` elements inside do.
+
+In addition to the usual events supported by HTML elements, the `` element supports the `toggle` event, which is dispatched to the `` element whenever its state changes between open and closed. The `Accordion` component listen to it to be able to close the other `` elements when one is opened.
+
+The `toggle` event is sent *after* the state is changed, although if the state changes multiple times before the browser can dispatch the event, the events are coalesced so that only one is sent.
+
+```js
+details.addEventListener("toggle", (event) => {
+ if (details.open) {
+ /* the element was toggled open */
+ } else {
+ /* the element was toggled closed */
+ }
+});
+```
diff --git a/docs/content/ui/index.md b/docs/content/ui/index.md
new file mode 100644
index 0000000..0a406a4
--- /dev/null
+++ b/docs/content/ui/index.md
@@ -0,0 +1,58 @@
+---
+title: UI components
+description: Unstyled, fully accessible UI components, to integrate with your projects.
+---
+
+
+ Unstyled, fully accessible UI components, to integrate with your projects.
+
+
+
+
+
+## How to use
+
+1. Install the `jinjax-ui` python library doing
+
+ ```bash
+ pip install jinjax-ui
+ ```
+
+2. Add it to your *JinjaX* catalog:
+
+ ```python
+ import jinjax_ui
+
+ catalog.add_folder(jinjax_ui.components_path, prefix="")
+ ```
+
+3. Use the UI components in your components/templates:
+
+ ```html+jinja
+ ...
+ ```
\ No newline at end of file
diff --git a/docs/content/ui/linkedlist.md b/docs/content/ui/linkedlist.md
new file mode 100644
index 0000000..ac3fce2
--- /dev/null
+++ b/docs/content/ui/linkedlist.md
@@ -0,0 +1,19 @@
+---
+title: Linked Lists
+description: A component to select multiple items from a long list, while keeping them sorted.
+---
+
+
+ A component to select multiple items from a long list, while keeping them sorted.
+
+
+
+
+The checkboxes above are displayed so you can see how they get checked/unchecked. If you might want to hide them with CSS, the component will keep working as usual, but they must be present.
diff --git a/docs/content/ui/menu.md b/docs/content/ui/menu.md
new file mode 100644
index 0000000..12539d5
--- /dev/null
+++ b/docs/content/ui/menu.md
@@ -0,0 +1,112 @@
+---
+title: Menu (Dropdown)
+description: Displays a list of options that a user can choose with robust support for keyboard navigation. Built using the Popover API.
+---
+
+
+ Displays a list of options that a user can choose with robust support for
+ keyboard navigation. Built using the Popover API.
+
+
+
+
+**Note:** This component does not handle keyboard shortcuts, here are shown only as an example.
+
+Menus are built using the `Menu`, `MenuButton`, `MenuItem`, and `MenuItemSub` components. Clicking on menu button or activating it with the keyboard will show the corresponding menu.
+
+```html+jinja
+Open menu
+
+ item1 〈-- Regular item
+ item2
+ item3
+ item4 〈----------- An item with a submenu
+ ... 〈----------- Submenu
+
+
+```
+
+A `Menu` starts hidden on page load by having `display:none` set on it (the Popover API does it automatically). To show/hide the menu, you need to add a `MenuButton`.
+
+When a `Menu` is shown, it has `display:none` removed from it and it is put into the top layer so, unlike just using `position: absolute`, it's guaranteed that it will sit on top of all other page content.
+
+
+## Anchor positioning
+
+By default, the menu appears centered in the layout view, but this component allows you to position it relative to an specific element in the page, using the `anchor` and `anchor-to` attributes.
+
+`anchor` is the ID of the element used as a reference, and `anchor-to` which side of the anchor to use: "top", "bottom", "right", or "left"; with an optional postfix of "start" or "end" ("center" is the default).
+
+
+
+
+
+The positioning is done every time the menu opens, but you can trigger the re-position, for example, on windows resizing, by calling the `jxui-popover/setPosition(menu)` function.
+
+
+## Styling states
+
+| CSS selector | Description
+| ----------------------- | --------------
+| `.ui-menu` | Every menu has this class
+| `.ui-menu:popover-open` | This pseudo-class matches only menus that are currently being shown
+| `::backdrop` | This pseudo-element is a full-screen element placed directly behind showing menu elements in the top layer, allowing effects to be added to the page content behind the menu(s) if desired. You might for example want to blur out the content behind the menu to help focus the user's attention on it
+
+To animate a menu, follow the [Animating popovers section](/headless/popover#animating-popovers) in the Popover page.
+
+
+## Component arguments
+
+### MenuButton
+
+| Argument | Type | Default | Description
+| --------------- | --------- | ---------- | --------------
+| `target` | `str` | | Required. The ID of the linked `Popover` component.
+| `action` | `str` | `"toggle"` | `"open"`, `"close"`, or `"toggle"`.
+| `tag` | `str` | `"button"` | HTML tag of the component.
+
+### Menu
+
+| Argument | Type | Default | Description
+| ------------ | ----- | -------- | --------------
+| `mode` | `str` | `"auto"` | `"auto"` or `"manual"`.
+| `anchor` | `str` | | ID of the element used as an anchor
+| `anchor-to` | `str` | | Which side/position of the anchor to use: "**top**", "**bottom**", "**right**", or "**left**"; with an optional postfix of "**start**", "**end**", "**center**".
+| `tag` | `str` | `"div"` | HTML tag of the component.
+
+### MenuItem
+
+| Argument | Type | Default | Description
+| ------------ | ----- | -------- | --------------
+| `mode` | `str` | `"auto"` | `"auto"` or `"manual"`.
+
+### MenuSubItem
+
+| Argument | Type | Default | Description
+| ------------ | ----- | -------- | --------------
+| `mode` | `str` | `"auto"` | `"auto"` or `"manual"`.
+
+
+## Accessibility notes
+
+### Mouse interaction
+
+- Clicking a `PopButton` will trigger the button action (open, close, or toggle state).
+
+- Clicking outside of a `Popover` will close *all* the `Popover` with `mode="auto"`.
+
+
+### Keyboard interaction
+
+- Pressing the Enter or Space keys on a `PopButton` will trigger
+the button action (open, close, or toggle state), and close *all* the `Popover` with `mode="auto"`.
+
+- Pressing the Escape key will close *all* the `Popover` with `mode="auto"`.
diff --git a/docs/content/ui/popover.md b/docs/content/ui/popover.md
new file mode 100644
index 0000000..673f96d
--- /dev/null
+++ b/docs/content/ui/popover.md
@@ -0,0 +1,204 @@
+---
+title: Pop-over
+description: A wrapper over the Popover API with anchor positioning.
+---
+
+
+ A wrapper over the Popover API with anchor positioning.
+
+
+Pop-overs are powerful components with many use cases like edit menus,
+custom notifications, content pickers, or help dialogs.
+
+They can also be used for big hideable sidebars, like a shopping cart or action panels.
+Pop-overs are **always non-modal**. If you want to create a modal popoverover, a `Dialog`
+component is the way to go instead.
+
+
+
+A `Popover` starts hidden on page load by having `display:none` set on it (the Popover API does it automatically). To show/hide the popover, you need to add some control `PopButton`s.
+
+When a popover is shown, it has `display:none` removed from it and it is put into the top layer so, unlike just using `position: absolute`, it's guaranteed that it will sit on top of all other page content.
+
+
+## Anchor positioning
+
+By default, a popover appears centered in the layout view, but this component allows you to position it relative to an specific element in the page, using the `anchor` and `anchor-to` attributes.
+
+`anchor` is the ID of the element used as a reference, and `anchor-to` which side of the anchor to use: "top", "bottom", "right", or "left"; with an optional postfix of "start" or "end" ("center" is the default).
+
+
+
+
+
+The positioning is done every time the popover opens, but you can trigger the re-position, for example, on windows resizing, by calling the `jxui-popover/setPosition(popover)` function.
+
+
+## Styling states
+
+| CSS selector | Description
+| ------------------- | --------------
+| `[popover]` | Every popover has this attribute
+| `:popover-open` | This pseudo-class matches only popovers that are currently being shown
+| `::backdrop` | This pseudo-element is a full-screen element placed directly behind showing popover elements in the top layer, allowing effects to be added to the page content behind the popover(s) if desired. You might for example want to blur out the content behind the popover to help focus the user's attention on it
+
+
+## Closing modes
+
+A `Popover` can be of two types: "auto" or "manual". This is controlled by the `mode` argument.
+
+| Argument | Description
+| ------------------ | --------------
+| `mode="auto"` | The `Popover` will close automatically when the user clicks outside of it, or when presses the Escape key.
+| `mode="manual"` | The `Popover` will not close automatically. It will only close when the user clicks on a linked `PopButton` with `action="close"` or `action="toggle"`.
+
+If the `mode` argument is not set, it defaults to "auto".
+
+
+## `PopButton` actions
+
+A `PopButton` can have an `action` argument, which can be set to one of three values: "open", "close", or "toggle". This argument determines what happens to the target `Popover` when the button is clicked.
+
+| Argument | Description
+| ----------------- | --------------
+| `action="open"` | Opens the target `Popover`. If the `Popover` is already open, it has no effect.
+| `action="close"` | Closes the target `Popover`. If the `Popover` is already closed, it has no effect.
+| `action="toggle"` | This is the default action. It toggles the target `Pop – opening it if it's closed and closing it if it's open.
+
+
+## Animating popovers
+
+Popovers are set to `display:none;` when hidden and `display:block;` when shown, as well as being removed from / added to the [top layer](https://developer.mozilla.org/en-US/docs/Glossary/Top_layer). Therefore, for popovers to be animated, the `display` property [needs to be animatable].
+
+[Supporting browsers](https://developer.mozilla.org/en-US/docs/Web/CSS/display#browser_compatibility) animate `display` flipping between `none` and another value of `display` so that the animated content is shown for the entire animation duration. So, for example:
+
+- When animating `display` from `none` to `block` (or another visible `display` value), the value will flip to `block` at `0%` of the animation duration so it is visible throughout.
+- When animating `display` from `block` (or another visible `display` value) to `none`, the value will flip to `none` at `100%` of the animation duration so it is visible throughout.
+
+
+When animating using CSS transitions, `transition-behavior:allow-discrete` needs to be set to enable the above behavior. When animating with CSS animations, the above behavior is available by default; an equivalent step is not required.
+
+
+
+### Transitioning a popover
+
+When animating popovers with CSS transitions, the following features are required:
+
+- `@starting-style` at-rule
+
+ Provides a set of starting values for properties set on the popover that you want to transition from when it is first shown. This is needed to avoid unexpected behavior. By default, CSS transitions only occur when a property changes from one value to another on a visible element; they are not triggered on an element's first style update, or when the `display` type changes from `none` to another type.
+
+- `display` property
+
+ Add `display` to the transitions list so that the popover will remain as `display:block` (or another visible `display` value) for the duration of the transition, ensuring the other transitions are visible.
+
+- `overlay` property
+
+ Include `overlay` in the transitions list to ensure the removal of the popover from the top layer is deferred until the transition completes, again ensuring the transition is visible.
+
+- `transition-behavior` property
+
+ Set `transition-behavior:allow-discrete` on the `display` and `overlay` transitions (or on the `transition` shorthand) to enable discrete transitions on these two properties that are not by default animatable.
+
+For example, let's say the styles we want to transition are `opacity` and `transform`: we want the popover to fade in or out while moving down or up.
+
+To achieve this, we set a starting state for these properties on the hidden state of the popover element (selected with the `[popover]` attribute selector) and an end state for the shown state of the popover (selected via the `:popover-open` pseudo-class). We also use the `transition` property to define the properties to animate and the animation's duration as the popover gets shown or hidden:
+
+```css
+/*** Transition for the popover itself ***/
+[popover]:popover-open {
+ opacity: 1;
+ transform: scaleX(1);
+}
+[popover] {
+ transition: all 0.2s allow-discrete;
+ /* Final state of the exit animation */
+ opacity: 0;
+ transform: translateY(-3rem);
+}
+[popover]:popover-open {
+ opacity: 1;
+ transform: translateY(0);
+}
+/* Needs to be after the previous [popover]:popover-open rule
+to take effect, as the specificity is the same */
+@starting-style {
+ [popover]:popover-open {
+ opacity: 0;
+ transform: translateY(-3rem);
+ }
+}
+
+/*** Transition for the popover's backdrop ***/
+[popover]::backdrop {
+ /* Final state of the exit animation */
+ background-color: rgb(0 0 0 / 0%);
+ transition: all 0.2s allow-discrete;
+}
+[popover]:popover-open::backdrop {
+ background-color: rgb(0 0 0 / 15%);
+}
+@starting-style {
+ [popover]:popover-open::backdrop {
+ background-color: rgb(0 0 0 / 0%);
+ }
+}
+```
+
+You can see a working example of this in the demo [at the beginning of the page](#startpage).
+
+
+Because popovers change from display:none
to display:block
each time they are shown, the popover transitions from its @starting-style
styles to its [popover]:popover-open
styles every time the entry transition occurs. When the popover closes, it transitions from its [popover]:popover-open
state to the default [popover]
state.
+
+So it is possible for the style transition on entry and exit to be different.
+
+
+
+This section was adapted from [Animating popovers](https://developer.mozilla.org/en-US/docs/Web/API/Popover_API/Using#animating_popovers)
+by [Mozilla Contributors](https://developer.mozilla.org/en-US/docs/MDN/Community/Roles_teams#contributor), licensed under [CC-BY-SA 2.5](https://creativecommons.org/licenses/by-sa/2.5/).
+
+
+
+## Component arguments
+
+### PopButton
+
+| Argument | Type | Default | Description
+| --------------- | --------- | ---------- | --------------
+| `target` | `str` | | Required. The ID of the linked `Popover` component.
+| `action` | `str` | `"toggle"` | `"open"`, `"close"`, or `"toggle"`.
+| `tag` | `str` | `"button"` | HTML tag of the component.
+
+### Pop
+
+| Argument | Type | Default | Description
+| ------------ | ----- | -------- | --------------
+| `mode` | `str` | `"auto"` | `"auto"` or `"manual"`.
+| `anchor` | `str` | | ID of the element used as an anchor
+| `anchor-to` | `str` | | Which side/position of the anchor to use: "**top**", "**bottom**", "**right**", or "**left**"; with an optional postfix of "**start**", "**end**", "**center**".
+| `tag` | `str` | `"div"` | HTML tag of the component.
+
+
+## Accessibility notes
+
+### Mouse interaction
+
+- Clicking a `PopButton` will trigger the button action (open, close, or toggle state).
+
+- Clicking outside of a `Popover` will close *all* the `Popover` with `mode="auto"`.
+
+
+### Keyboard interaction
+
+- Pressing the Enter or Space keys on a `PopButton` will trigger
+the button action (open, close, or toggle state), and close *all* the `Popover` with `mode="auto"`.
+
+- Pressing the Escape key will close *all* the `Popover` with `mode="auto"`.
diff --git a/docs/content/ui/reldate.md b/docs/content/ui/reldate.md
new file mode 100644
index 0000000..e3624c8
--- /dev/null
+++ b/docs/content/ui/reldate.md
@@ -0,0 +1,58 @@
+---
+title: Relative date
+description: A component to convert datetimes to relative dates strings, such as "a minute ago", "in 2 hours", "yesterday", "3 months ago", etc. using JavaScript's Intl.RelativeTimeFormat API.
+---
+
+
+A component to convert datetimes to relative dates strings,
+such as "a minute ago", "in 2 hours", "yesterday", "3 months ago",
+etc. using JavaScript's Intl.RelativeTimeFormat API .
+
+
+*Some examples (as if the datetime was `June 20th, 2024 6:30pm`)*:
+
+| Source | Relative date
+| -----------------------------------------| --------------
+| ` ` | 6 months ago
+| ` ` | yesterday
+| ` ` | 5 hours ago
+| ` ` | in 19 hours
+| ` ` | next week
+| ` ` | 32 years ago
+
+
+## How it works
+
+The `RelDate` component is rendered as an empty `` tag and, when the page load, the datetime is rendered by JavaScript.
+
+There is also a `MutationObserver` in place to render the datetime on any `` inserted later to the page by JavaScript.
+
+
+## Localization
+
+The locale used for the localization of the dates is, in order of priority:
+
+1. The optional `lang` attribute of the component; or
+2. The `lang` attribute of the `` tag
+
+Both can be a comma-separated lists of locales (e.g.: `"en-US,en-UK,en`). If none of these attributes exists, or if the locales are not supported by the browser, it fallsback to the default browser language.
+
+*Some examples (as if the datetime was `June 20th, 2024 6:30pm`)*:
+
+| Source | Relative date
+| ---------------------------------------------------------------| --------------
+| ` ` | 6 mesi fa
+| ` ` | hier
+| ` ` | dentro de 19 horas
+| ` ` | dentro de 19 horas
+
+
+## Component arguments
+
+## RelDate
+
+| Argument | Type | Description
+| -----------| ----- | --------------
+| `datetime` | `str` | Required.
+| `lang` | `str` | Optional comma-separated list of locales to use for formatting. If not defined, the attribute `lang` of the `` tag will be used. If that is also not defined, or none of the locales are supported by the browser, the default browser language is used
+| `now` | `str` | Optional ISO-formatted date to use as the "present time". Useful for testing.
diff --git a/docs/content/ui/tabs.md b/docs/content/ui/tabs.md
new file mode 100644
index 0000000..094e271
--- /dev/null
+++ b/docs/content/ui/tabs.md
@@ -0,0 +1,162 @@
+---
+title: Tabs
+description: Easily create accessible, fully customizable tab interfaces, with robust focus management and keyboard navigation support.
+---
+
+
+ Easily create accessible, fully customizable tab interfaces, with robust focus management and keyboard navigation support.
+
+
+
+
+Tabs are built using the `TabGroup`, `TabList`, `Tab`, and `TabPanel` components. Clicking on any tab or selecting it with the keyboard will activate the corresponding panel.
+
+
+## Styling states
+
+| CSS selector | Description
+| --------------- | --------------
+| `.ui-hidden` | Added to all `TabPanel` except the one that is active.
+| `.ui-selected` | Added to the selected `Tab`.
+| `.ui-disabled` | Added to disabled `Tab`s.
+
+
+## Disabling a tab
+
+To disable a tab, use the disabled attribute on the `Tab` component. Disabled tabs cannot be selected with the mouse, and are also skipped when navigating the tab list using the keyboard.
+
+
+Disabling tabs might be confusing for users. Instead, I reccomend you either remove it or explain why there is no content for that tab when is selected.
+
+
+
+## Manually activating tabs
+
+By default, tabs are automatically selected as the user navigates through them using the arrow kbds.
+
+If you'd rather not change the current tab until the user presses Enter or Space , use the `manual` attribute on the `TabGroup` component.
+
+Remember to add styles to the `:focus` state of the tab so is clear to the user that the tab is focused.
+
+
+
+The manual prop has no impact on mouse interactions — tabs will still be selected as soon as they are clicked.
+
+
+## Vertical tabs
+
+If you've styled your `TabList` to appear vertically, use the `vertical` attribute to enable navigating with the ↑ and ↓ arrow kbds instead of ← and → , and to update the `aria-orientation` attribute for assistive technologies.
+
+
+
+
+## Controlling the tabs with a ``
+
+Sometimes, you want to display a `` element in addition to tabs. To do so, use the `TabSelect` and `TabOption` components.
+A `TabSelect` component is a wrapper for a `` element, and it accepts `TabOption` components as children.
+
+Note that a `TabSelect` **is not a replacement for a `TabList`**. For accessibility the `TabList` must be remain in your code, even if it's visually hidden.
+
+
+
+
+## Component arguments
+
+### TabGroup
+
+| Argument | Type | Default | Description
+| ----------- | -------- | ---------- | --------------
+| tag | `str` | `"div"` | HTML tag used for rendering the wrapper.
+
+### TabList
+
+| Argument | Type | Default | Description
+| ----------- | -------- | ---------- | --------------
+| vertical | `bool` | `false` | Use the ↑ and ↓ arrow kbds to move between tabs instead of the defaults ← and → arrow kbds.
+| manual | `bool` | `false` | If `true`, selecting a tab with the keyboard won't activate it, you must press Enter os Space kbds to do it.
+| tag | `str` | `"nav"` | HTML tag used for rendering the wrapper.
+
+
+### Tab
+
+| Argument | Type | Default | Description
+| ----------- | -------- | ---------- | --------------
+| target | `str` | | Required. HTML id of the panel associated with this tab.
+| selected | `bool` | `false` | Initially selected tab. Only one tab in the `TabList` can be selected at the time.
+| disabled | `bool` | `false` | If the tab can be selected.
+| tag | `str` | `"button"` | HTML tag used for rendering the tab.
+
+### TabPanel
+
+| Argument | Type | Default | Description
+| ----------- | -------- | ---------- | --------------
+| hidden | `bool` | `false` | Initially hidden panel.
+| tag | `bool` | `"div"` | HTML tag used for rendering the panel.
+
+
+### TabSelect
+
+No arguments.
+
+
+### TabOption
+
+| Argument | Type | Default | Description
+| ----------- | -------- | ---------- | --------------
+| target | `str` | | Required. HTML id of the panel associated with this tab.
+| disabled | `bool` | `false` | Display the option but not allow to select it.
+
+
+## Events
+
+A tab emits a `jxui:tab:selected` event every time is selected. The event contains the `target` property with the tag node.
+
+```js
+document.addEventListener("jxui:tab:selected", (event) => {
+ console.log(`'${event.target.textContent}' tab selected`);
+});
+```
+
+
+## Accessibility notes
+
+### Mouse interaction
+
+Clicking a `Tab` will select that tab and display the corresponding `TabPanel`.
+
+### Keyboard interaction
+
+All interactions apply when a `Tab` component is focused.
+
+| Command | Description
+| ------------------------------------------------------------------------------------- | -----------
+| ← / → arrow kbds | Selects the previous/next non-disabled tab, cycling from last to first and vice versa.
+| ↑ / ↓ arrow kbds when `vertical` is set | Selects the previous/next non-disabled tab, cycling from last to first and vice versa.
+| Enter or Space when `manual` is set | Activates the selected tab
+| Home or PageUp | Activates the **first** tab
+| End or PageDown | Activates the **last** tab
diff --git a/docs/deploy.sh b/docs/deploy.sh
new file mode 100755
index 0000000..9fe8897
--- /dev/null
+++ b/docs/deploy.sh
@@ -0,0 +1,4 @@
+#!/bin/bash
+python docs.py build
+ssh code 'rm -rf /var/www/jinjax/build'
+rsync --recursive --delete --progress build code:/var/www/jinjax/
diff --git a/docs/docs.py b/docs/docs.py
new file mode 100755
index 0000000..d49699f
--- /dev/null
+++ b/docs/docs.py
@@ -0,0 +1,72 @@
+#!/usr/bin/env python
+import logging
+from pathlib import Path
+
+import jinjax_ui
+from claydocs import Docs
+
+
+logging.getLogger("jinjax").setLevel(logging.INFO)
+logging.getLogger("jinjax").addHandler(logging.StreamHandler())
+
+here = Path(__file__).parent
+
+pages = [
+ "index.md",
+ [
+ "Guide",
+ [
+ "guide/index.md",
+ "guide/components.md",
+ "guide/slots.md",
+ "guide/css_and_js.md",
+ # "guide/integrations.md",
+ # "guide/performance.md",
+ "guide/motivation.md",
+ ],
+ ],
+ [
+ "API",
+ [
+ "api.md",
+ ],
+ ],
+ [
+ "UI components", [
+ "ui/index.md",
+ "ui/tabs.md",
+ "ui/popover.md",
+ "ui/menu.md",
+ "ui/accordion.md",
+ "ui/linkedlist.md",
+ "ui/reldate.md",
+ ],
+ ],
+]
+
+def get_docs() -> Docs:
+ root_path = here / "content"
+ docs = Docs(
+ pages,
+ content_folder=root_path,
+ add_ons=[jinjax_ui],
+ search=False,
+ cache=False,
+ domain="https://jinjax.scaletti.dev",
+ default_component="Page",
+ default_social="SocialCard",
+ metadata={
+ "name": "JinjaX",
+ "language": "en",
+ "license": "MIT",
+ "version": "0.43",
+ "web": "https://jinjax.scaletti.dev",
+ }
+ )
+ docs.add_folder(here / "components")
+ docs.add_folder(here / "theme")
+ return docs
+
+
+if __name__ == "__main__":
+ get_docs().run()
diff --git a/docs/indexer.js b/docs/indexer.js
new file mode 100644
index 0000000..637645b
--- /dev/null
+++ b/docs/indexer.js
@@ -0,0 +1,27 @@
+var lunr = require("lunr");
+require("lunr-languages/lunr.stemmer.support")(lunr);
+const fs = require("node:fs");
+
+function build_index([lang, outpath]) {
+ lang = lang || "en"
+ outpath = outpath || "."
+
+ if (lang !== "en") {
+ const lunr_lang = require(`lunr-languages/lunr.${lang}`)(lunr);
+ this.use(lunr_lang);
+ }
+
+ const idx = lunr(function() {
+ this.ref("id");
+ this.field("title", { boost: 10 });
+ this.field("body");
+ const docs = JSON.parse(fs.readFileSync(`${outpath}/docs-${lang}.json`));
+
+ for (let doc in docs) {
+ this.add(doc)
+ }
+ })
+ fs.writeFileSync(`${outpath}/search-${lang}.json`, JSON.stringify(idx));
+}
+
+build_index(process.argv.slice(2));
diff --git a/docs/static/docs.css b/docs/static/docs.css
new file mode 100644
index 0000000..30c9898
--- /dev/null
+++ b/docs/static/docs.css
@@ -0,0 +1,413 @@
+.bg-cover {
+ position: absolute;
+ z-index: -1;
+ inset: 0;
+}
+
+.Logo {
+ display: flex;
+ height: 2.5rem;
+ align-items: center;
+ color: rgb(24 24 27);
+ opacity: 0.9;
+
+ &:hover {
+ opacity: 1;
+ }
+ & img.light {
+ display: block;
+ }
+ & img.dark {
+ display: none;
+ }
+ &:is(.dark *) img.light {
+ display: none;
+ }
+ &:is(.dark *) img.dark {
+ display: block;
+ }
+}
+
+.NavLinks {
+ & a {
+ padding: 0.25rem;
+ font-size: 0.875rem;
+ line-height: 1.25rem;
+ color: rgb(82 82 91);
+ }
+ & a:hover {
+ color: rgb(24 24 27);
+ }
+
+ & a:is(.dark *) {
+ color: rgb(212 212 216);
+ }
+ & a:is(.dark *):hover {
+ color: rgb(255 255 255);
+ }
+}
+
+.homepage {
+ padding-top: 0;
+ padding-bottom: 0;
+ padding-left: var(--cd-padding-left);
+ padding-right: var(--cd-padding-right);
+}
+.homepage section.hero {
+ margin-left: auto;
+ margin-right: auto;
+ display: flex;
+ max-width: 56rem;
+ flex-direction: column;
+ padding-top: 2.25rem;
+ padding-bottom: 2.25rem;
+ color: rgb(23 23 23);
+
+ &:is(.dark *) {
+ color: rgb(245 245 245);
+ }
+
+ & h1 {
+ margin: 0 auto;
+ width: 300px;
+ height: 140px;
+ background-image: url("/static/img/jinjax-logo.svg");
+ background-position: center center;
+ background-repeat: no-repeat;
+ background-size: contain;
+ text-indent: -999px;
+ display: none;
+ }
+
+ & h2 {
+ font-size: 2.2rem;
+ font-weight: 600;
+ line-height: 1.2;
+ letter-spacing: -0.05em;
+ }
+ & h2 .g1 {
+ background-image: linear-gradient(to bottom right, #fbbf24, #fb923c);
+ background-clip: text;
+ color: transparent;
+ }
+
+ & h2 .g2 {
+ background-image: linear-gradient(to bottom right, #34d399, #3b82f6);
+ background-clip: text;
+ color: transparent;
+ }
+
+ @media (min-width: 768px) {
+ & {
+ padding-top: 2.5rem;
+ padding-bottom: 3rem;
+ }
+ & h1 {
+ display: block;
+ width: 300px;
+ height: 100px;
+ }
+ & h2 {
+ font-size: 2.4rem;
+ text-align: center;
+ }
+ & h2 .g2 {
+ white-space: nowrap;
+ }
+ }
+
+ @media (min-width: 1024px) {
+ & h1 {
+ width: 400px;
+ height: 140px;
+ }
+ & h2 {
+ font-size: 3rem;
+ }
+ }
+}
+
+.homepage section.code {
+ margin-left: -1rem;
+ margin-right: -1rem;
+ max-width: 72rem;
+ border-width: 1px;
+ border-color: rgb(212 212 212);
+ background-color: rgb(231 229 228);
+ padding: 1.5rem 0;
+
+ &:is(.dark *) {
+ border-color: rgb(82 82 82);
+ background-color: rgb(41 37 36);
+ }
+
+ & .panel {
+ display: flex;
+ flex-direction: column;
+ }
+ & .panel ~ .panel {
+ margin-top: 1.5rem;
+ }
+ & h2 {
+ margin-bottom: 0.5rem;
+ text-align: center;
+ font-size: 1.5rem;
+ line-height: 1.1;
+ font-weight: 700;
+ }
+ & .highlight {
+ flex-grow: 1;
+ }
+ & pre {
+ height: 100%;
+ }
+
+ @media (min-width: 1024px) {
+ & {
+ border-radius: 1rem;
+ padding: 1.5rem;
+ margin-bottom: 2.5rem;
+ margin-left: auto;
+ margin-right: auto;
+ }
+ & .stack {
+ display: flex;
+ align-items: stretch;
+ }
+ & .panel {
+ width: 50%;
+ }
+ & .panel ~ .panel {
+ margin-top: 0;
+ margin-left: 0.5rem;
+ }
+ }
+}
+
+.homepage section.features {
+ margin-left: auto;
+ margin-right: auto;
+ max-width: 56rem;
+ padding-top: 2rem;
+ padding-bottom: 2rem;
+
+ & h2 {
+ margin-bottom: 2rem;
+ text-align: center;
+ font-size: 2.2rem;
+ line-height: 1.2;
+ font-weight: 800;
+ }
+ & h2 code {
+ font-size: 0.9em;
+ }
+ & .cards {
+ margin-top: 2.5rem;
+ display: grid;
+ grid-template-columns: repeat(1, minmax(0, 1fr));
+ column-gap: 1rem;
+ row-gap: 1.5rem;
+ font-size: 1rem;
+ line-height: 1.4rem;
+ }
+ & .card {
+ margin-left: auto;
+ margin-right: auto;
+ display: flex;
+ flex-direction: column;
+ height: 9rem;
+ max-width: 28rem;
+ border-radius: 1rem;
+ border-width: 2px;
+ border-color: rgb(245 245 244);
+ background-color: rgb(250 250 249);
+ padding-top: 1rem;
+ padding-bottom: 1rem;
+ padding-left: 1.5rem;
+ padding-right: 1.5rem;
+ box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
+ }
+ & .card:is(.dark *) {
+ border-color: rgb(41 37 36);
+ background-color: rgb(41 37 36);
+ }
+ & .card > .header {
+ margin-bottom: 0.5rem;
+ display: flex;
+ align-items: center;
+ flex-direction: row-reverse;
+ }
+ & .card > .header img {
+ float: left;
+ max-height: 32px;
+ width: 2.5rem;
+ padding-right: 0.75rem;
+ }
+ & .card > .header img:is(.dark *) {
+ filter: invert(100%)
+ }
+ & .card > .header h3 {
+ font-size: 1.4rem;
+ font-weight: 600;
+ color: rgb(24 24 27);
+ }
+ & .card > .header h3:is(.dark *) {
+ color: rgb(228 228 231);
+ }
+ & .card > .body {
+ flex-grow: 1;
+ margin-top: 0.5rem;
+ font-size: 1rem;
+ line-height: 1.4;
+ color: rgb(82 82 91);
+ }
+ & .card a {
+ font-weight: 600;
+ }
+
+ @media (min-width: 768px) {
+ & .cards {
+ grid-template-columns: repeat(2, minmax(0, 1fr));
+ }
+ & .card {
+ height: 10rem;
+ }
+ }
+
+ @media (min-width: 1280px) {
+ & {
+ max-width: 1280px;
+ }
+ & .cards {
+ grid-template-columns: repeat(4, minmax(0, 1fr));
+ }
+ & .card {
+ height: 13rem;
+ align-items: flex-start;
+ padding-top: 1.5rem;
+ padding-bottom: 1.5rem;
+ }
+ }
+}
+
+.homepage section.spaghetti {
+ margin-bottom: 1.25rem;
+ padding-left: var(--cd-padding-left);
+ padding-right: var(--cd-padding-right);
+
+ & .wrapper {
+ margin-left: auto;
+ margin-right: auto;
+ max-width: 64rem;
+ padding-left: 0.75rem;
+ padding-right: 0.75rem;
+ padding-top: 2rem;
+ padding-bottom: 2rem;
+ }
+
+ & h2 {
+ margin-bottom: 2rem;
+ text-align: center;
+ font-size: 2.2rem;
+ line-height: 1.2;
+ font-weight: 800;
+ }
+
+ & .text {
+ position: relative;
+ font-size: 1.4rem;
+ line-height: 1.4;
+ }
+ & .text img {
+ position: absolute;
+ left: 0;
+ top: 0;
+ display: none;
+ height: 100%;
+ max-height: 24rem;
+ }
+ & .text p {
+ margin-bottom:1.5rem;
+ }
+
+ @media (min-width: 640px) {
+ & .wrapper {
+ padding-top: 3rem;
+ padding-bottom: 3rem;
+ }
+ }
+
+ @media (min-width: 1024px) {
+ & .wrapper {
+ max-width: 72rem;
+ }
+ & .text {
+ padding-left: 440px;
+ }
+ & .text img {
+ display: block;
+ }
+ }
+}
+
+.homepage section.engage {
+ background-image: linear-gradient(to bottom, #d6d3d1, #e7e5e4, #a8a29e);
+ margin-left: -1rem;
+ margin-right: -1rem;
+
+ &:is(.dark *) {
+ background-image: linear-gradient(to bottom, #000, #1c1917);
+ }
+
+ & .wrapper {
+ padding-top: 3rem;
+ padding-bottom: 3rem;
+ text-align: center;
+ }
+
+ & h3 {
+ margin-bottom: 2rem;
+ text-align: center;
+ font-size: 1.875rem;
+ line-height: 1.4;
+ font-weight: 800;
+ }
+
+ & a {
+ display: flex-inline;
+ align-items: center;
+ justify-content: center;
+ margin-left: auto;
+ margin-right: auto;
+ margin-bottom: 1.25rem;
+ display: inline-block;
+ -webkit-appearance: none;
+ -moz-appearance: none;
+ appearance: none;
+ border-radius: 1rem;
+ background-image: linear-gradient(to top right, #a3e635, #65a30d);
+ padding: 1rem 2rem;
+ text-align: center;
+ font-family: var(--cd-font-sans);
+ font-size: 1.25rem;
+ line-height: 1.75rem;
+ font-weight: 700;
+ color: rgb(39 39 42);
+ text-decoration-line: none;
+ box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
+ transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
+ }
+ & a:hover {
+ background-image: linear-gradient(to top right, #a3e635, #a3e635);
+ color: rgb(0 0 0);
+ }
+ & a i {
+ font-style: normal;
+ font-size: 1.2rem;
+ }
+
+ & .hint {
+ font-size: 0.75rem;
+ line-height: 1rem;
+ }
+}
\ No newline at end of file
diff --git a/docs/static/favicon.ico b/docs/static/favicon.ico
new file mode 100644
index 0000000..3615f29
Binary files /dev/null and b/docs/static/favicon.ico differ
diff --git a/docs/static/fonts/karla-bold-ext.woff2 b/docs/static/fonts/karla-bold-ext.woff2
new file mode 100644
index 0000000..88c185a
Binary files /dev/null and b/docs/static/fonts/karla-bold-ext.woff2 differ
diff --git a/docs/static/fonts/karla-bold.woff2 b/docs/static/fonts/karla-bold.woff2
new file mode 100644
index 0000000..244e69d
Binary files /dev/null and b/docs/static/fonts/karla-bold.woff2 differ
diff --git a/docs/static/fonts/karla-regular-.woff2 b/docs/static/fonts/karla-regular-.woff2
new file mode 100644
index 0000000..244e69d
Binary files /dev/null and b/docs/static/fonts/karla-regular-.woff2 differ
diff --git a/docs/static/fonts/karla-regular-ext.woff2 b/docs/static/fonts/karla-regular-ext.woff2
new file mode 100644
index 0000000..88c185a
Binary files /dev/null and b/docs/static/fonts/karla-regular-ext.woff2 differ
diff --git a/docs/static/fonts/material-symbols-rounded.woff2 b/docs/static/fonts/material-symbols-rounded.woff2
new file mode 100644
index 0000000..0200f5e
Binary files /dev/null and b/docs/static/fonts/material-symbols-rounded.woff2 differ
diff --git a/docs/static/img/anatomy-en.png b/docs/static/img/anatomy-en.png
new file mode 100644
index 0000000..d880437
Binary files /dev/null and b/docs/static/img/anatomy-en.png differ
diff --git a/docs/static/img/anatomy-en.svg b/docs/static/img/anatomy-en.svg
new file mode 100644
index 0000000..bacfb60
--- /dev/null
+++ b/docs/static/img/anatomy-en.svg
@@ -0,0 +1,347 @@
+
+
+
+
+
+
+
+
+
+
+ components/Form.jinja {#def action, label, method="post" #} {#css form.css, /static/theme.css #} {#js form.js #} {% set method = method.lower() %} < form method= " {{ method }} " action= " {{ action }} " {{ attrs.render(class="form" ) }} > {% if method == "post" -%} <input type="hidden" name="csrf" value="{{token}} " /> {% endif -%} {{ content }} <Button :label="label" /> </form >
+
+
+
+
+
+
+
+ Everything before the first dot is the component name
+ Arguments definition
+ Arguments without a default value are required
+ Optional lists of CSS and JS files
+ Paths are absolute or relative to the root of
+ the components folder
+ You can have more than one parent element, unlike React
+ You can call any other component and pass attributes to them
+
diff --git a/docs/static/img/anatomy-es.svg b/docs/static/img/anatomy-es.svg
new file mode 100644
index 0000000..a3b3952
--- /dev/null
+++ b/docs/static/img/anatomy-es.svg
@@ -0,0 +1,288 @@
+
+
+
+
+
+
+
+
+
+
+ components/Form.jinja {#def action, label, method="post" #} {#css form.css %} {#js form.js %} {% set method = method.lower() %} < form method= " {{ method }} " action= " {{ action }} " {{ attrs.render(class="form" ) }}
+ > {% if method == "post" -%}
+ <input type="hidden" name="csrf" value="{{token}} " /> {% endif -%} {{ content }}
+ <Button label= {label} >
+ </form >
+
+
+
+
+
+
+
+ Todo antes del primer punto es el nombre del componente
+ Definición de argumentos
+ Los argumentos sin valores predefinidos son obligatorios
+ Listas opcionales de archivos CSS y JS
+ Las rutas son relativas al folder de componentes
+ Puedes tener mas de un elemento padre, a diferencia de React
+ Puedes llamar a cualquier otro componente
+
diff --git a/docs/static/img/anchors.png b/docs/static/img/anchors.png
new file mode 100644
index 0000000..ba74fe5
Binary files /dev/null and b/docs/static/img/anchors.png differ
diff --git a/docs/static/img/apple-touch-icon.png b/docs/static/img/apple-touch-icon.png
new file mode 100644
index 0000000..aa04ca4
Binary files /dev/null and b/docs/static/img/apple-touch-icon.png differ
diff --git a/docs/static/img/composable.svg b/docs/static/img/composable.svg
new file mode 100644
index 0000000..c54628c
--- /dev/null
+++ b/docs/static/img/composable.svg
@@ -0,0 +1,3 @@
+
+
+
diff --git a/docs/static/img/encapsulated.svg b/docs/static/img/encapsulated.svg
new file mode 100644
index 0000000..afb9119
--- /dev/null
+++ b/docs/static/img/encapsulated.svg
@@ -0,0 +1,3 @@
+
+
+
diff --git a/docs/static/img/favicon.png b/docs/static/img/favicon.png
new file mode 100644
index 0000000..9b6ccd2
Binary files /dev/null and b/docs/static/img/favicon.png differ
diff --git a/docs/static/img/favicon.svg b/docs/static/img/favicon.svg
new file mode 100644
index 0000000..d243cf2
--- /dev/null
+++ b/docs/static/img/favicon.svg
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/docs/static/img/jinjax-logo-w.png b/docs/static/img/jinjax-logo-w.png
new file mode 100644
index 0000000..74f52c3
Binary files /dev/null and b/docs/static/img/jinjax-logo-w.png differ
diff --git a/docs/static/img/jinjax-logo-w.svg b/docs/static/img/jinjax-logo-w.svg
new file mode 100644
index 0000000..0b8c9bf
--- /dev/null
+++ b/docs/static/img/jinjax-logo-w.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/docs/static/img/jinjax-logo.png b/docs/static/img/jinjax-logo.png
new file mode 100644
index 0000000..941df9f
Binary files /dev/null and b/docs/static/img/jinjax-logo.png differ
diff --git a/docs/static/img/jinjax-logo.svg b/docs/static/img/jinjax-logo.svg
new file mode 100644
index 0000000..4870abb
--- /dev/null
+++ b/docs/static/img/jinjax-logo.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/docs/static/img/logo.png b/docs/static/img/logo.png
new file mode 100644
index 0000000..4b12c00
Binary files /dev/null and b/docs/static/img/logo.png differ
diff --git a/docs/static/img/logo.svg b/docs/static/img/logo.svg
new file mode 100644
index 0000000..ed5ce3f
--- /dev/null
+++ b/docs/static/img/logo.svg
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/docs/static/img/modern.svg b/docs/static/img/modern.svg
new file mode 100644
index 0000000..e986962
--- /dev/null
+++ b/docs/static/img/modern.svg
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
diff --git a/docs/static/img/practical.svg b/docs/static/img/practical.svg
new file mode 100644
index 0000000..702446c
--- /dev/null
+++ b/docs/static/img/practical.svg
@@ -0,0 +1,3 @@
+
+
+
diff --git a/docs/static/img/simple.svg b/docs/static/img/simple.svg
new file mode 100644
index 0000000..b69150b
--- /dev/null
+++ b/docs/static/img/simple.svg
@@ -0,0 +1,3 @@
+
+
+
diff --git a/docs/static/img/slots-_slot.png b/docs/static/img/slots-_slot.png
new file mode 100644
index 0000000..93cbab3
Binary files /dev/null and b/docs/static/img/slots-_slot.png differ
diff --git a/docs/static/img/slots-diagram.png b/docs/static/img/slots-diagram.png
new file mode 100644
index 0000000..c085250
Binary files /dev/null and b/docs/static/img/slots-diagram.png differ
diff --git a/docs/static/img/spaghetti_code.png b/docs/static/img/spaghetti_code.png
new file mode 100644
index 0000000..df44455
Binary files /dev/null and b/docs/static/img/spaghetti_code.png differ
diff --git a/docs/static/img/ui-accordion.png b/docs/static/img/ui-accordion.png
new file mode 100644
index 0000000..adddd7b
Binary files /dev/null and b/docs/static/img/ui-accordion.png differ
diff --git a/docs/static/img/ui-linkedlist.png b/docs/static/img/ui-linkedlist.png
new file mode 100644
index 0000000..87667ba
Binary files /dev/null and b/docs/static/img/ui-linkedlist.png differ
diff --git a/docs/static/img/ui-menu.png b/docs/static/img/ui-menu.png
new file mode 100644
index 0000000..ee82e03
Binary files /dev/null and b/docs/static/img/ui-menu.png differ
diff --git a/docs/static/img/ui-popover.png b/docs/static/img/ui-popover.png
new file mode 100644
index 0000000..22507f5
Binary files /dev/null and b/docs/static/img/ui-popover.png differ
diff --git a/docs/static/img/ui-reldate.png b/docs/static/img/ui-reldate.png
new file mode 100644
index 0000000..e2258c5
Binary files /dev/null and b/docs/static/img/ui-reldate.png differ
diff --git a/docs/static/img/ui-tabs.png b/docs/static/img/ui-tabs.png
new file mode 100644
index 0000000..7b3bccd
Binary files /dev/null and b/docs/static/img/ui-tabs.png differ
diff --git a/docs/static/prose.css b/docs/static/prose.css
new file mode 100644
index 0000000..9a6531d
--- /dev/null
+++ b/docs/static/prose.css
@@ -0,0 +1,637 @@
+.prose {
+ --cd-prose-body: #3f3f46;
+ --cd-prose-headings: #18181b;
+ --cd-prose-lead: #52525b;
+ --cd-prose-links: #18181b;
+ --cd-prose-bold: #18181b;
+ --cd-prose-counters: #71717a;
+ --cd-prose-bullets: #d4d4d8;
+ --cd-prose-hr: #e4e4e7;
+ --cd-prose-quotes: #18181b;
+ --cd-prose-quote-borders: #e4e4e7;
+ --cd-prose-captions: #71717a;
+ --cd-prose-code: #18181b;
+ --cd-prose-pre-code: rgb(238 238 238);
+ --cd-prose-pre-border: rgb(51, 51, 51);
+ --cd-prose-pre-bg: rgb(24 24 24);
+ --cd-prose-th-borders: #ddd;
+ --cd-prose-td-borders: #eee;
+ --cd-prose-bg-hover: rgba(0,0,0,0.035);
+
+ --cd-prose-invert-body: #d4d4d8;
+ --cd-prose-invert-headings: #fff;
+ --cd-prose-invert-lead: #a1a1aa;
+ --cd-prose-invert-links: #fff;
+ --cd-prose-invert-bold: #fff;
+ --cd-prose-invert-counters: #a1a1aa;
+ --cd-prose-invert-bullets: #52525b;
+ --cd-prose-invert-hr: #3f3f46;
+ --cd-prose-invert-quotes: #f4f4f5;
+ --cd-prose-invert-quote-borders: #3f3f46;
+ --cd-prose-invert-captions: #a1a1aa;
+ --cd-prose-invert-code: #fff;
+ --cd-prose-invert-pre-code: rgb(238 238 238);
+ --cd-prose-invert-pre-border: rgb(51, 51, 51);
+ --cd-prose-invert-pre-bg: rgb(24 24 24);
+ --cd-prose-invert-th-borders: #52525b;
+ --cd-prose-invert-td-borders: #3f3f46;
+ --cd-prose-invert-bg-hover: rgba(0,0,0,0.035);
+}
+
+.dark .prose {
+ --cd-prose-body: var(--cd-prose-invert-body);
+ --cd-prose-headings: var(--cd-prose-invert-headings);
+ --cd-prose-lead: var(--cd-prose-invert-lead);
+ --cd-prose-links: var(--cd-prose-invert-links);
+ --cd-prose-bold: var(--cd-prose-invert-bold);
+ --cd-prose-counters: var(--cd-prose-invert-counters);
+ --cd-prose-bullets: var(--cd-prose-invert-bullets);
+ --cd-prose-hr: var(--cd-prose-invert-hr);
+ --cd-prose-quotes: var(--cd-prose-invert-quotes);
+ --cd-prose-quote-borders: var(--cd-prose-invert-quote-borders);
+ --cd-prose-captions: var(--cd-prose-invert-captions);
+ --cd-prose-code: var(--cd-prose-invert-code);
+ --cd-prose-pre-code: var(--cd-prose-invert-pre-code);
+ --cd-prose-pre-border: var(--cd-prose-invert-pre-border);
+ --cd-prose-pre-bg: var(--cd-prose-invert-pre-bg);
+ --cd-prose-th-borders: var(--cd-prose-invert-th-borders);
+ --cd-prose-td-borders: var(--cd-prose-invert-td-borders);
+ --cd-prose-bg-hover: var(--cd-prose-invert-bg-hover);
+}
+
+.prose {
+ font-size: 1em;
+ line-height: 1.75;
+ color: var(--cd-prose-body);
+}
+
+.prose h1:not(:where([class~="not-prose"] *)) ,
+.prose h2:not(:where([class~="not-prose"] *)) ,
+.prose h3:not(:where([class~="not-prose"] *)) ,
+.prose h4:not(:where([class~="not-prose"] *)) ,
+.prose h5:not(:where([class~="not-prose"] *)) ,
+.prose h6:not(:where([class~="not-prose"] *)) {
+ font-family: var(--cd-font-serif);
+}
+
+.prose :where(p):not(:where([class~="not-prose"] *)) {
+ margin-top: 1.25em;
+ margin-bottom: 1.25em;
+}
+
+.prose :where([class~="lead"]):not(:where([class~="not-prose"] *)) {
+ color: var(--cd-prose-lead);
+ font-size: 1.25em;
+ line-height: 1.6;
+ margin-top: 1.2em;
+ margin-bottom: 1.2em;
+}
+
+.prose :where(a):not(:where([class~="not-prose"] *)) {
+ color: var(--cd-prose-links);
+ text-decoration: underline;
+ font-weight: 500;
+}
+
+.prose :where(strong):not(:where([class~="not-prose"] *)) {
+ color: var(--cd-prose-bold);
+ font-weight: 600;
+}
+
+.prose :where(a strong):not(:where([class~="not-prose"] *)) {
+ color: inherit;
+}
+
+.prose :where(blockquote strong):not(:where([class~="not-prose"] *)) {
+ color: inherit;
+}
+
+.prose :where(thead th strong):not(:where([class~="not-prose"] *)) {
+ color: inherit;
+}
+
+.prose :where(ol):not(:where([class~="not-prose"] *)) {
+ list-style-type: decimal;
+ margin-top: 1.25em;
+ margin-bottom: 1.25em;
+ padding-left: 1.625em;
+}
+
+.prose :where(ol[type="A"]):not(:where([class~="not-prose"] *)) {
+ list-style-type: upper-alpha;
+}
+
+.prose :where(ol[type="a"]):not(:where([class~="not-prose"] *)) {
+ list-style-type: lower-alpha;
+}
+
+.prose :where(ol[type="A" s]):not(:where([class~="not-prose"] *)) {
+ list-style-type: upper-alpha;
+}
+
+.prose :where(ol[type="a" s]):not(:where([class~="not-prose"] *)) {
+ list-style-type: lower-alpha;
+}
+
+.prose :where(ol[type="I"]):not(:where([class~="not-prose"] *)) {
+ list-style-type: upper-roman;
+}
+
+.prose :where(ol[type="i"]):not(:where([class~="not-prose"] *)) {
+ list-style-type: lower-roman;
+}
+
+.prose :where(ol[type="I" s]):not(:where([class~="not-prose"] *)) {
+ list-style-type: upper-roman;
+}
+
+.prose :where(ol[type="i" s]):not(:where([class~="not-prose"] *)) {
+ list-style-type: lower-roman;
+}
+
+.prose :where(ol[type="1"]):not(:where([class~="not-prose"] *)) {
+ list-style-type: decimal;
+}
+
+.prose :where(ul):not(:where([class~="not-prose"] *)) {
+ list-style-type: disc;
+ margin-top: 1.25em;
+ margin-bottom: 1.25em;
+ padding-left: 1.625em;
+}
+
+.prose :where(ol > li):not(:where([class~="not-prose"] *))::marker {
+ font-weight: 400;
+ color: var(--cd-prose-counters);
+}
+
+.prose :where(ul > li):not(:where([class~="not-prose"] *))::marker {
+ color: var(--cd-prose-bullets);
+}
+
+.prose :where(hr):not(:where([class~="not-prose"] *)) {
+ border-color: var(--cd-prose-hr);
+ border-top-width: 1px;
+ margin-top: 3em;
+ margin-bottom: 3em;
+}
+
+.prose :where(blockquote):not(:where([class~="not-prose"] *)) {
+ font-weight: 500;
+ font-style: italic;
+ color: var(--cd-prose-quotes);
+ border-left-width: 0.25em;
+ border-left-color: var(--cd-prose-quote-borders);
+ quotes: "\201C""\201D""\2018""\2019";
+ margin-top: 1.6em;
+ margin-bottom: 1.6em;
+ padding-left: 1em;
+}
+
+.prose :where(blockquote p:first-of-type):not(:where([class~="not-prose"] *))::before {
+ content: open-quote;
+}
+
+.prose :where(blockquote p:last-of-type):not(:where([class~="not-prose"] *))::after {
+ content: close-quote;
+}
+
+.prose :where(h1):not(:where([class~="not-prose"] *)) {
+ color: var(--cd-prose-headings);
+ font-weight: 800;
+ font-size: 2.2rem;
+ margin-top: 0;
+ margin-bottom: 0.8888889em;
+ line-height: 1.1111111;
+}
+
+.prose :where(h1 strong):not(:where([class~="not-prose"] *)) {
+ font-weight: 900;
+ color: inherit;
+}
+
+.prose :where(h2):not(:where([class~="not-prose"] *)) {
+ color: var(--cd-prose-headings);
+ font-weight: 700;
+ font-size: 1.8em;
+ margin-top: 1.2em;
+ margin-bottom: 0.5em;
+ line-height: 1.3333333;
+}
+
+.prose :where(h2 strong):not(:where([class~="not-prose"] *)) {
+ font-weight: 800;
+ color: inherit;
+}
+
+.prose :where(h3):not(:where([class~="not-prose"] *)) {
+ color: var(--cd-prose-headings);
+ font-weight: 600;
+ font-size: 1.4em;
+ margin-top: 1.6em;
+ margin-bottom: 0.4em;
+ line-height: 1.6;
+}
+
+.prose :where(h3 strong):not(:where([class~="not-prose"] *)) {
+ font-weight: 700;
+ color: inherit;
+}
+
+.prose :where(h4):not(:where([class~="not-prose"] *)) {
+ color: var(--cd-prose-headings);
+ font-weight: 600;
+ font-size: 1.2em;
+ margin-top: 1.5em;
+ margin-bottom: 0.5em;
+ line-height: 1.5;
+}
+
+.prose :where(h4 strong):not(:where([class~="not-prose"] *)) {
+ font-weight: 700;
+ color: inherit;
+}
+
+.prose :where(h5):not(:where([class~="not-prose"] *)) {
+ color: var(--cd-prose-headings);
+ font-weight: 600;
+ font-size: 1em;
+ margin-top: 1em;
+ margin-bottom: 0.5em;
+ line-height: 1.5;
+}
+
+
+.prose :where(h6):not(:where([class~="not-prose"] *)) {
+ color: var(--cd-prose-headings);
+ font-weight: 600;
+ font-size: 1em;
+ margin-top: 1em;
+ margin-bottom: 0.5em;
+ line-height: 1.4;
+}
+
+
+.prose :where(img):not(:where([class~="not-prose"] *)) {
+ margin-top: 2em;
+ margin-bottom: 2em;
+}
+
+.prose :where(figure > *):not(:where([class~="not-prose"] *)) {
+ margin-top: 0;
+ margin-bottom: 0;
+}
+
+.prose :where(figcaption):not(:where([class~="not-prose"] *)) {
+ color: var(--cd-prose-captions);
+ font-size: 0.875em;
+ line-height: 1.4285714;
+ margin-top: 0.8571429em;
+}
+
+.prose :where(code):not(:where([class~="not-prose"] *)) {
+ color: var(--cd-prose-code);
+ font-size: 0.98em;
+ letter-spacing: -0.02em;
+}
+.prose :where(code):not(:where(pre code)):not(:where([class~="not-prose"] *)) {
+ padding: 0.1em;
+ background: var(--cd-bg-color-hover);
+}
+
+.prose :where(a code):not(:where([class~="not-prose"] *)) {
+ color: inherit;
+}
+
+.prose :where(h1 code):not(:where([class~="not-prose"] *)) {
+ color: inherit;
+}
+
+.prose :where(h2 code):not(:where([class~="not-prose"] *)) {
+ color: inherit;
+ font-size: 0.875em;
+}
+
+.prose :where(h3 code):not(:where([class~="not-prose"] *)) {
+ color: inherit;
+ font-size: 0.9em;
+}
+
+.prose :where(h4 code):not(:where([class~="not-prose"] *)) {
+ color: inherit;
+}
+
+.prose :where(blockquote code):not(:where([class~="not-prose"] *)) {
+ color: inherit;
+}
+
+.prose :where(thead th code):not(:where([class~="not-prose"] *)) {
+ color: inherit;
+}
+
+.prose :where(table):not(:where([class~="not-prose"] *)) {
+ width: 100%;
+ table-layout: auto;
+ text-align: left;
+ margin-top: 2em;
+ margin-bottom: 2em;
+ font-size: 0.875em;
+ line-height: 1.7142857;
+ border-width: 1px;
+ border-color: var(--cd-prose-td-borders);
+}
+
+.prose :where(thead):not(:where([class~="not-prose"] *)) {
+ border-bottom-width: 1px;
+ border-bottom-color: var(--cd-prose-th-borders);
+}
+
+.prose :where(thead th):not(:where([class~="not-prose"] *)) {
+ color: var(--cd-prose-headings);
+ font-weight: 600;
+ vertical-align: bottom;
+ border-left-width: 1px;
+ border-left-color: var(--cd-prose-th-borders);
+ /* text-transform: uppercase; */
+}
+.prose :where(thead th:first-child):not(:where([class~="not-prose"] *)) {
+ border-left-width: 0;
+}
+
+.prose :where(tbody tr):not(:where([class~="not-prose"] *)) {
+ border-bottom-width: 1px;
+ border-bottom-color: var(--cd-prose-td-borders);
+ transition: background-color 125ms;
+}
+.prose :where(tbody tr:hover):not(:where([class~="not-prose"] *)) {
+ background-color: var(--cd-prose-bg-hover);
+}
+
+.prose :where(tbody tr:last-child):not(:where([class~="not-prose"] *)) {
+ border-bottom-width: 0;
+}
+
+.prose :where(tbody td):not(:where([class~="not-prose"] *)) {
+ vertical-align: baseline;
+ border-left-width: 1px;
+ border-left-color: var(--cd-prose-th-borders);
+}
+.prose :where(tbody td:first-child):not(:where([class~="not-prose"] *)) {
+ border-left-width: 0;
+}
+.prose :where(tbody td p:first-child):not(:where([class~="not-prose"] *)) {
+ margin-top: 0;
+}
+
+.prose :where(tfoot):not(:where([class~="not-prose"] *)) {
+ border-top-width: 1px;
+ border-top-color: var(--cd-prose-th-borders);
+}
+
+.prose :where(tfoot td):not(:where([class~="not-prose"] *)) {
+ vertical-align: top;
+}
+
+.prose :where(th, td):not(:where([class~="not-prose"] *)) {
+ padding: 0.5rem 1rem;
+}
+
+.prose :where(video):not(:where([class~="not-prose"] *)) {
+ margin-top: 2em;
+ margin-bottom: 2em;
+}
+
+.prose :where(figure):not(:where([class~="not-prose"] *)) {
+ margin-top: 2em;
+ margin-bottom: 2em;
+}
+
+.prose :where(li):not(:where([class~="not-prose"] *)) {
+ margin-top: 0.5em;
+ margin-bottom: 0.5em;
+}
+
+.prose :where(ol > li):not(:where([class~="not-prose"] *)) {
+ padding-left: 0.375em;
+}
+
+.prose :where(ul > li):not(:where([class~="not-prose"] *)) {
+ padding-left: 0.375em;
+}
+
+.prose :where(.prose > ul > li p):not(:where([class~="not-prose"] *)) {
+ margin-top: 0.75em;
+ margin-bottom: 0.75em;
+}
+
+.prose :where(.prose > ul > li > *:first-child):not(:where([class~="not-prose"] *)) {
+ margin-top: 1.25em;
+}
+
+.prose :where(.prose > ul > li > *:last-child):not(:where([class~="not-prose"] *)) {
+ margin-bottom: 1.25em;
+}
+
+.prose :where(.prose > ol > li > *:first-child):not(:where([class~="not-prose"] *)) {
+ margin-top: 1.25em;
+}
+
+.prose :where(.prose > ol > li > *:last-child):not(:where([class~="not-prose"] *)) {
+ margin-bottom: 1.25em;
+}
+
+.prose :where(ul ul, ul ol, ol ul, ol ol):not(:where([class~="not-prose"] *)) {
+ margin-top: 0.75em;
+ margin-bottom: 0.75em;
+}
+
+.prose :where(hr + *):not(:where([class~="not-prose"] *)) {
+ margin-top: 0;
+}
+
+.prose :where(h2 + *):not(:where([class~="not-prose"] *)) {
+ margin-top: 0;
+}
+
+.prose :where(h3 + *):not(:where([class~="not-prose"] *)) {
+ margin-top: 0;
+}
+
+.prose :where(h4 + *):not(:where([class~="not-prose"] *)) {
+ margin-top: 0;
+}
+
+.prose :where(.prose > :first-child):not(:where([class~="not-prose"] *)) {
+ margin-top: 0;
+}
+
+.prose :where(.prose > :last-child):not(:where([class~="not-prose"] *)) {
+ margin-bottom: 0;
+}
+
+.prose :where(.task-list .task-list):not(:where([class~="not-prose"] *)) {
+ padding-left: 1em;
+}
+
+.prose :where(dl):not(:where([class~="not-prose"] *)) {
+ margin-top: 1.25em;
+ margin-bottom: 1.25em;
+}
+
+.prose :where(dt):not(:where([class~="not-prose"] *)) {
+ font-weight: bold;
+}
+
+.prose :where(dd):not(:where([class~="not-prose"] *)) {
+ padding-left: 1em;
+}
+
+pre {
+ border: 1px solid rgb(var(--cd-prose-pre-border));
+ overflow-x: auto;
+ font-weight: 400;
+ font-feature-settings: "kern";
+ white-space: pre;
+ scrollbar-width: thin;
+ padding: 1.25rem 1.5rem;
+}
+pre::-webkit-scrollbar {
+ width: 2px;
+ background-color: ButtonFace;
+}
+pre:has([data-linenos]) {
+ padding-left: 0;
+}
+pre code {
+ background-color: transparent;
+ border-width: 0;
+ border-radius: 0;
+ padding: 0;
+ font-weight: inherit;
+ color: inherit;
+ font-size: inherit;
+ font-family: inherit;
+ line-height: inherit;
+
+}
+pre a {
+ text-decoration: none;
+}
+
+.highlight {
+ margin-top: 0.5rem;
+ margin-bottom: 1rem;
+ border-radius: 6px;
+}
+.highlight:has(> .filename) {
+ background-color: rgb(249 250 251);
+ border: 1px solid rgb(153, 153, 153);
+}
+.highlight:is(.dark *):has(> .filename) {
+ background-color: rgb(55 65 81);
+ border-color: rgb(75 85 99);
+}
+.highlight > .filename {
+ border-radius: 6px 0 0 0;
+ display: inline-block;
+ border-right: 1px solid rgb(153, 153, 153);
+ background-color: #e7e9ed;
+ padding: 0.5rem;
+ color: #333;
+ font-weight: 500;
+ font-size: 0.9em;
+}
+.highlight:is(.dark *) > .filename {
+ border-color: rgb(75 85 99);
+ background-color: #111;
+ color: rgb(255 255 255);
+}
+.highlight pre {
+ background-color: rgba(0, 0, 0, 0.9);
+ border-radius: 6px;
+ font-size: 0.98rem;
+ line-height: 1.4;
+}
+.highlight .filename + pre {
+ border-radius: 0 0 6px 6px;
+}
+.highlight pre code { color: white; }
+
+.highlight pre code [data-linenos]:before {
+ content: attr(data-linenos);
+ display: inline-block;
+ width: 3rem;
+ text-align: right;
+ padding-right: 1rem;
+ white-space: nowrap;
+ color: rgb(82 82 91);
+ font-size: 0.75rem;
+}
+.highlight .hll {
+ background-color: #333;
+ display: block;
+}
+
+.highlight .c { color: hsl(31, 76%, 64%) } /* Comment */
+.highlight .err { color: #960050; background-color: #1e0010 } /* Error */
+.highlight .k { color: #66d9ef } /* Keyword */
+.highlight .l { color: #ae81ff } /* Literal */
+.highlight .n { color: #f8f8f2 } /* Name */
+.highlight .o { color: #f92672 } /* Operator */
+.highlight .p { color: #f8f8f2 } /* Punctuation */
+.highlight .cm { color: hsl(30, 20%, 50%) } /* Comment.Multiline */
+.highlight .cp { color: hsl(30, 20%, 50%) } /* Comment.Preproc */
+.highlight .c1 { color: hsl(30, 20%, 50%) } /* Comment.Single */
+.highlight .cs { color: hsl(30, 20%, 50%) } /* Comment.Special */
+.highlight .ge { font-style: italic } /* Generic.Emph */
+.highlight .gs { font-weight: bold } /* Generic.Strong */
+.highlight .kc { color: #66d9ef } /* Keyword.Constant */
+.highlight .kd { color: #66d9ef } /* Keyword.Declaration */
+.highlight .kn { color: #f92672 } /* Keyword.Namespace */
+.highlight .kp { color: #66d9ef } /* Keyword.Pseudo */
+.highlight .kr { color: #66d9ef } /* Keyword.Reserved */
+.highlight .kt { color: #66d9ef } /* Keyword.Type */
+.highlight .ld { color: #e6db74 } /* Literal.Date */
+.highlight .m { color: #ae81ff } /* Literal.Number */
+.highlight .s { color: #e6db74 } /* Literal.String */
+.highlight .na { color: #a6e22e } /* Name.Attribute */
+.highlight .nb { color: #f8f8f2 } /* Name.Builtin */
+.highlight .nc { color: #a6e22e } /* Name.Class */
+.highlight .no { color: #66d9ef } /* Name.Constant */
+.highlight .nd { color: #a6e22e } /* Name.Decorator */
+.highlight .ni { color: #f8f8f2 } /* Name.Entity */
+.highlight .ne { color: #a6e22e } /* Name.Exception */
+.highlight .nf { color: #a6e22e } /* Name.Function */
+.highlight .nl { color: #f8f8f2 } /* Name.Label */
+.highlight .nn { color: #f8f8f2 } /* Name.Namespace */
+.highlight .nx { color: #a6e22e } /* Name.Other */
+.highlight .py { color: #f8f8f2 } /* Name.Property */
+.highlight .nt { color: #f92672 } /* Name.Tag */
+.highlight .nv { color: #f8f8f2 } /* Name.Variable */
+.highlight .ow { color: #f92672 } /* Operator.Word */
+.highlight .w { color: #f8f8f2 } /* Text.Whitespace */
+.highlight .mf { color: #ae81ff } /* Literal.Number.Float */
+.highlight .mh { color: #ae81ff } /* Literal.Number.Hex */
+.highlight .mi { color: #ae81ff } /* Literal.Number.Integer */
+.highlight .mo { color: #ae81ff } /* Literal.Number.Oct */
+.highlight .sb { color: #e6db74 } /* Literal.String.Backtick */
+.highlight .sc { color: #e6db74 } /* Literal.String.Char */
+.highlight .sd { color: #e6db74 } /* Literal.String.Doc */
+.highlight .s2 { color: #e6db74 } /* Literal.String.Double */
+.highlight .se { color: #ae81ff } /* Literal.String.Escape */
+.highlight .sh { color: #e6db74 } /* Literal.String.Heredoc */
+.highlight .si { color: #e6db74 } /* Literal.String.Interpol */
+.highlight .sx { color: #e6db74 } /* Literal.String.Other */
+.highlight .sr { color: #e6db74 } /* Literal.String.Regex */
+.highlight .s1 { color: #e6db74 } /* Literal.String.Single */
+.highlight .ss { color: #e6db74 } /* Literal.String.Symbol */
+.highlight .bp { color: #f8f8f2 } /* Name.Builtin.Pseudo */
+.highlight .vc { color: #f8f8f2 } /* Name.Variable.Class */
+.highlight .vg { color: #f8f8f2 } /* Name.Variable.Global */
+.highlight .vi { color: #f8f8f2 } /* Name.Variable.Instance */
+.highlight .il { color: #ae81ff } /* Literal.Number.Integer.Long */
+
+.highlight .gh { } /* Generic Heading & Diff Header */
+.highlight .gu { color: hsl(30, 20%, 50%); } /* Generic.Subheading & Diff Unified/Comment? */
+.highlight .gd { color: #f92672; } /* Generic.Deleted & Diff Deleted */
+.highlight .gi { color: #a6e22e; } /* Generic.Inserted & Diff Inserted */
diff --git a/docs/static/theme.css b/docs/static/theme.css
new file mode 100644
index 0000000..8dad4aa
--- /dev/null
+++ b/docs/static/theme.css
@@ -0,0 +1,1808 @@
+/* latin */
+@font-face {
+ font-family: "Karla";
+ font-style: normal;
+ font-weight: 400;
+ src: url("./fonts/karla-regular-.woff2") format("woff2");
+ unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
+}
+/* latin-ext */
+@font-face {
+ font-family: "Karla";
+ font-style: normal;
+ font-weight: 400;
+ src: url("./fonts/karla-regular-ext.woff2") format("woff2");
+ unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
+}
+/* latin */
+@font-face {
+ font-family: "Karla";
+ font-style: normal;
+ font-weight: 700;
+ src: url("./fonts/karla-bold.woff2") format("woff2");
+ unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
+}
+/* latin-ext */
+@font-face {
+ font-family: "Karla";
+ font-style: normal;
+ font-weight: 700;
+ src: url("./fonts/karla-bold-ext.woff2") format("woff2");
+ unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
+}
+@font-face {
+ font-family: "Material Symbols Rounded";
+ font-style: normal;
+ font-weight: 100 700;
+ font-display: block;
+ src: url("./fonts/material-symbols-rounded.woff2") format("woff2");
+}
+
+/* ---------------------------------------------------------------------- */
+
+html {
+ --cd-font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
+ --cd-font-sans: Karla, sans-serif;
+ --cd-font-icons: "Material Symbols Rounded";
+
+ --cd-padding-left: max(1rem, env(safe-area-inset-right));
+ --cd-padding-right: max(1rem, env(safe-area-inset-left));
+
+ --cd-brand-color: #fbbf24;
+ --cd-bg-color-light: rgb(255 255 255);
+ --cd-bg-color-dark: rgb(23 23 23);
+
+ --cd-bg-color: var(--cd-bg-color-light);
+ --cd-bg-color-hover: rgb(240, 240, 240);
+ --cd-text-color: rgb(23 23 23);
+ --cd-text-color-mild: rgb(63 63 70);
+ --cd-border-color: #e3e3e4;
+
+ --cd-nav-bg-color: rgba(255, 255, 255, 0.8);
+ --cd-nav-bg-color-hover: rgb(244, 244, 244);
+
+ --doc-symbol-parameter-fg-color: #df50af;
+ --doc-symbol-attribute-fg-color: #953800;
+ --doc-symbol-function-fg-color: #8250df;
+ --doc-symbol-method-fg-color: #8250df;
+ --doc-symbol-class-fg-color: #0550ae;
+ --doc-symbol-module-fg-color: #5cad0f;
+
+ --doc-symbol-parameter-bg-color: #df50af1a;
+ --doc-symbol-attribute-bg-color: #9538001a;
+ --doc-symbol-function-bg-color: #8250df1a;
+ --doc-symbol-method-bg-color: #8250df1a;
+ --doc-symbol-class-bg-color: #0550ae1a;
+ --doc-symbol-module-bg-color: #5cad0f1a;
+}
+
+html.dark {
+ --cd-brand-color: #3451b2;
+
+ --cd-bg-color: var(--cd-bg-color-dark);
+ --cd-bg-color-hover: rgb(40 40 40);
+ --cd-text-color: rgb(250 250 250);
+ --cd-text-color-mild: rgb(161 161 170);
+ --cd-border-color: rgb(60 60 60);
+
+ --cd-nav-bg-color: rgba(60, 60, 60, 0.8);
+ --cd-nav-bg-color-hover: rgb(70, 70, 70);
+
+ --doc-symbol-parameter-fg-color: #ffa8cc;
+ --doc-symbol-attribute-fg-color: #ffa657;
+ --doc-symbol-function-fg-color: #d2a8ff;
+ --doc-symbol-method-fg-color: #d2a8ff;
+ --doc-symbol-class-fg-color: #79c0ff;
+ --doc-symbol-module-fg-color: #baff79;
+
+ --doc-symbol-parameter-bg-color: #ffa8cc1a;
+ --doc-symbol-attribute-bg-color: #ffa6571a;
+ --doc-symbol-function-bg-color: #d2a8ff1a;
+ --doc-symbol-method-bg-color: #d2a8ff1a;
+ --doc-symbol-class-bg-color: #79c0ff1a;
+ --doc-symbol-module-bg-color: #baff791a;
+}
+
+/* ---------------------------------------------------------------------- */
+
+/*
+1. Prevent padding and border from affecting element width. (https://github.com/mozdevs/cssremedy/issues/4)
+2. Allow adding a border to an element by just adding a border-width. (https://github.com/tailwindcss/tailwindcss/pull/116)
+*/
+*,
+::before,
+::after {
+ /* 1 */
+ box-sizing: border-box;
+ /* 2 */
+ border-width: 0;
+ /* 2 */
+ border-style: solid;
+ /* 2 */
+ border-color: #e5e7eb;
+}
+::before,
+::after {
+ --cd-content: "";
+}
+
+/*
+1. Use a consistent sensible line-height in all browsers.
+2. Prevent adjustments of font size after orientation changes in iOS.
+3. Use a more readable tab size.
+4. Set default font sans
+4. Disable tap highlights on iOS
+*/
+html,
+:host {
+ /* 1 */
+ line-height: 1.5;
+ /* 2 */
+ tab-size: 4;
+ /* 3 */
+ -webkit-text-size-adjust: 100%;
+ /* 4 */
+ font-family: var(--cd-font-sans);
+ font-feature-settings: normal;
+ font-variation-settings: normal;
+ /* 5 */
+ -webkit-tap-highlight-color: transparent;
+}
+
+/*
+1. Remove the margin in all browsers.
+2. Inherit line-height from `html` so users can set them as a class
+ directly on the `html` element.
+*/
+body {
+ /* 1 */
+ margin: 0;
+ /* 2 */
+ line-height: inherit;
+}
+
+/*
+1. Add the correct height in Firefox.
+2. Correct the inheritance of border color in Firefox. (https://bugzilla.mozilla.org/show_bug.cgi?id=190655)
+3. Ensure horizontal rules are visible by default.
+*/
+hr {
+ /* 1 */
+ height: 0;
+ /* 2 */
+ color: inherit;
+ /* 3 */
+ border-top-width: 1px;
+}
+
+/*
+Add the correct text decoration in Chrome, Edge, and Safari.
+*/
+abbr:where([title]) {
+ -webkit-text-decoration: underline dotted;
+ text-decoration: underline dotted;
+}
+
+/* Remove the default font size and weight for headings. */
+h1, h2, h3, h4, h5, h6 {
+ font-size: inherit;
+ font-weight: inherit;
+}
+
+/* Reset links to optimize for opt-in styling instead of opt-out. */
+a {
+ color: inherit;
+ text-decoration: inherit;
+}
+
+/* Add the correct font weight in Edge and Safari. */
+b, strong {
+ font-weight: bolder;
+}
+
+/*
+1. Use the user"s configured `mono` font-family by default.
+2. Correct the odd `em` font sizing in all browsers.
+*/
+code, kbd, samp, pre {
+ /* 1 */
+ font-family: var(--cd-font-mono);
+ font-feature-settings: normal;
+ font-variation-settings: normal;
+ /* 2 */
+ font-size: 1em;
+}
+
+/* Add the correct font size in all browsers. */
+small {
+ font-size: 80%;
+}
+
+/*
+Prevent `sub` and `sup` elements from affecting the line height in
+all browsers.
+*/
+sub, sup {
+ font-size: 75%;
+ line-height: 0;
+ position: relative;
+ vertical-align: baseline;
+}
+sub {
+ bottom: -0.25em;
+}
+sup {
+ top: -0.5em;
+}
+
+/*
+1. Remove text indentation from table contents in Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=999088, https://bugs.webkit.org/show_bug.cgi?id=201297)
+2. Correct table border color inheritance in all Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=935729, https://bugs.webkit.org/show_bug.cgi?id=195016)
+3. Remove gaps between table borders by default.
+*/
+table {
+ /* 1 */
+ text-indent: 0;
+ /* 2 */
+ border-color: inherit;
+ /* 3 */
+ border-collapse: collapse;
+}
+
+/*
+1. Change the font styles in all browsers.
+2. Remove the margin in Firefox and Safari.
+3. Remove default padding in all browsers.
+*/
+button, input, optgroup, select, textarea {
+ /* 1 */
+ font-family: inherit;
+ font-feature-settings: inherit;
+ font-variation-settings: inherit;
+ font-size: 100%;
+ font-weight: inherit;
+ line-height: inherit;
+ letter-spacing: inherit;
+ color: inherit;
+ /* 2 */
+ margin: 0;
+ /* 3 */
+ padding: 0;
+}
+
+/* Remove the inheritance of text transform in Edge and Firefox. */
+button, select {
+ text-transform: none;
+}
+
+/*
+1. Correct the inability to style clickable types in iOS and Safari.
+2. Remove default button styles.
+*/
+button,
+input:where([type="button"]),
+input:where([type="reset"]),
+input:where([type="submit"]) {
+ /* 1 */
+ -webkit-appearance: button;
+ /* 2 */
+ background-color: transparent;
+ background-image: none;
+}
+
+/* Use the modern Firefox focus style for all focusable elements. */
+:-moz-focusring {
+ outline: auto;
+}
+
+/* Remove the additional `:invalid` styles in Firefox. (https://github.com/mozilla/gecko-dev/blob/2f9eacd9d3d995c937b4251a5557d95d494c9be1/layout/style/res/forms.css#L728-L737) */
+:-moz-ui-invalid {
+ box-shadow: none;
+}
+
+/* Add the correct vertical alignment in Chrome and Firefox. */
+progress {
+ vertical-align: baseline;
+}
+
+/* Correct the cursor style of increment and decrement buttons in Safari. */
+::-webkit-inner-spin-button,
+::-webkit-outer-spin-button {
+ height: auto;
+}
+
+/*
+1. Correct the odd appearance in Chrome and Safari.
+2. Correct the outline style in Safari.
+*/
+[type="search"] {
+ /* 1 */
+ -webkit-appearance: textfield;
+ /* 2 */
+ outline-offset: -2px;
+}
+
+/* Remove the inner padding in Chrome and Safari on macOS. */
+::-webkit-search-decoration {
+ -webkit-appearance: none;
+}
+
+/*
+1. Correct the inability to style clickable types in iOS and Safari.
+2. Change font properties to `inherit` in Safari.
+*/
+::-webkit-file-upload-button {
+ /* 1 */
+ -webkit-appearance: button;
+ /* 2 */
+ font: inherit;
+}
+
+/* Add the correct display in Chrome and Safari. */
+summary {
+ display: list-item;
+}
+
+/* Removes the default spacing and border for appropriate elements. */
+blockquote, dl, dd, h1, h2, h3, h4, h5, h6, hr, figure, p, pre {
+ margin: 0;
+}
+fieldset {
+ margin: 0;
+ padding: 0;
+}
+legend {
+ padding: 0;
+}
+ol, ul, menu {
+ list-style: none;
+ margin: 0;
+ padding: 0;
+}
+
+/* Reset default styling for dialogs. */
+dialog {
+ padding: 0;
+}
+
+/* Prevent resizing textareas horizontally by default. */
+textarea {
+ resize: vertical;
+}
+
+/*
+1. Reset the default placeholder opacity in Firefox. (https://github.com/tailwindlabs/tailwindcss/issues/3300)
+2. Set the default placeholder color to the user"s configured gray 400 color.
+*/
+input::-moz-placeholder,
+textarea::-moz-placeholder {
+ /* 1 */
+ opacity: 1;
+ /* 2 */
+ color: #9ca3af;
+}
+input::placeholder,
+textarea::placeholder {
+ /* 1 */
+ opacity: 1;
+ /* 2 */
+ color: #9ca3af;
+}
+
+/* Set the default cursor for buttons. */
+button,
+[role="button"] {
+ cursor: pointer;
+}
+
+/* Make sure disabled buttons don"t get the pointer cursor. */
+:disabled {
+ cursor: default;
+}
+
+/*
+1. Make replaced elements `display: block` by default. (https://github.com/mozdevs/cssremedy/issues/14)
+2. Add `vertical-align: middle` to align replaced elements more sensibly by default. (https://github.com/jensimmons/cssremedy/issues/14#issuecomment-634934210)
+ This can trigger a poorly considered lint error in some tools but is included by design.
+*/
+img, svg, video, canvas, audio, iframe, embed, object {
+ /* 1 */
+ display: block;
+ /* 2 */
+ vertical-align: middle;
+}
+
+/*
+Constrain images and videos to the parent width and preserve their
+intrinsic aspect ratio. (https://github.com/mozdevs/cssremedy/issues/14)
+*/
+img, video {
+ max-width: 100%;
+ height: auto;
+}
+
+/* Make elements with the HTML hidden attribute stay hidden by default */
+[hidden] {
+ display: none;
+}
+
+/* ---------------------------------------------------------------------- */
+
+html:has(.cd-nav-mobile:popover-open) {
+ overflow: hidden !important;
+ overflow-x: hidden !important;
+ overflow-y: hidden !important;
+}
+body {
+ position: relative;
+ min-height: 100vh;
+ color: var(--cd-text-color);
+ -webkit-font-smoothing: antialiased;
+ -moz-osx-font-smoothing: grayscale;
+ background-color: var(--cd-bg-color-light);
+ transition: background 100ms linear;
+}
+html.dark body {
+ background-color: var(--cd-bg-color-dark);
+}
+
+.keys,
+kbd:not(.keys > kbd) {
+ font-family: var(--cd-font-mono);
+ display: inline-block;
+ padding: 0.2rem 0.25rem;
+ margin-left: 0.1rem;
+ margin-right: 0.1rem;
+ font-size: 0.875rem;
+ line-height: 1;
+ font-weight: 500;
+ letter-spacing: -0.025em;
+ line-height: 1;
+ border-radius: 0.25rem;
+ border-width: 1px;
+ border-color: #ffffff;
+ box-shadow: 0 0 2px 0 #000;
+
+ &:is(.dark *) {
+ border-color: rgb(0 0 0);
+ background-color: rgb(24 24 27);
+ }
+}
+
+.scrollbar-thin {
+ scrollbar-width: thin; /* Firefox */
+}
+.scrollbar-thin::-webkit-scrollbar {
+ /* Safari and Chrome */
+ width: 2px;
+ background-color: ButtonFace;
+}
+.scrollbar-default {
+ -ms-overflow-style: auto; /* IE and Edge */
+ scrollbar-width: auto; /* Firefox */
+}
+.scrollbar-default::-webkit-scrollbar {
+ /* Safari and Chrome */
+ width: auto;
+}
+
+a.headerlink {
+ margin-left: .25rem;
+ display: inline-block;
+ text-decoration-line: none;
+ opacity: 0;
+ transition-property: opacity;
+ transition-timing-function: cubic-bezier(.4,0,.2,1);
+ transition-duration: .15s;
+}
+h2:hover a.headerlink,
+h3:hover a.headerlink,
+h4:hover a.headerlink,
+h5:hover a.headerlink,
+h6:hover a.headerlink {
+ opacity: 0.5;
+}
+
+/* ---------------------------------------------------------------------- */
+
+.doc-symbol {
+ border-radius: 0.1rem;
+ padding: 0 0.3em;
+ font-weight: bold;
+}
+.doc-symbol-attr {
+ color: var(--doc-symbol-attribute-fg-color) !important;
+ background-color: var(--doc-symbol-attribute-bg-color) !important;
+}
+.doc-symbol-function {
+ color: var(--doc-symbol-function-fg-color) !important;
+ background-color: var(--doc-symbol-function-bg-color) !important;
+}
+.doc-symbol-method {
+ color: var(--doc-symbol-method-fg-color) !important;
+ background-color: var(--doc-symbol-method-bg-color) !important;
+}
+.doc-symbol-class {
+ color: var(--doc-symbol-class-fg-color) !important;
+ background-color: var(--doc-symbol-class-bg-color) !important;
+}
+.doc-symbol-module {
+ color: var(--doc-symbol-module-fg-color) !important;
+ background-color: var(--doc-symbol-module-bg-color) !important;
+}
+
+.doc-oname {
+ font-weight: normal;
+}
+.doc-olabel {
+ font-size: 0.6em !important;
+ color: #36464e !important;
+ font-weight: 400;
+ padding: 0.1rem 0.4rem !important;
+}
+
+.doc-attrs ~ .doc-methods,
+.doc-properties ~ .doc-methods {
+ margin-top; 1rem;
+}
+
+/* ---------------------------------------------------------------------- */
+
+.icon {
+ font-family: var(--cd-font-icons);
+ font-weight: normal;
+ font-style: normal;
+ letter-spacing: normal;
+ text-transform: none;
+ display: inline-block;
+ white-space: nowrap;
+ word-wrap: normal;
+ direction: ltr;
+ -webkit-font-smoothing: antialiased;
+ -moz-osx-font-smoothing: grayscale;
+ text-rendering: optimizeLegibility;
+ font-feature-settings: "liga";
+ cursor: default;
+ pointer-events: none;
+}
+
+/* ---------------------------------------------------------------------- */
+
+.cd-source {
+ display: flex;
+ align-items: center;
+ font-size: 0.85rem;
+ line-height: 1.2;
+ white-space: nowrap;
+ cursor: pointer;
+ text-decoration: none;
+ padding: 0.5rem 0.75rem;
+ min-width: 150px;
+ backdrop-filter: blur(4px);
+ background-color: var(--cd-nav-bg-color);
+ border-radius: 1rem;
+ transition: background 300ms ease-in-out;
+
+ &:hover {
+ background-color: var(--cd-nav-bg-color-hover);
+ }
+ & > div {
+ opacity: 0.8;
+ transition: opacity 300ms ease-in-out;
+ }
+ &:hover > div {
+ opacity: 1;
+ }
+ & .cd-source__icon {
+ padding-right: 0.5rem;
+ }
+ & .cd-source__icon svg {
+ height: 1.5rem;
+ width: 1.5rem;
+ fill: currentcolor;
+ display: block;
+ }
+ & .cd-source__label {
+ font-size: 0.9rem;
+ font-weight: bold;
+ }
+ & .cd-source__repo {
+ display: inline-block;
+ max-width: calc(100% - 1.2rem);
+ overflow: hidden;
+ text-overflow: ellipsis;
+ vertical-align: middle;
+ }
+ @media (max-width: 480px) {
+ & {
+ min-width: 0;
+ }
+ & .cd-source__icon {
+ padding-right: 0;
+ }
+ & .cd-source__repo {
+ display: none;
+ }
+ }
+ & .cd-source__facts {
+ display: hidden;
+ gap: 0.4rem;
+ list-style-type: none;
+ margin: 0.1rem 0 0;
+ overflow: hidden;
+ padding: 0;
+ width: 100%;
+ opacity: 0;
+ transform: translateY(100%);
+ transition: all 0.5s ease-out;
+ }
+ & .cd-source__facts.cd-source__facts--visible {
+ display: flex;
+ opacity: 1;
+ transform: translateY(0);
+ }
+ & .cd-source__facts [data-fact] {
+ overflow: hidden;
+ text-overflow: ellipsis;
+ display: flex;
+ align-items: center;
+ line-height: 1;
+ }
+ & .cd-source__facts [data-fact]:nth-child(1n+2) {
+ flex-shrink: 0;
+ }
+ & .cd-source__facts [data-fact]:not([hidden]):before {
+ width: 0.6rem;
+ padding-right: 0.8rem;
+ font-family: var(--cd-font-icons);
+ font-weight: normal;
+ font-style: normal;
+ letter-spacing: normal;
+ text-transform: none;
+ display: inline-block;
+ white-space: nowrap;
+ word-wrap: normal;
+ direction: ltr;
+ -webkit-font-smoothing: antialiased;
+ -moz-osx-font-smoothing: grayscale;
+ text-rendering: optimizeLegibility;
+ font-feature-settings: "liga";
+ cursor: default;
+ pointer-events: none;
+ }
+ & .cd-source__facts [data-fact="version"]:not([hidden]):before {
+ content: "tag";
+ }
+ & .cd-source__facts [data-fact="stars"]:not([hidden]):before {
+ content: "star";
+ }
+ & .cd-source__facts [data-fact="forks"]:not([hidden]):before {
+ content: "fork_right";
+ }
+ & .cd-source__facts [data-fact="numrepos"]:not([hidden]):before {
+ content: "numbers";
+ }
+}
+
+/* ---------------------------------------------------------------------- */
+
+.cd-cards {
+ & {
+ display: grid;
+ grid-gap: 1rem;
+ }
+ @media (min-width: 480px) {
+ & { grid-template-columns: repeat(2, 1fr); }
+ }
+ @media (min-width: 900px) {
+ & { grid-template-columns: repeat(4, 1fr); }
+ }
+ & a.card {
+ display: block;
+ border: 1px solid var(--cd-border-color);
+ padding: 1rem;
+ border-radius: 6px;
+ background-color: var(--cd-bg-color);
+ transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
+ }
+ & a.card:hover {
+ display: block;
+ background-color: var(--cd-bg-color-hover);
+ }
+ & a.card h2 {
+ text-decoration: none;
+ font-family: var(--cd-font-sans);
+ font-weight: bold;
+ }
+}
+
+/* ---------------------------------------------------------------------- */
+
+.cd-text-button {
+ display: inline-flex;
+ cursor: pointer;
+ touch-action: manipulation;
+ -webkit-appearance: none;
+ -moz-appearance: none;
+ appearance: none;
+ align-items: center;
+ justify-content: center;
+ white-space: nowrap;
+ border-radius: 0.25rem;
+ border-width: 1px;
+ border-color: rgb(228 228 231);
+ background-color: rgb(250 250 250);
+ padding: 0.25rem 0.5rem;
+ font-size: 0.875rem;
+ line-height: 1.25rem;
+ font-weight: 600;
+ color: rgb(39 39 42);
+
+ &:hover {
+ border-color: rgb(212 212 216);
+ background-color: rgb(244 244 245);
+ color: rgb(24 24 27);
+ box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);;
+ }
+ &:focus {
+ outline-style: solid;
+ outline-offset: 1px;
+ outline-color: rgb(82 82 91 / 0.5);
+ }
+ &:active {
+ border-color: rgb(161 161 170);
+ }
+ &:disabled {
+ cursor: default;
+ outline: 2px solid transparent;
+ outline-offset: 2px;
+ }
+ &:is(.dark *) {
+ border-color: rgb(82 82 91);
+ background-color: rgb(82 82 91 / 0.1);
+ color: rgb(228 228 231);
+ }
+ &:is(.dark *):hover {
+ border-color: rgb(113 113 122);
+ background-color: rgb(24 24 27);
+ color: rgb(244 244 245);
+ }
+ &:is(.dark *):active {
+ border-color: var(--cd-bg-color);
+ }
+}
+
+/* ---------------------------------------------------------------------- */
+
+.cd-callout {
+ --bg-color: rgb(244 244 245);
+ --border-color: rgb(212 212 216);
+ --text-color: rgb(39 39 42);
+
+ &.type-note,
+ &.type-info,
+ &.type-todo {
+ --bg-color: rgb(244 244 245);
+ --border-color: rgb(212 212 216);
+ --text-color: rgb(39 39 42);
+ }
+ &.type-tip {
+ --bg-color: rgb(254 249 195);
+ --border-color: rgb(254 240 138);
+ --text-color: rgb(133 77 14);
+ }
+ &.type-alert {
+ --bg-color: rgb(255 237 213);
+ --border-color: rgb(254 215 170);
+ --text-color: rgb(154 52 18);
+ }
+ &.type-warning {
+ --bg-color: rgb(255 237 213);
+ --border-color: rgb(254 215 170);
+ --text-color: rgb(154 52 18);
+ }
+ &.type-danger {
+ --bg-color: rgb(255 228 230);
+ --border-color: rgb(254 205 211);
+ --text-color: rgb(136 19 55);
+ }
+ &.type-error {
+ --bg-color: rgb(255 228 230);
+ --border-color: rgb(254 205 211);
+ --text-color: rgb(136 19 55);
+ }
+ &.type-internal {
+ --bg-color: rgb(231 229 228);
+ --border-color: rgb(214 211 209);
+ --text-color: rgb(28 25 23);
+ }
+ & {
+ position: relative;
+ border-top-width: 1px;
+ border-bottom-width: 1px;
+ overflow: hidden;
+ margin-left: -1rem;
+ margin-right: -1rem;
+ background-color: var(--bg-color);
+ border-color: var(--border-color);
+ color: var(--text-color);
+ }
+ @media (min-width: 640px) {
+ & {
+ border-left-width: 1px;
+ border-right-width: 1px;
+ border-radius: 0.25rem;
+ margin-left: 0;
+ margin-right: 0;
+ }
+ }
+ &:is(.dark *) {
+ background-color: oklch(from var(--bg-color) calc(l * 2) calc(c * 3) h / 0.8);
+ border-color: oklch(from var(--border-color) calc(l * 1.5) c h);
+ color: oklch(from var(--text-color) calc(l * 0.5) c h);
+ }
+ &:is(.dark *) ::selection {
+ background-color: oklch(from var(--bg-color) calc(l * 1.2) calc(c * 4) h)
+ }
+ &:is(aside) {
+ display: flex;
+ align-items: flex-start;
+ padding: 1.25rem 1rem 1rem;
+ }
+ @media (min-width: 640px) {
+ &:is(aside) {
+ padding-left: 1.25rem;
+ padding-right: 1.25rem;
+ }
+ }
+ & summary {
+ display: flex;
+ align-items: center;
+ font-weight: 700;
+ height: 3rem;
+ padding-left: 1.25rem;
+ padding-right: 1.25rem;
+ cursor: pointer;
+ }
+ & .icon {
+ margin: -0.1rem 1rem 0 -0.25rem;
+ opacity: 0.9;
+ font-size: 1.2rem;
+ line-height: 1.4;
+ }
+ @media (max-width: 639px) {
+ & .icon {
+ display: none;
+ }
+ }
+ & .icon.arrow {
+ margin-left: auto;
+ transition-property: transform;
+ transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
+ transition-duration: 150ms;
+ }
+ & details&[open] .icon.arrow {
+ transform: rotate(180deg);
+ }
+ & .content {
+ line-height: 1.4;
+ }
+ & details& .content {
+ padding: 0 1rem 1rem;
+ }
+ @media (min-width: 640px) {
+ & details& .content {
+ padding: 0 1.25rem 1rem;
+ }
+ }
+}
+/* Cannot be nested */
+.cd-callout::selection {
+ background-color: oklch(from var(--bg-color) calc(l * 0.9) calc(c * 3) h);
+}
+
+/* ---------------------------------------------------------------------- */
+
+.cd-example-tabs {
+ position: relative;
+ margin-top: 2rem;
+ margin-bottom: 3rem;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ width: 100%;
+
+ & .example-tabgroup {
+ width: 100%;
+ overflow: hidden;
+ position: relative;
+ border: 1px solid #999;
+ border-radius: 0.4rem;
+ }
+
+ & .example-tablist {
+ z-index: 0;
+ display: flex;
+ border-bottom: 1px solid #999;
+ background-color: rgb(249 250 251);
+ overflow-x: auto;
+ overflow-y: hidden;
+ -ms-scroll-chaining: none;
+ overscroll-behavior: contain;
+ width: 100%;
+ text-align: center;
+ font-size: 0.875rem;
+ line-height: 1.25rem;
+ font-weight: 500;
+ color: rgb(107 114 128);
+ }
+ & .example-tablist:is(.dark *) {
+ border-color: rgb(75 85 99);
+ background-color: rgb(55 65 81);
+ color: rgb(156 173 175);
+ }
+
+ & .example-tab {
+ user-select: none;
+ border-right-width: 1px;
+ border-color: #999;
+ background-color: rgb(255 255 255);
+ padding: 0.5rem 1.6rem;
+ color: #333;
+ }
+ & .example-tab:is(.dark *) {
+ border-color: rgb(75 85 99);
+ background-color: rgb(31 41 55);
+ color: rgb(255 255 255);
+ }
+ & .example-tab:not(.ui-disabled):not(.ui-selected):hover {
+ background-color: rgb(249 250 251);
+ color: rgb(55 65 81);
+ }
+ & .example-tab:not(.ui-disabled):not(.ui-selected):hover:is(.dark *) {
+ background-color: rgb(55 65 81);
+ color: rgb(255 255 255);
+ }
+ & .example-tab.ui-disabled {
+ color: rgb(193 204 220);
+ }
+ & .example-tab.ui-selected {
+ color: black;
+ background-color: #e7e9ed;
+ }
+ & .example-tab.ui-selected:is(.dark *) {
+ color: white;
+ background-color: #111;
+ }
+
+ & .example-tabpanel {
+ width: 100%;
+ flex-grow: 0;`
+ z-index: 10;
+ overflow: auto;
+ position: relative;
+ max-height: 400px;
+ }
+ & .example-tabpanel.ui-hidden {
+ display: none;
+ }
+ & .example-tabpanel div.highlight {
+ margin: 0;
+ padding: 0;
+ border-radius: 0;
+ font-size: 0.9rem;
+ }
+ & .example-tabpanel div.highlight pre {
+ border-radius: 0;
+ }
+}
+
+/* ---------------------------------------------------------------------- */
+
+.cd-footer {
+ padding-top: 1.25rem;
+ padding-bottom: 1.25rem;
+ padding-left: var(--cd-padding-left);
+ padding-right: var(--cd-padding-right);
+ font-size: 0.875rem;
+ line-height: 1.25rem;
+ text-align: center;
+ border-top: 1px solid rgb(228 228 231);
+
+ &:is(.dark *){
+ border-color: rgb(82 82 91);
+ }
+ & .wrapper {
+ display: flex;
+ align-items: center;
+ }
+ & .copy {
+ margin-right: auto;
+ text-align: left;
+ padding: 0 16px;
+ }
+ & .built-with {
+ height: 100%;
+ color: rgb(113 113 122);
+ }
+ & .built-with:is(.dark *) {
+ color: inherit;
+ }
+ & .built-with a {
+ text-decoration: underline;
+ cursor: pointer;
+ }
+ & .themeswitch {
+ margin-left: 1.5rem;
+ margin-right: 0;
+ opacity: 0.8;
+ border-radius: 1rem;
+ background-color: var(--cd-nav-bg-color);
+ transition: opacity 300ms ease-in-out, background 300ms ease-in-out;
+ padding-left: 0.5rem;
+ padding-right: 0.5rem;
+ }
+ & .themeswitch:hover {
+ opacity: 1;
+ background-color: var(--cd-nav-bg-color-hover);
+ }
+ @media (max-width: 640px) {
+ & .built-with,
+ & .themeswitch {
+ display: none;
+ }
+ }
+}
+
+/* ---------------------------------------------------------------------- */
+
+.cd-header {
+ margin-bottom: 2rem;
+
+ & div p {
+ margin-bottom: 0.5rem;
+ font-size: 0.875rem;
+ line-height: 1;
+ font-weight: 600;
+ }
+ & h1 {
+ display: inline-block;
+ font-size: 1.9rem;
+ line-height: 1.25rem;
+ color: rgb(24 24 27);
+ font-weight: 800;
+ margin: 0;
+ }
+ & h1:is(.dark *) {
+ color: rgb(228 228 231);
+ }
+ @media (min-width: 640px) {
+ & h1 {
+ font-size: 2.2rem;
+ }
+ }
+ & p.description {
+ margin-top: 0.25rem;
+ font-size: 1.125rem;
+ line-height: 1.75rem;
+ color: var(--cd-text-color-mild);
+ }
+}
+
+/* ---------------------------------------------------------------------- */
+
+.cd-navbar {
+ display: flex;
+ align-items: center;
+ border-radius: 1rem;
+ padding: 0 0.75rem;
+ font-size: 0.875rem;
+ font-weight: bold;
+ backdrop-filter: blur(4px);
+ background-color: var(--cd-nav-bg-color);
+ box-shadow: rgb(15, 15, 15) 0px 0px 0px 0px inset,
+ rgba(163, 163, 170, 0.3) 0px 0px 0px 1px inset,
+ rgba(255, 255, 255, 0.2) 0px 20px 25px -5px,
+ rgba(255, 255, 255, 0.2) 0px 8px 10px -6px;
+
+ &:is(.dark *) {
+ box-shadow: rgb(255, 255, 255) 0px 0px 0px 0px inset,
+ rgba(63, 63, 70, 0.3) 0px 0px 0px 1px inset,
+ rgba(0, 0, 0, 0.2) 0px 20px 25px -5px,
+ rgba(0, 0, 0, 0.2) 0px 8px 10px -6px;
+ }
+
+ & a {
+ white-space: nowrap;
+ padding: 0.75rem;
+ }
+ & a,
+ & button {
+ opacity: 0.8;
+ transition: opacity 300ms ease-in-out, background 300ms ease-in-out;
+ border-radius: 4px;
+ }
+ & a:hover,
+ & button:hover {
+ opacity: 1;
+ background-color: var(--cd-nav-bg-color-hover);
+ }
+ & a svg {
+ height: 20px;
+ }
+}
+
+/* ---------------------------------------------------------------------- */
+
+.cd-nav-top {
+ z-index: 1000;
+ width: 100%;
+ margin-top: 1rem;
+
+ /* @media ((min-width: 1024px) and (min-height: 640px)) {
+ & {
+ position: sticky;
+ top: 1rem;
+ }
+ } */
+ & .wrapper {
+ margin-left: auto;
+ margin-right: auto;
+ display: flex;
+ max-width: 100rem;
+ align-items: center;
+ padding-left: var(--cd-padding-left);
+ padding-right: var(--cd-padding-right);
+ }
+
+ & .logo {
+ padding: 0.75rem;
+ margin-left: -0.75rem;
+ margin-right: auto;
+ background-color: transparent;
+ transition: background 300ms ease-in-out;
+ }
+ @media (min-width: 640px) {
+ & .logo {
+ border-radius: 4px;
+ backdrop-filter: blur(4px);
+ background-color: var(--cd-nav-bg-color);
+ }
+ }
+
+ & .nav-links {
+ display: none;
+ }
+ @media (min-width: 768px) {
+ & .nav-links {
+ display: inline-flex;
+ }
+ }
+ & .nav-extra {
+ margin-left: 0.75rem;
+ }
+ & .nav-links > .themeswitch {
+ border: none;
+ outline: none;
+ margin-left: 0.25rem;
+ }
+ & .cd-toggle-sidebar {
+ font-size: 1rem;
+ margin-left: 0.75rem;
+ width: 4.5rem;
+ line-height: 1;
+ padding: 0.75rem 0.5rem;
+ }
+}
+
+/* ---------------------------------------------------------------------- */
+
+.cd-nav-global {
+ /* position: sticky; */
+ /* top: 0; */
+ z-index: 0;
+ width: 12rem;
+ border-right-width: 1px;
+ border-color: rgb(228 228 231);
+ padding-right: 1rem;
+ padding-bottom: 2rem;
+ font-size: 0.875rem;
+ line-height: 1.2;
+ flex-shrink: 0;
+ /*
+ @media (min-height: 640px) {
+ & {
+ overflow-y: auto;
+ height: 100vh;
+ top: 3rem;
+ min-height: calc(100vh - 3rem);
+ }
+ } */
+
+ @media (min-width: 1536px) {
+ & {
+ font-size: 1rem;
+ line-height: 1.5rem;
+ width: 18rem;
+ }
+ }
+ &:is(.dark *) {
+ border-color: rgb(82 82 91);
+ }
+
+ & nav {
+ display: flex;
+ width: 100%;
+ flex-direction: column;
+ padding-bottom: 3.5rem;
+ }
+}
+
+/* ---------------------------------------------------------------------- */
+
+.cd-nav-local {
+ position: sticky;
+ top: 5rem;
+ z-index: 0;
+ width: 25rem;
+ height: calc(100vh - 6.5rem);
+ margin-right: -1rem;
+ overflow: hidden;
+ border-left-width: 1px;
+ border-color: rgb(228 228 231);
+
+ &:is(.dark *) {
+ border-color: rgb(82 82 91);
+ }
+ & .wrapper {
+ position: absolute;
+ inset: 0;
+ overflow-y: auto;
+ overflow-x: hidden;
+ -ms-scroll-chaining: none;
+ overscroll-behavior: contain;
+ scroll-behavior: smooth;
+ padding: 1.5rem 0.25rem;
+ font-size: 0.9rem;
+ line-height: 1.2;
+ }
+}
+
+/* ---------------------------------------------------------------------- */
+
+.cd-nav-mobile {
+ position: fixed;
+ left: 0;
+ top: 0;
+ height: 100vh;
+ width: 100%;
+ min-width: 360px;
+ max-width: 640px;
+ -ms-scroll-chaining: none;
+ overscroll-behavior: contain;
+ margin: 0;
+ padding: 0 0 4rem 0;
+ background-color: var(--cd-bg-color-hover);
+ color: var(--cd-text-color);
+
+ transition: all 0.2s allow-discrete;
+ /* Final state of the exit animation */
+ opacity: 0;
+ transform: translateX(-100%);
+
+ &:popover-open {
+ opacity: 1;
+ transform: translateX(0);
+ }
+ /* Needs to be after the previous &:popover-open rule
+ to take effect, as the specificity is the same */
+ @starting-style {
+ &:popover-open {
+ opacity: 0;
+ transform: translateX(-100%);
+ }
+ }
+
+ @media (min-width: 640px) {
+ & {
+ border-right: 1px solid var(--cd-border-color);
+ }
+ }
+ & header {
+ margin: 1rem 0;
+ display: flex;
+ align-items: center;
+ padding-left: var(--cd-padding-left);
+ padding-right: var(--cd-padding-right);
+ }
+ & .logo {
+ margin-right: auto;
+ }
+ & .themeswitch {
+ border: none;
+ background: none;
+ outline: none;
+ }
+ & .cd-toggle-sidebar {
+ font-size: 1rem;
+ margin-left: 0.75rem;
+ width: 4.5rem;
+ line-height: 1;
+ padding: 0.75rem 0.5rem;
+ }
+
+ & .toc {
+ margin-bottom: 1.25rem;
+ display: flex;
+ flex-direction: column;
+ -ms-scroll-chaining: none;
+ overscroll-behavior: contain;
+ padding-left: var(--cd-padding-left);
+ padding-right: var(--cd-padding-right);
+ font-size: 1rem;
+ line-height: 1.5rem;
+ }
+}
+/* Transition for the popover's backdrop.
+ ::backdrop cannot be nested */
+.cd-nav-mobile::backdrop {
+ transition: all 0.5s allow-discrete;
+ /* Final state of the exit animation */
+ backdrop-filter: blur(0);
+ background-color: rgb(0 0 0 / 0%);
+}
+.cd-nav-mobile:popover-open::backdrop {
+ backdrop-filter: blur(2px);
+ background-color: rgb(0 0 0 / 15%);
+}
+@starting-style {
+ .cd-nav-mobile:popover-open::backdrop {
+ backdrop-filter: blur(0);
+ background-color: rgb(0 0 0 / 0%);
+ }
+}
+
+/* ---------------------------------------------------------------------- */
+
+.cd-page-single > main {
+ margin: 0;
+ max-width: 100%;
+ padding: 0;
+}
+
+.cd-page {
+ & .page-wrapper {
+ z-index: 10;
+ margin-left: auto;
+ margin-right: auto;
+ display: flex;
+ max-width: 100rem;
+ padding-top: 1rem;
+ padding-left: var(--cd-padding-left);
+ padding-right: var(--cd-padding-right);
+ padding-bottom: 1.5rem;
+ min-width: 360px;
+ }
+ & .page-wrapper > main {
+ width: 100%;
+ padding-top: 1rem;
+ }
+ @media (min-width: 640px) {
+ & {
+ padding-bottom: 1rem;
+ }
+ }
+}
+
+/* ---------------------------------------------------------------------- */
+
+.cd-prevnext {
+ display: flex;
+ align-items: stretch;
+ width: 100%;
+ margin-top: 2rem;
+ padding-top: 2rem;
+ padding-bottom: 2rem;
+ padding-left: var(--cd-padding-left);
+ padding-right: var(--cd-padding-right);
+ border-top: 1px solid var(--cd-border-color);
+ font-family: var(--cd-font-sans);
+
+ & a.prev,
+ & a.next {
+ display: flex;
+ align-items: center;
+ padding: 0.75rem 0.25rem;
+ text-decoration: none;
+ width: 50%;
+ border: 1px solid var(--cd-border-color);
+ color: var(--cd-text-color);
+ border-radius: 10px;
+ transition: all 0.2s ease-in;
+ }
+ & a.prev {
+ margin-right: 1.25rem;
+ justify-content: flex-start;
+ text-align: left;
+ }
+ & a.next {
+ margin-left: auto;
+ justify-content: flex-end;
+ text-align: right;
+ }
+ & a.prev:hover,
+ & a.next:hover {
+ border-color: rgb(113, 113, 122);
+ }
+ &:is(.dark *) a.prev:hover,
+ &:is(.dark *) a.next:hover {
+ border-color: rgb(150, 150, 150);
+ }
+ & .section {
+ font-size: 0.875rem;
+ line-height: 1;
+ color: rgb(113, 113, 122);
+ margin-bottom: 0.1rem;
+ }
+ &:is(.dark *) .section {
+ color: rgb(150, 150, 150);
+ }
+ & .title {
+ font-size: 1rem;
+ line-height: 1.1;
+ }
+ & i {
+ opacity: 0.8;
+ font-style: normal;
+ font-size: 1.4rem;
+ padding: 0 0.5rem;
+ }
+}
+
+/* ---------------------------------------------------------------------- */
+
+.cd-theme-switch {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ -webkit-tap-highlight-color: transparent;
+
+ & {
+ font-weight: 400;
+ height: 2.5rem;
+ width: 2.5rem;
+ flex-grow: 0;
+ padding: 0.2rem;
+ }
+ @media (min-width: 1024px) {
+ & {
+ width: auto;
+ }
+ }
+ & svg {
+ padding: 0.3rem;
+ margin: 0;
+ }
+ &:is(.dark *) svg {
+ padding: 0.1rem;
+ }
+ & .sun-and-moon {
+ pointer-events: none;
+ display: block;
+ height: 100%;
+ width: 100%;
+ }
+ & .sun {
+ transform-origin: center;
+ transform: scale(1, 1);
+ transform: translate3d(0, 0, 0);
+ fill: #3f3f46;
+ stroke: transparent;
+ }
+ &:hover .sun {
+ fill: #27272a;
+ }
+ &:focus-visible .sun {
+ fill: #27272a;
+ }
+ @media (prefers-reduced-motion: no-preference) {
+ & .sun {
+ transition-property: transform;
+ transition-timing-function: cubic-bezier(0.5, 1.25, 0.75, 1.25);
+ transition-duration: 0.5s;
+ }
+ }
+ & .sun:is(.dark *) {
+ transform: scale(1.75, 1).75;
+ fill: #e4e4e7;
+ }
+ &:hover .sun:is(.dark *) {
+ fill: #f4f4f5;
+ }
+ &:focus-visible .sun:is(.dark *) {
+ fill: #f4f4f5;
+ }
+ @media (prefers-reduced-motion: no-preference) {
+ & .sun:is(.dark *) {
+ transition-timing-function: cubic-bezier(0.25, 0, 0.3, 1);
+ transition-duration: 250ms;
+ }
+ }
+ & .sun-beams {
+ transform-origin: center;
+ stroke: #3f3f46;
+ stroke-width: 2;
+ }
+ &:hover .sun-beams {
+ stroke: #27272a;
+ }
+ &:focus-visible .sun-beams {
+ stroke: #27272a;
+ }
+ @media (prefers-reduced-motion: no-preference) {
+ & .sun-beams {
+ transition-property: transform, opacity;
+ transition-timing-function: cubic-bezier(0.5, 1.5, 0.75, 1.25);
+ transition-duration: 400ms;
+ }
+ }
+ & .sun-beams:is(.dark *) {
+ transform: translate3d(0, 0, 0);
+ transform: rotate(-25deg);
+ stroke: #e4e4e7;
+ opacity: 0;
+ }
+ &:hover .sun-beams:is(.dark *) {
+ stroke: #f4f4f5;
+ }
+ &:focus-visible .sun-beams:is(.dark *) {
+ stroke: #f4f4f5;
+ }
+ @media (prefers-reduced-motion: no-preference) {
+ & .sun-beams:is(.dark *) {
+ transition-duration: 150ms;
+ }
+ }
+ & .moon {
+ transform-origin: center;
+ fill: #52525b;
+ }
+ &:hover .moon {
+ fill: #71717a;
+ }
+ & .moon circle {
+ transform: translate3d(0, 0, 0);
+ }
+ @media (prefers-reduced-motion: no-preference) {
+ & .moon circle {
+ transition-property: transform;
+ transition-timing-function: cubic-bezier(0, 0, 0, 1);
+ transition-duration: 0.3s;
+ }
+ }
+ & .moon circle:is(.dark *) {
+ transform: translateX(-7px);
+ }
+ @media (prefers-reduced-motion: no-preference) {
+ & .moon circle:is(.dark *) {
+ transition-delay: 0.3s;
+ }
+ }
+ & .light-text,
+ & .dark-text {
+ padding: 0.5rem;
+ padding-left: 0;
+ display: none;
+ white-space: nowrap;
+ font-weight: bold;
+ text-align: left;
+ }
+ @media (min-width: 1024px) {
+ & .light-text {
+ display: block;
+ }
+ & .light-text:is(.dark *) {
+ display: none;
+ }
+ & .dark-text:is(.dark *) {
+ display: block;
+ }
+ }
+}
+
+/* ---------------------------------------------------------------------- */
+
+.cd-toc {
+ & details,
+ & section {
+ margin-top: 1.5rem;
+ }
+
+ & summary {
+ margin-bottom: 0.5rem;
+ font-weight: 600;
+ color: rgb(39 39 42);
+ }
+ & summary:is(.dark *) {
+ color: rgb(244 244 245);
+ }
+
+ & h2 {
+ margin-bottom: 0.5rem;
+ font-weight: 600;
+ color: rgb(39 39 42);
+ }
+ & h2:is(.dark *) {
+ color: rgb(244 244 245);
+ }
+
+ & .page {
+ border-left-width: 2px;
+ border-color: rgb(244 244 245);
+ padding-left: 0.5rem;
+ }
+ & .page:hover {
+ border-color: rgb(212 212 216);
+ }
+
+ & .page:is(.dark *) {
+ border-color: rgb(63 63 70 / 0.5);
+ }
+ & .page:is(.dark *):hover {
+ border-color: rgb(161 161 170);
+ }
+
+ & a {
+ position: relative;
+ display: flex;
+ align-items: center;
+ border-radius: 0.25rem;
+ border-width: 1px;
+ border-color: transparent;
+ line-height: 1.2;
+ margin: 0;
+ padding-top: 0.25rem;
+ padding-bottom: 0.25rem;
+ padding-left: 0.5rem;
+ padding-right: 0.5rem;
+ color: rgb(63 63 70);
+ }
+ & a:hover {
+ color: rgb(0 0 0);
+ }
+ & a:is(.dark *) {
+ color: rgb(161 161 170);
+ }
+ & a:is(.dark *):hover {
+ color: rgb(244 244 245);
+ }
+ & .active a {
+ border-color: rgb(228 228 231);
+ background-color: rgb(244 244 245);
+ font-weight: bold;
+ color: rgb(39 39 42);
+ }
+ & .active:is(.dark *) a {
+ color: black;
+ }
+}
+
+/* ---------------------------------------------------------------------- */
+
+.cd-toc-page {
+ margin-top: -0.25rem;
+
+ & li {
+ position: relative;
+ display: flex;
+ align-items: center;
+ }
+
+ & li::after {
+ content: "";
+ display: block;
+ position: absolute;
+ inset: 0;
+ background-color: var(--cd-brand-color);
+ border-radius: 0.25rem;
+ opacity: 0;
+ transition: opacity 0.2s ease-in-out;
+ z-index: -1;
+ }
+
+ & li:has(a.active)::after {
+ opacity: 0.15;
+ }
+
+ & a {
+ display: flex;
+ align-items: center;
+ color: rgb(82 82 91);
+ padding: 0.3rem 0 0.3rem 0.5rem;
+ }
+ & a:is(.dark *) {
+ color: rgb(161 161 170);
+ }
+ & a:hover:not(.active) {
+ & span {
+ text-decoration: underline;
+ }
+ }
+
+ & li.indent-0 a {
+ padding-left: 0rem;
+ font-size: smaller;
+ text-transform: uppercase;
+ font-weight: bold;
+ border-bottom-width: 1px;
+ }
+ & li.indent-1 a {
+ padding-left: 0rem;
+ font-weight: bold;
+ }
+ & li.indent-2 a { padding-left: 1rem; }
+ & li.indent-3 a { padding-left: 1.5rem; }
+ & li.indent-4 a { padding-left: 2rem; }
+ & li.indent-5 a { padding-left: 2.5rem; }
+ & li.indent-6 a { padding-left: 3rem; }
+
+ & li a::before {
+ content: "";
+ display: inline-flex;
+ align-items: center;
+ justify-content: right;
+ line-height: 1;
+ height: 8px;
+ width: 8px;
+ margin: 0 0.5rem 0 0.5rem;
+ flex-grow: 0;
+ flex-shrink: 0;
+ }
+ li.indent-2 a::before { content: "○" }
+ li.indent-3 a::before { content: "•" }
+ li.indent-4 a::before { content: "·" }
+ li.indent-5 a::before { content: "⁃" }
+ li.indent-6 a::before { content: "·" }
+
+ & li a.active::before {
+ content: "";
+ border-radius: 3px;
+ background-color: var(--cd-brand-color);
+ }
+}
+
+/* ---------------------------------------------------------------------- */
+
+.cd-nav-global,
+.cd-nav-local,
+.cd-nav-mobile {
+ display: none;
+}
+.cd-nav-mobile:popover-open,
+.cd-nav-top .cd-toggle-sidebar {
+ display: block;
+}
+
+@media (min-width: 924px) {
+ .cd-nav-mobile,
+ .cd-nav-top .cd-toggle-sidebar {
+ display: none;
+ }
+}
+
+@media (min-width: 924px) {
+ .cd-nav-global {
+ display: block;
+ }
+}
+
+@media (min-width: 1024px) {
+ .cd-page .page-wrapper > main {
+ margin-left: 2.5rem;
+ margin-right: 2.5rem;
+ }
+ .cd-nav-local {
+ display: block;
+ }
+}
diff --git a/docs/theme/Autodoc.jinja b/docs/theme/Autodoc.jinja
new file mode 100644
index 0000000..e1a967c
--- /dev/null
+++ b/docs/theme/Autodoc.jinja
@@ -0,0 +1,127 @@
+{#def
+ obj: dict | None = None,
+ name: str = "",
+ level: int = 2,
+ members: bool = True,
+#}
+
+{% set obj = obj or autodoc(name) %}
+
+
+ {{ obj.symbol }}
+ {{ name or obj.name }}
+ {% if obj.label -%}
+
+ {{ obj.label }}
+
+ {%- endif %}
+
+
+{%- if obj.short_description -%}
+
+ {{ obj.short_description | markdown | utils.widont }}
+
+{% endif -%}
+
+{%- if obj.signature -%}
+
+{% filter markdown -%}
+```python
+{{ obj.signature }}
+```
+{%- endfilter %}
+
+{%- endif %}
+
+{% if obj.bases -%}
+
+
Bases:
+ {%- for base in obj.bases %} {{ base }}
{% if not loop.last %}, {% endif %}
+ {%- endfor %}
+
+
+{%- endif %}
+
+{% if obj.params -%}
+
+ Argument Description
+
+
+{%- for param in obj.params %}
+
+ {{ param.name }}
+ {{ param.description | markdown | utils.widont }}
+
+{%- endfor %}
+
+
+{%- endif %}
+
+{%- if obj.description -%}
+
+ {{ obj.description | markdown | utils.widont }}
+
+{% endif -%}
+
+{% if obj.examples -%}
+
+
Example:
+
+{% for ex in obj.examples -%}
+
+{% if ex.description %}{{ ex.description | markdown | utils.widont }}{% endif %}
+{% if ex.snippet %}{{ ex.snippet }}{% endif %}
+
+{% endfor -%}
+
+{%- endif %}
+
+{% if obj.returns -%}
+
+ Returns:
+
+ {% if ex.returns -%}
+ {{ obj.returns }}
+ {%- endif %}
+ {% if ex.many_returns -%}
+
+ {% for return in ex.many_returns %}
+ {{ return }}
+ {%- endfor %}
+
+ {%- endif %}
+
+{%- endif %}
+
+{% if obj.raises -%}
+
+
Raises:
+
+
+ {% for raises in obj.raises -%}
+ {{ raises.description | markdown | utils.widont }}
+
+{%- endif %}
+
+{% if members -%}
+ {% if obj.attrs or obj.properties-%}
+
+ {% for attr in obj.attrs -%}
+
+ {% endfor %}
+ {% for attr in obj.properties %}
+
+ {%- endfor %}
+
+ {%- endif %}
+
+ {% if obj.methods -%}
+
+ {% for method in obj.methods %}
+
+ {%- endfor %}
+
+ {%- endif %}
+{%- endif %}
\ No newline at end of file
diff --git a/docs/theme/Callout.jinja b/docs/theme/Callout.jinja
new file mode 100644
index 0000000..4279b3a
--- /dev/null
+++ b/docs/theme/Callout.jinja
@@ -0,0 +1,45 @@
+{#def title="", type="info", icon="", open=True #}
+
+{% set icons = {
+ "note": "sticky_note",
+ "info": "info",
+ "tip": "check_circle",
+ "alert": "release_alert",
+ "warning": "warning",
+ "danger": "release_alert",
+ "error": "release_alert",
+ "internal": "rocket_launch",
+ "todo": "checklist",
+} %}
+
+{% if icon != False %}
+ {% set icon = icon or icons.get(type) %}
+{% endif %}
+
+{% do attrs.set(class="type-" + type or "none") %}
+
+{% if title -%}
+
+
+
+ {% if icon -%}
+ {{ icon }}
+ {% endif -%}
+ {{ title }}
+ keyboard_arrow_down
+
+ {{content}}
+
+
+{%- else -%}
+
+
+ {% if icon -%}
+
+ {{ icon }}
+
+ {%- endif %}
+ {{content}}
+
+
+{%- endif %}
diff --git a/docs/theme/ExampleTabs.jinja b/docs/theme/ExampleTabs.jinja
new file mode 100644
index 0000000..0853ec5
--- /dev/null
+++ b/docs/theme/ExampleTabs.jinja
@@ -0,0 +1,27 @@
+{#def prefix, panels={} #}
+
+
+
+
+ {%- for text in panels.keys() %}
+ {{ text }}
+ {%- endfor %}
+
+ {%- for name in panels.values() %}
+
+ {{ catalog.irender(name) }}
+
+ {%- endfor %}
+
+
diff --git a/docs/theme/Footer.jinja b/docs/theme/Footer.jinja
new file mode 100644
index 0000000..a9e9c5a
--- /dev/null
+++ b/docs/theme/Footer.jinja
@@ -0,0 +1,10 @@
+
diff --git a/docs/theme/Header.jinja b/docs/theme/Header.jinja
new file mode 100644
index 0000000..1b719cf
--- /dev/null
+++ b/docs/theme/Header.jinja
@@ -0,0 +1,17 @@
+{#def title="", section="" #}
+
+{% set section = section or page.section if section != false else None %}
+{% set title = title or page.title %}
+
+
diff --git a/docs/theme/Layout.jinja b/docs/theme/Layout.jinja
new file mode 100644
index 0000000..e76046f
--- /dev/null
+++ b/docs/theme/Layout.jinja
@@ -0,0 +1,25 @@
+{#def title="", description="" #}
+
+
+
+
+
+
+
+
+
+
+
+{{ catalog.render_assets() }}
+{% if page.prev_page and page.prev_page.url -%}
+
+{% endif -%}
+{% if page.next_page and page.next_page.url -%}
+
+{% endif -%}
+
+
+
+{{ content }}
+
+
diff --git a/docs/theme/MetaTags.jinja b/docs/theme/MetaTags.jinja
new file mode 100644
index 0000000..2639afb
--- /dev/null
+++ b/docs/theme/MetaTags.jinja
@@ -0,0 +1,22 @@
+{#def page #}
+
+{% set DEFAULT_TITLE = "JinjaX Documentation" %}
+{% set title = (page.title + " | " + DEFAULT_TITLE) if page.title else DEFAULT_TITLE %}
+{% set description = page.description %}
+
+{{ title }}
+
+
+
+
+
+{% if description -%}
+
+
+{%- endif %}
+
+
+
+
+
+
diff --git a/docs/theme/NavBar.jinja b/docs/theme/NavBar.jinja
new file mode 100644
index 0000000..50f8ca2
--- /dev/null
+++ b/docs/theme/NavBar.jinja
@@ -0,0 +1,3 @@
+
+{{ content }}
+
\ No newline at end of file
diff --git a/docs/theme/NavGlobal.jinja b/docs/theme/NavGlobal.jinja
new file mode 100644
index 0000000..1171db0
--- /dev/null
+++ b/docs/theme/NavGlobal.jinja
@@ -0,0 +1,3 @@
+
+
+
diff --git a/docs/theme/NavLocal.jinja b/docs/theme/NavLocal.jinja
new file mode 100644
index 0000000..2af7606
--- /dev/null
+++ b/docs/theme/NavLocal.jinja
@@ -0,0 +1,5 @@
+
diff --git a/docs/theme/NavMobile.jinja b/docs/theme/NavMobile.jinja
new file mode 100644
index 0000000..4126fb0
--- /dev/null
+++ b/docs/theme/NavMobile.jinja
@@ -0,0 +1,18 @@
+{% do attrs.set(id="navMobile", class="cd-nav-mobile", data_component="NavMobile") %}
+
+
+
+
+
+
diff --git a/docs/theme/NavTop.jinja b/docs/theme/NavTop.jinja
new file mode 100644
index 0000000..8518391
--- /dev/null
+++ b/docs/theme/NavTop.jinja
@@ -0,0 +1,17 @@
+
diff --git a/docs/theme/Page.jinja b/docs/theme/Page.jinja
new file mode 100644
index 0000000..8fec014
--- /dev/null
+++ b/docs/theme/Page.jinja
@@ -0,0 +1,19 @@
+
+
+
+
+ {{ content }}
+
+
+
+
+
+
diff --git a/docs/theme/PageSingle.jinja b/docs/theme/PageSingle.jinja
new file mode 100644
index 0000000..d89fd49
--- /dev/null
+++ b/docs/theme/PageSingle.jinja
@@ -0,0 +1,10 @@
+
+
+ {{ content }}
+
+
+
diff --git a/docs/theme/PrevNext.jinja b/docs/theme/PrevNext.jinja
new file mode 100644
index 0000000..9c6a572
--- /dev/null
+++ b/docs/theme/PrevNext.jinja
@@ -0,0 +1,26 @@
+{#def curr, prev, next #}
+
+
+ {% if prev.url -%}
+
+ ←
+
+
+ {{ prev.section or "Previous" if prev.section != curr.section else "Previous" }}
+
+
{{ prev.title }}
+
+
+ {%- endif %}
+ {% if next.url -%}
+
+
+
+ {{ next.section or "Next" if next.section != curr.section else "Next" }}
+
+
{{ next.title }}
+
+ →
+
+ {%- endif %}
+
diff --git a/docs/theme/SocialCard.jinja b/docs/theme/SocialCard.jinja
new file mode 100644
index 0000000..2fe00be
--- /dev/null
+++ b/docs/theme/SocialCard.jinja
@@ -0,0 +1,61 @@
+{#def page #}
+
+
+
+
+
+
+
{{ page.section }}
+
{{ page.title | utils.widont }}
+
{{ page.description | utils.widont }}
+
+
+
diff --git a/docs/theme/Source.jinja b/docs/theme/Source.jinja
new file mode 100644
index 0000000..c742f56
--- /dev/null
+++ b/docs/theme/Source.jinja
@@ -0,0 +1,24 @@
+{# def url: str, label: str = "" #}
+{% do attrs.set(href=url, target="_blank") %}
+{% set icon = url.replace("http://", "").replace("https://", "").split(".")[0] %}
+
+
+
+ {% if icon == "github" -%}
+
+ {% elif icon == "gitlab" -%}
+
+ {%- else -%}
+
+ {%- endif %}
+
+
+
{{ label or url.split("/", 3)[-1] }}
+
+
+
\ No newline at end of file
diff --git a/docs/theme/Source.js b/docs/theme/Source.js
new file mode 100644
index 0000000..e627460
--- /dev/null
+++ b/docs/theme/Source.js
@@ -0,0 +1,123 @@
+const ATTR_FACT = "data-fact";
+const CLASS_FACTS = "cd-source__facts";
+const CLASS_FACTS_VISIBLE = `${CLASS_FACTS}--visible`;
+
+document.addEventListener("DOMContentLoaded", function () {
+ document.querySelectorAll('[data-component="Source"]').forEach(showFacts);
+});
+
+function showFacts(node) {
+ function renderFacts(facts) {
+ Array.from(node.querySelectorAll(`[${ATTR_FACT}]`))
+ .forEach(function(node) {
+ const name = node.getAttribute(ATTR_FACT);
+ if (facts[name]) {
+ node.removeAttribute("hidden");
+ node.innerText = facts[name];
+ }
+ });
+
+ node.querySelector(`.${CLASS_FACTS}`).classList.add(CLASS_FACTS_VISIBLE);
+ }
+
+ getSourceFacts(node.href, renderFacts);
+}
+
+function getSourceFacts(url, callback) {
+ const key = `Source:${url}`;
+ let facts = sessionStorage.getItem(key);
+ if (facts) {
+ callback(JSON.parse(facts));
+ return;
+ }
+
+ fetchSourceFacts(url)
+ .then((facts) => {
+ if (facts && Object.keys(facts).length) {
+ sessionStorage.setItem(key, JSON.stringify(facts));
+ callback(facts);
+ }
+ });
+}
+
+function fetchJSON(url) {
+ return fetch(url)
+ .then(response => response.json())
+ .catch((error) => {
+ console.log(error);
+ });
+}
+
+function fetchSourceFacts(url) {
+ /* Try to match GitHub repository */
+ let match = url.match(/^.+github\.com\/([^/]+)\/?([^/]+)?/i);
+ if (match) {
+ const [, user, repo] = match;
+ return fetchSourceFactsFromGitHub(user, repo);
+ }
+
+ /* Try to match GitLab repository */
+ match = url.match(/^.+?([^/]*gitlab[^/]+)\/(.+?)\/?$/i);
+ if (match) {
+ const [, base, slug] = match;
+ return fetchSourceFactsFromGitLab(base, slug);
+ }
+
+ /* Fallback */
+ return null;
+}
+
+function fetchSourceFactsFromGitLab(base, project) {
+ const url = `https://${base}/api/v4/projects/${encodeURIComponent(project)}`
+
+ fetchJSON(url)
+ .then(function({ star_count, forks_count }) {
+ return {
+ stars: star_count,
+ forks: forks_count,
+ };
+ });
+}
+
+function fetchSourceFactsFromGitHub (user, repo) {
+ if (typeof repo === "undefined") {
+ return fetchSourceFactsFromGitHubOrg(user);
+ } else {
+ return fetchSourceFactsFromGitHubRepo(user, repo);
+ }
+}
+
+function fetchSourceFactsFromGitHubOrg(user) {
+ const url = `https://api.github.com/users/${user}`
+
+ fetchJSON(url)
+ .then(function(data) {
+ return {
+ numrepos: data.public_repos,
+ };
+ });
+}
+
+function fetchSourceFactsFromGitHubRepo(user, repo) {
+ const url = `https://api.github.com/repos/${user}/${repo}`
+
+ const release = fetchJSON(`${url}/releases/latest`)
+ .then((data) => {
+ return {
+ version: data.tag_name,
+ };
+ });
+
+ const info = fetchJSON(url)
+ .then((data) => {
+ return {
+ stars: data.stargazers_count,
+ forks: data.forks_count,
+ };
+ });
+
+ return Promise.all([release, info])
+ .then(([release, info]) => {
+ return { ...release, ...info };
+ });
+}
diff --git a/docs/theme/Test.jinja b/docs/theme/Test.jinja
new file mode 100644
index 0000000..00176ce
--- /dev/null
+++ b/docs/theme/Test.jinja
@@ -0,0 +1,6 @@
+
+
+
+{{ content }}
+
+
\ No newline at end of file
diff --git a/docs/theme/ThemeSwitch.jinja b/docs/theme/ThemeSwitch.jinja
new file mode 100644
index 0000000..3543b73
--- /dev/null
+++ b/docs/theme/ThemeSwitch.jinja
@@ -0,0 +1,36 @@
+{#def text=true #}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {% if text -%}
+ Light
+ Dark
+ {%- endif %}
+
diff --git a/docs/theme/ThemeSwitch.js b/docs/theme/ThemeSwitch.js
new file mode 100644
index 0000000..c8b2847
--- /dev/null
+++ b/docs/theme/ThemeSwitch.js
@@ -0,0 +1,41 @@
+import { on } from "./jxui.js";
+
+const SEL_TARGET = ".cd-theme-switch";
+const STORAGE_KEY = "theme";
+
+const DARK = "dark";
+const LIGHT = "light";
+const theme = {value: getColorPreference()};
+
+reflectPreference();
+on("click", SEL_TARGET, onClick);
+// sync with system changes
+window
+ .matchMedia("(prefers-color-scheme: dark)")
+ .addEventListener("change", ({matches:isDark}) => {
+ theme.value = isDark ? DARK : LIGHT
+ setPreference()
+ });
+
+function onClick (event, target) {
+ if (target.matches("[disabled]")) return;
+ theme.value = theme.value === LIGHT ? DARK : LIGHT;
+ setPreference();
+}
+function setPreference () {
+ localStorage.setItem(STORAGE_KEY, theme.value);
+ reflectPreference();
+}
+function reflectPreference () {
+ const value = getColorPreference ();
+ if (value === DARK) {
+ document.documentElement.classList.add(DARK);
+ document.documentElement.classList.remove(LIGHT);
+ } else {
+ document.documentElement.classList.add(LIGHT);
+ document.documentElement.classList.remove(DARK);
+ }
+}
+function getColorPreference () {
+ return localStorage.getItem(STORAGE_KEY);
+}
\ No newline at end of file
diff --git a/docs/theme/Toc.jinja b/docs/theme/Toc.jinja
new file mode 100644
index 0000000..2670b62
--- /dev/null
+++ b/docs/theme/Toc.jinja
@@ -0,0 +1,45 @@
+{# def toc, page #}
+
+{% macro render_page(url, title) %}
+{% if url != "/" -%}
+
+{%- endif %}
+{% endmacro %}
+
+
+{% macro render_collapsable(title, children) %}
+
+ {% if title %}{{ title }} {% endif %}
+ {{ render_children(children) }}
+
+{% endmacro %}
+
+
+{% macro render_section(title, children) %}
+
+ {% if title %}{{ title }} {% endif %}
+ {{ render_children(children) }}
+
+{% endmacro %}
+
+
+{% macro render_children(children, collapsable=True) %}
+ {%- for url, title, sub_children in children %}
+ {% if sub_children -%}
+ {% if collapsable -%}
+ {{ render_collapsable(title, sub_children) }}
+ {%- else -%}
+ {{ render_section(title, sub_children) }}
+ {%- endif %}
+ {%- else -%}
+ {{ render_page(url, title) }}
+ {%- endif %}
+ {%- endfor %}
+{% endmacro %}
+
+
+
+ {{ render_children(toc, collapsable=False) }}
+
\ No newline at end of file
diff --git a/docs/theme/TocPage.jinja b/docs/theme/TocPage.jinja
new file mode 100644
index 0000000..754b624
--- /dev/null
+++ b/docs/theme/TocPage.jinja
@@ -0,0 +1,21 @@
+{#def page_toc, max_depth=3 #}
+
+{% macro render_sub_items(pages) %}
+{%- for section in pages %}
+
+ {{ section.name }}
+
+ {% if section.level <= max_depth -%}
+ {{ render_sub_items(section.children) }}
+ {%- endif %}
+{%- endfor %}
+{% endmacro %}
+
+
+{%- for section in page_toc %}
+
+ {{ section.name }}
+
+ {{ render_sub_items(section.children) }}
+{%- endfor %}
+
diff --git a/docs/theme/TocPage.js b/docs/theme/TocPage.js
new file mode 100644
index 0000000..77bad1e
--- /dev/null
+++ b/docs/theme/TocPage.js
@@ -0,0 +1,97 @@
+import { on } from "./jxui.js";
+
+const ACTIVE = "active";
+const SEL_BACKTOTOP = ".cd-back-to-top"
+const SEL_PAGETOC = ".cd-toc-page"
+const SEL_TARGET = `${SEL_PAGETOC} a`;
+const SEL_ACTIVE = `${SEL_TARGET}.${ACTIVE}`;
+const SEL_PAGE = "#main.page";
+const SEL_SECTIONS = `${SEL_PAGE} section[id]`;
+const DESKTOP_THRESHOLD = 1024;
+
+on("click", SEL_TARGET, handleClick);
+on("click", SEL_BACKTOTOP, backToTop);
+
+function handleClick(event, target) {
+ removeHighlight();
+ setTimeout(function () { updateHighlight(target) }, 10);
+}
+
+function updateHighlight (elem) {
+ if (window.innerWidth > DESKTOP_THRESHOLD && !elem?.classList.contains(ACTIVE)) {
+ removeHighlight();
+ if (!elem) return;
+ elem.classList.add(ACTIVE);
+ }
+}
+
+function removeHighlight () {
+ document.querySelectorAll(SEL_ACTIVE).forEach(function (node) {
+ node.classList.remove(ACTIVE);
+ });
+}
+
+function resetNavPosition () {
+ var pagetoc = document.querySelector(SEL_TOC);
+ pagetoc?.scroll({ top: 0 });
+}
+
+export function backToTop () {
+ window.scrollTo({ top: 0, behavior: "smooth" });
+ resetNavPosition();
+}
+
+export function scrollSpy() {
+ const sections = Array.from(document.querySelectorAll(SEL_SECTIONS));
+
+ function matchingNavLink(elem) {
+ if (!elem) return;
+ var index = sections.indexOf(elem);
+
+ var match;
+ while (index >= 0 && !match) {
+ var sectionId = sections[index].getAttribute("id");
+ if (sectionId) {
+ match = document.querySelector(`${SEL_PAGETOC} [href="#${sectionId}"]`);
+ }
+ index--;
+ }
+ return match;
+ }
+
+ function belowBottomHalf(i) {
+ return i.boundingClientRect.bottom > (i.rootBounds.bottom + i.rootBounds.top) / 2;
+ }
+
+ function prevElem(elem) {
+ var index = sections.indexOf(elem);
+ if (index <= 0) {
+ return null;
+ }
+ return sections[index - 1];
+ }
+
+ const PAGE_LOAD_BUFFER = 1000;
+
+ function navHighlight(entries) {
+ entries.forEach(function (entry) {
+ if (entry.isIntersecting) {
+ updateHighlight(matchingNavLink(entry.target));
+ } else if (entry.time >= PAGE_LOAD_BUFFER && belowBottomHalf(entry)) {
+ updateHighlight(matchingNavLink(prevElem(entry.target)));
+ }
+ });
+ }
+
+ const observer = new IntersectionObserver(navHighlight, {
+ threshold: 0,
+ rootMargin: "0% 0px -95% 0px"
+ });
+
+ sections.forEach(function (elem) {
+ observer.observe(elem);
+ })
+ observer.observe(document.querySelector(SEL_PAGE));
+}
+
+document.addEventListener("DOMContentLoaded", scrollSpy);
diff --git a/jinjax-logo.png b/jinjax-logo.png
new file mode 100644
index 0000000..941df9f
Binary files /dev/null and b/jinjax-logo.png differ
diff --git a/poetry.lock b/poetry.lock
index 6bd91d8..5bcb8e2 100644
--- a/poetry.lock
+++ b/poetry.lock
@@ -1,4 +1,4 @@
-# This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand.
+# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand.
[[package]]
name = "cachetools"
@@ -355,13 +355,13 @@ testing = ["covdefaults (>=2.3)", "pytest (>=8.2.2)", "pytest-cov (>=5)", "pytes
[[package]]
name = "pyright"
-version = "1.1.369"
+version = "1.1.377"
description = "Command line wrapper for pyright"
optional = false
python-versions = ">=3.7"
files = [
- {file = "pyright-1.1.369-py3-none-any.whl", hash = "sha256:06d5167a8d7be62523ced0265c5d2f1e022e110caf57a25d92f50fb2d07bcda0"},
- {file = "pyright-1.1.369.tar.gz", hash = "sha256:ad290710072d021e213b98cc7a2f90ae3a48609ef5b978f749346d1a47eb9af8"},
+ {file = "pyright-1.1.377-py3-none-any.whl", hash = "sha256:af0dd2b6b636c383a6569a083f8c5a8748ae4dcde5df7914b3f3f267e14dd162"},
+ {file = "pyright-1.1.377.tar.gz", hash = "sha256:aabc30fedce0ded34baa0c49b24f10e68f4bfc8f68ae7f3d175c4b0f256b4fcf"},
]
[package.dependencies]
diff --git a/pyproject.toml b/pyproject.toml
index 693d296..e5836e6 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -5,7 +5,7 @@ build-backend = "poetry.core.masonry.api"
[tool.poetry]
name = "jinjax"
-version = "0.45"
+version = "0.46"
description = "Replace your HTML templates with Python server-Side components"
authors = ["Juan-Pablo Scaletti "]
license = "MIT"
diff --git a/src/jinjax/catalog.py b/src/jinjax/catalog.py
index c70f81d..d0d0635 100644
--- a/src/jinjax/catalog.py
+++ b/src/jinjax/catalog.py
@@ -1,6 +1,7 @@
import os
import typing as t
from collections import UserString
+from contextvars import ContextVar
from hashlib import sha256
from pathlib import Path
@@ -22,6 +23,10 @@ DEFAULT_EXTENSION = ".jinja"
ARGS_ATTRS = "attrs"
ARGS_CONTENT = "content"
+# Create ContextVars containers at module level
+collected_css: dict[int, ContextVar[list[str]]] = {}
+collected_js: dict[int, ContextVar[list[str]]] = {}
+
class CallerWrapper(UserString):
def __init__(self, caller: t.Callable | None, content: str = "") -> None:
@@ -42,7 +47,6 @@ class CallerWrapper(UserString):
return self()
-
class Catalog:
"""
The object that manages the components and their global settings.
@@ -50,12 +54,12 @@ class Catalog:
Arguments:
globals:
- Dictionary of Jinja globals to add to the Catalog's Jinja environment
- (or the one passed in `jinja_env`).
+ Dictionary of Jinja globals to add to the Catalog's Jinja
+ environment (or the one passed in `jinja_env`).
filters:
- Dictionary of Jinja filters to add to the Catalog's Jinja environment
- (or the one passed in `jinja_env`).
+ Dictionary of Jinja filters to add to the Catalog's Jinja
+ environment (or the one passed in `jinja_env`).
tests:
Dictionary of Jinja tests to add to the Catalog's Jinja environment
@@ -63,34 +67,36 @@ class Catalog:
extensions:
List of Jinja extensions to add to the Catalog's Jinja environment
- (or the one passed in `jinja_env`). The `jinja2.ext.do` extension is
- always added at the end of these.
+ (or the one passed in `jinja_env`). The `jinja2.ext.do` extension
+ is always added at the end of these.
jinja_env:
- Custom Jinja environment to use. This argument is useful to reuse an
- existing Jinja Environment from your web framework.
+ Custom Jinja environment to use. This argument is useful to reuse
+ an existing Jinja Environment from your web framework.
root_url:
- Add this prefix to every asset URL of the static middleware. By default,
- it is `/static/components/`, so, for example, the URL of the CSS file of
- a `Card` component is `/static/components/Card.css`.
+ Add this prefix to every asset URL of the static middleware.
+ By default, it is `/static/components/`, so, for example,
+ the URL of the CSS file of a `Card` component is
+ `/static/components/Card.css`.
- You can also change this argument so the assets are requested from a
- Content Delivery Network (CDN) in production, for example,
+ You can also change this argument so the assets are requested from
+ a Content Delivery Network (CDN) in production, for example,
`root_url="https://example.my-cdn.com/"`.
file_ext:
The extensions the components files have. By default, ".jinja".
- This argument can also be a list to allow more than one type of file to
- be a component.
+ This argument can also be a list to allow more than one type of
+ file to be a component.
use_cache:
Cache the metadata of the component in memory.
auto_reload:
- Used with `use_cache`. If `True`, the last-modified date of the component
- file is checked every time to see if the cache is up-to-date.
+ Used with `use_cache`. If `True`, the last-modified date of the
+ component file is checked every time to see if the cache
+ is up-to-date.
Set to `False` in production.
@@ -98,12 +104,12 @@ class Catalog:
If `True`, inserts a hash of the updated time into the URL of the
asset files (after the name but before the extension).
- This strategy encourages long-term caching while ensuring that new copies
- are only requested when the content changes, as any modification alters the
- fingerprint and thus the filename.
+ This strategy encourages long-term caching while ensuring that
+ new copies are only requested when the content changes, as any
+ modification alters the fingerprint and thus the filename.
- **WARNING**: Only works if the server knows how to filter the fingerprint
- to get the real name of the file.
+ **WARNING**: Only works if the server knows how to filter the
+ fingerprint to get the real name of the file.
Attributes:
@@ -124,12 +130,11 @@ class Catalog:
"file_ext",
"jinja_env",
"fingerprint",
- "collected_css",
- "collected_js",
"auto_reload",
"use_cache",
"_tmpl_globals",
"_cache",
+ "_key",
)
def __init__(
@@ -141,14 +146,14 @@ class Catalog:
extensions: "list | None" = None,
jinja_env: "jinja2.Environment | None" = None,
root_url: str = DEFAULT_URL_ROOT,
- file_ext: "str | tuple[str, ...]" = DEFAULT_EXTENSION,
+ file_ext: "str | list[str] | tuple[str, ...]" = DEFAULT_EXTENSION,
use_cache: bool = True,
auto_reload: bool = True,
fingerprint: bool = False,
) -> None:
self.prefixes: dict[str, jinja2.FileSystemLoader] = {}
- self.collected_css: list[str] = []
- self.collected_js: list[str] = []
+ if isinstance(file_ext, list):
+ file_ext = tuple(file_ext)
self.file_ext = file_ext
self.use_cache = use_cache
self.auto_reload = auto_reload
@@ -186,11 +191,49 @@ class Catalog:
self._tmpl_globals: "t.MutableMapping[str, t.Any] | None" = None
self._cache: dict[str, dict] = {}
+ self._key = id(self)
+
+ def __del__(self) -> None:
+ name = f"collected_css_{self._key}"
+ if name in collected_css:
+ del collected_css[name]
+ name = f"collected_js_{self._key}"
+ if name in collected_js:
+ del collected_js[name]
+
+ @property
+ def collected_css(self) -> list[str]:
+ if self._key not in collected_css:
+ name = f"collected_css_{self._key}"
+ collected_css[self._key] = ContextVar(name, default=[])
+ return collected_css[self._key].get()
+
+ @collected_css.setter
+ def collected_css(self, value: list[str]) -> None:
+ if self._key not in collected_css:
+ name = f"collected_css_{self._key}"
+ collected_css[self._key] = ContextVar(name, default=[])
+ collected_css[self._key].set(list(value))
+
+ @property
+ def collected_js(self) -> list[str]:
+ if self._key not in collected_js:
+ name = f"collected_js_{self._key}"
+ collected_js[self._key] = ContextVar(name, default=[])
+ return collected_js[self._key].get()
+
+ @collected_js.setter
+ def collected_js(self, value: list[str]) -> None:
+ if self._key not in collected_js:
+ name = f"collected_js_{self._key}"
+ collected_js[self._key] = ContextVar(name, default=[])
+ collected_js[self._key].set(list(value))
@property
def paths(self) -> list[Path]:
"""
- A helper property that returns a list of all the components folder paths.
+ A helper property that returns a list of all the components
+ folder paths.
"""
_paths = []
for loader in self.prefixes.values():
@@ -204,15 +247,17 @@ class Catalog:
prefix: str = DEFAULT_PREFIX,
) -> None:
"""
- Add a folder path from where to search for components, optionally under a prefix.
+ Add a folder path from where to search for components, optionally
+ under a prefix.
The prefix acts like a namespace. For example, the name of a
`components/Card.jinja` component is, by default, "Card",
but under the prefix "common", it becomes "common.Card".
- The rule for subfolders remains the same: a `components/wrappers/Card.jinja`
- name is, by default, "wrappers.Card", but under the prefix "common",
- it becomes "common.wrappers.Card".
+ The rule for subfolders remains the same: a
+ `components/wrappers/Card.jinja` name is, by default,
+ "wrappers.Card", but under the prefix "common", it
+ becomes "common.wrappers.Card".
If there is more than one component with the same name in multiple
added folders under the same prefix, the one in the folder added
@@ -228,26 +273,35 @@ class Catalog:
have. The default is empty.
"""
- prefix = prefix.strip().strip(f"{DELIMITER}{SLASH}").replace(SLASH, DELIMITER)
+ prefix = (
+ prefix.strip()
+ .strip(f"{DELIMITER}{SLASH}")
+ .replace(SLASH, DELIMITER)
+ )
root_path = str(root_path)
if prefix in self.prefixes:
loader = self.prefixes[prefix]
if root_path in loader.searchpath:
return
- logger.debug(f"Adding folder `{root_path}` with the prefix `{prefix}`")
+ logger.debug(
+ f"Adding folder `{root_path}` with the prefix `{prefix}`"
+ )
loader.searchpath.append(root_path)
else:
- logger.debug(f"Adding folder `{root_path}` with the prefix `{prefix}`")
+ logger.debug(
+ f"Adding folder `{root_path}` with the prefix `{prefix}`"
+ )
self.prefixes[prefix] = jinja2.FileSystemLoader(root_path)
def add_module(self, module: t.Any, *, prefix: str | None = None) -> None:
"""
- Reads an absolute path from `module.components_path` and an optional prefix
- from `module.prefix`, then calls `Catalog.add_folder(path, prefix)`.
+ Reads an absolute path from `module.components_path` and an optional
+ prefix from `module.prefix`, then calls
+ `Catalog.add_folder(path, prefix)`.
- The prefix can also be passed as an argument instead of being read from
- the module.
+ The prefix can also be passed as an argument instead of being read
+ from the module.
This method exists to make it easy and consistent to have
components installable as Python libraries.
@@ -263,7 +317,9 @@ class Catalog:
"""
mprefix = (
- prefix if prefix is not None else getattr(module, "prefix", DEFAULT_PREFIX)
+ prefix
+ if prefix is not None
+ else getattr(module, "prefix", DEFAULT_PREFIX)
)
self.add_folder(module.components_path, prefix=mprefix)
@@ -314,16 +370,25 @@ class Catalog:
if source:
logger.debug("Rendering from source %s", __name)
- component = self._get_from_source(name=name, prefix=prefix, source=source)
+ component = self._get_from_source(
+ name=name, prefix=prefix, source=source
+ )
elif self.use_cache:
logger.debug("Rendering from cache or file %s", __name)
- component = self._get_from_cache(prefix=prefix, name=name, file_ext=file_ext)
+ component = self._get_from_cache(
+ prefix=prefix, name=name, file_ext=file_ext
+ )
else:
logger.debug("Rendering from file %s", __name)
- component = self._get_from_file(prefix=prefix, name=name, file_ext=file_ext)
+ component = self._get_from_file(
+ prefix=prefix, name=name, file_ext=file_ext
+ )
root_path = component.path.parent if component.path else None
+ css = self.collected_css
+ js = self.collected_js
+
for url in component.css:
if (
root_path
@@ -332,8 +397,8 @@ class Catalog:
):
url = self._fingerprint(root_path, url)
- if url not in self.collected_css:
- self.collected_css.append(url)
+ if url not in css:
+ css.append(url)
for url in component.js:
if (
@@ -343,8 +408,8 @@ class Catalog:
):
url = self._fingerprint(root_path, url)
- if url not in self.collected_js:
- self.collected_js.append(url)
+ if url not in js:
+ js.append(url)
attrs = attrs.as_dict if isinstance(attrs, HTMLAttrs) else attrs
attrs.update(kw)
@@ -368,7 +433,8 @@ class Catalog:
**kwargs,
) -> ComponentsMiddleware:
"""
- Wraps you application with [Withenoise](https://whitenoise.readthedocs.io/),
+ Wraps you application with
+ [Withenoise](https://whitenoise.readthedocs.io/),
a static file serving middleware.
Tecnically not neccesary if your components doesn't use static assets
@@ -380,13 +446,15 @@ class Catalog:
A WSGI application
allowed_ext:
- A list of file extensions the static middleware is allowed to read
- and return. By default, is just ".css", ".js", and ".mjs".
+ A list of file extensions the static middleware is allowed to
+ read and return. By default, is just ".css", ".js", and ".mjs".
"""
logger.debug("Creating middleware")
middleware = ComponentsMiddleware(
- application=application, allowed_ext=tuple(allowed_ext or []), **kwargs
+ application=application,
+ allowed_ext=tuple(allowed_ext or []),
+ **kwargs,
)
for prefix, loader in self.prefixes.items():
url_prefix = get_url_prefix(prefix)
@@ -396,7 +464,11 @@ class Catalog:
return middleware
- def get_source(self, cname: str, file_ext: "tuple[str, ...] | str" = "") -> str:
+ def get_source(
+ self,
+ cname: str,
+ file_ext: "tuple[str, ...] | str" = "",
+ ) -> str:
"""
A helper method that returns the source file of a component.
"""
@@ -445,12 +517,26 @@ class Catalog:
return f"{parent}{stem}-{fingerprint}{ext}"
- def _get_from_source(self, *, name: str, prefix: str, source: str) -> Component:
+ def _get_from_source(
+ self,
+ *,
+ name: str,
+ prefix: str,
+ source: str,
+ ) -> Component:
tmpl = self.jinja_env.from_string(source, globals=self._tmpl_globals)
- component = Component(name=name, prefix=prefix, source=source, tmpl=tmpl)
+ component = Component(
+ name=name, prefix=prefix, source=source, tmpl=tmpl
+ )
return component
- def _get_from_cache(self, *, prefix: str, name: str, file_ext: str) -> Component:
+ def _get_from_cache(
+ self,
+ *,
+ prefix: str,
+ name: str,
+ file_ext: str,
+ ) -> Component:
key = f"{prefix}.{name}.{file_ext}"
cache = self._from_cache(key)
if cache:
@@ -461,7 +547,9 @@ class Catalog:
return component
logger.debug("Loading %s", key)
- component = self._get_from_file(prefix=prefix, name=name, file_ext=file_ext)
+ component = self._get_from_file(
+ prefix=prefix, name=name, file_ext=file_ext
+ )
self._to_cache(key, component)
return component
@@ -475,10 +563,16 @@ class Catalog:
def _to_cache(self, key: str, component: Component) -> None:
self._cache[key] = component.serialize()
- def _get_from_file(self, *, prefix: str, name: str, file_ext: str) -> Component:
- path, tmpl_name = self._get_component_path(prefix, name, file_ext=file_ext)
+ def _get_from_file(
+ self, *, prefix: str, name: str, file_ext: str
+ ) -> Component:
+ path, tmpl_name = self._get_component_path(
+ prefix, name, file_ext=file_ext
+ )
component = Component(name=name, prefix=prefix, path=path)
- component.tmpl = self.jinja_env.get_template(tmpl_name, globals=self._tmpl_globals)
+ component.tmpl = self.jinja_env.get_template(
+ tmpl_name, globals=self._tmpl_globals
+ )
return component
def _split_name(self, cname: str) -> tuple[str, str]:
@@ -492,7 +586,10 @@ class Catalog:
return DEFAULT_PREFIX, cname
def _get_component_path(
- self, prefix: str, name: str, file_ext: "tuple[str, ...] | str" = ""
+ self,
+ prefix: str,
+ name: str,
+ file_ext: "tuple[str, ...] | str" = "",
) -> tuple[Path, str]:
name = name.replace(DELIMITER, SLASH)
root_paths = self.prefixes[prefix].searchpath
@@ -512,7 +609,10 @@ class Catalog:
filepath = f"{relfolder}/{filename}"
else:
filepath = filename
- if filepath.startswith(name_dot) and filepath.endswith(file_ext):
+ if (
+ filepath.startswith(name_dot) and
+ filepath.endswith(file_ext)
+ ):
return Path(curr_folder) / filename, filepath
raise ComponentNotFound(
diff --git a/tests/test_render.py b/tests/test_render.py
index 1e52cda..0f37ea7 100644
--- a/tests/test_render.py
+++ b/tests/test_render.py
@@ -1,6 +1,7 @@
import time
from pathlib import Path
from textwrap import dedent
+from threading import Thread
import jinja2
import pytest
@@ -923,7 +924,7 @@ def test_vue_like_syntax(catalog, folder):
)
html = catalog.render("Caller")
print(html)
- expected = """4 2+2 {'lorem': 'ipsum'} False""".strip()
+ expected = """4 2+2 {'lorem': 'ipsum'} False""".strip()
assert html == Markup(expected)
@@ -937,7 +938,7 @@ def test_jinja_like_syntax(catalog, folder):
)
html = catalog.render("Caller")
print(html)
- expected = """4 2+2 {'lorem': 'ipsum'} False""".strip()
+ expected = """4 2+2 {'lorem': 'ipsum'} False""".strip()
assert html == Markup(expected)
@@ -951,7 +952,7 @@ def test_mixed_syntax(catalog, folder):
)
html = catalog.render("Caller")
print(html)
- expected = """4 {{2+2}} {'lorem': 'ipsum'} False""".strip()
+ expected = """4 {{2+2}} {'lorem': 'ipsum'} False""".strip()
assert html == Markup(expected)
@@ -990,3 +991,130 @@ def test_slots(catalog, folder, autoescape):
Default
""".strip()
assert html == Markup(expected)
+
+
+class ThreadWithReturnValue(Thread):
+ def __init__(self, group=None, target=None, name=None, args=None, kwargs=None):
+ args = args or ()
+ kwargs = kwargs or {}
+ Thread.__init__(
+ self,
+ group=group,
+ target=target,
+ name=name,
+ args=args,
+ kwargs=kwargs,
+ )
+ self._target = target
+ self._args = args
+ self._kwargs = kwargs
+ self._return = None
+
+ def run(self):
+ if self._target is not None:
+ self._return = self._target(*self._args, **self._kwargs)
+
+ def join(self, *args):
+ Thread.join(self, *args)
+ return self._return
+
+
+def test_thread_safety_of_render_assets(catalog, folder):
+ NUM_THREADS = 5
+
+ child_tmpl = """
+{#css "c{i}.css" #}
+{#js "c{i}.js" #}
+Child {i}
""".strip()
+
+ parent_tmpl = """
+{{ catalog.render_assets() }}
+{{ content }}""".strip()
+
+ comp_tmpl = """
+{#css "a{i}.css", "b{i}.css" #}
+{#js "a{i}.js", "b{i}.js" #}
+ """.strip()
+
+ expected_tmpl = """
+
+
+
+
+
+
+Child {i}
""".strip()
+
+ def render(i):
+ return catalog.render(f"Page{i}")
+
+
+ for i in range(NUM_THREADS):
+ si = str(i)
+ child_name = f"Child{i}.jinja"
+ child_src = child_tmpl.replace("{i}", si)
+
+ parent_name = f"Parent{i}.jinja"
+ parent_src = parent_tmpl.replace("{i}", si)
+
+ comp_name = f"Page{i}.jinja"
+ comp_src = comp_tmpl.replace("{i}", si)
+
+ (folder / child_name).write_text(child_src)
+ (folder / comp_name).write_text(comp_src)
+ (folder / parent_name).write_text(parent_src)
+
+ threads = []
+
+ for i in range(NUM_THREADS):
+ thread = ThreadWithReturnValue(target=render, args=(i,))
+ threads.append(thread)
+ thread.start()
+
+ results = [thread.join() for thread in threads]
+
+ for i, result in enumerate(results):
+ expected = expected_tmpl.replace("{i}", str(i))
+ print(f"---- EXPECTED {i}----")
+ print(expected)
+ print(f"---- RESULT {i}----")
+ print(result)
+ assert result == Markup(expected)
+
+
+def test_same_thread_assets_independence(catalog, folder):
+ catalog2 = jinjax.Catalog()
+ catalog2.add_folder(folder)
+
+ print(catalog._key)
+ print(catalog2._key)
+
+ (folder / "Parent.jinja").write_text("""
+{{ catalog.render_assets() }}
+{{ content }}""".strip())
+
+ (folder / "Comp1.jinja").write_text("""
+{#css "a.css" #}
+{#js "a.js" #}
+ """.strip())
+
+ (folder / "Comp2.jinja").write_text("""
+{#css "b.css" #}
+{#js "b.js" #}
+ """.strip())
+
+ expected_1 = """
+
+""".strip()
+
+ expected_2 = """
+
+""".strip()
+
+ html1 = catalog.render("Comp1")
+ # `irender` instead of `render` so the assets are not cleared
+ html2 = catalog2.irender("Comp2")
+ print(html1)
+ print(html2)
+ assert html1 == Markup(expected_1)
+ assert html2 == Markup(expected_2)