mirror of
https://github.com/discourse/discourse.git
synced 2024-12-03 01:13:39 +08:00
UX: Remove reliance on JS for category box links
This commit is contained in:
parent
dcbe527a82
commit
ef9828b25d
|
@ -1,7 +1,6 @@
|
||||||
import discourseComputed from "discourse-common/utils/decorators";
|
import discourseComputed from "discourse-common/utils/decorators";
|
||||||
import { isEmpty } from "@ember/utils";
|
import { isEmpty } from "@ember/utils";
|
||||||
import Component from "@ember/component";
|
import Component from "@ember/component";
|
||||||
import DiscourseURL from "discourse/lib/url";
|
|
||||||
|
|
||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
tagName: "section",
|
tagName: "section",
|
||||||
|
@ -19,16 +18,5 @@ export default Component.extend({
|
||||||
@discourseComputed("categories.[].subcategories")
|
@discourseComputed("categories.[].subcategories")
|
||||||
hasSubcategories() {
|
hasSubcategories() {
|
||||||
return this.categories.any(c => !isEmpty(c.get("subcategories")));
|
return this.categories.any(c => !isEmpty(c.get("subcategories")));
|
||||||
},
|
|
||||||
|
|
||||||
click(e) {
|
|
||||||
if (!$(e.target).is("a")) {
|
|
||||||
const url = $(e.target)
|
|
||||||
.closest(".category-box")
|
|
||||||
.data("url");
|
|
||||||
if (url) {
|
|
||||||
DiscourseURL.routeTo(url);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="category-details">
|
<div class="category-details">
|
||||||
<div class='category-box-heading'>
|
<div class='category-box-heading'>
|
||||||
<a href={{c.url}}>
|
<a class="parent-box-link" href={{c.url}}>
|
||||||
<h3>
|
<h3>
|
||||||
{{#if c.read_restricted}}
|
{{#if c.read_restricted}}
|
||||||
{{d-icon 'lock'}}
|
{{d-icon 'lock'}}
|
||||||
|
|
|
@ -30,16 +30,13 @@
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
||||||
.category-box {
|
.category-box {
|
||||||
|
position: relative;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
align-content: flex-start;
|
align-content: flex-start;
|
||||||
cursor: pointer;
|
|
||||||
|
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
|
||||||
border-width: 0;
|
border-width: 0;
|
||||||
border-left-width: 6px;
|
border-left-width: 6px;
|
||||||
|
|
||||||
border-style: solid;
|
border-style: solid;
|
||||||
border-color: $primary-low;
|
border-color: $primary-low;
|
||||||
|
|
||||||
|
@ -47,6 +44,19 @@
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.parent-box-link {
|
||||||
|
// This avoids an issue with nested links by layering links instead
|
||||||
|
&:before {
|
||||||
|
content: "";
|
||||||
|
position: absolute;
|
||||||
|
z-index: 0;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.logo.aspect-image img {
|
.logo.aspect-image img {
|
||||||
display: block;
|
display: block;
|
||||||
width: auto;
|
width: auto;
|
||||||
|
@ -134,6 +144,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.subcategory.with-subcategories {
|
.subcategory.with-subcategories {
|
||||||
|
position: relative;
|
||||||
border: none;
|
border: none;
|
||||||
border-left-width: 4px;
|
border-left-width: 4px;
|
||||||
border-left-style: solid;
|
border-left-style: solid;
|
||||||
|
@ -153,6 +164,16 @@
|
||||||
margin-bottom: 0.25em;
|
margin-bottom: 0.25em;
|
||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
}
|
}
|
||||||
|
&:before {
|
||||||
|
// This avoids an issue with nested links by layering links instead
|
||||||
|
content: "";
|
||||||
|
position: absolute;
|
||||||
|
z-index: 0;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.subcategory-box-inner {
|
.subcategory-box-inner {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user