Skip to content

Commit

Permalink
Add new tab support && update linting
Browse files Browse the repository at this point in the history
  • Loading branch information
angusmcleod committed Dec 19, 2024
1 parent ec20648 commit 7151c2c
Show file tree
Hide file tree
Showing 13 changed files with 4,235 additions and 3,657 deletions.
7 changes: 0 additions & 7 deletions .eslintrc

This file was deleted.

1 change: 0 additions & 1 deletion .eslintrc.cjs

This file was deleted.

2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
engine-strict = true
auto-install-peers = false
2 changes: 2 additions & 0 deletions .streerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--print-width=100
--plugins=plugin/trailing_comma,plugin/disable_auto_ternary
2 changes: 1 addition & 1 deletion about.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"component": true,
"about_url": "https://github.com/paviliondev/discourse-dropdown-header",
"license_url": "https://github.com/paviliondev/discourse-dropdown-header/blob/main/LICENSE.txt",
"theme_version": "1.0",
"theme_version": "1.1",
"assets": {},
"modifiers": {
"svg_icons": [
Expand Down
3 changes: 3 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import DiscourseRecommendedTheme from "@discourse/lint-configs/eslint-theme";

export default [...DiscourseRecommendedTheme];
38 changes: 0 additions & 38 deletions javascripts/discourse/components/custom-header-dropdown.gjs

This file was deleted.

35 changes: 25 additions & 10 deletions javascripts/discourse/components/custom-header-link.gjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { inject as service } from "@ember/service";
import concatClass from "discourse/helpers/concat-class";
import DiscourseURL from "discourse/lib/url";
import dIcon from "discourse-common/helpers/d-icon";
import CustomHeaderDropdown from "./custom-header-dropdown";
import CustomIcon from "./custom-icon";

export default class CustomHeaderLink extends Component {
Expand Down Expand Up @@ -65,12 +64,18 @@ export default class CustomHeaderLink extends Component {
}

@action
redirectToUrl(url) {
redirectToUrl(item) {
if (this.site.mobileView) {
this.toggleHeaderLinks();
}

DiscourseURL.routeTo(url);
if (item.newTab) {
window.open(item.url, "_blank");
} else {
DiscourseURL.routeTo(item.url);
}

event.stopPropagation();
}

<template>
Expand All @@ -82,9 +87,7 @@ export default class CustomHeaderLink extends Component {
(if this.hasDropdown "has-dropdown")
}}
title={{@item.title}}
{{(if
@item.url (modifier on "click" (fn this.redirectToUrl @item.url))
)}}
{{(if @item.url (modifier on "click" (fn this.redirectToUrl @item)))}}
>
<CustomIcon @icon={{@item.icon}} />
<span class="custom-header-link-title">{{@item.title}}</span>
Expand All @@ -98,10 +101,22 @@ export default class CustomHeaderLink extends Component {
{{#if this.hasDropdown}}
<ul class="custom-header-dropdown">
{{#each this.dropdownLinks as |dropdownItem|}}
<CustomHeaderDropdown
@item={{dropdownItem}}
@toggleHeaderLinks={{this.toggleHeaderLinks}}
/>
<li
class="custom-header-dropdown-link"
title={{dropdownItem.title}}
role="button"
{{on "click" (fn this.redirectToUrl dropdownItem)}}
>
<CustomIcon @icon={{dropdownItem.icon}} />
<span
class="custom-header-link-title"
>{{dropdownItem.title}}</span>
{{#if dropdownItem.description}}
<span
class="custom-header-link-desc"
>{{dropdownItem.description}}</span>
{{/if}}
</li>
{{/each}}
</ul>
{{/if}}
Expand Down
19 changes: 11 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
{
"name": "discourse-dropdown-header",
"repository": "https://github.com/paviliondev/discourse-dropdown-header/",
"author": "Keegan George",
"license": "GPL-2.0-or-later",
"private": true,
"devDependencies": {
"@discourse/lint-configs": "^1.3.7",
"ember-template-lint": "^5.13.0",
"eslint": "^8.56.0",
"prettier": "^2.8.8"
"@discourse/lint-configs": "2.2.2",
"ember-template-lint": "6.0.0",
"eslint": "9.15.0",
"prettier": "2.8.8"
},
"engines": {
"node": ">= 18",
"npm": "please-use-pnpm",
"yarn": "please-use-pnpm",
"pnpm": ">= 9"
}
}
Loading

0 comments on commit 7151c2c

Please sign in to comment.