Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

container_queries: Add baseline container queries and fallbacks.

Karl Stolleyf27a69be716b
diff --git a/web/styles/zulip.css b/web/styles/zulip.css
index 9671c452faa..7c36236bf1a 100644
--- a/web/styles/zulip.css
+++ b/web/styles/zulip.css
@@ -234,6 +234,12 @@ p.n-margin {
box-shadow: 0 0 30px hsl(0deg 0% 0% / 25%);
z-index: 110;
+ @container app (width < $cq_md_min) {
+ width: calc(90% - 30px);
+ left: 5%;
+ top: 5%;
+ }
+
&.show-feedback-container {
display: block;
animation: feedback-slide-in 0.6s forwards;
@@ -1651,6 +1657,31 @@ div.toggle_resolve_topic_spinner .loading_indicator_spinner {
margin-left: 7px;
}
}
+
+ @container header-container (width < $cq_xl_min) {
+ #realm-navbar-icon-logo {
+ display: inline-block;
+ }
+
+ #realm-navbar-wide-logo {
+ display: none;
+ }
+
+ #top_navbar .column-left {
+ width: auto;
+ }
+
+ #navbar-middle {
+ margin-left: var(--left-sidebar-width-with-realm-icon-logo);
+ }
+ }
+
+ @container app (width < $cq_xl_min) {
+ #compose-content,
+ .app-main .column-middle {
+ margin-left: 7px;
+ }
+ }
}
body:not(.hide-left-sidebar) {
@@ -1661,73 +1692,49 @@ body:not(.hide-left-sidebar) {
}
}
-@media (width < $xl_min) {
- .app-main {
- @extend %hide-right-sidebar;
- }
+/* We have some regrettable but temporarily necessary code duplication
+ in the queries that follow.
- .app-main .column-middle {
- margin-right: 7px;
- }
+ In browsers that support spec-aligned, em-aware container queries,
+ we query on the app-main container. That enables breakpoints that
+ look best at a chose base font size.
+
+ However, in browsers that lag the spec, we fall back to the original
+ media queries. The layout will not look as good as it could, but
+ essential scrolling behavior will be maintained. */
+@container header-container (width < $cq_xl_min) {
#navbar-middle {
/* = (width of button, square with header) * 4 (number of buttons) + 3px extra margin. */
margin-right: calc(var(--header-height) * 4 + 3px);
}
+}
+
+@container app (width < $cq_xl_min) {
+ .app-main {
+ @extend %hide-right-sidebar;
+
+ .column-middle {
+ margin-right: 7px;
+ }
+ }
#typing_notifications,
#scheduled_message_indicator,
#compose-content {
margin-right: 7px;
}
-
- .hide-left-sidebar {
- #compose-content,
- .app-main .column-middle {
- margin-left: 7px;
- }
-
- #realm-navbar-icon-logo {
- display: inline-block;
- }
-
- #realm-navbar-wide-logo {
- display: none;
- }
-
- #top_navbar .column-left {
- width: auto;
- }
-
- #navbar-middle {
- margin-left: var(--left-sidebar-width-with-realm-icon-logo);
- }
- }
}
-@media (width < $md_min) {
- .app-main {
- @extend %hide-left-sidebar;
- }
-
+@container header-container (width < $cq_md_min) {
.header-main .column-left {
display: none;
}
- .app-main .column-middle {
- margin-left: 7px;
- margin-right: 7px;
- }
-
#navbar-middle {
margin-left: 0;
}
- .app-main .column-middle .column-middle-inner {
- margin-left: 0;
- margin-right: 0;
- }
-
#streamlist-toggle {
display: block;
}
@@ -1735,11 +1742,21 @@ body:not(.hide-left-sidebar) {
.top-navbar-container {
margin-left: 40px;
}
+}
- #feedback_container {
- width: calc(90% - 30px);
- left: 5%;
- top: 5%;
+@container app (width < $cq_md_min) {
+ .app-main {
+ @extend %hide-left-sidebar;
+
+ .column-middle {
+ margin-left: 7px;
+ margin-right: 7px;
+ }
+
+ .column-middle .column-middle-inner {
+ margin-left: 0;
+ margin-right: 0;
+ }
}
#typing_notifications,
@@ -1749,6 +1766,101 @@ body:not(.hide-left-sidebar) {
}
}
+/* Begin fallback media queries. */
+@media (width < $xl_min) {
+ .without-container-query-support {
+ .app-main {
+ @extend %hide-right-sidebar;
+
+ .column-middle {
+ margin-right: 7px;
+ }
+ }
+
+ #navbar-middle {
+ /* = (width of button, square with header) * 4 (number of buttons) + 3px extra margin. */
+ margin-right: calc(var(--header-height) * 4 + 3px);
+ }
+
+ #typing_notifications,
+ #scheduled_message_indicator,
+ #compose-content {
+ margin-right: 7px;
+ }
+
+ .hide-left-sidebar {
+ #compose-content,
+ .app-main .column-middle {
+ margin-left: 7px;
+ }
+
+ #realm-navbar-icon-logo {
+ display: inline-block;
+ }
+
+ #realm-navbar-wide-logo {
+ display: none;
+ }
+
+ #top_navbar .column-left {
+ width: auto;
+ }
+
+ #navbar-middle {
+ margin-left: var(--left-sidebar-width-with-realm-icon-logo);
+ }
+ }
+ }
+}
+
+@media (width < $md_min) {
+ .without-container-query-support {
+ .app-main {
+ @extend %hide-left-sidebar;
+
+ .column-middle {
+ margin-left: 7px;
+ margin-right: 7px;
+ }
+
+ .column-middle .column-middle-inner {
+ margin-left: 0;
+ margin-right: 0;
+ }
+ }
+
+ .header-main .column-left {
+ display: none;
+ }
+
+ #navbar-middle {
+ margin-left: 0;
+ }
+
+ #streamlist-toggle {
+ display: block;
+ }
+
+ .top-navbar-container {
+ margin-left: 40px;
+ }
+
+ #feedback_container {
+ width: calc(90% - 30px);
+ left: 5%;
+ top: 5%;
+ }
+
+ #typing_notifications,
+ #scheduled_message_indicator,
+ #compose-content {
+ margin-left: 7px;
+ }
+ }
+}
+
+/* End fallback media queries. */
+
@media (height < $short_navbar_cutoff_height) {
.app-main .column-right.expanded .right-sidebar,
.app-main .column-left.expanded .left-sidebar {
@@ -1810,6 +1922,9 @@ body:not(.hide-left-sidebar) {
}
}
+/* As these adjustments are properly the province of
+ the viewport, we do not present these mm_min queries
+ in a corresponding container query block. */
@media (width < $mm_min) {
html {
overflow-x: hidden;