Skip to content

Commit e332851

Browse files
committed
fix: use icon gts instead svg file + adapt test + use dropdown popover for action menu and design table
1 parent a988657 commit e332851

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+753
-302
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import type { TOC } from '@ember/component/template-only';
2+
3+
const DeleteIcon: TOC<{ Element: SVGSVGElement }> = <template>
4+
<svg
5+
xmlns="http://www.w3.org/2000/svg"
6+
fill="none"
7+
viewBox="0 0 24 24"
8+
stroke-width="1.5"
9+
stroke="currentColor"
10+
...attributes
11+
>
12+
<path
13+
stroke-linecap="round"
14+
stroke-linejoin="round"
15+
d="m14.74 9-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 0 1-2.244 2.077H8.084a2.25 2.25 0 0 1-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 0 0-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 0 1 3.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 0 0-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 0 0-7.5 0"
16+
/>
17+
</svg>
18+
</template>;
19+
20+
export default DeleteIcon;

doc-app/app/assets/icons/edit.gts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import type { TOC } from '@ember/component/template-only';
2+
3+
const EditIcon: TOC<{ Element: SVGSVGElement }> = <template>
4+
<svg
5+
xmlns="http://www.w3.org/2000/svg"
6+
fill="none"
7+
viewBox="0 0 24 24"
8+
stroke-width="1.5"
9+
stroke="currentColor"
10+
...attributes
11+
>
12+
<path
13+
stroke-linecap="round"
14+
stroke-linejoin="round"
15+
d="m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L10.582 16.07a4.5 4.5 0 0 1-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 0 1 1.13-1.897l8.932-8.931Zm0 0L19.5 7.125M18 14v4.75A2.25 2.25 0 0 1 15.75 21H5.25A2.25 2.25 0 0 1 3 18.75V8.25A2.25 2.25 0 0 1 5.25 6H10"
16+
/>
17+
</svg>
18+
</template>;
19+
20+
export default EditIcon;

doc-app/app/components/docs/ember-ui/prefabs/table-generic.gts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import type { TOC } from '@ember/component/template-only';
88
import type { TpkSelectSignature } from '@triptyk/ember-input/components/tpk-select';
99
import { hash } from '@ember/helper';
1010
import stringify from 'doc-app/helpers/to-string';
11+
import EditIcon from 'doc-app/assets/icons/edit.gts';
12+
import DeleteIcon from 'doc-app/assets/icons/delete.gts';
1113

