Skip to content

Commit c03bca1

Browse files
committed
Add Glint support to the AuFieldset component
1 parent 5edb3cd commit c03bca1

File tree

4 files changed

+73
-4
lines changed

4 files changed

+73
-4
lines changed

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

+42-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,25 @@
1-
import { AuBadge, AuPill } from '@appuniversum/ember-appuniversum';
1+
import type { TOC } from '@ember/component/template-only';
22
import { hash } from '@ember/helper';
33
import Component from '@glimmer/component';
4+
import AuBadge from './au-badge';
5+
import AuPill from './au-pill';
46

5-
export default class AuFieldset extends Component {
7+
export interface AuFieldsetSignature {
8+
Args: {
9+
alignment?: 'inline';
10+
};
11+
Blocks: {
12+
default: [
13+
{
14+
legend?: typeof Legend;
15+
content?: typeof Content;
16+
},
17+
];
18+
};
19+
Element: HTMLFieldSetElement;
20+
}
21+
22+
export default class AuFieldset extends Component<AuFieldsetSignature> {
623
get alignment() {
724
if (this.args.alignment == 'inline') return 'au-c-fieldset--inline';
825
else return '';
@@ -16,7 +33,22 @@ export default class AuFieldset extends Component {
1633
</template>
1734
}
1835

19-
class Legend extends Component {
36+
interface LegendSignature {
37+
Args: {
38+
error?: boolean;
39+
inline?: boolean;
40+
required?: boolean;
41+
requiredLabel?: string;
42+
skin?: '1' | '2' | '3' | '4' | '5' | '6' | 'functional';
43+
warning?: boolean;
44+
};
45+
Blocks: {
46+
default: [];
47+
};
48+
Element: HTMLDivElement;
49+
}
50+
51+
class Legend extends Component<LegendSignature> {
2052
get skin() {
2153
if (this.args.skin == '1') return 'au-u-h1';
2254
if (this.args.skin == '2') return 'au-u-h2';
@@ -86,7 +118,13 @@ class Legend extends Component {
86118
</template>
87119
}
88120

89-
const Content = <template>
121+
interface ContentSignature {
122+
Blocks: {
123+
default: [];
124+
};
125+
Element: HTMLDivElement;
126+
}
127+
const Content: TOC<ContentSignature> = <template>
90128
{{#if (has-block)}}
91129
<div class="au-c-fieldset__content" ...attributes>
92130
{{yield}}

addon/template-registry.ts

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import type AuCheckboxGroup from '@appuniversum/ember-appuniversum/components/au
1313
import type AuContentHeader from '@appuniversum/ember-appuniversum/components/au-content-header';
1414
import type AuContent from '@appuniversum/ember-appuniversum/components/au-content';
1515
import type AuDateInput from '@appuniversum/ember-appuniversum/components/au-date-input';
16+
import type AuFieldset from '@appuniversum/ember-appuniversum/components/au-fieldset';
1617
import type AuFileCard from '@appuniversum/ember-appuniversum/components/au-file-card';
1718
import type AuFileUpload from '@appuniversum/ember-appuniversum/components/au-file-upload';
1819
import type AuFormRow from '@appuniversum/ember-appuniversum/components/au-form-row';
@@ -54,6 +55,7 @@ export default interface AppuniversumRegistry {
5455
AuContentHeader: typeof AuContentHeader;
5556
AuContent: typeof AuContent;
5657
AuDateInput: typeof AuDateInput;
58+
AuFieldset: typeof AuFieldset;
5759
AuFileCard: typeof AuFileCard;
5860
AuFileUpload: typeof AuFileUpload;
5961
AuFormRow: typeof AuFormRow;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { module, test } from 'qunit';
2+
import { setupRenderingTest } from 'ember-qunit';
3+
import { render } from '@ember/test-helpers';
4+
import AuFieldset from '@appuniversum/ember-appuniversum/components/au-fieldset';
5+
6+
module('Integration | Component | au-fieldset', function (hooks) {
7+
setupRenderingTest(hooks);
8+
9+
test('it yields a legend and content component', async function (assert) {
10+
await render(
11+
<template>
12+
<AuFieldset data-test-fieldset as |f|>
13+
<f.legend data-test-legend>Legend</f.legend>
14+
<f.content data-test-content>Content</f.content>
15+
</AuFieldset>
16+
</template>,
17+
);
18+
19+
assert.dom('[data-test-fieldset]').exists();
20+
assert.dom('[data-test-legend]').hasText('Legend');
21+
assert.dom('[data-test-content]').hasText('Content');
22+
});
23+
});

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

+6
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,12 @@ module('Integration | Component | Loose mode', function (hooks) {
107107
assert.dom('[data-test-date-input]').exists();
108108
});
109109

110+
test('`<AuFieldset>` resolves in loose mode', async function (assert) {
111+
await render(hbs`<AuFieldset data-test-fieldset />`);
112+
113+
assert.dom('[data-test-fieldset]').exists();
114+
});
115+
110116
test('`<AuFileCard>` resolves in loose mode', async function (assert) {
111117
await render(hbs`<AuFileCard @filename="test.txt" data-test-file-card />`);
112118

0 commit comments

Comments
 (0)