mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 17:43:42 +08:00
DEV: Remove default button classes from sidebar buttons (#26893)
This commit is contained in:
parent
26c8eab1f3
commit
01e725a225
|
@ -3,13 +3,18 @@
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
<li class="sidebar-section-link-wrapper">
|
<li class="sidebar-section-link-wrapper">
|
||||||
<DButton
|
<button
|
||||||
@icon="ellipsis-v"
|
class="sidebar-section-link sidebar-row sidebar-more-section-links-details-summary --link-button"
|
||||||
@action={{this.toggleSectionLinks}}
|
|
||||||
@label="sidebar.more"
|
|
||||||
class="btn-flat sidebar-more-section-links-details-summary"
|
|
||||||
aria-expanded={{if this.open "true" "false"}}
|
aria-expanded={{if this.open "true" "false"}}
|
||||||
/>
|
{{on "click" this.toggleSectionLinks}}
|
||||||
|
>
|
||||||
|
<span class="sidebar-section-link-prefix icon">
|
||||||
|
{{d-icon "ellipsis-v"}}
|
||||||
|
</span>
|
||||||
|
<span class="sidebar-section-link-content-text">
|
||||||
|
{{i18n "sidebar.more"}}
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
{{#if this.open}}
|
{{#if this.open}}
|
||||||
|
@ -33,6 +38,7 @@
|
||||||
@action={{@moreButtonAction}}
|
@action={{@moreButtonAction}}
|
||||||
@icon={{@moreButtonIcon}}
|
@icon={{@moreButtonIcon}}
|
||||||
@text={{@moreButtonText}}
|
@text={{@moreButtonText}}
|
||||||
|
@name="customize"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
|
@ -47,10 +47,14 @@ export default class SidebarMoreSectionLinks extends Component {
|
||||||
|
|
||||||
@bind
|
@bind
|
||||||
closeDetails(event) {
|
closeDetails(event) {
|
||||||
|
if (event.target.closest(".sidebar-more-section-links-details-summary")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (this.open) {
|
if (this.open) {
|
||||||
const isLinkClick =
|
const isLinkClick =
|
||||||
event.target.className.includes("sidebar-section-link") ||
|
event.target.className.includes("sidebar-section-link") ||
|
||||||
event.target.className.includes("sidebar-section-link-button");
|
event.target.className.includes("--link-button");
|
||||||
|
|
||||||
if (isLinkClick || this.#isOutsideDetailsClick(event)) {
|
if (isLinkClick || this.#isOutsideDetailsClick(event)) {
|
||||||
this.open = false;
|
this.open = false;
|
||||||
|
@ -69,7 +73,8 @@ export default class SidebarMoreSectionLinks extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
toggleSectionLinks() {
|
toggleSectionLinks(event) {
|
||||||
|
event.stopPropagation();
|
||||||
this.open = !this.open;
|
this.open = !this.open;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<div class="sidebar-section-link-wrapper">
|
<div class="sidebar-section-link-wrapper">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
class="btn btn-flat sidebar-section-link-button sidebar-row"
|
class="sidebar-section-link sidebar-row --link-button"
|
||||||
{{on "click" @action}}
|
{{on "click" @action}}
|
||||||
>
|
>
|
||||||
<span class="sidebar-section-link-prefix icon">
|
<span class="sidebar-section-link-prefix icon">
|
||||||
|
|
|
@ -357,7 +357,6 @@ createWidget("hamburger-dropdown-wrapper", {
|
||||||
click(event) {
|
click(event) {
|
||||||
if (
|
if (
|
||||||
event.target.closest(".sidebar-section-header-button") ||
|
event.target.closest(".sidebar-section-header-button") ||
|
||||||
event.target.closest(".sidebar-section-link-button") ||
|
|
||||||
event.target.closest(".sidebar-section-link")
|
event.target.closest(".sidebar-section-link")
|
||||||
) {
|
) {
|
||||||
this.sendWidgetAction("toggleHamburger");
|
this.sendWidgetAction("toggleHamburger");
|
||||||
|
@ -649,7 +648,6 @@ export default createWidget("header", {
|
||||||
} else {
|
} else {
|
||||||
this.state.hamburgerVisible = !this.state.hamburgerVisible;
|
this.state.hamburgerVisible = !this.state.hamburgerVisible;
|
||||||
this.toggleBodyScrolling(this.state.hamburgerVisible);
|
this.toggleBodyScrolling(this.state.hamburgerVisible);
|
||||||
|
|
||||||
schedule("afterRender", () => {
|
schedule("afterRender", () => {
|
||||||
// Remove focus from hamburger toggle button
|
// Remove focus from hamburger toggle button
|
||||||
document.querySelector("#toggle-hamburger-menu")?.blur();
|
document.querySelector("#toggle-hamburger-menu")?.blur();
|
||||||
|
|
|
@ -6,6 +6,7 @@ export default createWidget("sidebar-toggle", {
|
||||||
|
|
||||||
html() {
|
html() {
|
||||||
const attrs = this.attrs;
|
const attrs = this.attrs;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
this.attach("button", {
|
this.attach("button", {
|
||||||
title: "sidebar.title",
|
title: "sidebar.title",
|
||||||
|
|
|
@ -295,7 +295,7 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) {
|
||||||
|
|
||||||
assert.strictEqual(
|
assert.strictEqual(
|
||||||
query(
|
query(
|
||||||
".sidebar-section[data-section-name='community'] .sidebar-more-section-links-details-summary"
|
".sidebar-section[data-section-name='community'] .sidebar-more-section-links-details-summary .sidebar-section-link-content-text"
|
||||||
).textContent.trim(),
|
).textContent.trim(),
|
||||||
I18n.t("sidebar.more"),
|
I18n.t("sidebar.more"),
|
||||||
"displays the right count as users link is currently active"
|
"displays the right count as users link is currently active"
|
||||||
|
@ -404,7 +404,7 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) {
|
||||||
|
|
||||||
assert.strictEqual(
|
assert.strictEqual(
|
||||||
query(
|
query(
|
||||||
".sidebar-section[data-section-name='community'] .sidebar-more-section-links-details-summary"
|
".sidebar-section[data-section-name='community'] .sidebar-more-section-links-details-summary .sidebar-section-link-content-text"
|
||||||
).textContent.trim(),
|
).textContent.trim(),
|
||||||
I18n.t("sidebar.more"),
|
I18n.t("sidebar.more"),
|
||||||
"displays the right count as groups link is currently active"
|
"displays the right count as groups link is currently active"
|
||||||
|
|
|
@ -1,30 +1,3 @@
|
||||||
.btn-flat.sidebar-more-section-links-details-summary {
|
|
||||||
&:focus-within,
|
|
||||||
&:active,
|
|
||||||
&:hover {
|
|
||||||
background: var(--d-sidebar-highlight-background);
|
|
||||||
svg.d-icon {
|
|
||||||
color: var(--d-sidebar-highlight-color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
height: var(--d-sidebar-row-height);
|
|
||||||
color: var(--d-sidebar-link-color);
|
|
||||||
display: flex;
|
|
||||||
list-style: none;
|
|
||||||
box-sizing: border-box;
|
|
||||||
width: 100%;
|
|
||||||
padding: 0 var(--d-sidebar-row-horizontal-padding);
|
|
||||||
justify-content: left;
|
|
||||||
|
|
||||||
.d-icon {
|
|
||||||
width: var(--d-sidebar-section-link-prefix-width);
|
|
||||||
margin-right: var(--d-sidebar-section-link-prefix-margin-right);
|
|
||||||
color: var(--d-sidebar-link-icon-color);
|
|
||||||
font-size: var(--font-down-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.sidebar-more-section-links-details-content {
|
.sidebar-more-section-links-details-content {
|
||||||
background-color: var(--d-sidebar-background);
|
background-color: var(--d-sidebar-background);
|
||||||
transition: background-color 0.25s;
|
transition: background-color 0.25s;
|
||||||
|
|
|
@ -83,24 +83,9 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebar-section-link-button {
|
.--link-button {
|
||||||
color: var(--d-sidebar-link-color);
|
border: none;
|
||||||
background-color: var(--secondary);
|
background: inherit;
|
||||||
width: 100%;
|
|
||||||
justify-content: flex-start;
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
color: var(--d-sidebar-link-color);
|
|
||||||
background-color: var(--primary-low);
|
|
||||||
|
|
||||||
.d-icon {
|
|
||||||
color: var(--d-sidebar-link-icon-color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.d-icon {
|
|
||||||
color: var(--d-sidebar-link-icon-color);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebar-section-link[data-link-name="personal-messages-sent"],
|
.sidebar-section-link[data-link-name="personal-messages-sent"],
|
||||||
|
|
|
@ -83,7 +83,7 @@ describe "Homepage", type: :system do
|
||||||
expect(page).to have_css(".new-home", text: "Hi friends!")
|
expect(page).to have_css(".new-home", text: "Hi friends!")
|
||||||
expect(page).to have_no_css(".list-container")
|
expect(page).to have_no_css(".list-container")
|
||||||
|
|
||||||
find("#sidebar-section-content-community .sidebar-section-link:first-child").click
|
find("#sidebar-section-content-community li:first-child").click
|
||||||
expect(page).to have_css(".list-container")
|
expect(page).to have_css(".list-container")
|
||||||
|
|
||||||
find("#site-logo").click
|
find("#site-logo").click
|
||||||
|
|
|
@ -18,7 +18,7 @@ module PageObjects
|
||||||
end
|
end
|
||||||
|
|
||||||
def has_no_customize_community_section_button?
|
def has_no_customize_community_section_button?
|
||||||
community_section.has_no_button?(class: "sidebar-section-link-button")
|
community_section.has_no_button?('[data-list-item-name="customize"]')
|
||||||
end
|
end
|
||||||
|
|
||||||
def click_customize_community_section_button
|
def click_customize_community_section_button
|
||||||
|
|
Loading…
Reference in New Issue
Block a user