Skip to content

Commit 81a30ca

Browse files
committed
Add missing file
1 parent 3886e3e commit 81a30ca

1 file changed

Lines changed: 46 additions & 0 deletions

File tree

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
# This Source Code Form is subject to the terms of the Mozilla Public
3+
# License, v. 2.0. If a copy of the MPL was not distributed with this
4+
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
5+
*/
6+
'use strict';
7+
8+
import {
9+
sanitizeForHTMLText,
10+
} from '/common/common.js';
11+
import * as Constants from '/common/constants.js';
12+
13+
export function tabsToHTMLList(tabs, { maxHeight, maxWidth }) {
14+
const rootLevelOffset = tabs.map(tab => parseInt(tab.$TST?.getAttribute(Constants.kLEVEL) || tab.indent || 0)).sort()[0];
15+
return (
16+
`<ul style="border: 1px inset;
17+
display: flex;
18+
flex-direction: column;
19+
flex-grow: 1;
20+
flex-shrink: 1;
21+
margin-block: 0.5em;
22+
margin-inline: 0;
23+
min-height: 2em;
24+
max-height: calc(${maxHeight}px - 12em /* title bar, message, checkbox, buttons, and margins */);
25+
max-width: ${maxWidth}px;
26+
overflow: auto;
27+
padding-block: 0.5em;
28+
padding-inline: 0.5em;">` +
29+
tabs.map(tab => `<li style="align-items: center;
30+
display: flex;
31+
flex-direction: row;
32+
padding-inline-start: calc((${tab.$TST?.getAttribute(Constants.kLEVEL) || tab.indent || 0} - ${rootLevelOffset}) * 0.25em);"
33+
title="${sanitizeForHTMLText(tab.title)}"
34+
><img style="display: flex;
35+
max-height: 1em;
36+
max-width: 1em;"
37+
alt=""
38+
src="${sanitizeForHTMLText(tab.favIconUrl || browser.runtime.getURL('resources/icons/defaultFavicon.svg'))}"
39+
><span style="margin-inline-start: 0.25em;
40+
overflow: hidden;
41+
text-overflow: ellipsis;
42+
white-space: nowrap;"
43+
>${sanitizeForHTMLText(tab.title)}</span></li>`).join('') +
44+
`</ul>`
45+
);
46+
}

0 commit comments

Comments
 (0)