Skip to content

Commit 5032b08

Browse files
committed
FEATURE: optional whitespace between default Discourse and custom links
This commit adds a toggle that allows you to add some whitespace between the Discourse header icons and the icons added via this component. The space is only added on desktop due to lack of space on mobile devices.
1 parent fe7c801 commit 5032b08

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

common/common.scss

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,18 @@
99
display: none;
1010
}
1111
}
12+
13+
// whitespace
14+
@if $add_whitespace == "true" {
15+
.desktop-view:not(.anon) {
16+
.last-custom-icon {
17+
margin-right: 2.5em;
18+
}
19+
&.rtl {
20+
.last-custom-icon {
21+
margin-right: 0;
22+
margin-left: 2.5em;
23+
}
24+
}
25+
}
26+
}

javascripts/discourse/initializers/initialize-for-header-icon-links.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,17 @@ export default {
99
try {
1010
const splitLinks = settings.Header_links.split("|").filter(Boolean);
1111

12-
splitLinks.forEach((link) => {
12+
splitLinks.forEach((link, index, links) => {
1313
const fragments = link.split(",").map((fragment) => fragment.trim());
1414
const title = fragments[0];
1515
const icon = iconNode(fragments[1].toLowerCase());
1616
const href = fragments[2];
1717
const className = `header-icon-${dasherize(fragments[0])}`;
1818
const viewClass = fragments[3].toLowerCase();
1919
const target = fragments[4].toLowerCase() === "blank" ? "_blank" : "";
20-
const selector = `li.${className}.${viewClass}`;
20+
const isLastLink =
21+
link === links[links.length - 1] ? ".last-custom-icon" : "";
22+
const selector = `li.custom-header-icon-link.${className}.${viewClass}${isLastLink}`;
2123

2224
api.decorateWidget("header-icons:before", (helper) => {
2325
return helper.h(selector, [

settings.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ Header_links:
1616
</ul>
1717
<b>URL</b>: the desired URL you want the link to point to. <br>
1818
<b>Target</b>: same tab (self) or new tab (blank)."
19+
add_whitespace:
20+
type: bool
21+
default: false
22+
description:
23+
en: "If checked, this will add some whitespace between the default Discourse header icons and the custom icons added via this component"
1924
Svg_icons:
2025
type: "list"
2126
list_type: "compact"

0 commit comments

Comments
 (0)