-
Notifications
You must be signed in to change notification settings - Fork 23
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
feat(start-ui): allow usage of tooltip #2146
Open
dm148
wants to merge
2
commits into
NationalBankBelgium:master
Choose a base branch
from
dm148:feature/1700-table-tooltip
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 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
This file contains 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 |
---|---|---|
|
@@ -214,6 +214,40 @@ export class StarkTableColumnComponent extends AbstractStarkUiComponent implemen | |
@Input() | ||
public stickyEnd = false; | ||
|
||
/** | ||
* A function to generate tooltip for cells based on the value, its row and the name of the column. | ||
* Or a static string with the tooltip. | ||
*/ | ||
@Input() | ||
public cellTooltip?: ((value: any, row?: object, columnName?: string) => string) | string; | ||
|
||
/** | ||
* Position where the tooltip should be displayed. | ||
* Default: "below" | ||
* Possible positions: above, below, left, right, before, after | ||
*/ | ||
@Input() | ||
public get cellTooltipPosition(): string { | ||
return this._cellTooltipPosition; | ||
} | ||
|
||
public set cellTooltipPosition(tooltip: string) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same remark about using specific types instead of just |
||
this._cellTooltipPosition = tooltip || "below"; | ||
} | ||
|
||
/** | ||
* @ignore | ||
* @internal | ||
*/ | ||
private _cellTooltipPosition = "below" | ||
|
||
/** | ||
* A function to generate classNames for the tooltip of cells based on the value, its row and the name of the column. | ||
* Or a static string with the classNames. | ||
*/ | ||
@Input() | ||
public cellTooltipClassName?: ((value: any, row?: object, columnName?: string) => string) | string; | ||
|
||
/** | ||
* Output that will emit a StarkColumnCellClickedOutput whenever a cell in the column is clicked | ||
*/ | ||
|
@@ -420,4 +454,40 @@ export class StarkTableColumnComponent extends AbstractStarkUiComponent implemen | |
|
||
return classes.join(" "); | ||
} | ||
|
||
/** | ||
* Gets the tooltip for a specific cell, if the cellTooltip Input or the cellTooltipFn function has been given as an Input. | ||
* @param row - The data object of the row the cell is in. | ||
* @returns The tooltip for the cell. | ||
*/ | ||
public getCellTooltip(row: object): string { | ||
if (!this.cellTooltip) { | ||
return ""; | ||
} | ||
|
||
if (typeof this.cellTooltip === "string") { | ||
return this.cellTooltip; | ||
} | ||
|
||
const value: any = this.getRawValue(row); | ||
return this.cellTooltip(value, row, this.name); | ||
} | ||
|
||
/** | ||
* Gets the classes for the tooltip of a specific cell, if the cellTooltipClassName Input or the cellTooltipClassNameFn function has been given as an Input. | ||
* @param row - The data object of the row the cell is in. | ||
* @returns The classes for the tooltip of the cell. | ||
*/ | ||
public getCellTooltipClassNames(row: object): string { | ||
if (!this.cellTooltipClassName) { | ||
return ""; | ||
} | ||
|
||
if (typeof this.cellTooltipClassName === "string") { | ||
return this.cellTooltipClassName; | ||
} | ||
|
||
const value: any = this.getRawValue(row); | ||
return this.cellTooltipClassName(value, row, this.name); | ||
} | ||
} |
This file contains 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
Oops, something went wrong.
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.
What if the tooltip is an empty string
""
? I think we should disable the tooltip in such cases with thematTooltipDisabled
property otherwise I fear that Angular Material would still be doing some logic to display the tooltip which will be overkill if that would be an empty string in the end.Another solution would be to have 2
<td mat-cell>
with an*ngIf
: one will contain the[matTooltip]
if there is a relevant tooltip to show (not empty). And the other one won't contain the[matTooltip]
, basically the same we had before, when there is no tooltip to show.What do you think?