-
Notifications
You must be signed in to change notification settings - Fork 11
feat: adding explore filter link component #776
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...bservability/src/shared/components/explore-filter-link/explore-filter-link.component.scss
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
@import 'font'; | ||
@import 'color-palette'; | ||
|
||
.explore-filter { | ||
display: flex; | ||
flex-direction: row; | ||
align-items: center; | ||
|
||
.filter-icon { | ||
transition: all 0.2s ease-in-out; | ||
} | ||
|
||
&:hover { | ||
.filter-icon { | ||
transform: scale(1.2); | ||
} | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
...rvability/src/shared/components/explore-filter-link/explore-filter-link.component.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { IconType } from '@hypertrace/assets-library'; | ||
import { IconComponent, IconSize, LinkComponent } from '@hypertrace/components'; | ||
import { createHostFactory, SpectatorHost } from '@ngneat/spectator/jest'; | ||
import { MockComponent } from 'ng-mocks'; | ||
import { ExploreFilterLinkComponent } from './explore-filter-link.component'; | ||
|
||
describe('Explore Filter Link component', () => { | ||
let spectator: SpectatorHost<ExploreFilterLinkComponent>; | ||
|
||
const createHost = createHostFactory({ | ||
component: ExploreFilterLinkComponent, | ||
declarations: [MockComponent(LinkComponent), MockComponent(IconComponent)] | ||
}); | ||
|
||
test('should display all elements', () => { | ||
spectator = createHost(`<ht-explore-filter-link [paramsOrUrl]="paramsOrUrl"></ht-explore-filter-link>`, { | ||
props: { | ||
paramsOrUrl: undefined | ||
} | ||
}); | ||
|
||
expect(spectator.query('.ht-link')).not.toExist(); | ||
}); | ||
|
||
test('Link should navigate correctly to external URLs', () => { | ||
spectator = createHost(`<ht-explore-filter-link [paramsOrUrl]="paramsOrUrl"></ht-explore-filter-link>`, { | ||
hostProps: { | ||
paramsOrUrl: 'http://test.hypertrace.ai' | ||
} | ||
}); | ||
|
||
const linkComponent = spectator.query(LinkComponent); | ||
expect(linkComponent).toExist(); | ||
expect(linkComponent?.paramsOrUrl).toEqual('http://test.hypertrace.ai'); | ||
|
||
const iconComponent = spectator.query(IconComponent); | ||
expect(iconComponent).toExist(); | ||
expect(iconComponent?.icon).toEqual(IconType.Filter); | ||
expect(iconComponent?.size).toEqual(IconSize.ExtraSmall); | ||
}); | ||
}); |
20 changes: 20 additions & 0 deletions
20
.../observability/src/shared/components/explore-filter-link/explore-filter-link.component.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { ChangeDetectionStrategy, Component, Input } from '@angular/core'; | ||
import { IconType } from '@hypertrace/assets-library'; | ||
import { NavigationParams } from '@hypertrace/common'; | ||
import { IconSize } from '@hypertrace/components'; | ||
|
||
@Component({ | ||
selector: 'ht-explore-filter-link', | ||
styleUrls: ['./explore-filter-link.component.scss'], | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
template: ` | ||
<ht-link class="explore-filter" [paramsOrUrl]="this.paramsOrUrl"> | ||
<ng-content></ng-content> | ||
<ht-icon class="filter-icon" size="${IconSize.ExtraSmall}" icon="${IconType.Filter}"></ht-icon> | ||
</ht-link> | ||
` | ||
}) | ||
export class ExploreFilterLinkComponent { | ||
@Input() | ||
public paramsOrUrl?: NavigationParams | string; | ||
} |
11 changes: 11 additions & 0 deletions
11
...cts/observability/src/shared/components/explore-filter-link/explore-filter-link.module.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { CommonModule } from '@angular/common'; | ||
import { NgModule } from '@angular/core'; | ||
import { IconModule, LinkModule } from '@hypertrace/components'; | ||
import { ExploreFilterLinkComponent } from './explore-filter-link.component'; | ||
|
||
@NgModule({ | ||
declarations: [ExploreFilterLinkComponent], | ||
exports: [ExploreFilterLinkComponent], | ||
imports: [CommonModule, LinkModule, IconModule] | ||
}) | ||
export class ExploreFilterLinkModule {} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feels a bit weird to call this explore filter link when it doesn't reference explorer, it just adds a filter icon around a provided link + content.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The icon type should be more specific to explorer.