Skip to content

Commit

Permalink
Merge pull request #11 from Arkshine/modernize
Browse files Browse the repository at this point in the history
COMPATIBILITY: Modernize the component
  • Loading branch information
nathan-nz authored Jul 10, 2024
2 parents f3561ce + 0a8d0fb commit cf2593e
Show file tree
Hide file tree
Showing 24 changed files with 3,021 additions and 1,085 deletions.
1 change: 1 addition & 0 deletions .discourse-compatibility
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
< 3.3.0.beta1-dev: f3561ce7fd9dded965fb8e9a99229539c7af3aa1
1 change: 1 addition & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require("@discourse/lint-configs/eslint-theme");
38 changes: 3 additions & 35 deletions .github/workflows/component-linting.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Linting
name: Discourse Theme

on:
push:
Expand All @@ -7,37 +7,5 @@ on:
pull_request:

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v1
with:
node-version: 12

- name: Yarn install
run: yarn install

- name: ESLint
if: ${{ always() }}
run: yarn eslint --ext .js,.js.es6 --no-error-on-unmatched-pattern {test,javascripts}

- name: Prettier
if: ${{ always() }}
shell: bash
run: |
yarn prettier -v
shopt -s extglob
if ls @(javascripts|desktop|mobile|common|scss)/**/*.@(scss|js|es6) &> /dev/null; then
yarn prettier --list-different "@(javascripts|desktop|mobile|common|scss)/**/*.{scss,js,es6}"
fi
if ls test/**/*.@(js|es6) &> /dev/null; then
yarn prettier --list-different "test/**/*.{js,es6}"
fi
- name: Ember template lint
if: ${{ always() }}
run: yarn ember-template-lint javascripts --no-error-on-unmatched-pattern
ci:
uses: discourse/.github/.github/workflows/discourse-theme.yml@v1
121 changes: 0 additions & 121 deletions .github/workflows/component-tests.yml

This file was deleted.

1 change: 0 additions & 1 deletion .prettierrc

This file was deleted.

1 change: 1 addition & 0 deletions .prettierrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require("@discourse/lint-configs/prettier");
1 change: 1 addition & 0 deletions .template-lintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require("@discourse/lint-configs/template-lint");
4 changes: 0 additions & 4 deletions .template-lintrc.js

This file was deleted.

26 changes: 18 additions & 8 deletions common/common.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
@import 'mixins';
@import 'buttons';
@import "mixins";
@import "buttons";

@if $links_position == "left" {
.home-logo-wrapper-outlet {
display: flex;
align-items: center;
gap: 1rem;
}
}

.custom-header-links {
.top-level-links {
Expand All @@ -8,10 +16,11 @@
justify-content: center;
align-items: center;
gap: 1rem;
margin: 0;

.custom-header-link {
color: $main_link_color;
padding-block: 1rem;
padding-block: 0.5rem;
cursor: default;

&-icon {
Expand Down Expand Up @@ -55,7 +64,8 @@
list-style: none;
transform: scale(0);
transition: transform 0.2s ease;
transition-delay: 0.3s;
transition-delay: 0.1s;
will-change: transform;

&-link {
color: $dropdown_item_color;
Expand All @@ -81,11 +91,11 @@
}

// hide on scroll when nav is positioned to left of header:
.title .custom-header-links.scrolling {
.d-header .custom-header-links.scrolling {
display: none;
}

// maintains suitable spacing when Sign Up buttons are present
.anon .d-header .sign-up-button {
margin-left: 1.25em;
// maintains suitable spacing when auth buttons are present
.anon .d-header .header-buttons:has(.custom-header-links) .auth-buttons {
margin-left: 1.25em;
}
6 changes: 6 additions & 0 deletions desktop/desktop.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
.custom-header-links {
display: flex;

.custom-header-link {
display: flex;
}

@media screen and (max-width: 712px) {
display: none;
}
Expand Down
16 changes: 16 additions & 0 deletions javascripts/discourse/api-initializers/dropdown-header.gjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { apiInitializer } from "discourse/lib/api";
import CustomHeaderLinks from "../components/custom-header-links";

export default apiInitializer("1.29.0", (api) => {
if (!settings.header_links) {
return;
}

if (settings.links_position === "right") {
api.headerButtons.add("dropdown-header", CustomHeaderLinks, {
before: "auth",
});
} else {
api.renderAfterWrapperOutlet("home-logo", CustomHeaderLinks);
}
});
22 changes: 0 additions & 22 deletions javascripts/discourse/api-initializers/dropdown-header.js.es6

This file was deleted.

38 changes: 38 additions & 0 deletions javascripts/discourse/components/custom-header-dropdown.gjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import Component from "@ember/component";
import { fn } from "@ember/helper";
import { on } from "@ember/modifier";
import { action } from "@ember/object";
import { service } from "@ember/service";
import DiscourseURL from "discourse/lib/url";
import CustomIcon from "./custom-icon";

export default class CustomHeaderDropdown extends Component {
@service site;
@service router;

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

DiscourseURL.routeTo(url);

event.stopPropagation();
}

<template>
<li
class="custom-header-dropdown-link"
title={{@item.title}}
role="button"
{{on "click" (fn this.redirectToUrl @item.url)}}
>
<CustomIcon @icon={{@item.icon}} />
<span class="custom-header-link-title">{{@item.title}}</span>
{{#if @item.description}}
<span class="custom-header-link-desc">{{@item.description}}</span>
{{/if}}
</li>
</template>
}
Loading

0 comments on commit cf2593e

Please sign in to comment.