Skip to content

Commit ddbf6c1

Browse files
committed
Use bootstrap's collapse feature to show/hide entity features
1 parent 5ccbb00 commit ddbf6c1

File tree

6 files changed

+59
-28
lines changed

6 files changed

+59
-28
lines changed

src/plugins/roomslist/styles/roomsgroups.scss

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
.conversejs {
2-
32
#chatrooms {
3+
.collapsed {
4+
height: 0 !important;
5+
overflow: hidden !important;
6+
padding: 0 !important;
7+
}
8+
49
.muc-domain-group-toggle {
510
margin: 0.75em 0 0.25em 0;
611
}

src/plugins/rosterview/styles/roster.scss

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
.conversejs {
2-
32
#controlbox {
3+
.collapsed {
4+
height: 0 !important;
5+
overflow: hidden !important;
6+
padding: 0 !important;
7+
}
8+
49
.open-contacts-toggle, .open-contacts-toggle .fa {
510
color: var(--chat-color) !important;
611
&:hover {

src/plugins/todo/modals/add-todo-modal.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { default as Collapse } from 'bootstrap/js/src/collapse.js';
12
import { _converse, api, converse, parsers } from '@converse/headless';
23
import BaseModal from 'plugins/modal/modal.js';
34
import { __ } from 'i18n';
@@ -6,7 +7,6 @@ import tplAddTodo from './templates/add-todo-modal.js';
67
const { Strophe } = converse.env;
78

89
export default class AddTodoModal extends BaseModal {
9-
1010
static get properties() {
1111
return {
1212
...super.properties,
@@ -27,6 +27,14 @@ export default class AddTodoModal extends BaseModal {
2727
);
2828
}
2929

30+
/**
31+
* @param {import('lit').PropertyValues} changed
32+
*/
33+
firstUpdated(changed) {
34+
super.firstUpdated(changed);
35+
this.collapse = new Collapse(/** @type {HTMLElement} */ (this));
36+
}
37+
3038
renderModal() {
3139
return tplAddTodo(this);
3240
}

src/plugins/todo/modals/templates/add-todo-modal.js

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,41 @@ export default (el) => {
2121
? html`<div class="mb-3">
2222
<label class="form-label">${__('Available PubSub services:')}</label>
2323
<div class="list-group">
24-
${el._entities.map(/** @param {import('@converse/headless').DiscoEntity} entity */(entity) => {
25-
const jid = entity.get('jid');
26-
const features = entity.features
27-
.map((f) => f.get('var'))
28-
.filter((f) => f.includes('pubsub'));
29-
return html`<div class="form-check">
30-
<input
31-
class="form-check-input"
32-
type="radio"
33-
name="pubsub_service"
34-
id="${jid}"
35-
value="${jid}"
36-
/>
37-
<label class="form-check-label fw-bold" for="${jid}">${jid}</label>
38-
<ul class="list-unstyled mt-2 text-muted small">
39-
${features.map((feature) => html`<li>${feature}</li>`)}
40-
</ul>
41-
</div>`;
42-
})}
24+
${el._entities.map(
25+
/** @param {import('@converse/headless').DiscoEntity} entity */ (entity) => {
26+
const jid = entity.get('jid');
27+
const features = entity.features
28+
.map((f) => f.get('var'))
29+
.filter((f) => f.includes('pubsub'));
30+
return html`<div class="form-check">
31+
<input
32+
class="form-check-input"
33+
type="radio"
34+
name="jid"
35+
id="${jid}"
36+
value="${jid}"
37+
/>
38+
<label class="form-check-label fw-bold" for="${jid}">${jid}</label>
39+
<button
40+
class="btn btn-link p-0"
41+
type="button"
42+
data-bs-toggle="collapse"
43+
data-bs-target="#collapse-${jid}"
44+
aria-expanded="false"
45+
aria-controls="collapse-${jid}"
46+
>
47+
${__('Show Features')}
48+
</button>
49+
<div class="collapse" id="collapse-${jid}">
50+
<div class="card card-body">
51+
<ul class="list-unstyled mt-2 text-muted small">
52+
${features.map((feature) => html`<li>${feature}</li>`)}
53+
</ul>
54+
</div>
55+
</div>
56+
</div>`;
57+
}
58+
)}
4359
</div>
4460
</div>`
4561
: html`<div class="mb-3">

src/shared/components/dropdownbase.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import EventHandler from "bootstrap/js/src/dom/event-handler.js";
33
import { CustomElement } from "./element.js";
44

55
export default class DropdownBase extends CustomElement {
6+
/**
7+
* @param {import('lit').PropertyValues} changed
8+
*/
69
firstUpdated(changed) {
710
super.firstUpdated(changed);
811
this.menu = this.querySelector(".dropdown-menu");

src/shared/styles/_core.scss

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -383,12 +383,6 @@
383383
animation-timing-function: ease-in-out;
384384
}
385385

386-
.collapsed {
387-
height: 0 !important;
388-
overflow: hidden !important;
389-
padding: 0 !important;
390-
}
391-
392386
.locked {
393387
padding-inline-end: 22px;
394388
}

0 commit comments

Comments
 (0)