Skip to content

Commit 75e54ed

Browse files
committed
Add Glint support to the AuToolbar component
1 parent 40bf920 commit 75e54ed

File tree

4 files changed

+43
-12
lines changed

4 files changed

+43
-12
lines changed

addon/components/au-toolbar.gjs addon/components/au-toolbar.gts

+24-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
1+
import type { TOC } from '@ember/component/template-only';
12
import Component from '@glimmer/component';
23

3-
export default class AuToolbar extends Component {
4+
export interface AuToolbarSignature {
5+
Args: {
6+
reverse?: boolean;
7+
border?: 'top' | 'bottom';
8+
skin?: 'tint';
9+
size?: 'small' | 'medium' | 'large';
10+
nowrap?: boolean;
11+
};
12+
Blocks: {
13+
default: [typeof Group];
14+
};
15+
Element: HTMLDivElement;
16+
}
17+
18+
export default class AuToolbar extends Component<AuToolbarSignature> {
419
get reverse() {
520
if (this.args.reverse) return 'au-c-toolbar--reverse';
621
else return '';
@@ -44,7 +59,14 @@ export default class AuToolbar extends Component {
4459
</template>
4560
}
4661

47-
const Group = <template>
62+
interface GroupSignature {
63+
Blocks: {
64+
default: [];
65+
};
66+
Element: HTMLDivElement;
67+
}
68+
69+
const Group: TOC<GroupSignature> = <template>
4870
<div class="au-c-toolbar__group" ...attributes>
4971
{{yield}}
5072
</div>

addon/template-registry.ts

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import type AuLinkExternal from '@appuniversum/ember-appuniversum/components/au-
1818
import type AuLink from '@appuniversum/ember-appuniversum/components/au-link';
1919
import type AuList from '@appuniversum/ember-appuniversum/components/au-list';
2020
import type AuLoader from '@appuniversum/ember-appuniversum/components/au-loader';
21+
import type AuToolbar from '@appuniversum/ember-appuniversum/components/au-toolbar';
2122

2223
// Modifiers
2324
import type AuDateInputModifier from '@appuniversum/ember-appuniversum/modifiers/au-date-input';
@@ -43,6 +44,7 @@ export default interface AppuniversumRegistry {
4344
AuLink: typeof AuLink;
4445
AuList: typeof AuList;
4546
AuLoader: typeof AuLoader;
47+
AuToolbar: typeof AuToolbar;
4648

4749
// Modifiers
4850
'au-date-input': typeof AuDateInputModifier;

tests/integration/components/au-toolbar-test.js tests/integration/components/au-toolbar-test.gts

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
import { module, test } from 'qunit';
22
import { setupRenderingTest } from 'ember-qunit';
33
import { render } from '@ember/test-helpers';
4-
import { hbs } from 'ember-cli-htmlbars';
4+
import AuToolbar from '@appuniversum/ember-appuniversum/components/au-toolbar';
55

66
module('Integration | Component | au-toolbar', function (hooks) {
77
setupRenderingTest(hooks);
88

99
test('it yields a group component', async function (assert) {
10-
await render(hbs`
11-
<AuToolbar as |Group|>
12-
<Group data-test-foo>Foo</Group>
13-
<Group data-test-bar>Bar</Group>
14-
</AuToolbar>
15-
`);
10+
await render(
11+
<template>
12+
<AuToolbar as |Group|>
13+
<Group data-test-foo>Foo</Group>
14+
<Group data-test-bar>Bar</Group>
15+
</AuToolbar>
16+
</template>,
17+
);
1618

1719
assert.dom('[data-test-foo]').hasText('Foo');
1820
assert.dom('[data-test-bar]').hasText('Bar');
1921
});
2022

2123
test('it passes through extra html attributes', async function (assert) {
22-
await render(hbs`
23-
<AuToolbar data-test-foo="bar"></AuToolbar>
24-
`);
24+
await render(<template><AuToolbar data-test-foo="bar" /></template>);
2525

2626
assert.dom('[data-test-foo]').exists();
2727
});

tests/integration/components/loose-mode-test.ts

+7
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,13 @@ module('Integration | Component | Loose mode', function (hooks) {
139139
`);
140140
assert.dom('[data-test-loader]').exists();
141141
});
142+
143+
test('`<AuToolbar>` resolves in loose mode', async function (assert) {
144+
await render(hbs`
145+
<AuToolbar data-test-toolbar></AuToolbar>
146+
`);
147+
assert.dom('[data-test-toolbar]').exists();
148+
});
142149
});
143150

144151
module('Integration | Modifier | Loose mode', function (hooks) {

0 commit comments

Comments
 (0)