Skip to content

Commit c0fab97

Browse files
committedMar 7, 2024
Add Glint support to the AuLabel component
1 parent 5b7f559 commit c0fab97

File tree

5 files changed

+46
-28
lines changed

5 files changed

+46
-28
lines changed
 

‎addon/components/au-label.gjs ‎addon/components/au-label.gts

+17-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
11
import Component from '@glimmer/component';
2-
import { AuBadge, AuPill } from '@appuniversum/ember-appuniversum';
2+
import AuBadge from './au-badge';
3+
import AuPill from './au-pill';
34

4-
export default class AuLabel extends Component {
5+
export interface AuLabelSignature {
6+
Args: {
7+
error?: boolean;
8+
inline?: boolean;
9+
required?: boolean;
10+
requiredLabel?: string;
11+
warning?: boolean;
12+
};
13+
Blocks: {
14+
default: [];
15+
};
16+
Element: HTMLLabelElement;
17+
}
18+
19+
export default class AuLabel extends Component<AuLabelSignature> {
520
get inline() {
621
if (this.args.inline) return 'au-c-label--inline';
722
else return '';

‎addon/template-registry.ts

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import type AuHelpText from '@appuniversum/ember-appuniversum/components/au-help
2121
import type AuHr from '@appuniversum/ember-appuniversum/components/au-hr';
2222
import type AuIcon from '@appuniversum/ember-appuniversum/components/au-icon';
2323
import type AuInput from '@appuniversum/ember-appuniversum/components/au-input';
24+
import type AuLabel from '@appuniversum/ember-appuniversum/components/au-label';
2425
import type AuLinkExternal from '@appuniversum/ember-appuniversum/components/au-link-external';
2526
import type AuLink from '@appuniversum/ember-appuniversum/components/au-link';
2627
import type AuList from '@appuniversum/ember-appuniversum/components/au-list';
@@ -61,6 +62,7 @@ export default interface AppuniversumRegistry {
6162
AuHr: typeof AuHr;
6263
AuIcon: typeof AuIcon;
6364
AuInput: typeof AuInput;
65+
AuLabel: typeof AuLabel;
6466
AuLinkExternal: typeof AuLinkExternal;
6567
AuLink: typeof AuLink;
6668
AuList: typeof AuList;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { module, test } from 'qunit';
2+
import { setupRenderingTest } from 'ember-qunit';
3+
import { render } from '@ember/test-helpers';
4+
import AuLabel from '@appuniversum/ember-appuniversum/components/au-label';
5+
6+
module('Integration | Component | au-label', function (hooks) {
7+
setupRenderingTest(hooks);
8+
9+
test('it displays block contents and accepts extra attributes', async function (assert) {
10+
await render(
11+
<template>
12+
<AuLabel data-test-label>
13+
Some label
14+
</AuLabel>
15+
</template>,
16+
);
17+
18+
assert.dom('[data-test-label]').hasText('Some label');
19+
});
20+
});

‎tests/integration/components/au-label-test.js

-26
This file was deleted.

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

+7
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,13 @@ module('Integration | Component | Loose mode', function (hooks) {
158158
assert.dom('[data-test-input]').exists();
159159
});
160160

161+
test('`<AuLabel>` resolves in loose mode', async function (assert) {
162+
await render(hbs`
163+
<AuLabel data-test-label>Some label</AuLabel>
164+
`);
165+
assert.dom('[data-test-label]').exists();
166+
});
167+
161168
test('`<AuLinkExternal>` resolves in loose mode', async function (assert) {
162169
await render(hbs`
163170
<AuLinkExternal data-test-link-external>Foo</AuLinkExternal>

0 commit comments

Comments
 (0)