DEV: Minor cleanup of navbar components (#25222)

Convert components to template-only where applicable.
This commit is contained in:
Jarek Radosz 2024-01-11 19:20:27 +01:00 committed by GitHub
parent c2aa64b251
commit 3a0bf97401
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 77 additions and 87 deletions

View File

@ -1,4 +1,3 @@
import Component from "@glimmer/component";
import { hash } from "@ember/helper";
import CloseDrawerButton from "./close-drawer-button";
import CloseThreadButton from "./close-thread-button";
@ -11,23 +10,23 @@ import ThreadTrackingDropdown from "./thread-tracking-dropdown";
import ThreadsListButton from "./threads-list-button";
import ToggleDrawerButton from "./toggle-drawer-button";
export default class ChatNavbarActions extends Component {
<template>
<nav class="c-navbar__actions">
{{yield
(hash
OpenDrawerButton=OpenDrawerButton
NewChannelButton=NewChannelButton
ThreadTrackingDropdown=ThreadTrackingDropdown
CloseThreadButton=CloseThreadButton
CloseThreadsButton=CloseThreadsButton
ThreadSettingsButton=ThreadSettingsButton
ThreadsListButton=ThreadsListButton
CloseDrawerButton=CloseDrawerButton
ToggleDrawerButton=ToggleDrawerButton
FullPageButton=FullPageButton
)
}}
</nav>
</template>
}
const ChatNavbarActions = <template>
<nav class="c-navbar__actions">
{{yield
(hash
OpenDrawerButton=OpenDrawerButton
NewChannelButton=NewChannelButton
ThreadTrackingDropdown=ThreadTrackingDropdown
CloseThreadButton=CloseThreadButton
CloseThreadsButton=CloseThreadsButton
ThreadSettingsButton=ThreadSettingsButton
ThreadsListButton=ThreadsListButton
CloseDrawerButton=CloseDrawerButton
ToggleDrawerButton=ToggleDrawerButton
FullPageButton=FullPageButton
)
}}
</nav>
</template>;
export default ChatNavbarActions;

View File

@ -1,17 +1,16 @@
import Component from "@glimmer/component";
import { LinkTo } from "@ember/routing";
import ChannelTitle from "discourse/plugins/chat/discourse/components/channel-title";
export default class ChatNavbarChannelTitle extends Component {
<template>
{{#if @channel}}
<LinkTo
@route="chat.channel.info.members"
@models={{@channel.routeModels}}
class="c-navbar__channel-title"
>
<ChannelTitle @channel={{@channel}} />
</LinkTo>
{{/if}}
</template>
}
const ChatNavbarChannelTitle = <template>
{{#if @channel}}
<LinkTo
@route="chat.channel.info.members"
@models={{@channel.routeModels}}
class="c-navbar__channel-title"
>
<ChannelTitle @channel={{@channel}} />
</LinkTo>
{{/if}}
</template>;
export default ChatNavbarChannelTitle;

View File

@ -1,4 +1,3 @@
import Component from "@glimmer/component";
import { hash } from "@ember/helper";
import { on } from "@ember/modifier";
import concatClass from "discourse/helpers/concat-class";
@ -8,23 +7,23 @@ import BackButton from "./back-button";
import ChannelTitle from "./channel-title";
import Title from "./title";
export default class ChatNavbar extends Component {
<template>
{{! template-lint-disable no-invalid-interactive }}
<div
class={{concatClass "c-navbar-container" (if @onClick "-clickable")}}
{{on "click" (if @onClick @onClick (noop))}}
>
<nav class="c-navbar">
{{yield
(hash
BackButton=BackButton
ChannelTitle=ChannelTitle
Title=Title
Actions=Actions
)
}}
</nav>
</div>
</template>
}
const ChatNavbar = <template>
{{! template-lint-disable no-invalid-interactive }}
<div
class={{concatClass "c-navbar-container" (if @onClick "-clickable")}}
{{on "click" (if @onClick @onClick (noop))}}
>
<nav class="c-navbar">
{{yield
(hash
BackButton=BackButton
ChannelTitle=ChannelTitle
Title=Title
Actions=Actions
)
}}
</nav>
</div>
</template>;
export default ChatNavbar;

View File

@ -1,13 +1,11 @@
import Component from "@glimmer/component";
const ChatNavbarSubTitle = <template>
<div class="c-navbar__sub-title">
{{#if (has-block)}}
{{yield}}
{{else}}
{{@title}}
{{/if}}
</div>
</template>;
export default class ChatNavbarSubTitle extends Component {
<template>
<div class="c-navbar__sub-title">
{{#if (has-block)}}
{{yield}}
{{else}}
{{@title}}
{{/if}}
</div>
</template>
}
export default ChatNavbarSubTitle;

View File

@ -1,23 +1,18 @@
import Component from "@glimmer/component";
import { hash } from "@ember/helper";
import icon from "discourse-common/helpers/d-icon";
import SubTitle from "./sub-title";
export default class ChatNavbarTitle extends Component {
<template>
<div title={{@title}} class="c-navbar__title">
{{#if (has-block)}}
{{#if @icon}}
{{icon @icon}}
{{/if}}
{{@title}}
{{yield (hash SubTitle=SubTitle)}}
{{else}}
{{#if @icon}}
{{icon @icon}}
{{/if}}
{{@title}}
{{/if}}
</div>
</template>
}
const ChatNavbarTitle = <template>
<div title={{@title}} class="c-navbar__title">
{{#if (has-block)}}
{{if @icon (icon @icon)}}
{{@title}}
{{yield (hash SubTitle=SubTitle)}}
{{else}}
{{if @icon (icon @icon)}}
{{@title}}
{{/if}}
</div>
</template>;
export default ChatNavbarTitle;