Skip to content

Commit a61955b

Browse files
authored
Mickey makes more js (#144)
* fix: use icon gts instead svg file + adapt test + use dropdown popover for action menu and design table * feat: new theme selector ember ui + convert more svg * fix: test lint lefthook * fix: test lint lefthook * fix: test lint lefthook again * fix: handle also french trad * refactor: update chevron icons to use attributes and replace inline SVG in navbar with ChevronDownIcon
1 parent a988657 commit a61955b

File tree

79 files changed

+1054
-415
lines changed

Some content is hidden

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

79 files changed

+1054
-415
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;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import type { TOC } from '@ember/component/template-only';
2+
3+
const GettingStartedIcon: 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="M4.26 10.147a60.438 60.438 0 0 0-.491 6.347A48.62 48.62 0 0 1 12 20.904a48.62 48.62 0 0 1 8.232-4.41 60.46 60.46 0 0 0-.491-6.347m-15.482 0a50.636 50.636 0 0 0-2.658-.813A59.906 59.906 0 0 1 12 3.493a59.903 59.903 0 0 1 10.399 5.84c-.896.248-1.783.52-2.658.814m-15.482 0A50.717 50.717 0 0 1 12 13.489a50.702 50.702 0 0 1 7.74-3.342M6.75 15a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5Zm0 0v-3.675A55.378 55.378 0 0 1 12 8.443m-7.007 11.55A5.981 5.981 0 0 0 6.75 15.75v-1.5"
16+
/>
17+
</svg>
18+
</template>;
19+
export default GettingStartedIcon;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import type { TOC } from '@ember/component/template-only';
2+
3+
const InstallationIcon: 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="m9 12.75 3 3m0 0 3-3m-3 3v-7.5M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"
16+
/>
17+
</svg>
18+
</template>;
19+
export default InstallationIcon;

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/routes/application.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import Route from '@ember/routing/route';
33
import { type Registry as Services, service } from '@ember/service';
44
import translationsForEnUs from 'virtual:ember-intl/translations/en-us';
5+
import translationsForFrFr from 'virtual:ember-intl/translations/fr-fr';
56

67
export default class ApplicationRoute extends Route {
78
@service declare intl: Services['intl'];
@@ -12,6 +13,7 @@ export default class ApplicationRoute extends Route {
1213

1314
private setupIntl(): void {
1415
this.intl.addTranslations('en-us', translationsForEnUs);
16+
this.intl.addTranslations('fr-fr', translationsForFrFr);
1517
this.intl.setLocale(['en-us']);
1618
}
1719
}

doc-app/app/templates/dashboard.gts

Lines changed: 10 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ import TpkDashBoard, {
44
type SidebarItem,
55
} from '@triptyk/ember-ui/components/prefabs/tpk-dashboard';
66
import type { TOC } from '@ember/component/template-only';
7-
import ThemeSelector from 'doc-app/components/theme-selector';
7+
import TpkThemeSelector from '@triptyk/ember-ui/components/prefabs/tpk-theme-selector';
88
import { service } from '@ember/service';
99
import type { IntlService } from 'ember-intl';
1010
import { action } from '@ember/object';
11+
import GettingStartedIcon from 'doc-app/assets/icons/getting-started.gts';
12+
import InstallationIcon from 'doc-app/assets/icons/installation.gts';
1113

1214
export default class DashboardTemplate extends Component {
1315
@service declare intl: IntlService;
@@ -27,43 +29,17 @@ export default class DashboardTemplate extends Component {
2729
type: 'link',
2830
label: 'Getting Started',
2931
route: 'dashboard.docs.ember-input-validation.prefabs.input',
30-
icon: <template>
31-
<svg
32-
xmlns="http://www.w3.org/2000/svg"
33-
fill="none"
34-
viewBox="0 0 24 24"
35-
stroke-width="1.5"
36-
stroke="currentColor"
37-
class="size-4"
38-
>
39-
<path
40-
stroke-linecap="round"
41-
stroke-linejoin="round"
42-
d="M4.26 10.147a60.438 60.438 0 0 0-.491 6.347A48.62 48.62 0 0 1 12 20.904a48.62 48.62 0 0 1 8.232-4.41 60.46 60.46 0 0 0-.491-6.347m-15.482 0a50.636 50.636 0 0 0-2.658-.813A59.906 59.906 0 0 1 12 3.493a59.903 59.903 0 0 1 10.399 5.84c-.896.248-1.783.52-2.658.814m-15.482 0A50.717 50.717 0 0 1 12 13.489a50.702 50.702 0 0 1 7.74-3.342M6.75 15a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5Zm0 0v-3.675A55.378 55.378 0 0 1 12 8.443m-7.007 11.55A5.981 5.981 0 0 0 6.75 15.75v-1.5"
43-
/>
44-
</svg>
45-
</template> as TOC<{ Element: SVGSVGElement }>,
32+
icon: <template><GettingStartedIcon class="size-4" /></template> as TOC<{
33+
Element: SVGSVGElement;
34+
}>,
4635
},
4736
{
4837
type: 'link',
4938
label: 'Installation',
5039
route: 'dashboard.docs.ember-input-validation.prefabs.input',
51-
icon: <template>
52-
<svg
53-
xmlns="http://www.w3.org/2000/svg"
54-
fill="none"
55-
viewBox="0 0 24 24"
56-
stroke-width="1.5"
57-
stroke="currentColor"
58-
class="size-4"
59-
>
60-
<path
61-
stroke-linecap="round"
62-
stroke-linejoin="round"
63-
d="m9 12.75 3 3m0 0 3-3m-3 3v-7.5M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"
64-
/>
65-
</svg>
66-
</template> as TOC<{ Element: SVGSVGElement }>,
40+
icon: <template><InstallationIcon class="size-4" /></template> as TOC<{
41+
Element: SVGSVGElement;
42+
}>,
6743
},
6844
{
6945
type: 'group',
@@ -314,7 +290,7 @@ export default class DashboardTemplate extends Component {
314290
</svg>
315291
</a>
316292
</div>
317-
<ThemeSelector />
293+
<TpkThemeSelector @localStorageKey="doc-app-theme" />
318294
</div>
319295
</:footer>
320296
<:content>

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/app/templates/home.gts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import TpkDashBoard, {
77
type Language,
88
} from '@triptyk/ember-ui/components/prefabs/tpk-dashboard';
99
import type { TOC } from '@ember/component/template-only';
10-
import ThemeSelector from 'doc-app/components/theme-selector';
10+
import TpkThemeSelector from '@triptyk/ember-ui/components/prefabs/tpk-theme-selector';
1111
import { hash } from '@ember/helper';
1212
import type { IntlService } from 'ember-intl';
1313

@@ -165,7 +165,10 @@ export default class DashboardTemplate extends Component {
165165
</:content>
166166
<:footer>
167167
<div class="flex items-center justify-center w-full p-2 px-4">
168-
<ThemeSelector @sidebarCollapsed={{this.sidebarCollapsed}} />
168+
<TpkThemeSelector
169+
@sidebarCollapsed={{this.sidebarCollapsed}}
170+
@localStorageKey="doc-app-theme"
171+
/>
169172
</div>
170173
</:footer>
171174
<:menu>

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) {

0 commit comments

Comments
 (0)