Skip to content

Commit

Permalink
feat(data-grid): added tooltip and scale-icon in data-grid action cell (
Browse files Browse the repository at this point in the history
telekom#2308)

Co-authored-by: felixw <[email protected]>
  • Loading branch information
felix-ico and felixw authored Oct 24, 2024
1 parent 6e8c380 commit 30a0ce5
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,22 @@ export const ActionsCell: Cell = {
return (
<div class={`tbody__actions`}>
{content.map((action) => {
const { label, ...props } = action;
const { label, iconName, tooltip, ...props } = action;
const tooltipProps = tooltip ? { title: tooltip } : {};
const IconComponent = resolveIconComponent(iconName);
if (typeof label === 'object' && '__html' in label) {
return (
<scale-button
size="small"
innerHTML={label.__html}
{...props}
{...tooltipProps}
></scale-button>
);
}
return (
<scale-button size="small" {...props}>
<scale-button size="small" {...props} {...tooltipProps}>
{IconComponent}
{label}
</scale-button>
);
Expand All @@ -38,3 +42,15 @@ export const ActionsCell: Cell = {
);
},
};

function resolveIconComponent(iconName) {
switch (iconName) {
case 'edit':
return <scale-icon-action-edit></scale-icon-action-edit>;
case 'delete':
return <scale-icon-action-remove></scale-icon-action-remove>;

default:
return null;
}
}
4 changes: 4 additions & 0 deletions packages/components/src/components/data-grid/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@
- [scale-dropdown-select-item](../dropdown-select-item)
- [scale-tag](../tag)
- [scale-text-field](../text-field)
- [scale-icon-action-edit](../icons/action-edit)
- [scale-icon-action-remove](../icons/action-remove)

### Graph
```mermaid
Expand All @@ -87,6 +89,8 @@ graph TD;
scale-data-grid --> scale-dropdown-select-item
scale-data-grid --> scale-tag
scale-data-grid --> scale-text-field
scale-data-grid --> scale-icon-action-edit
scale-data-grid --> scale-icon-action-remove
scale-menu-flyout-item --> scale-icon-action-checkmark
scale-menu-flyout-item --> scale-icon-navigation-right
scale-checkbox --> scale-icon-action-minus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ export class DatePicker {
dateAdapter={this.dateAdapter}
disabled={this.disabled}
value={this.value}
ref={(element: HTMLElement & DuetDatePicker) =>
ref={(element: HTMLDuetDatePickerElement & DuetDatePicker) =>
(this.duetInput = element)
}
></duet-date-picker>
Expand Down

0 comments on commit 30a0ce5

Please sign in to comment.