UX: core adjustments and styles for the experimental sidebar (#17271)

This commit is contained in:
Kris 2022-06-28 22:49:01 -04:00 committed by GitHub
parent 9d870f151c
commit f0005401b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 62 additions and 33 deletions

View File

@ -48,6 +48,9 @@ const ApplicationRoute = DiscourseRoute.extend(OpenComposer, {
}, },
toggleSidebar() { toggleSidebar() {
// enables CSS transitions, but not on did-insert
document.querySelector("body").classList.add("sidebar-animate");
this.controllerFor("application").toggleProperty("showSidebar"); this.controllerFor("application").toggleProperty("showSidebar");
}, },

View File

@ -327,11 +327,10 @@ table {
} }
.wrap { .wrap {
@extend .clearfix; max-width: var(--d-max-width);
margin-right: auto; margin-right: auto;
margin-left: auto; margin-left: auto;
padding: 0 10px; padding: 0 10px;
.contents { .contents {
position: relative; position: relative;
} }

View File

@ -1,3 +1,7 @@
:root {
--d-sidebar-width: 240px;
}
.header-sidebar-toggle { .header-sidebar-toggle {
margin-right: 1em; margin-right: 1em;
margin-left: -10px; margin-left: -10px;
@ -49,10 +53,16 @@
text-transform: uppercase; text-transform: uppercase;
font-size: 1em; font-size: 1em;
font-weight: bold; font-weight: bold;
align-items: center; align-items: stretch;
} }
.sidebar-section-header-link { .sidebar-section-header-link {
@include ellipsis;
flex: 1 1 auto;
color: var(--primary);
font-size: var(--font-down-1);
padding: 0.25em 0.5em;
&:visited { &:visited {
color: var(--primary); color: var(--primary);
} }
@ -60,11 +70,6 @@
&:hover { &:hover {
background: var(--primary-low); background: var(--primary-low);
} }
flex: 1 1 auto;
color: var(--primary);
font-size: var(--font-down-1);
padding: 0.25em 0.5em;
} }
.sidebar-section-header-button { .sidebar-section-header-button {
@ -142,17 +147,25 @@
} }
.sidebar-section-header-caret { .sidebar-section-header-caret {
flex: 0 0 auto;
width: 1.5em; width: 1.5em;
display: flex; display: flex;
justify-content: center; justify-content: flex-end;
align-items: center;
border: none; border: none;
background-color: transparent; background: transparent;
padding: 0.25em 0;
opacity: 0;
transition: opacity 0.25s;
&:hover { &:hover {
opacity: 100; opacity: 100;
} }
opacity: 0; svg {
display: block;
flex: 0 0 auto;
}
.d-icon { .d-icon {
font-size: $font-down-1; font-size: $font-down-1;

View File

@ -32,6 +32,7 @@ $topic-progress-height: 42px;
max-width: calc( max-width: calc(
100vw - 20px 100vw - 20px
); // 20px is the left + right padding on .wrap in common/base/discourse.scss ); // 20px is the left + right padding on .wrap in common/base/discourse.scss
min-width: 0; // grid needs to be able to shrink
} }
.timeline-container { .timeline-container {

View File

@ -208,7 +208,7 @@
align-self: flex-start; align-self: flex-start;
@media screen and (min-width: 767px) { @media screen and (min-width: 767px) {
max-width: calc(#{$large-width} / 2); max-width: calc(var(--d-max-width) / 2);
margin-right: 1.5em; margin-right: 1.5em;
} }

View File

@ -116,16 +116,6 @@ pre code {
} }
} }
// TODO figure out a clean place to put stuff like this
.row:before,
.row:after {
display: table;
content: "";
}
.row:after {
clear: both;
}
// Tables // Tables
// -------------------------------------------------- // --------------------------------------------------

View File

@ -3,6 +3,10 @@
// BEWARE: changing these styles implies they take effect anywhere they are seen // BEWARE: changing these styles implies they take effect anywhere they are seen
// throughout the Discourse application // throughout the Discourse application
:root {
--d-max-width: 1110px;
}
// Base Elements // Base Elements
body.widget-dragging { body.widget-dragging {
cursor: ns-resize; cursor: ns-resize;
@ -187,8 +191,11 @@ input {
box-sizing: border-box; box-sizing: border-box;
width: 100%; width: 100%;
display: grid; display: grid;
grid-template-areas: "content"; // we can CSS transition the sidebar grid width change
grid-template-columns: minmax(0, 1fr); // as long as we keep the column count consistent
// grid transitions are only supported in Firefox at the moment, but coming summer 2022 to Chrome
grid-template-areas: "sidebar content";
grid-template-columns: 0 minmax(0, 1fr);
gap: 0; gap: 0;
#main-outlet { #main-outlet {
@ -196,8 +203,24 @@ input {
} }
} }
body.has-sidebar-page #main-outlet-wrapper { body.has-sidebar-page {
grid-template-areas: "sidebar content"; .wrap {
grid-template-columns: 240px 1fr; // increase page max-width to accommodate sidebar width
gap: 0 2em; max-width: calc(var(--d-sidebar-width) + var(--d-max-width));
}
.d-header .wrap {
padding-left: 1.75em;
}
#main-outlet-wrapper {
grid-template-columns: var(--d-sidebar-width) minmax(0, 1fr);
gap: 0 2em;
padding-left: 0;
}
}
body.sidebar-animate {
.d-header .wrap,
#main-outlet-wrapper {
transition: ease-in-out 0.5s;
}
} }

View File

@ -2,7 +2,7 @@
.modal.history-modal { .modal.history-modal {
.modal-inner-container { .modal-inner-container {
max-width: $large-width; max-width: var(--d-max-width);
} }
.modal-body { .modal-body {
height: 70vh; height: 70vh;

View File

@ -1,7 +1,3 @@
.wrap {
max-width: $large-width;
}
.full-width { .full-width {
margin-left: 0; margin-left: 0;
} }

View File

@ -120,6 +120,10 @@
left: 0; left: 0;
} }
.onscreen-post .row {
display: flex; // children should never wrap
}
@media all and (min-width: 400px) { @media all and (min-width: 400px) {
#topic-footer-main-buttons { #topic-footer-main-buttons {
max-width: 70%; max-width: 70%;