discourse/app/assets/stylesheets/common/base/topic.scss
chapoi 759fc04041
UX: rework button classes (#34882)
Context: The `btn` mixin is used for every functional button, but this
includes button elements that are not, or should not be, styled like our
default or primary buttons.

To change how this works this commit:
* stripped down the mixin to the bare essentials, mainly limiting to the
properties that use variables.
* moved most things into the `btn` class
* moved some things into specific descriptive classes (default, danger,
success) such as border-radius
Example of button that does not need a border-radius and would benefit
from this:
<img width="464" height="184" alt="CleanShot 2025-09-19 at 12 56 04@2x"
src="https://github.com/user-attachments/assets/e908b2cf-971f-4c1f-aade-7492bad2f89c"
/>

* Deprecated…
  * FlatButton component
* btn-active: we should use the proper pseudoclass :active or a –-active
modifier in code if we need it
* btn-text: every button by default is a btn-text. We already have a
class to indicate when it isn’t (no-text)
* fixed btn-link property to make DButton component behave like an
inline link (no padding, link-styling)
* Since I moved styling from .btn, ths means every button now needs a
specific declaration. So I’ve added btn-default where necessary.
* Fixed btn-flat hover effect: The difference between btn-flat and
btn-transparent was getting very ambiguous. I’ve fixed the hover effect
for btn-flat so that the distinction is:
<img width="1094" height="408" alt="image"
src="https://github.com/user-attachments/assets/addf56a9-1f61-463d-abd9-5028a3b88fad"
/>
* Changed the custom icon colour from header icons so it follows the
normal btn-flat styling, the way the sidebar icon already was doing.
(Consistency)


**Other small button-related change along the way**
What | BC | AC |
|----| ----|--------|
Inconsistent save/cancel colours | <img width="1720" height="1084"
alt="CleanShot 2025-09-19 at 15 31 40@2x"
src="https://github.com/user-attachments/assets/227289c3-6ded-4633-868d-6e33c32d83c3"
/> | <img width="1720" height="1084" alt="CleanShot 2025-09-19 at 15 30
56@2x"
src="https://github.com/user-attachments/assets/b23f96c9-04f3-40ea-9fba-2be59eae8e64"
/> |

---------

Co-authored-by: Martin Brennan <martin@discourse.org>
2025-10-02 13:32:36 -06:00

527 lines
9.6 KiB
SCSS
Vendored

@use "lib/viewport";
#main-outlet {
--below-topic-margin: 0.75em;
}
.container.posts {
display: grid;
grid-template-areas: "posts timeline";
grid-template-columns: auto auto;
margin-bottom: var(--below-topic-margin);
> .row {
grid-area: posts;
max-width: calc(
100vw - 20px
); // 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 {
margin-left: unset !important;
/* This is a temporary override to ease the transition
to the sticky position timeline for themes with custom timeline positioning.
Without this those themes would render topics unreadable. */
}
.topic-navigation {
overflow-anchor: none;
.btn-toggle-localized-content.--active {
background-image: linear-gradient(
to bottom,
rgb(var(--primary-rgb), 0.6) 100%,
rgb(var(--primary-rgb), 0.6) 100%
);
color: var(--d-button-default-text-color--hover);
.d-icon {
color: var(--d-button-default-text-color--hover);
}
}
}
// timeline
@media screen and (width >= 925px) {
// at 925px viewport width and above the timeline is visible (see topic-navigation.js)
.topic-navigation {
grid-area: timeline;
align-self: start;
position: sticky;
top: calc(var(--header-offset, 60px) + 1.5em);
margin-left: 1em;
z-index: z("timeline");
&.with-topic-progress {
align-self: end;
}
&.topic-progress-expanded {
z-index: z("fullscreen");
}
> * {
margin-bottom: 0.5em;
}
}
.topic-navigation-popup {
box-sizing: border-box;
position: absolute;
top: 0;
overflow-y: auto;
z-index: z("timeline");
padding: var(--space-4);
box-shadow: var(--shadow-dropdown);
background: var(--tertiary-low);
h2 {
font-size: var(--font-0);
padding-right: calc(
1em + 0.65em - var(--space-2)
); // more or less reserved space for floating close button
}
.close {
display: flex;
align-items: center;
position: absolute;
right: 0;
top: 0;
color: var(--primary);
opacity: 0.5;
}
}
}
// progress bar
@media screen and (width <= 924px) {
grid-template-areas: "posts";
grid-template-columns: auto;
.timeline-container:not(.timeline-fullscreen) {
display: none; // hiding this because sometimes the JS switch lags and causes layout issues
}
.timeline-container .timeline-scroller-content {
position: relative;
}
}
}
.progress-back-container {
z-index: z("dropdown");
text-align: center;
margin-bottom: 0;
margin-right: 0.5em;
position: absolute;
right: 0;
bottom: 100%;
.btn {
margin: 0;
}
}
.topic-status-info,
.topic-timer-info {
border-top: 1px solid var(--content-border-color);
margin: 0;
max-width: calc(
var(--topic-body-width) + (var(--topic-body-width-padding) * 2) +
var(--topic-avatar-width)
);
&:empty {
padding: 0;
}
span .d-icon {
font-size: var(--font-down-1);
}
.topic-timer-heading,
.slow-mode-heading {
display: flex;
align-items: center;
margin: 0;
padding: var(--below-topic-margin) 0;
}
.slow-mode-remove,
.topic-timer-modify {
display: flex;
margin-left: auto;
align-self: flex-start;
}
button {
font-size: var(--font-down-2);
background: transparent;
}
}
.title-wrapper {
display: flex;
flex-wrap: wrap;
.topic-statuses {
line-height: 1.2;
.d-icon {
color: var(--primary-medium);
}
}
.header-title .private-message-glyph-wrapper {
float: left;
margin-right: 0.25em;
}
}
#topic-title {
z-index: z("base");
margin-bottom: 1em;
.title-wrapper {
display: flex;
flex-wrap: wrap;
@media screen and (width >= 925px) {
width: 90%; // topic title isn't full-width on wide screens
}
input#edit-title {
width: 100%;
}
.fancy-title {
.d-icon-pencil {
font-size: var(--font-down-3);
}
}
html.discourse-no-touch & {
.fancy-title {
.edit-topic {
opacity: 0;
transition: opacity 0.15s linear;
background: none;
}
&:hover,
&:focus {
.edit-topic {
opacity: 1;
}
}
}
}
@include viewport.until(sm) {
.topic-category {
margin-top: 0.25em;
}
}
}
h1 {
margin-bottom: 0;
font-size: var(--font-up-4);
line-height: var(--line-height-medium);
overflow-wrap: break-word;
width: 100%;
z-index: z("base");
@include viewport.until(sm) {
font-size: var(--font-up-3);
}
a {
color: var(--primary);
}
}
a.edit-topic .d-icon {
font-size: 0.8em;
}
.edit-topic-title {
display: flex;
flex-wrap: wrap;
box-sizing: border-box;
gap: 0.5em;
width: 100%;
max-width: calc(
var(--topic-body-width) + (var(--topic-body-width-padding) * 2) +
var(--topic-avatar-width)
);
.select-kit .category-row {
max-width: unset;
}
}
.edit-title__wrapper {
flex: 1 1 100%;
#edit-title {
width: 100%;
margin: 0;
}
}
.edit-category__wrapper {
flex: 1 1 5%;
@include viewport.until(md) {
min-width: 0; // allows category name to shrink to fit narrow screens
}
.select-kit.combo-box.category-chooser {
width: 100%;
height: 100%;
}
}
.edit-tags__wrapper {
flex: 1 1 33%;
@include viewport.until(md) {
flex: 1 1 100%; // force full row on narrow screens
}
.mini-tag-chooser {
width: 100%;
}
.select-kit-header--filter {
flex-wrap: nowrap; // forces the whole input to wrap if needed, rather than individual tags
min-width: 0;
@include viewport.until(md) {
flex-wrap: wrap; // individual tags will need to wrap on narrow screens
}
button {
min-width: 0;
}
}
.multi-select-filter {
flex-shrink: 0;
min-width: 2em; // always provide a minimal space for input
}
}
.edit-controls {
display: flex;
width: 100%;
gap: 0.5em;
}
}
.private-message-glyph {
color: var(--primary-medium);
height: 0.95em;
}
.private_message {
background: var(--d-content-background);
#topic-title {
.edit-topic-title {
position: relative;
min-width: 0;
.private-message-glyph {
position: absolute;
z-index: 1;
left: 0.75em;
top: 1.2em;
.mobile-view & {
top: 1.1em;
}
}
#edit-title {
padding-left: 2.25em;
}
.mini-tag-chooser {
margin-left: 0;
@include viewport.from(sm) {
.selected-name {
max-width: 500px;
}
}
}
}
}
}
.topic-title-outlet {
clear: both;
}
.has-pending-posts {
display: flex;
justify-content: space-between;
padding: 0.5em;
background-color: var(--highlight-bg);
margin-top: 1em;
max-width: 757px;
}
.post-links-container {
@include unselectable;
clear: both;
.post-links {
margin-top: 1em;
padding-top: 1em;
border-top: 1px solid var(--content-border-color);
li:last-of-type {
margin-bottom: 1em;
}
}
.expand-links {
color: var(--primary-med-or-secondary-med);
}
.track-link {
display: flex;
align-items: center;
gap: var(--space-2);
color: var(--primary-med-or-secondary-med);
span:not(.badge) {
@include ellipsis;
}
}
ul {
margin: 0;
list-style: none;
li {
margin-bottom: 0.5em;
.d-icon {
font-size: var(--font-down-2);
}
.emoji {
width: 1em;
height: 1em;
}
}
}
a.reply-new {
.d-icon {
background: var(--secondary);
border-radius: 20px;
transition: all linear 0.15s;
}
&:hover {
color: var(--tertiary);
.d-icon {
background: var(--tertiary-low);
}
}
}
}
a.topic-featured-link {
display: inline-flex;
align-items: center;
text-transform: lowercase;
color: var(--primary-med-or-secondary-med);
font-size: 0.875rem;
.d-icon {
font-size: var(--font-down-1);
margin-right: 0.25em;
}
}
.topic-area {
.pending-posts {
max-width: calc(
var(--topic-body-width) + (var(--topic-body-width-padding) * 2) +
var(--topic-avatar-width)
);
.reviewable-item {
.post-body {
max-height: unset;
}
}
}
}
.published-page-notice {
display: flex;
justify-content: space-between;
padding-bottom: 1em;
max-width: calc(
var(--topic-body-width) + (var(--topic-body-width-padding) * 2) +
var(--topic-avatar-width)
);
align-items: center;
.is-public {
padding: 0.25em 0.5em;
font-size: var(--font-down-2);
background: var(--tertiary);
color: var(--secondary);
border-radius: 3px;
text-transform: lowercase;
}
}
a[data-clicks]::after {
@include click-counter-badge;
}
.post-info a,
.post-info svg {
color: var(--primary-medium);
}
.topic-error {
padding: 18px;
margin-left: auto;
margin-right: auto;
font-size: var(--font-up-4);
line-height: var(--line-height-medium);
width: 60%;
@include viewport.until(sm) {
width: 90%;
}
@include viewport.from(sm) {
text-align: center;
}
.topic-retry {
display: block;
margin-left: auto;
margin-right: auto;
margin-top: 28px;
@include viewport.until(sm) {
margin-top: 20px;
}
}
}