diff --git a/src/css/popup.css b/src/css/popup.css index f2423a3..67271fb 100644 --- a/src/css/popup.css +++ b/src/css/popup.css @@ -40,6 +40,7 @@ body { --block-url-label-size: 2rem; /* 24px */ --inline-start-size: 1.66rem; /* 20px */ --inline-button-size: 5.833rem; /* 70px */ + --inline-button-large-size: 11.666rem; /* 140px */ --icon-size: 1.166rem; /* 14px */ --small-text-size: 0.833rem; /* 10px */ @@ -308,6 +309,16 @@ table { transform: rotate(180deg); } +.up-arrow-img { + block-size: 16px; + inline-size: 16px; +} + +.down-arrow-img { + block-size: 16px; + inline-size: 16px; +} + /* Onboarding styles */ .onboarding * { text-align: center; @@ -452,7 +463,8 @@ manage things like container crud */ margin-inline-start: var(--inline-item-space-size); } -#container-panel #sort-containers-link { +#container-panel #sort-containers-link, +#container-panel #sort-containers-list-link { align-items: center; block-size: var(--block-url-label-size); border: 1px solid #d8d8d8; @@ -460,13 +472,23 @@ manage things like container crud */ color: var(--title-text-color); display: flex; font-size: var(--small-text-size); - inline-size: var(--inline-button-size); justify-content: center; text-decoration: none; } +#container-panel #sort-containers-link { + inline-size: var(--inline-button-size); +} + +#container-panel #sort-containers-list-link { + inline-size: var(--inline-button-large-size); + margin-left: 1rem; +} + #container-panel #sort-containers-link:hover, -#container-panel #sort-containers-link:focus { +#container-panel #sort-containers-link:focus, +#container-panel #sort-containers-list-link:hover, +#container-panel #sort-containers-list-link:focus { background: #f2f2f2; } diff --git a/src/img/chevron-down.svg b/src/img/chevron-down.svg new file mode 100644 index 0000000..278c6a3 --- /dev/null +++ b/src/img/chevron-down.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/img/chevron-up.svg b/src/img/chevron-up.svg new file mode 100644 index 0000000..4eb5ecc --- /dev/null +++ b/src/img/chevron-up.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/js/popup.js b/src/js/popup.js index a672017..3e10a12 100644 --- a/src/js/popup.js +++ b/src/js/popup.js @@ -235,6 +235,23 @@ const Logic = { moveTabsEl.parentNode.insertBefore(fragment, moveTabsEl.nextSibling); }, + async sortContainerList(list) { + const update = [...list]; + const result = await browser.storage.local.get({containerSortOrder: null}); + const upArrowElement = document.querySelector("#sort-containers-list-link .up-arrow-img"); + const downArrowElement = document.querySelector("#sort-containers-list-link .down-arrow-img"); + if (result.containerSortOrder === "asc") { + update.sort((a, b) => (a.name.toLowerCase() > b.name.toLowerCase()) ? 1 : -1); + downArrowElement.style.display = "inline"; + upArrowElement.style.display = "none"; + } else if (result.containerSortOrder === "desc") { + update.sort((a, b) => (a.name.toLowerCase() < b.name.toLowerCase()) ? 1 : -1); + upArrowElement.style.display = "inline"; + downArrowElement.style.display = "none"; + } + return update; + }, + async refreshIdentities() { const [identities, state] = await Promise.all([ browser.contextualIdentities.query({}), @@ -245,7 +262,7 @@ const Logic = { } }) ]); - this._identities = identities.map((identity) => { + const identitiesList = identities.map((identity) => { const stateObject = state[identity.cookieStoreId]; if (stateObject) { identity.hasOpenTabs = stateObject.hasOpenTabs; @@ -255,6 +272,8 @@ const Logic = { } return identity; }); + this._identities = await this.sortContainerList(identitiesList); + return this._identities; }, getPanelSelector(panel) { @@ -382,6 +401,63 @@ const Logic = { } } }, + + createContainerList(listParentElement) { + const fragment = document.createDocumentFragment(); + + Logic.identities().forEach(identity => { + const hasTabs = (identity.hasHiddenTabs || identity.hasOpenTabs); + const tr = document.createElement("tr"); + const context = document.createElement("td"); + const manage = document.createElement("td"); + + tr.classList.add("container-panel-row"); + + context.classList.add("userContext-wrapper", "open-newtab", "clickable"); + manage.classList.add("show-tabs", "pop-button"); + manage.title = escaped`View ${identity.name} container`; + context.setAttribute("tabindex", "0"); + context.title = escaped`Create ${identity.name} tab`; + context.innerHTML = escaped` +
+ `; + context.querySelector(".container-name").textContent = identity.name; + manage.innerHTML = "