0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-07 13:19:19 +08:00
discourse/app/assets/stylesheets/common/toolbar-popup-menu-options.scss
Kris 6629088309
UX: move post language selector to toolbar, deprioritize for AI (#39208)
When content localization is enabled, we show a button in the toolbar to
set your post language. The current position stands out quite a lot and
can get in the way on smaller screens.

This PR accomplishes two things: 

1. Moves the button to the toolbar, which is a more stable and less
in-the-way position
2. De-prioritizes the button on new post creation when AI translations
are enabled, as language is auto-detected most of the time.

A new value transformer is added `"post-language-selector-priority"` to
allow the AI plugin to change the priority of the button, and support
for a header has been added to `toolbar-popup-menu-options`

<img width="400" alt="image"
src="https://github.com/user-attachments/assets/5ca7a45f-d6cc-49ac-9334-3a8613622e10"
/>

<img width="600" alt="image"
src="https://github.com/user-attachments/assets/7393439c-3086-4fd0-bac7-74ed4a59074f"
/>
2026-04-15 08:25:15 -04:00

195 lines
3.8 KiB
SCSS
Vendored

@use "lib/viewport";
.fk-d-menu[class*="toolbar-menu"] {
z-index: z("composer", "dropdown");
@include viewport.from(sm) {
// making sure it's only limited in height on floating menu, not mobile menu
&.fk-d-menu {
max-height: 30vh;
}
}
.fk-d-menu__inner-content {
flex-direction: column;
--fade-height: 2.5em;
&::before,
&::after {
content: "";
position: sticky;
display: block;
flex-shrink: 0;
height: var(--fade-height);
pointer-events: none;
opacity: 0;
z-index: 1;
}
&::before {
top: 0;
margin-bottom: calc(var(--fade-height) * -1);
background: linear-gradient(to top, transparent, var(--secondary));
}
&::after {
bottom: 0;
margin-top: calc(var(--fade-height) * -1);
background: linear-gradient(to bottom, transparent, var(--secondary));
}
}
&.--scroll-top .fk-d-menu__inner-content::before,
&.--scroll-bottom .fk-d-menu__inner-content::after {
opacity: 1;
}
.fullscreen-composer & {
z-index: z("header") + 1;
}
// eventho mobile composer shouldnt be used in conjuction with fk-d-menu (floating version), on tablets the possibility unfortunately exists
.discourse-touch & {
z-index: z("mobile-composer");
}
.shortcut {
line-height: 1;
vertical-align: middle;
&.--apple {
letter-spacing: 0.25em;
padding-right: 0.35em;
}
@include viewport.until(sm) {
display: none;
}
}
}
.fk-d-menu[class*="toolbar-menu"] .dropdown-menu__header {
padding: var(--space-2) 0.35em;
color: var(--primary-medium);
font-size: var(--font-down-1-rem);
}
.toolbar-menu__options-content,
.toolbar-menu__list-content,
.toolbar-menu__heading-content {
.dropdown-menu {
.btn {
&.--active {
.d-button-label__active-icon {
visibility: visible;
margin-left: auto;
}
}
}
.d-button-label {
display: flex;
flex: 1;
justify-content: space-between;
align-items: center;
min-width: 0; // shrink if needed
&__active-icon {
visibility: hidden;
}
.shortcut {
margin-left: var(--space-4);
}
}
}
}
.toolbar-menu__heading-content,
.toolbar-menu__list-content {
.dropdown-menu {
.btn {
&:hover,
&:focus,
&:focus-visible {
.shortcut {
display: block;
}
.d-button-label__active-icon {
visibility: hidden;
}
}
}
.d-button-label {
position: relative;
flex-grow: 1;
display: flex;
align-items: center;
gap: var(--space-4);
&__active-icon {
visibility: hidden;
}
&__text {
padding-right: var(--space-8); // extra spacing for the shortcut
}
.shortcut {
position: absolute;
right: 0;
top: 50%;
transform: translateY(-50%);
display: none;
margin: 0;
font-size: var(--font-down-1-rem);
}
}
}
}
.toolbar-menu__heading-content {
.dropdown-menu {
.btn[data-name="heading-1"] {
.d-button-label__text,
.d-icon[class*="d-icon-discourse"] {
font-size: var(--font-up-2-rem);
font-weight: bold;
}
}
.btn[data-name="heading-2"] {
.d-button-label__text,
.d-icon {
font-size: var(--font-up-1-rem);
font-weight: bold;
}
}
.btn[data-name="heading-3"] {
.d-button-label__text,
.d-icon {
font-size: var(--font-0);
font-weight: bold;
}
}
.btn[data-name="heading-4"] {
.d-button-label__text,
.d-icon {
font-weight: bold;
font-size: var(--font-down-1-rem);
}
}
.btn[data-name="heading-paragraph"] {
.d-button-label__text,
.d-icon {
font-size: var(--font-down-1-rem);
}
}
}
}