Skip to content

Commit

Permalink
Add Glint support to the AuTable component
Browse files Browse the repository at this point in the history
  • Loading branch information
Windvis committed Apr 4, 2024
1 parent eb42b17 commit 9858859
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 22 deletions.
15 changes: 14 additions & 1 deletion addon/components/au-table.gjs → addon/components/au-table.gts
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
import Component from '@glimmer/component';

export default class AuTable extends Component {
export interface AuTableSignature {
Args: {
size?: 'small';
};
Blocks: {
body: [];
footer: [];
header: [];
title: [];
};
Element: HTMLTableElement;
}

export default class AuTable extends Component<AuTableSignature> {
get size() {
if (this.args.size == 'small') return 'au-c-table--small';
else return '';
Expand Down
2 changes: 2 additions & 0 deletions addon/template-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import type AuPanel from '@appuniversum/ember-appuniversum/components/au-panel';
import type AuPill from '@appuniversum/ember-appuniversum/components/au-pill';
import type AuRadioGroup from '@appuniversum/ember-appuniversum/components/au-radio-group';
import type AuRadio from '@appuniversum/ember-appuniversum/components/au-radio';
import type AuTable from '@appuniversum/ember-appuniversum/components/au-table';
import type AuToolbar from '@appuniversum/ember-appuniversum/components/au-toolbar';

// Modifiers
Expand Down Expand Up @@ -82,6 +83,7 @@ export default interface AppuniversumRegistry {
AuPill: typeof AuPill;
AuRadioGroup: typeof AuRadioGroup;
AuRadio: typeof AuRadio;
AuTable: typeof AuTable;
AuToolbar: typeof AuToolbar;

// Modifiers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import AuTable from '@appuniversum/ember-appuniversum/components/au-table';
import { render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
import { setupRenderingTest } from 'ember-qunit';
import { module, test } from 'qunit';

const TABLE = {
TABLE: '[data-test-table]',
Expand All @@ -15,26 +15,24 @@ module('Integration | Component | au-table', function (hooks) {
setupRenderingTest(hooks);

test('it has optional named blocks', async function (assert) {
await render(hbs`
<AuTable>
default block content
</AuTable>
`);
await render(<template><AuTable /></template>);

assert.dom(TABLE.TABLE).hasNoText();
assert.dom(TABLE.TITLE).doesNotExist();
assert.dom(TABLE.HEADER).doesNotExist();
assert.dom(TABLE.BODY).doesNotExist();
assert.dom(TABLE.FOOTER).doesNotExist();

await render(hbs`
<AuTable>
<:title>Title</:title>
<:header>Header</:header>
<:body>Body</:body>
<:footer>Footer</:footer>
</AuTable>
`);
await render(
<template>
<AuTable>
<:title>Title</:title>
<:header>Header</:header>
<:body>Body</:body>
<:footer>Footer</:footer>
</AuTable>
</template>,
);

assert.dom(TABLE.TITLE).hasText('Title');
assert.dom(TABLE.HEADER).hasText('Header');
Expand All @@ -43,11 +41,7 @@ module('Integration | Component | au-table', function (hooks) {
});

test('it accepts extra html attributes', async function (assert) {
await render(hbs`
<AuTable class="test">
default block content
</AuTable>
`);
await render(<template><AuTable class="test" /></template>);

assert.dom(TABLE.TABLE).hasClass('test');
});
Expand Down
7 changes: 7 additions & 0 deletions tests/integration/components/loose-mode-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,13 @@ module('Integration | Component | Loose mode', function (hooks) {
assert.dom('[data-test-radio]').exists();
});

test('`<AuTable>` resolves in loose mode', async function (assert) {
await render(hbs`
<AuTable data-test-table />
`);
assert.dom('[data-test-table]').exists();
});

test('`<AuToolbar>` resolves in loose mode', async function (assert) {
await render(hbs`
<AuToolbar data-test-toolbar></AuToolbar>
Expand Down

0 comments on commit 9858859

Please sign in to comment.