@kubohiroya/turbowarp-title-menu 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +1 -1
- package/README.md +2 -2
- package/dist/turbowarp-title-menu.js +40 -5
- package/package.json +2 -2
package/README.ja.md
CHANGED
|
@@ -33,7 +33,7 @@ IndexedDBはoriginごとに分かれます。TurboWarp Web、TurboWarp Desktop
|
|
|
33
33
|
## インストール
|
|
34
34
|
|
|
35
35
|
```bash
|
|
36
|
-
pnpm add --save-exact @kubohiroya/turbowarp-title-menu@0.2.
|
|
36
|
+
pnpm add --save-exact @kubohiroya/turbowarp-title-menu@0.2.3
|
|
37
37
|
```
|
|
38
38
|
|
|
39
39
|
TurboWarpでは `dist/turbowarp-title-menu.js` をCustom Extensionとして読み込み、sandboxなしの実行を許可します。
|
package/README.md
CHANGED
|
@@ -48,7 +48,7 @@ The reviewed JavaScript build is committed to this repository, so users do not n
|
|
|
48
48
|
Install an exact version that you have reviewed:
|
|
49
49
|
|
|
50
50
|
```bash
|
|
51
|
-
pnpm add --save-exact @kubohiroya/turbowarp-title-menu@0.2.
|
|
51
|
+
pnpm add --save-exact @kubohiroya/turbowarp-title-menu@0.2.3
|
|
52
52
|
```
|
|
53
53
|
|
|
54
54
|
Load the standalone bundle from:
|
|
@@ -60,7 +60,7 @@ node_modules/@kubohiroya/turbowarp-title-menu/dist/turbowarp-title-menu.js
|
|
|
60
60
|
A version-pinned CDN URL is:
|
|
61
61
|
|
|
62
62
|
```text
|
|
63
|
-
https://cdn.jsdelivr.net/npm/@kubohiroya/turbowarp-title-menu@0.2.
|
|
63
|
+
https://cdn.jsdelivr.net/npm/@kubohiroya/turbowarp-title-menu@0.2.3/dist/turbowarp-title-menu.js
|
|
64
64
|
```
|
|
65
65
|
|
|
66
66
|
## Quick start
|
|
@@ -237,6 +237,41 @@
|
|
|
237
237
|
const scalars = [...text];
|
|
238
238
|
return scalars.length <= limit ? text : `${scalars.slice(0, limit - 1).join("")}...`;
|
|
239
239
|
}
|
|
240
|
+
function applicationMenuGrid(count) {
|
|
241
|
+
const columns = count <= 4 ? 2 : count <= 12 ? 3 : 4;
|
|
242
|
+
const rows = Math.ceil(count / columns);
|
|
243
|
+
const top = 25.5556;
|
|
244
|
+
const bottom = rows <= 2 ? 80 : 90;
|
|
245
|
+
const gapX = columns === 2 ? 6.6667 : 3.3333;
|
|
246
|
+
const gapY = rows <= 2 ? 5.5556 : 2.7778;
|
|
247
|
+
const width = (80 - (columns - 1) * gapX) / columns;
|
|
248
|
+
const height = (bottom - top - (rows - 1) * gapY) / rows;
|
|
249
|
+
const scale = Math.min(1, width / 36.6667, height / 24.4444);
|
|
250
|
+
const percent = (value) => `${Number(value.toFixed(4))}%`;
|
|
251
|
+
return {
|
|
252
|
+
cell(index) {
|
|
253
|
+
const row = Math.floor(index / columns);
|
|
254
|
+
const column = index % columns;
|
|
255
|
+
if (count <= 4) {
|
|
256
|
+
return {
|
|
257
|
+
left: column === 0 ? "10%" : "53.3333%",
|
|
258
|
+
top: `${25.5556 + row * 30}%`,
|
|
259
|
+
width: "36.6667%",
|
|
260
|
+
height: "24.4444%"
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
return {
|
|
264
|
+
left: percent(10 + column * (width + gapX)),
|
|
265
|
+
top: percent(top + row * (height + gapY)),
|
|
266
|
+
width: percent(width),
|
|
267
|
+
height: percent(height)
|
|
268
|
+
};
|
|
269
|
+
},
|
|
270
|
+
cqw(size) {
|
|
271
|
+
return `${count <= 4 ? size : Number((size * scale).toFixed(4))}cqw`;
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
}
|
|
240
275
|
function createAppShellApplicationMenu(options) {
|
|
241
276
|
if (!isRecord$1(options))
|
|
242
277
|
throw new TypeError("application menu options must be an object.");
|
|
@@ -273,6 +308,7 @@
|
|
|
273
308
|
const buttons = /* @__PURE__ */ new Map();
|
|
274
309
|
const seen = /* @__PURE__ */ new Set();
|
|
275
310
|
let locale = optionalString(options.initialLocale, "initialLocale") ?? resolveAppShellLocale();
|
|
311
|
+
const grid = applicationMenuGrid(options.actions.length);
|
|
276
312
|
for (const [index, definition] of options.actions.entries()) {
|
|
277
313
|
if (!isRecord$1(definition))
|
|
278
314
|
throw new TypeError(`actions.${index} must be an object.`);
|
|
@@ -294,17 +330,16 @@
|
|
|
294
330
|
const button = document.createElement("button");
|
|
295
331
|
const iconElement = document.createElement("span");
|
|
296
332
|
const label = document.createElement("span");
|
|
297
|
-
const
|
|
298
|
-
const column = index % 2;
|
|
333
|
+
const cell = grid.cell(index);
|
|
299
334
|
button.type = "button";
|
|
300
335
|
button.setAttribute("data-turbowarp-app-shell-menu-action", id);
|
|
301
|
-
button.style.cssText = `position:absolute;left:${
|
|
336
|
+
button.style.cssText = `position:absolute;left:${cell.left};top:${cell.top};width:${cell.width};height:${cell.height};display:flex;min-width:0;min-height:0;align-items:center;justify-content:center;flex-direction:column;gap:.4167cqw;border:.4167cqw solid #005f50;border-radius:2.9167cqw;background:#007d66;color:#fff;box-shadow:0 .625cqw 1.6667cqw rgba(0,0,0,.2);cursor:pointer;font:inherit;`;
|
|
302
337
|
button.style.cursor = "pointer";
|
|
303
338
|
applyTestId(button, testId);
|
|
304
339
|
applyAttributes(button, actionAttributes);
|
|
305
340
|
iconElement.setAttribute("aria-hidden", "true");
|
|
306
|
-
iconElement.style.cssText =
|
|
307
|
-
label.style.cssText =
|
|
341
|
+
iconElement.style.cssText = `display:inline-flex;width:${grid.cqw(10)};height:${grid.cqw(10)};align-items:center;justify-content:center;line-height:1;font-size:${grid.cqw(6)};`;
|
|
342
|
+
label.style.cssText = `font-size:${grid.cqw(3.8)};line-height:1.15;text-align:center;`;
|
|
308
343
|
button.appendChild(iconElement);
|
|
309
344
|
button.appendChild(label);
|
|
310
345
|
const onClick = (event) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubohiroya/turbowarp-title-menu",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "Reusable title, application menu, and DSL source storage controls for TurboWarp.",
|
|
5
5
|
"author": "Hiroya Kubo <hiroya@cuc.ac.jp>",
|
|
6
6
|
"license": "MPL-2.0",
|
|
@@ -79,6 +79,6 @@
|
|
|
79
79
|
"vitest": "^4.1.10"
|
|
80
80
|
},
|
|
81
81
|
"dependencies": {
|
|
82
|
-
"@kubohiroya/turbowarp-app-shell": "0.2.
|
|
82
|
+
"@kubohiroya/turbowarp-app-shell": "0.2.1"
|
|
83
83
|
}
|
|
84
84
|
}
|