[EuiBasicTable] add `nameTooltip` API
alexwizp opened this issue · 3 comments
This feature request is based on this comment and suggests adding a new nameTooltip
API for EuiBasicTable
.
Example:
const columns = [
{
field: 'github',
name: 'Github',
nameTooltip: {
content: 'Their mascot is Octokitty',
icon: 'questionInCircle', // default icon, but can be customized
iconProps: { color: 'subdued' }, // allows customizing the icon color/size etc if needed
tooltipProps: { position: 'bottom' }, // allows additional tooltip configuration
},
render: (username: User['github']) => (
<EuiLink href="#" target="_blank">
{username}
</EuiLink>
),
},
];
I started implementing this in #8273 and I have a question regarding the actual API. (I went and read thru all previous discussion I could find).
I understand the proposed API is flexible enough while keeping things under control. And I believe it's also decoupled from the implementation. If we use EuiIconTip
, the props are mapped like this:
nameTooltip: {
content: 'Their mascot is Octokitty', // passed to EuiIconTip's `content` [same]
icon: 'questionInCircle', // passed to EuiIconTip's `type`
iconProps: { color: 'subdued' }, // passed to EuiIconTip's `iconProps` [same]
tooltipProps: { position: 'bottom' }, // spreaad to EuiIconTip's subset of the EuiToolTip props
},
I think this is good. But I'm also thinking whether things would be simpler if the shape of nameTooltip
would match exactly the props from EuiIconTip
.
The implementation would be simpler, there would be no need for a new shape/type, but it would be somehow bound to EuiIconTip
.
Is this a silly idea? What do you think?
Definitely not a silly idea, but (unfortunately) it's a bit of a question of consistency rather than optimal naming at this point. tooltipProps
is a fairly commonly used API across multiple components in EUI at this point, so it's one that's more familiar for devs to reach for (as opposed to having an entire object be the props for a dogfooded component, which isn't a pattern we've used previously in EUI).
Additionally, my 2c is I think a custom object structure is more flexible in terms of typing than doing something like nameTooltip?: EuiIconTipProps;
. It allows us to set default props for props that may otherwise be required by the underlying component. That's not necessarily a dealbreaker, just a typing hassle, so I think the consistency argument above is a slightly stronger one.