1214
const TpkSelectElement: TOC<
1315
TpkSelectSignature & {
@@ -36,6 +38,9 @@ export default class TpkTableGenericPrefabExample extends Component {
3638
entity: 'user',
3739
pageSizes: [10, 30, 50, 75],
3840
defaultSortColumn: 'firstName',
41+
rowClick: (element: unknown) => {
42+
console.log('Row clicked:', element);
43+
},
3944
columns: [
4045
{
4146
field: 'lastName',
@@ -56,14 +61,18 @@ export default class TpkTableGenericPrefabExample extends Component {
5661
],
5762
actionMenu: [
5863
{
59-
icon: 'edit',
64+
icon: <template><EditIcon class="size-4" /></template> as TOC<{
65+
Element: SVGSVGElement;
66+
}>,
6067
action: (element: unknown) => {
6168
console.log('Edit clicked', element);
6269
},
6370
name: 'Edit',
6471
},
6572
{
66-
icon: 'delete',
73+
icon: <template><DeleteIcon class="size-4" /></template> as TOC<{
74+
Element: SVGSVGElement;
75+
}>,
6776
action: (element: unknown) => {
6877
console.log('Delete clicked', element);
6978
},

doc-app/app/templates/dashboard/docs/ember-ui/prefabs/table-generic.gts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ export default class TpkTableGenericPrefabDocs extends Component<TpkTableGeneric
4646
)
4747
actionMenu=(array
4848
(hash
49-
icon="edit"
49+
icon=(component EditIcon)
5050
action=this.onEdit
5151
name="Edit"
5252
)
5353
(hash
54-
icon="delete"
54+
icon=(component DeleteIcon)
5555
action=this.onDelete
5656
name="Delete"
5757
)

doc-app/tests/integration/components/ember-input-validation/prefabs/tpk-validation-password-test.gts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,7 @@ module(
5757
await renderComponent({
5858
disabled: false,
5959
});
60-
assert
61-
.dom('[data-test-tpk-password-toggle-button]')
62-
.hasClass('tpk-password-toggle-button');
63-
assert
64-
.dom('[data-test-tpk-password-toggle-icon]')
65-
.hasAttribute('src', /data:image\/svg\+xml/);
60+
assert.dom('[data-test-tpk-password-toggle-icon-eye-shut]').exists();
6661
});
6762

6863
test('Input type should be password', async function (assert) {
@@ -86,10 +81,10 @@ module(
8681
disabled: false,
8782
});
8883
await click('[data-test-tpk-password-toggle-button]');
89-
84+
assert.dom('[data-test-tpk-password-toggle-icon-eye]').exists();
9085
assert
91-
.dom('[data-test-tpk-password-toggle-button] img')
92-
.hasAttribute('src', /data:image\/svg\+xml/);
86+
.dom('[data-test-tpk-password-toggle-icon-eye-shut]')
87+
.doesNotExist();
9388
});
9489

9590
test('When button is clicked twice, input type should be password', async function (assert) {

doc-app/tests/integration/components/ember-ui/action-menu-test.gts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,32 @@ import { setupRenderingTest } from 'ember-qunit';
33
import { render } from '@ember/test-helpers';
44
import { actionMenuObject } from 'doc-app/tests/pages/ember-actions-menu';
55
import TpkActionsMenu from '@triptyk/ember-ui/components/tpk-actions-menu';
6+
import EditIcon from 'doc-app/assets/icons/edit.gts';
67

78
module('Integration | Component | Action Menu', function (hooks) {
89
setupRenderingTest(hooks);
910

10-
async function renderActionMenu(assert: Assert, iconSrc?: string) {
11+
async function renderActionMenu(assert: Assert) {
1112
const act = () => {
1213
assert.step('action');
1314
};
1415

1516
return render(
1617
<template>
1718
<TpkActionsMenu as |Action|>
18-
<Action @icon={{iconSrc}} @action={{act}}>
19+
<Action @icon={{component EditIcon}} @action={{act}}>
1920
ActionText
2021
</Action>
2122
</TpkActionsMenu>
2223
</template>
2324
);
2425
}
2526

27+
test('actions list is not visible by default', async function (assert) {
28+
await renderActionMenu(assert);
29+
assert.false(actionMenuObject.areActionsVisible);
30+
});
31+
2632
test('when seeAllAction button is clicked, toggle actions visibility', async function (assert) {
2733
await renderActionMenu(assert);
2834
await actionMenuObject.seeAllAction();
@@ -40,17 +46,11 @@ module('Integration | Component | Action Menu', function (hooks) {
4046
});
4147

4248
test('when icon is passed, icon is displayed', async function (assert) {
43-
await renderActionMenu(assert, 'assets/action.svg');
49+
await renderActionMenu(assert);
4450
await actionMenuObject.seeAllAction();
4551
assert.true(actionMenuObject.actions.objectAt(0).isIconRendered);
4652
});
4753

48-
test('when menu is opened, pressing ESC close it', async function (assert) {
49-
await renderActionMenu(assert);
50-
await actionMenuObject.escape();
51-
assert.false(actionMenuObject.areActionsVisible);
52-
});
53-
5454
test('All base classes are present', async function (assert) {
5555
await renderActionMenu(assert);
5656
assert.dom('.actions').exists();

doc-app/tests/integration/components/ember-ui/prefabs/tpk-table-generic-prefab-test.gts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,12 @@ module(
9595
test('It passes correctly the actionMenu', async function (assert) {
9696
const actionMenu = [
9797
{
98-
icon: 'edit',
9998
action: () => {
10099
assert.step('rowClick function called');
101100
},
102101
name: 'Edit',
103102
},
104103
{
105-
icon: 'delete',
106104
action: () => {
107105
assert.step('delete function called');
108106
},
@@ -141,7 +139,7 @@ module(
141139
await renderComponent(tableParams);
142140
assert
143141
.dom('[data-test-table-generic-prefab] [data-test-row="1"]')
144-
?.hasText('Leroy Simon info@triptyk.eu');
142+
?.hasTextContaining('Leroy Simon info@triptyk.eu');
145143
});
146144

147145
test('it passes a renderElement', async function (assert) {

doc-app/tests/integration/components/ember-ui/table-generic/component-test.gts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { TableGenericUserWorker } from 'doc-app/tests/workers/table-generic';
66
import { setupRenderingTest } from 'ember-qunit';
77
import TpkTableGeneric from '@triptyk/ember-ui/components/tpk-table-generic';
88
import stringify from 'doc-app/helpers/to-string';
9+
import DeleteIcon from 'doc-app/assets/icons/delete.gts';
910

1011
module('Integration | Component | table-generic', function (hooks) {
1112
setupRenderingTest(hooks);
@@ -73,7 +74,7 @@ module('Integration | Component | table-generic', function (hooks) {
7374
</Body.Cell>
7475
<Body.ActionMenu as |Action|>
7576
<Action
76-
@icon="/assets/icons/delete.svg"
77+
@icon={{component DeleteIcon}}
7778
@action={{deleteAction}}
7879
data-test-delete
7980
>

doc-app/tests/pages/ember-actions-menu.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,27 @@ import {
33
collection,
44
create,
55
isPresent,
6-
triggerable,
76
} from 'ember-cli-page-object';
87

98
export const actionMenuObject = create({
109
scope: '[data-test-actions-menu]',
1110
seeAllAction: clickable('[data-test-actions-open-action]'),
12-
areActionsVisible: isPresent('ul'),
13-
escape: triggerable('keyup', undefined, {
14-
eventProperties: { key: 'Escape' },
15-
}),
11+
areActionsVisible: isPopoverOpen('[data-test-actions-list]'),
1612
actions: collection(
1713
'ul li',
1814
create({
1915
trigger: clickable('button'),
20-
isIconRendered: isPresent('img'),
16+
isIconRendered: isPresent('svg'),
2117
})
2218
),
2319
});
20+
21+
function isPopoverOpen(selector: string) {
22+
return {
23+
isDescriptor: true,
24+
get() {
25+
const el = document.querySelector(selector);
26+
return el?.matches(':popover-open') ?? false;
27+
},
28+
};
29+
}

doc-app/translations/en-us.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ global:
22
on: 'on'
33
results: 'results'
44
results_by_page: 'results by page'
5+
search: 'Search'
56

67
docs:
78
sections:

0 commit comments

Comments
 (0)