-
Notifications
You must be signed in to change notification settings - Fork 119
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(tooltip): composable tooltips - phase 1 #1725
Conversation
- Use tooltip provider for internal style pass through - Add column definitions to control table renderings - Improve color strip styles to render nicely in all cases - Add empty column/row states and logic to hide empties - Add rtl support - Add styles overrides for tooltip table components - Add highlighted row styles - Remove obsolete list styles
- Create new Tooltip spec for applying tooltip options - Merge deprecated legacy tooltip options from settings - Dry up all getSpecs repeated usages - Remove over simplified tooltip setting selectors - Remove unused tooltip default constants
buildkite update vrt |
- remove hideColor option and provider sync logic - add color, text, number and custom tooltip table column types - implement pass-through of generic types through all new types - fix missing generic type when using ComponentProps helper type - cleanup tooltip component api and render logic
@markov00 I updated the things we talked about this morning, namely:
Additionally, I added the option for a <Tooltip header={(items) => items.find(({ isHighlighted }) => isHighlighted)?.label ?? null} /> I still want to look at renaming some of the properties in the column types (i.e. |
buildkite update vrt |
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.
It looks great, I've left a few minor comments, but code-wise looks perfect.
packages/charts/src/chart_types/xy_chart/renderer/dom/annotations/line_marker.tsx
Show resolved
Hide resolved
Redesigned tooltip styles and adds composable tooltip components for users to develop custom tooltip configurations. Adds the option for `header` and `tooltip` on the default tooltip that provides the tooltip items for contextual headers and footers. BREAKING CHANGE: `Settings.tooltip` is deprecated in favor of the new `Tooltip` spec. Type changes related to `TooltipProps`, `TooltipSettings` and others see #1725. Changes to tooltip styles from dark to light theme. The Annotation tooltip class `.echAnnotation` used to target the icon, but now refers to the tooltip itself similar to `.echTooltip` and now `.echAnnotation__marker` refers to the icon itself. ```diff const tooltipProps = {...}; <Chart> - <Settings tooltip={tooltipProps} /> + <Tooltip {...tooltipProps} /> </Chart> ```
# [47.0.0](v46.13.0...v47.0.0) (2022-07-22) ### Bug Fixes * **deps:** update dependency @elastic/eui to ^60.3.0 ([#1755](#1755)) ([623b19f](623b19f)) ### Features * **tooltip:** composable tooltips - phase 1 ([#1725](#1725)) ([e79fa20](e79fa20)) ### BREAKING CHANGES * **tooltip:** `Settings.tooltip` is deprecated in favor of the new `Tooltip` spec. Type changes related to `TooltipProps`, `TooltipSettings` and others see #1725. Changes to tooltip styles from dark to light theme. The Annotation tooltip class `.echAnnotation` used to target the icon, but now refers to the tooltip itself similar to `.echTooltip` and now `.echAnnotation__marker` refers to the icon itself. ```diff const tooltipProps = {...}; <Chart> - <Settings tooltip={tooltipProps} /> + <Tooltip {...tooltipProps} /> </Chart> ```
Summary
Redesigns tooltip styles and adds composable tooltip components for users to develop custom tooltip configurations. Adds the option for
header
andtooltip
on the default tooltip that provides the tooltip items for contextual headers and footers.BREAKING CHANGES:
Settings.tooltip
is deprecated in favor of the newTooltip
spec. Type changes related toTooltipProps
,TooltipSettings
and others see #1725. Changes to tooltip styles from dark to light theme. The Annotation tooltip class.echAnnotation
used to target the icon, but now refers to the tooltip itself similar to.echTooltip
and now.echAnnotation__marker
refers to the icon itself.Details
Demo the tooltip in storybook here.
This pr decouples the existing tooltip components into exported atomic elements to make it easier to compose a tooltip as a list or table while maintaining styles. Cleans-up and simplifies tooltip logic and styles to reuse the same composable components.
New
Tooltip
SpecThe
Settings.tooltip
option is now deprecated in favor of the newTooltip
spec. All options are the same such thatSettings.tooltip
can be spread over theTooltip
option, such as...New components
Tooltip components
TooltipWrapper
- Used as wrapper around content (i.e..echTooltip
)TooltipHeader
TooltipMetricRow
TooltipFooter
Tabular Tooltip components
TooltipTable
TooltipTableHeader
TooltipTableBody
TooltipTableFooter
TooltipTableRow
TooltipTableCell
TooltipTableColorCell
Tooltip portal ref changes
These changes improve and simplify the internal ref logic related to the tooltip and portals. The main api change is that now the
anchor
prop on theTooltipPortal
allows for passing a ref (i.e.PortalAnchorRef
) being an actual dom element ref or passing an indirect ref and position (i.e.PositionedPortalAnchorRef
) which will be used to create an pseudo-ref to place tooltip.Type changes
Added types
The
PropsOrChildrenWithProps
type allows for simple type to defined a union between rendering props which includeschildren
(i.e.PropsWithChildren
) or render props that excludechildren
(i.e.PropsWithoutChildren
). This enables a flexible component that can be used in either case and split the props respective of the usage.Adds
TooltipTableColumn
to define the columns for generating a tabular tooltip.Changed types
TooltipSettings
- Used to unionize the string tooltip type and theTooltipProps
object. This is no longer needed and is deprecated to be removed soon.TooltipValue
- Now acceptsDatum
andSeriesIdentifier
generics to narrow type for different chart types.TooltipProps
- To maintain naming conventions for all spec props to be exported as<Spec>Props
name. The oldTooltipProps
type was used to define all tooltip settings. The newTooltipProps
type defines to props of the newTooltip
spec which overlaps all previous values, so should be minimal impact.XYChartSeriesIdentifier
- AddsxAccessor
stringIssues
related to #615
Checklist
:xy
,:partition
):interactions
,:axis
):theme
label has been added and the@elastic/eui-design
team has been pinged when there areTheme
API changescloses #123
,fixes #123
)packages/charts/src/index.ts
dark
,light
,eui-dark
&eui-light