Skip to content

Commit ede25fc

Browse files
authored
feat: adding explore filter link component (#776)
* feat: adding explore filter link component * refactor: fixing lint
1 parent f9a0b85 commit ede25fc

File tree

5 files changed

+94
-0
lines changed

5 files changed

+94
-0
lines changed

projects/observability/src/public-api.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,10 @@ export * from './shared/components/timeline-card-list/timeline-card-list.compone
197197
export * from './shared/components/timeline-card-list/container/timeline-card-container.component';
198198
export * from './shared/components/timeline-card-list/timeline-card-list.module';
199199

200+
// Explore Filter link
201+
export * from './shared/components/explore-filter-link/explore-filter-link.component';
202+
export * from './shared/components/explore-filter-link/explore-filter-link.module';
203+
200204
// Interval Select
201205
export * from './shared/components/interval-select/interval-select.component';
202206
export * from './shared/components/interval-select/interval-select.module';
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
@import 'font';
2+
@import 'color-palette';
3+
4+
.explore-filter {
5+
display: flex;
6+
flex-direction: row;
7+
align-items: center;
8+
9+
.filter-icon {
10+
transition: all 0.2s ease-in-out;
11+
}
12+
13+
&:hover {
14+
.filter-icon {
15+
transform: scale(1.2);
16+
}
17+
}
18+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { IconType } from '@hypertrace/assets-library';
2+
import { IconComponent, IconSize, LinkComponent } from '@hypertrace/components';
3+
import { createHostFactory, SpectatorHost } from '@ngneat/spectator/jest';
4+
import { MockComponent } from 'ng-mocks';
5+
import { ExploreFilterLinkComponent } from './explore-filter-link.component';
6+
7+
describe('Explore Filter Link component', () => {
8+
let spectator: SpectatorHost<ExploreFilterLinkComponent>;
9+
10+
const createHost = createHostFactory({
11+
component: ExploreFilterLinkComponent,
12+
declarations: [MockComponent(LinkComponent), MockComponent(IconComponent)]
13+
});
14+
15+
test('should display all elements', () => {
16+
spectator = createHost(`<ht-explore-filter-link [paramsOrUrl]="paramsOrUrl"></ht-explore-filter-link>`, {
17+
props: {
18+
paramsOrUrl: undefined
19+
}
20+
});
21+
22+
expect(spectator.query('.ht-link')).not.toExist();
23+
});
24+
25+
test('Link should navigate correctly to external URLs', () => {
26+
spectator = createHost(`<ht-explore-filter-link [paramsOrUrl]="paramsOrUrl"></ht-explore-filter-link>`, {
27+
hostProps: {
28+
paramsOrUrl: 'http://test.hypertrace.ai'
29+
}
30+
});
31+
32+
const linkComponent = spectator.query(LinkComponent);
33+
expect(linkComponent).toExist();
34+
expect(linkComponent?.paramsOrUrl).toEqual('http://test.hypertrace.ai');
35+
36+
const iconComponent = spectator.query(IconComponent);
37+
expect(iconComponent).toExist();
38+
expect(iconComponent?.icon).toEqual(IconType.Filter);
39+
expect(iconComponent?.size).toEqual(IconSize.ExtraSmall);
40+
});
41+
});
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
2+
import { IconType } from '@hypertrace/assets-library';
3+
import { NavigationParams } from '@hypertrace/common';
4+
import { IconSize } from '@hypertrace/components';
5+
6+
@Component({
7+
selector: 'ht-explore-filter-link',
8+
styleUrls: ['./explore-filter-link.component.scss'],
9+
changeDetection: ChangeDetectionStrategy.OnPush,
10+
template: `
11+
<ht-link class="explore-filter" [paramsOrUrl]="this.paramsOrUrl">
12+
<ng-content></ng-content>
13+
<ht-icon class="filter-icon" size="${IconSize.ExtraSmall}" icon="${IconType.Filter}"></ht-icon>
14+
</ht-link>
15+
`
16+
})
17+
export class ExploreFilterLinkComponent {
18+
@Input()
19+
public paramsOrUrl?: NavigationParams | string;
20+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { CommonModule } from '@angular/common';
2+
import { NgModule } from '@angular/core';
3+
import { IconModule, LinkModule } from '@hypertrace/components';
4+
import { ExploreFilterLinkComponent } from './explore-filter-link.component';
5+
6+
@NgModule({
7+
declarations: [ExploreFilterLinkComponent],
8+
exports: [ExploreFilterLinkComponent],
9+
imports: [CommonModule, LinkModule, IconModule]
10+
})
11+
export class ExploreFilterLinkModule {}

0 commit comments

Comments
 (0)