) {
@@ -96,5 +94,27 @@ export class TabGroup extends HTMLElement {
}
}
});
+ this.addEventListener("ui-tab-updated", () => {
+ this.render();
+ });
+
+ this.render();
+ }
+
+ render() {
+ const tabs = Array.prototype.slice.call(
+ this.getElementsByTagName("ui-tab"),
+ ) as Tab[];
+ render(
+ html`
+
+
+ ${tabs.map((tab) => tab.getContentTemplate())}
+
+ `,
+ this.node,
+ );
}
}
diff --git a/core/static/core/components/tabs.scss b/core/static/core/components/tabs.scss
new file mode 100644
index 00000000..e8665967
--- /dev/null
+++ b/core/static/core/components/tabs.scss
@@ -0,0 +1,53 @@
+@import "core/static/core/colors";
+
+ui-tab-group {
+ *[hidden] {
+ display: none;
+ }
+
+ .tabs {
+ border-radius: 5px;
+
+ .tab-headers {
+ display: flex;
+ flex-flow: row wrap;
+ background-color: $primary-neutral-light-color;
+ padding: 3px 12px 12px;
+ column-gap: 20px;
+ border-top-left-radius: 5px;
+ border-top-right-radius: 5px;
+
+ .tab-header {
+ border: none;
+ padding-right: 0;
+ padding-left: 0;
+ font-size: 120%;
+ background-color: unset;
+ position: relative;
+
+ &:after {
+ content: '';
+ position: absolute;
+ bottom: 0;
+ left: 0;
+ width: 100%;
+ border-bottom: 4px solid darken($primary-neutral-light-color, 10%);
+ border-radius: 2px;
+ transition: all 0.2s ease-in-out;
+ }
+
+ &:hover:after {
+ border-bottom-color: darken($primary-neutral-light-color, 20%);
+ }
+
+ &.active:after {
+ border-bottom-color: $primary-dark-color;
+ }
+ }
+ }
+
+ section {
+ padding: 20px;
+ }
+ }
+}
\ No newline at end of file
diff --git a/core/static/core/style.scss b/core/static/core/style.scss
index 107126ec..cbc125d7 100644
--- a/core/static/core/style.scss
+++ b/core/static/core/style.scss
@@ -352,52 +352,6 @@ body {
text-align: center;
}
- .tabs {
- border-radius: 5px;
-
- .tab-headers {
- display: flex;
- flex-flow: row wrap;
- background-color: $primary-neutral-light-color;
- padding: 3px 12px 12px;
- column-gap: 20px;
- border-top-left-radius: 5px;
- border-top-right-radius: 5px;
-
- .tab-header {
- border: none;
- padding-right: 0;
- padding-left: 0;
- font-size: 120%;
- background-color: unset;
- position: relative;
-
- &:after {
- content: '';
- position: absolute;
- bottom: 0;
- left: 0;
- width: 100%;
- border-bottom: 4px solid darken($primary-neutral-light-color, 10%);
- border-radius: 2px;
- transition: all 0.2s ease-in-out;
- }
-
- &:hover:after {
- border-bottom-color: darken($primary-neutral-light-color, 20%);
- }
-
- &.active:after {
- border-bottom-color: $primary-dark-color;
- }
- }
- }
-
- section {
- padding: 20px;
- }
- }
-
.tool_bar {
overflow: auto;
padding: 4px;
diff --git a/core/templates/core/macros.jinja b/core/templates/core/macros.jinja
index 40676258..ba42046f 100644
--- a/core/templates/core/macros.jinja
+++ b/core/templates/core/macros.jinja
@@ -245,65 +245,3 @@
{% trans %}Select All{% endtrans %}
{% trans %}Unselect All{% endtrans %}
{% endmacro %}
-
-{% macro tabs(tab_list, attrs = "") %}
- {# Tab component
-
- Parameters:
- tab_list: list[tuple[str, str]] The list of tabs to display.
- Each element of the list is a tuple which first element
- is the title of the tab and the second element its content
- attrs: str Additional attributes to put on the enclosing div
-
- Example:
- A basic usage would be as follow :
-
- {{ tabs([("title 1", "content 1"), ("title 2", "content 2")]) }}
-
- If you want to display more complex logic, you can define macros
- and use those macros in parameters :
-
- {{ tabs([("title", my_macro())]) }}
-
- It's also possible to get and set the currently selected tab using Alpine.
- Here, the title of the currently selected tab will be displayed.
- Moreover, on page load, the tab will be opened on "tab 2".
-
-
-
- {{ tabs([("tab 1", "Hello"), ("tab 2", "World")], "x-model=current_tab") }}
-
-
- If you want to have translated tab titles, you can enclose the macro call
- in a with block :
-
- {% with title=_("title"), content=_("Content") %}
- {{ tabs([(tab1, content)]) }}
- {% endwith %}
- #}
-
-
-
- {% for title, content in tab_list %}
-
- {% endfor %}
-
-
-{% endmacro %}
diff --git a/subscription/templates/subscription/subscription.jinja b/subscription/templates/subscription/subscription.jinja
index 98916827..9046c296 100644
--- a/subscription/templates/subscription/subscription.jinja
+++ b/subscription/templates/subscription/subscription.jinja
@@ -12,6 +12,7 @@
So we give them here.
If the aforementioned bug is resolved, you can remove this. #}
{% block additional_js %}
+
{% endblock %}
{% block additional_css %}
+
@@ -34,12 +36,12 @@
{% block content %}
{% trans %}New subscription{% endtrans %}
-
- {% with title1=_("Existing member"), title2=_("New member") %}
- {{ tabs([
- (title1, form_fragment(existing_user_form, existing_user_post_url)),
- (title2, form_fragment(new_user_form, new_user_post_url)),
- ]) }}
- {% endwith %}
-
+
+
+ {{ form_fragment(existing_user_form, existing_user_post_url) }}
+
+
+ {{ form_fragment(new_user_form, new_user_post_url) }}
+
+
{% endblock %}