diff --git a/src/platform/Masonry.css b/src/platform/Masonry.css index 0c452aa..ed6264f 100644 --- a/src/platform/Masonry.css +++ b/src/platform/Masonry.css @@ -5,7 +5,12 @@ @supports (grid-template-rows: masonry) { .NativeMasonry { display: grid; - grid-template-columns: repeat(auto-fit, minmax(33%, min-content)); + grid-template-columns: repeat(auto-fit, minmax(44px, min-content)); grid-template-rows: masonry; + + &:has(> :last-child:nth-child(2n)) { + grid-template-columns: repeat(2, minmax(auto, min-content)); + } } } + diff --git a/src/platform/Masonry.tsx b/src/platform/Masonry.tsx index bd461b9..7071cd8 100644 --- a/src/platform/Masonry.tsx +++ b/src/platform/Masonry.tsx @@ -5,8 +5,10 @@ import { type Ref, createRenderEffect, onCleanup, + children, createEffect, createSignal, + onMount, } from "solid-js"; import { Dynamic, type DynamicProps } from "solid-js/web"; import MasonryLayout from "masonry-layout"; @@ -18,6 +20,7 @@ type MasonryContainer = | Component<{ ref?: Ref; class?: string; + children?: JSX.Element; }>; type ElementOf = @@ -34,10 +37,7 @@ function forwardRef(value: T, ref?: Ref) { (ref as (value: T) => void)(value); } -function createCompatMasonry( - element: Element, - options: () => MasonryLayout.Options, -) { +function createMasonry(element: Element, options: () => MasonryLayout.Options) { const layout = new MasonryLayout(element, { initLayout: false, }); @@ -46,21 +46,11 @@ function createCompatMasonry( const size = createElementSize(element); - const treeMutObx = new MutationObserver(() => { - layout.reloadItems?.(); - }); - - onCleanup(() => treeMutObx.disconnect()); - createRenderEffect(() => { const opts = options(); layout.option?.(opts); }); - createRenderEffect(() => { - treeMutObx.observe(element, { childList: true }); - }); - createRenderEffect(() => { const width = size.width; // only tracking width layout.layout?.(); @@ -71,6 +61,8 @@ function createCompatMasonry( layout.layout?.(); }); } + + return layout; } const supportsCSSMasonryLayout = /* @__PURE__ */ CSS.supports( @@ -93,7 +85,9 @@ if (import.meta.env.VITE_PLATFROM_MASONRY_ALWAYS_COMPAT) { function MasonryCompat( oprops: DynamicProps & { class?: string }, ) { - const [props, rest] = splitProps(oprops, ["ref", "class"]); + const [props, rest] = splitProps(oprops, ["ref", "children", "class"]); + + const childrenComponents = children(() => props.children); return ( ( const [columnGap, setColumnGap] = createSignal(); - createCompatMasonry(element, () => { + const layout = createMasonry(element, () => { return { gutter: columnGap(), }; @@ -121,9 +115,18 @@ function MasonryCompat( setColumnGap(Number(colGap.slice(0, colGap.length - 2))); } }); + + createRenderEffect(() => { + childrenComponents(); // just tracks + setTimeout(() => { + layout.reloadItems?.(); + layout.layout?.(); + }, 0); + }); }} class={`Masonry CompatMasonry ${props.class || ""}`} {...rest} + children={childrenComponents} /> ); } @@ -144,13 +147,6 @@ function MasonryNative( * and fallback to masonry-layout if not supported. The children * must have specified width and height. * - * Testing native behaviour: - * - Firefox: in `about:config`, search for `layout.css.grid-template-masonry-value.enabled` - * - * Class `NativeMasonry` will be added to the element if it's under the - * css masonry layout, otherwise it's `CompatMasonry`. `Masonry` is always - * added. - * * **Children Changes** As the children changed, reflow will be triggered, * and there is might be a blink (or transition) for user. If it's not your * intention, don't remove/add the direct children. Instead wraps them under diff --git a/src/platform/StackedRouter.css b/src/platform/StackedRouter.css index 320dfe7..a946a2d 100644 --- a/src/platform/StackedRouter.css +++ b/src/platform/StackedRouter.css @@ -1,10 +1,10 @@ .StackedPage { - contain: strict; - container: StackedPage / inline-size; - width: 100vw; - width: 100dvw; - height: 100vh; - height: 100dvh; + container: StackedPage / size; + display: contents; + max-width: 100vw; + max-width: 100dvw; + + contain: layout; } dialog.StackedPage { diff --git a/src/profiles/Profile.css b/src/profiles/Profile.css index a8ce070..994a278 100644 --- a/src/profiles/Profile.css +++ b/src/profiles/Profile.css @@ -115,46 +115,6 @@ } } -@supports (container-type: inline-size) { - @container StackedPage (inline-size >=960px) { - .Profile { - display: grid; - grid-template-columns: auto 560px; - grid-template-rows: min-content 1fr; - height: 100cqh; - - >.topbar { - grid-column: 1 / 3; - grid-row: 1 /2; - - .MuiToolbar-root { - padding-right: calc(560px + 24px); - } - } - - >.details { - height: 100%; - display: flex; - flex-flow: column nowrap; - - >.intro { - flex-grow: 1; - } - } - - >.recent-toots { - overflow-y: auto; - margin-top: calc(-1 * var(--scaffold-topbar-height)); - z-index: calc(var(--tutu-zidx-nav, 1) + 1); - - >.toot-list-toolbar { - top: 0; - } - } - } - } -} - .Profile__page-title { flex-grow: 1; white-space: nowrap; diff --git a/src/profiles/Profile.tsx b/src/profiles/Profile.tsx index f795c7c..04aba5f 100644 --- a/src/profiles/Profile.tsx +++ b/src/profiles/Profile.tsx @@ -237,321 +237,315 @@ const Profile: Component = () => { } class="Profile" > -
- - document.getElementById(menuButId)!.getBoundingClientRect() - } - aria-label="Options for the Profile" - > - - - - - - - - - {/* // for future */} + + document.getElementById(menuButId)!.getBoundingClientRect() + } + aria-label="Options for the Profile" + > + + + + + + + + + {/* // for future */} + + + + { + const { left, right, top } = + event.currentTarget.getBoundingClientRect(); + openSubscribeMenu({ + left, + right, + top, + e: 1, + }); + }} + > + + + + Subscribe... + + } + > + + + + + Edit... - - + + + + + + Followers + + + {profile()?.followersCount ?? ""} + + + + + + + + Following + + + {profile()?.followingCount ?? ""} + + + + + + + + Blocklist + + + + + + Mention in... + + + + + + + Open in browser... + + share({ url: profile()?.url })}> + + + + Share... + + + + + + + + + + + + 's Home + + + + + + +
+
+ +
+
+ + + + + + + + createRenderEffect(() => (e.innerHTML = displayName())) + } + aria-label="Display name" + > +
+ {fullUsername()} +
+
+ + + {<>} + + + + + + + +
- - - - - - - - - - 's Home - - - - - - -
-
- -
-
- - - - - - - - createRenderEffect(() => (e.innerHTML = displayName())) - } - aria-label="Display name" - > -
- - {fullUsername()} - -
-
- - - {<>} - - - - - - - - - - -
-
-
- createRenderEffect(() => (e.innerHTML = description() || "")) - } - >
- - - - - {(item, index) => { - return ( - - - - - - ); - }} - - -
{item.name} - - - - { - createRenderEffect(() => (e.innerHTML = item.value)); - }} - >
-
-
- -
-
- -
- - - 0}> - - - - - - - -
- - }> - - - + {relationship()?.following ? "Subscribed" : "Subscribe"} + + +
-
+ +
+ createRenderEffect(() => (e.innerHTML = description() || "")) + } + >
+ + + + + {(item, index) => { + return ( + + + + + + ); + }} + + +
{item.name} + + + + { + createRenderEffect(() => (e.innerHTML = item.value)); + }} + >
+ +
+ +
+ + + 0}> + + + + + + + +
+ + }> + + + +
+
); }; diff --git a/src/timelines/toots/MediaAttachmentGrid.css b/src/timelines/toots/MediaAttachmentGrid.css index 0043007..8fd667a 100644 --- a/src/timelines/toots/MediaAttachmentGrid.css +++ b/src/timelines/toots/MediaAttachmentGrid.css @@ -6,7 +6,7 @@ contain: layout style; gap: 4px; - >* { + > * { max-height: 35vh; min-height: 40px; min-width: 40px; @@ -26,16 +26,16 @@ } } - >*>* { + > * > * { width: 100%; height: 100%; } - >*> :where(img, video) { + > * > :where(img, video) { object-fit: contain; } - >*>.sensitive-placeholder { + > * >.sensitive-placeholder { display: inline-flex; display: inline flex; align-items: center;