UX: improve back button styles, add optional models (#37588)

Updates our back button styles and adds the ability to pass models. 

Before:
<img width="240" alt="image"
src="https://github.com/user-attachments/assets/c00354d2-b632-4232-9568-adf74f3bd67e"
/>


After:
<img width="240" alt="image"
src="https://github.com/user-attachments/assets/f162cf84-64d5-4f49-b319-124d37c68c00"
/>

Applies globally, so impacts existing uses (mostly admin) 

Before:

<img width="240" alt="image"
src="https://github.com/user-attachments/assets/49d7eaeb-dda4-4380-a01b-d81242a9665a"
/>


After:
<img width="240" alt="image"
src="https://github.com/user-attachments/assets/aed9ab7e-268f-4b21-9cfb-d749a6210b54"
/>
This commit is contained in:
Kris
2026-02-06 08:00:01 -05:00
committed by GitHub
parent 339746a413
commit d779aeb37b
3 changed files with 22 additions and 15 deletions
@@ -470,10 +470,6 @@
color: var(--primary);
}
}
&.back-button {
margin-bottom: 1em;
}
}
@mixin btn-colors($btn-type) {
@@ -538,6 +534,13 @@
&.--success {
@include btn-colors("success");
}
&.back-button {
--d-button-transparent-text-color: var(--tertiary);
--d-button-transparent-icon-color: var(--tertiary);
margin-bottom: 1em;
padding-left: 0;
}
}
.btn-mini-toggle {
@@ -1,27 +1,26 @@
import { concat } from "@ember/helper";
import { on } from "@ember/modifier";
import EditCategoryTab from "discourse/admin/components/edit-category-tab";
import BackButton from "discourse/components/back-button";
import BreadCrumbs from "discourse/components/bread-crumbs";
import DBreadcrumbsItem from "discourse/components/d-breadcrumbs-item";
import DPageHeader from "discourse/components/d-page-header";
import DToggleSwitch from "discourse/components/d-toggle-switch";
import { and } from "discourse/truth-helpers";
import { i18n } from "discourse-i18n";
const EditCategoryTabsHorizontalTemplate = <template>
{{#if (and @controller.site.desktopView @controller.model.id)}}
<BackButton
@route="discovery.category"
@model={{concat @controller.parentParams.slug "/" @controller.model.id}}
@label="category.back"
/>
{{/if}}
<DPageHeader
@titleLabel={{@controller.baseTitle}}
@showDrawer={{true}}
@collapseActionsOnMobile={{false}}
>
<:breadcrumbs>
{{#if (and @controller.site.desktopView @controller.model.id)}}
<DBreadcrumbsItem
@path={{concat "/c/" @controller.model.slug}}
@label={{i18n "category.back"}}
/>
{{/if}}
</:breadcrumbs>
<:actions>
<DToggleSwitch
@label="category.show_advanced"
@@ -1,10 +1,15 @@
import { array } from "@ember/helper";
import { LinkTo } from "@ember/routing";
import icon from "discourse/helpers/d-icon";
import { or } from "discourse/truth-helpers";
import { i18n } from "discourse-i18n";
<template>
<LinkTo class="btn btn-flat back-button" @route={{@route}}>
<LinkTo
class="btn btn-transparent back-button"
@route={{@route}}
@models={{if @model (array @model) (array)}}
>
{{icon "chevron-left"}}
{{i18n (or @label "back_button")}}
</LinkTo>