DEV: Remove extra whitespace from glimmer topic list items (#27225)

This commit is contained in:
Jarek Radosz 2024-05-28 14:23:36 +02:00 committed by GitHub
parent aea1f4417a
commit e02b8b4a83
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 52 additions and 58 deletions

View File

@ -1,15 +1,15 @@
{{#if @tagName}} {{~#if @tagName~}}
{{! {{!
Older outlets have a wrapper tagName. RFC0389 proposes an interface for dynamic tag names, which we may want to use in future. Older outlets have a wrapper tagName. RFC0389 proposes an interface for dynamic tag names, which we may want to use in future.
But for now, this classic component wrapper takes care of the tagName. But for now, this classic component wrapper takes care of the tagName.
}} }}
<this.wrapperComponent @tagName={{@tagName}}> <this.wrapperComponent @tagName={{@tagName}}>
{{#each (this.getConnectors) as |c|}} {{~#each (this.getConnectors) as |c|~}}
{{#if c.componentClass}} {{~#if c.componentClass~}}
<c.componentClass @outletArgs={{this.outletArgsWithDeprecations}} /> <c.componentClass @outletArgs={{this.outletArgsWithDeprecations}} />
{{else if @defaultGlimmer}} {{~else if @defaultGlimmer~}}
<c.templateOnly @outletArgs={{this.outletArgsWithDeprecations}} /> <c.templateOnly @outletArgs={{this.outletArgsWithDeprecations}} />
{{else}} {{~else~}}
<PluginConnector <PluginConnector
@connector={{c}} @connector={{c}}
@args={{this.outletArgs}} @args={{this.outletArgs}}
@ -19,29 +19,29 @@
@layout={{c.template}} @layout={{c.template}}
class={{c.classicClassNames}} class={{c.classicClassNames}}
/> />
{{/if}} {{~/if~}}
{{/each}} {{~/each~}}
</this.wrapperComponent> </this.wrapperComponent>
{{else if (this.connectorsExist hasBlock=(has-block))}} {{~else if (this.connectorsExist hasBlock=(has-block))~}}
{{! The modern path: no wrapper element = no classic component }} {{~! The modern path: no wrapper element = no classic component ~}}
{{#if (has-block)}} {{~#if (has-block)~}}
<PluginOutlet <PluginOutlet
@name={{concat @name "__before"}} @name={{concat @name "__before"}}
@outletArgs={{this.outletArgsWithDeprecations}} @outletArgs={{this.outletArgsWithDeprecations}}
/> />
{{/if}} {{~/if~}}
{{#each (this.getConnectors hasBlock=(has-block)) as |c|}} {{~#each (this.getConnectors hasBlock=(has-block)) as |c|~}}
{{#if c.componentClass}} {{~#if c.componentClass~}}
<c.componentClass <c.componentClass
@outletArgs={{this.outletArgsWithDeprecations}} @outletArgs={{this.outletArgsWithDeprecations}}
>{{yield}}</c.componentClass> >{{yield}}</c.componentClass>
{{else if @defaultGlimmer}} {{~else if @defaultGlimmer~}}
<c.templateOnly <c.templateOnly
@outletArgs={{this.outletArgsWithDeprecations}} @outletArgs={{this.outletArgsWithDeprecations}}
>{{yield}}</c.templateOnly> >{{yield}}</c.templateOnly>
{{else}} {{~else~}}
<PluginConnector <PluginConnector
@connector={{c}} @connector={{c}}
@args={{this.outletArgs}} @args={{this.outletArgs}}
@ -51,17 +51,17 @@
@layout={{c.template}} @layout={{c.template}}
class={{c.classicClassNames}} class={{c.classicClassNames}}
>{{yield}}</PluginConnector> >{{yield}}</PluginConnector>
{{/if}} {{~/if~}}
{{else}} {{~else~}}
{{yield}} {{yield}}
{{/each}} {{~/each~}}
{{#if (has-block)}} {{~#if (has-block)~}}
<PluginOutlet <PluginOutlet
@name={{concat @name "__after"}} @name={{concat @name "__after"}}
@outletArgs={{this.outletArgsWithDeprecations}} @outletArgs={{this.outletArgsWithDeprecations}}
/> />
{{/if}} {{~/if~}}
{{else}} {{~else~}}
{{yield}} {{yield}}
{{/if}} {{~/if~}}

View File

@ -9,6 +9,7 @@ export default class TopicLink extends Component {
} }
<template> <template>
{{~! no whitespace ~}}
<a <a
href={{this.url}} href={{this.url}}
data-topic-id={{@topic.id}} data-topic-id={{@topic.id}}
@ -17,5 +18,6 @@ export default class TopicLink extends Component {
class="title" class="title"
...attributes ...attributes
>{{htmlSafe @topic.fancyTitle}}</a> >{{htmlSafe @topic.fancyTitle}}</a>
{{~! no whitespace ~}}
</template> </template>
} }

View File

@ -300,14 +300,13 @@ export default class TopicListItem extends Component {
<td class="main-link clearfix topic-list-data" colspan="1"> <td class="main-link clearfix topic-list-data" colspan="1">
<PluginOutlet @name="topic-list-before-link" /> <PluginOutlet @name="topic-list-before-link" />
<span class="link-top-line">{{! no whitespace <span class="link-top-line">
}}<PluginOutlet {{~! no whitespace ~}}
@name="topic-list-before-status" <PluginOutlet @name="topic-list-before-status" />
/>{{! no whitespace {{~! no whitespace ~}}
}}<TopicStatus <TopicStatus @topic={{@topic}} />
@topic={{@topic}} {{~! no whitespace ~}}
/>{{! no whitespace <TopicLink
}}<TopicLink
{{on "focus" this.onTitleFocus}} {{on "focus" this.onTitleFocus}}
{{on "blur" this.onTitleBlur}} {{on "blur" this.onTitleBlur}}
@topic={{@topic}} @topic={{@topic}}
@ -317,10 +316,8 @@ export default class TopicListItem extends Component {
&nbsp; &nbsp;
{{~topicFeaturedLink @topic}} {{~topicFeaturedLink @topic}}
{{~/if~}} {{~/if~}}
<PluginOutlet <PluginOutlet @name="topic-list-after-title" />
@name="topic-list-after-title" {{~! no whitespace ~}}
/>{{! no whitespace
}}
<UnreadIndicator <UnreadIndicator
@includeUnreadIndicator={{this.includeUnreadIndicator}} @includeUnreadIndicator={{this.includeUnreadIndicator}}
@topicId={{@topic.id}} @topicId={{@topic.id}}
@ -428,23 +425,17 @@ export default class TopicListItem extends Component {
{{/if}} {{/if}}
</div> </div>
<div <div class="topic-item-metadata right">
class="topic-item-metadata right" {{~! no whitespace ~}}
>{{! no whitespace <PluginOutlet @name="topic-list-before-link" />
}}<PluginOutlet
@name="topic-list-before-link"
/>
<div <div class="main-link">
class="main-link" {{~! no whitespace ~}}
>{{! no whitespace <PluginOutlet @name="topic-list-before-status" />
}}<PluginOutlet {{~! no whitespace ~}}
@name="topic-list-before-status" <TopicStatus @topic={{@topic}} />
/>{{! no whitespace {{~! no whitespace ~}}
}}<TopicStatus <TopicLink
@topic={{@topic}}
/>{{! no whitespace
}}<TopicLink
{{on "focus" this.onTitleFocus}} {{on "focus" this.onTitleFocus}}
{{on "blur" this.onTitleBlur}} {{on "blur" this.onTitleBlur}}
@topic={{@topic}} @topic={{@topic}}
@ -463,10 +454,9 @@ export default class TopicListItem extends Component {
<TopicExcerpt @topic={{@topic}} /> <TopicExcerpt @topic={{@topic}} />
{{~/if~}} {{~/if~}}
<PluginOutlet @name="topic-list-main-link-bottom" /> <PluginOutlet @name="topic-list-main-link-bottom" />
</div>{{! no whitespace </div>
}}<PluginOutlet {{~! no whitespace ~}}
@name="topic-list-after-main-link" <PluginOutlet @name="topic-list-after-main-link" />
/>
<div class="pull-right"> <div class="pull-right">
<PostCountOrBadges <PostCountOrBadges

View File

@ -4,7 +4,7 @@ import icon from "discourse-common/helpers/d-icon";
import i18n from "discourse-common/helpers/i18n"; import i18n from "discourse-common/helpers/i18n";
const UnreadIndicator = <template> const UnreadIndicator = <template>
{{#if @includeUnreadIndicator~}} {{~#if @includeUnreadIndicator~}}
&nbsp;<span &nbsp;<span
title={{i18n "topic.unread_indicator"}} title={{i18n "topic.unread_indicator"}}
class={{concatClass class={{concatClass
@ -15,7 +15,7 @@ const UnreadIndicator = <template>
> >
{{~icon "asterisk"~}} {{~icon "asterisk"~}}
</span> </span>
{{~/if}} {{~/if~}}
</template>; </template>;
export default UnreadIndicator; export default UnreadIndicator;

View File

@ -16,6 +16,7 @@ export default class TopicPostBadges extends Component {
} }
<template> <template>
{{~! no whitespace ~}}
<span class="topic-post-badges"> <span class="topic-post-badges">
{{~#if this.displayUnreadPosts~}} {{~#if this.displayUnreadPosts~}}
&nbsp;<a &nbsp;<a
@ -23,7 +24,7 @@ export default class TopicPostBadges extends Component {
title={{i18n "topic.unread_posts" count=this.displayUnreadPosts}} title={{i18n "topic.unread_posts" count=this.displayUnreadPosts}}
class="badge badge-notification unread-posts" class="badge badge-notification unread-posts"
>{{this.displayUnreadPosts}}</a> >{{this.displayUnreadPosts}}</a>
{{/if~}} {{~/if~}}
{{~#if @unseen~}} {{~#if @unseen~}}
&nbsp;<a &nbsp;<a
@ -31,7 +32,8 @@ export default class TopicPostBadges extends Component {
title={{i18n "topic.new"}} title={{i18n "topic.new"}}
class="badge badge-notification new-topic" class="badge badge-notification new-topic"
>{{this.newDotText}}</a> >{{this.newDotText}}</a>
{{/if~}} {{~/if~}}
</span> </span>
{{~! no whitespace ~}}
</template> </template>
} }