diff --git a/package.json b/package.json index a9e7ed83..e02443de 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "impro", - "version": "0.18.73", + "version": "0.18.74", "type": "module", "scripts": { "start": "rm -rf \"${BUILD_DIR:-build}\" && NODE_ENV=development eleventy --serve", diff --git a/src/css/style.css b/src/css/style.css index a9e86c59..b3edcf3f 100644 --- a/src/css/style.css +++ b/src/css/style.css @@ -6582,20 +6582,10 @@ button.profile-list-item-button.is-disabled { inset: 0; } -@media (min-width: 800px) { - .context-menu-container.open { - position: relative; - inset: auto; - } -} - .context-menu { z-index: var(--context-menu-z-index); background-color: var(--background-color); - padding-top: 16px; - padding-left: 16px; - padding-right: 16px; - padding-bottom: calc(var(--safe-area-inset-bottom) + 16px); + padding: 16px 16px calc(var(--safe-area-inset-bottom) + 16px); touch-action: pan-y; max-height: 90dvh; overflow-y: auto; @@ -6606,70 +6596,30 @@ button.profile-list-item-button.is-disabled { animation: fade-in 0.25s ease-out; } -@media (min-width: 800px) { - .context-menu::backdrop { - background-color: transparent; - animation: none; - } -} - .context-menu-label { font-size: 13px; font-weight: 500; color: var(--text-color-muted); white-space: nowrap; - padding-bottom: 8px; - padding-top: 4px; -} - -@media (min-width: 800px) { - .context-menu-label { - padding: 12px 14px 4px; - font-size: inherit; - font-weight: normal; - color: var(--text-color-muted); - } + padding: 4px 0 8px; } context-menu-item, context-menu-item-group { display: block; -} - -context-menu-item:last-child { - margin-bottom: 0; -} - -context-menu-item:last-child .context-menu-item { - margin-bottom: 0; -} - -.context-menu-item { - margin-bottom: 12px; - white-space: nowrap; color: var(--text-color); - width: 100%; } -.context-menu-item-group { - border: var(--hair) solid var(--post-border-color); - border-radius: var(--context-menu-item-group-border-radius); - overflow: hidden; -} - -context-menu-item-group:not(:last-child) .context-menu-item-group { +context-menu-item { margin-bottom: 12px; + white-space: nowrap; } -.context-menu-item-group .context-menu-item { +context-menu-item:last-child { margin-bottom: 0; } -.context-menu-item-group context-menu-item:not(:last-child) .context-menu-item { - border-bottom: var(--hair) solid var(--post-border-color); -} - -.context-menu-item button { +context-menu-item > button { width: 100%; border: var(--hair) solid var(--post-border-color); background-color: light-dark(var(--off-white), var(--gray)); @@ -6677,7 +6627,6 @@ context-menu-item-group:not(:last-child) .context-menu-item-group { text-align: left; color: inherit; cursor: pointer; - flex: 1; padding: 14px; border-radius: var(--context-menu-button-radius); display: flex; @@ -6686,29 +6635,69 @@ context-menu-item-group:not(:last-child) .context-menu-item-group { gap: 16px; } -.context-menu-item button > .icon, -.context-menu-item button > .context-menu-item-icon { +context-menu-item > button > .icon, +context-menu-item > button > .context-menu-item-icon { width: 20px; height: 20px; flex-shrink: 0; color: var(--text-color-muted); } -.context-menu-item button > .context-menu-item-icon { +context-menu-item > button > .context-menu-item-icon { margin-left: 10px; } -.context-menu-item button > .context-menu-item-icon svg { +context-menu-item > button > .context-menu-item-icon svg { width: 100%; height: 100%; display: block; } -.context-menu-item-group .context-menu-item button { +context-menu-item > a { + padding: 14px 16px; + width: 100%; + color: inherit; + display: inline-block; + text-align: left; +} + +context-menu-item-group { + border: var(--hair) solid var(--post-border-color); + border-radius: var(--context-menu-item-group-border-radius); + overflow: hidden; + margin-bottom: 12px; +} + +context-menu-item-group:last-child { + margin-bottom: 0; +} + +context-menu-item-group > context-menu-item { + margin-bottom: 0; +} + +context-menu-item-group > context-menu-item:not(:last-child) { + border-bottom: var(--hair) solid var(--post-border-color); +} + +context-menu-item-group > context-menu-item > button { border: none; + border-radius: 0; +} + +@media (hover: hover) { + context-menu-item > a:hover, + context-menu-item > button:not([disabled]):hover { + background-color: var(--context-menu-item-hover-color); + } } @media (min-width: 800px) { + .context-menu-container.open { + position: relative; + inset: auto; + } + .context-menu { position: absolute; left: auto; @@ -6727,63 +6716,53 @@ context-menu-item-group:not(:last-child) .context-menu-item-group { touch-action: auto; } - .context-menu-item { - margin-bottom: 0; + .context-menu::backdrop { + background-color: transparent; + animation: none; } - .context-menu-item-group - context-menu-item:not(:last-child) - .context-menu-item { - border-bottom: none; + .context-menu-label { + padding: 12px 14px 4px; + font-size: inherit; + font-weight: normal; + } + + context-menu-item { + margin-bottom: 0; } .context-menu > context-menu-item { border-bottom: var(--hair) solid var(--post-border-color); - border-radius: 0; - overflow: hidden; padding: 4px 0; } - .context-menu-item button { + context-menu-item > button { background-color: transparent; padding: 10px 12px; border: none; font-size: 14px; } -} - -.context-menu-item a { - padding: 14px 16px; - width: 100%; - color: inherit; - display: inline-block; - text-align: left; -} - -@media (hover: hover) { - .context-menu-item a:hover { - background-color: var(--context-menu-item-hover-color); - } - .context-menu-item button:not([disabled]):hover { - background-color: var(--context-menu-item-hover-color); + context-menu-item-group > context-menu-item > button { + border-radius: var(--context-menu-button-radius); } -} -@media (min-width: 800px) { - .context-menu-item-group { + context-menu-item-group { border: none; border-radius: 0; margin-bottom: 0; } - context-menu-item-group:not(:last-child) .context-menu-item-group { + context-menu-item-group > context-menu-item:not(:last-child) { + border-bottom: none; + } + + context-menu-item-group:not(:last-child) { border-bottom: var(--hair) solid var(--post-border-color); - margin-bottom: 0; padding-bottom: 4px; } - context-menu-item-group:not(:first-child) .context-menu-item-group { + context-menu-item-group:not(:first-child) { padding-top: 4px; } } diff --git a/src/js/components/context-menu-item-group.js b/src/js/components/context-menu-item-group.js index dc77f4e2..b050d029 100644 --- a/src/js/components/context-menu-item-group.js +++ b/src/js/components/context-menu-item-group.js @@ -1,22 +1,5 @@ -import { Component, getChildrenFragment } from "/js/components/component.js"; -import { html, render } from "/js/lib/lit-html.js"; +import { Component } from "/js/components/component.js"; -class ContextMenuItemGroup extends Component { - connectedCallback() { - if (this._initialized) { - return; - } - this._children = getChildrenFragment(this); - this.innerHTML = ""; - this.render(); - this._initialized = true; - } - - render() { - render(html`
`, this); - const el = this.querySelector(".context-menu-item-group"); - el.appendChild(this._children); - } -} +class ContextMenuItemGroup extends Component {} ContextMenuItemGroup.register(); diff --git a/src/js/components/context-menu-item.js b/src/js/components/context-menu-item.js index 35566416..66d043fc 100644 --- a/src/js/components/context-menu-item.js +++ b/src/js/components/context-menu-item.js @@ -33,17 +33,15 @@ class ContextMenuItem extends Component { render() { render( - html` `, + html``, this, ); } diff --git a/tests/unit/specs/components/context-menu-item-group.test.js b/tests/unit/specs/components/context-menu-item-group.test.js index 4fd92bb7..b85ee3b1 100644 --- a/tests/unit/specs/components/context-menu-item-group.test.js +++ b/tests/unit/specs/components/context-menu-item-group.test.js @@ -8,20 +8,11 @@ describe("context-menu-item-group", () => { }); describe("ContextMenuItemGroup - rendering", () => { - it("should render context-menu-item-group div", () => { - const element = document.createElement("context-menu-item-group"); - document.body.appendChild(element); - const group = element.querySelector(".context-menu-item-group"); - assert(group !== null); - }); - - it("should preserve children in the group", () => { + it("should preserve children", () => { const element = document.createElement("context-menu-item-group"); element.innerHTML = "Test"; document.body.appendChild(element); - const child = element.querySelector( - ".context-menu-item-group .test-child", - ); + const child = element.querySelector(".test-child"); assert(child !== null); assert.deepEqual(child.textContent, "Test"); }); @@ -30,22 +21,8 @@ describe("context-menu-item-group", () => { const element = document.createElement("context-menu-item-group"); element.innerHTML = "OneTwoThree"; document.body.appendChild(element); - const spans = element.querySelectorAll(".context-menu-item-group span"); + const spans = element.querySelectorAll(":scope > span"); assert.deepEqual(spans.length, 3); }); }); - - describe("ContextMenuItemGroup - reinitialization protection", () => { - it("should not reinitialize when connectedCallback is called multiple times", () => { - const element = document.createElement("context-menu-item-group"); - element.innerHTML = "Original"; - document.body.appendChild(element); - - element.connectedCallback(); - - const child = element.querySelector(".context-menu-item-group .test"); - assert(child !== null); - assert.deepEqual(child.textContent, "Original"); - }); - }); }); diff --git a/tests/unit/specs/components/context-menu-item.test.js b/tests/unit/specs/components/context-menu-item.test.js index cbec38e6..dd083647 100644 --- a/tests/unit/specs/components/context-menu-item.test.js +++ b/tests/unit/specs/components/context-menu-item.test.js @@ -8,17 +8,10 @@ describe("context-menu-item", () => { }); describe("ContextMenuItem - rendering", () => { - it("should render context-menu-item div", () => { + it("should render a button as its child", () => { const element = document.createElement("context-menu-item"); document.body.appendChild(element); - const item = element.querySelector(".context-menu-item"); - assert(item !== null); - }); - - it("should render a button inside the item", () => { - const element = document.createElement("context-menu-item"); - document.body.appendChild(element); - const button = element.querySelector(".context-menu-item button"); + const button = element.querySelector(":scope > button"); assert(button !== null); });