Skip to content

Commit

Permalink
Merge pull request #2495 from hashicorp/showcase-gts/template-only
Browse files Browse the repository at this point in the history
Showcase `.gts` - Convert some components to TemplateOnly
  • Loading branch information
didoo authored Oct 14, 2024
2 parents 4e4d2b3 + bec81b2 commit e83460a
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 84 deletions.
14 changes: 6 additions & 8 deletions showcase/app/components/shw/divider/index.gts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: MPL-2.0
*/

import Component from '@glimmer/component';
import type { TemplateOnlyComponent } from '@ember/component/template-only';
import { concat } from '@ember/helper';

export interface ShwDividerSignature {
Expand All @@ -13,10 +13,8 @@ export interface ShwDividerSignature {
Element: HTMLHRElement;
}

export default class ShwDivider extends Component<ShwDividerSignature> {
<template>
<hr
class="shw-divider {{if @level (concat 'shw-divider--level-' @level)}}"
/>
</template>
}
const ShwDivider: TemplateOnlyComponent<ShwDividerSignature> = <template>
<hr class="shw-divider {{if @level (concat 'shw-divider--level-' @level)}}" />
</template>;

export default ShwDivider;
16 changes: 8 additions & 8 deletions showcase/app/components/shw/label/index.gts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: MPL-2.0
*/

import Component from '@glimmer/component';
import type { TemplateOnlyComponent } from '@ember/component/template-only';

export interface ShwLabelSignature {
Blocks: {
Expand All @@ -12,10 +12,10 @@ export interface ShwLabelSignature {
Element: HTMLParagraphElement;
}

export default class ShwLabel extends Component<ShwLabelSignature> {
<template>
<p class="shw-label shw-text-body-small" ...attributes>
{{yield}}
</p>
</template>
}
const ShwLabel: TemplateOnlyComponent<ShwLabelSignature> = <template>
<p class="shw-label shw-text-body-small" ...attributes>
{{yield}}
</p>
</template>;

export default ShwLabel;
17 changes: 9 additions & 8 deletions showcase/app/components/shw/outliner/index.gts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
import Component from '@glimmer/component';

import type { TemplateOnlyComponent } from '@ember/component/template-only';

export interface ShwOutlinerSignature {
Blocks: {
Expand All @@ -11,10 +12,10 @@ export interface ShwOutlinerSignature {
Element: HTMLDivElement;
}

export default class ShwOutliner extends Component<ShwOutlinerSignature> {
<template>
<div class="shw-outliner" ...attributes>
{{yield}}
</div>
</template>
}
const ShwOutliner: TemplateOnlyComponent<ShwOutlinerSignature> = <template>
<div class="shw-outliner" ...attributes>
{{yield}}
</div>
</template>;

export default ShwOutliner;
24 changes: 12 additions & 12 deletions showcase/app/components/shw/text/body.gts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: MPL-2.0
*/

import Component from '@glimmer/component';
import type { TemplateOnlyComponent } from '@ember/component/template-only';

import ShwText from './index';
import type { ShwTextSignature } from './index';
Expand All @@ -20,14 +20,14 @@ export interface ShwBodySignature {
Element: ShwTextSignature['Element'];
}

export default class ShwTextBody extends Component<ShwBodySignature> {
<template>
<ShwText
@variant="body"
@align={{@align}}
@weight={{@weight}}
@tag={{@tag}}
...attributes
>{{yield}}</ShwText>
</template>
}
const ShwTextBody: TemplateOnlyComponent<ShwBodySignature> = <template>
<ShwText
@variant="body"
@align={{@align}}
@weight={{@weight}}
@tag={{@tag}}
...attributes
>{{yield}}</ShwText>
</template>;

export default ShwTextBody;
24 changes: 12 additions & 12 deletions showcase/app/components/shw/text/h1.gts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: MPL-2.0
*/

import Component from '@glimmer/component';
import type { TemplateOnlyComponent } from '@ember/component/template-only';

import ShwText from './index';
import type { ShwTextSignature } from './index';
Expand All @@ -20,14 +20,14 @@ export interface ShwTextH1Signature {
Element: ShwTextSignature['Element'];
}

export default class ShwTextH1 extends Component<ShwTextH1Signature> {
<template>
<ShwText
@variant="h1"
@align={{@align}}
@weight={{@weight}}
@tag={{@tag}}
...attributes
>{{yield}}</ShwText>
</template>
}
const ShwTextH1: TemplateOnlyComponent<ShwTextH1Signature> = <template>
<ShwText
@variant="h1"
@align={{@align}}
@weight={{@weight}}
@tag={{@tag}}
...attributes
>{{yield}}</ShwText>
</template>;

export default ShwTextH1;
24 changes: 12 additions & 12 deletions showcase/app/components/shw/text/h2.gts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: MPL-2.0
*/

import Component from '@glimmer/component';
import type { TemplateOnlyComponent } from '@ember/component/template-only';

import ShwText from './index';
import type { ShwTextSignature } from './index';
Expand All @@ -20,14 +20,14 @@ export interface ShwTextH2Signature {
Element: ShwTextSignature['Element'];
}

export default class ShwTextH2 extends Component<ShwTextH2Signature> {
<template>
<ShwText
@variant="h2"
@align={{@align}}
@weight={{@weight}}
@tag={{@tag}}
...attributes
>{{yield}}</ShwText>
</template>
}
const ShwTextH2: TemplateOnlyComponent<ShwTextH2Signature> = <template>
<ShwText
@variant="h2"
@align={{@align}}
@weight={{@weight}}
@tag={{@tag}}
...attributes
>{{yield}}</ShwText>
</template>;

export default ShwTextH2;
24 changes: 12 additions & 12 deletions showcase/app/components/shw/text/h3.gts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: MPL-2.0
*/

import Component from '@glimmer/component';
import type { TemplateOnlyComponent } from '@ember/component/template-only';

import ShwText from './index';
import type { ShwTextSignature } from './index';
Expand All @@ -20,14 +20,14 @@ export interface ShwTextH3Signature {
Element: ShwTextSignature['Element'];
}

export default class ShwTextH3 extends Component<ShwTextH3Signature> {
<template>
<ShwText
@variant="h3"
@align={{@align}}
@weight={{@weight}}
@tag={{@tag}}
...attributes
>{{yield}}</ShwText>
</template>
}
const ShwTextH3: TemplateOnlyComponent<ShwTextH3Signature> = <template>
<ShwText
@variant="h3"
@align={{@align}}
@weight={{@weight}}
@tag={{@tag}}
...attributes
>{{yield}}</ShwText>
</template>;

export default ShwTextH3;
24 changes: 12 additions & 12 deletions showcase/app/components/shw/text/h4.gts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: MPL-2.0
*/

import Component from '@glimmer/component';
import type { TemplateOnlyComponent } from '@ember/component/template-only';

import ShwText from './index';
import type { ShwTextSignature } from './index';
Expand All @@ -20,14 +20,14 @@ export interface ShwTextH4Signature {
Element: ShwTextSignature['Element'];
}

export default class ShwTextH4 extends Component<ShwTextH4Signature> {
<template>
<ShwText
@variant="h4"
@align={{@align}}
@weight={{@weight}}
@tag={{@tag}}
...attributes
>{{yield}}</ShwText>
</template>
}
const ShwTextH4: TemplateOnlyComponent<ShwTextH4Signature> = <template>
<ShwText
@variant="h4"
@align={{@align}}
@weight={{@weight}}
@tag={{@tag}}
...attributes
>{{yield}}</ShwText>
</template>;

export default ShwTextH4;

0 comments on commit e83460a

Please sign in to comment.