Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
container_queries: Detect spec-aligned support.
Karl Stolley430c4d179ac5
diff --git a/web/src/information_density.ts b/web/src/information_density.tsindex cee4c257f5b..ee48e245b8f 100644--- a/web/src/information_density.ts+++ b/web/src/information_density.ts@@ -143,9 +143,31 @@ export function calculate_timestamp_widths(): void {$temp_time_div.remove();}+function determine_container_query_support(): void {+ const body = document.querySelector("body");+ const test_container = document.createElement("div");+ const test_child = document.createElement("div");+ test_container.classList.add("container-query-test");+ test_child.classList.add("container-query-test-child");+ test_container.append(test_child);++ body?.append(test_container);++ if (test_child?.getClientRects()[0]?.y === 0) {+ /* Conforming browsers will place the child element+ at the very top of the viewport. */+ body?.classList.add("with-container-query-support");+ } else {+ body?.classList.add("without-container-query-support");+ }++ test_container?.remove();+}+export function initialize(): void {set_base_typography_css_variables();// We calculate the widths of a candidate set of timestamps,// and use the largest to set `--message-box-timestamp-column-width`calculate_timestamp_widths();+ determine_container_query_support();}diff --git a/web/styles/zulip.css b/web/styles/zulip.cssindex d67d5c1615d..58148677d0c 100644--- a/web/styles/zulip.css+++ b/web/styles/zulip.css@@ -511,6 +511,29 @@ body.has-overlay-scrollbar {}}+/* We test for spec-aligned container query support+ using these styles. */+.container-query-test {+ /* Keep the test div from rendering. */+ visibility: hidden;+ /* Establish a container. */+ container: test-container / inline-size;+ /* Establish a positioning context that+ conforming browsers will ignore. */+ position: relative;+ top: 100px;++ .container-query-test-child {+ /* Non-spec aligned browsers will keep+ this element to the top of the containing+ <div>; spec-aligned browsers move it to the+ top of the viewport. We check for this in+ information_density.ts */+ position: fixed;+ top: 0;+ }+}+.column-middle,#compose-content {margin-right: var(--right-column-width);