diff --git a/packages/eui/.loki/reference/chrome_desktop_Display_EuiComment_EuiCommentEvent_Custom.png b/packages/eui/.loki/reference/chrome_desktop_Display_EuiComment_EuiCommentEvent_Custom.png index cb94ac0fc4b..1fc03a4403f 100644 Binary files a/packages/eui/.loki/reference/chrome_desktop_Display_EuiComment_EuiCommentEvent_Custom.png and b/packages/eui/.loki/reference/chrome_desktop_Display_EuiComment_EuiCommentEvent_Custom.png differ diff --git a/packages/eui/.loki/reference/chrome_desktop_Display_EuiComment_EuiCommentEvent_Regular.png b/packages/eui/.loki/reference/chrome_desktop_Display_EuiComment_EuiCommentEvent_Regular.png index 185a7e3f18a..4a62d32f172 100644 Binary files a/packages/eui/.loki/reference/chrome_desktop_Display_EuiComment_EuiCommentEvent_Regular.png and b/packages/eui/.loki/reference/chrome_desktop_Display_EuiComment_EuiCommentEvent_Regular.png differ diff --git a/packages/eui/.loki/reference/chrome_desktop_Display_EuiComment_EuiCommentEvent_Update.png b/packages/eui/.loki/reference/chrome_desktop_Display_EuiComment_EuiCommentEvent_Update.png index 09e7ca679f2..af8f4552179 100644 Binary files a/packages/eui/.loki/reference/chrome_desktop_Display_EuiComment_EuiCommentEvent_Update.png and b/packages/eui/.loki/reference/chrome_desktop_Display_EuiComment_EuiCommentEvent_Update.png differ diff --git a/packages/eui/.loki/reference/chrome_desktop_Display_EuiComment_EuiCommentList_Playground.png b/packages/eui/.loki/reference/chrome_desktop_Display_EuiComment_EuiCommentList_Playground.png index 3f944d8ccc3..6c08187739d 100644 Binary files a/packages/eui/.loki/reference/chrome_desktop_Display_EuiComment_EuiCommentList_Playground.png and b/packages/eui/.loki/reference/chrome_desktop_Display_EuiComment_EuiCommentList_Playground.png differ diff --git a/packages/eui/.loki/reference/chrome_desktop_Display_EuiComment_EuiComment_Playground.png b/packages/eui/.loki/reference/chrome_desktop_Display_EuiComment_EuiComment_Playground.png index a0d83fb343c..8d384568d3f 100644 Binary files a/packages/eui/.loki/reference/chrome_desktop_Display_EuiComment_EuiComment_Playground.png and b/packages/eui/.loki/reference/chrome_desktop_Display_EuiComment_EuiComment_Playground.png differ diff --git a/packages/eui/.loki/reference/chrome_desktop_Display_EuiListGroup_EuiListGroupItem_Playground.png b/packages/eui/.loki/reference/chrome_desktop_Display_EuiListGroup_EuiListGroupItem_Playground.png index 6e4394a2fea..466bfbb7380 100644 Binary files a/packages/eui/.loki/reference/chrome_desktop_Display_EuiListGroup_EuiListGroupItem_Playground.png and b/packages/eui/.loki/reference/chrome_desktop_Display_EuiListGroup_EuiListGroupItem_Playground.png differ diff --git a/packages/eui/.loki/reference/chrome_desktop_Display_EuiListGroup_EuiListGroup_Playground.png b/packages/eui/.loki/reference/chrome_desktop_Display_EuiListGroup_EuiListGroup_Playground.png index 010b123f9b4..e4bb644b468 100644 Binary files a/packages/eui/.loki/reference/chrome_desktop_Display_EuiListGroup_EuiListGroup_Playground.png and b/packages/eui/.loki/reference/chrome_desktop_Display_EuiListGroup_EuiListGroup_Playground.png differ diff --git a/packages/eui/.loki/reference/chrome_desktop_Display_EuiPinnableListGroup_Playground.png b/packages/eui/.loki/reference/chrome_desktop_Display_EuiPinnableListGroup_Playground.png index b311bebd95f..a06879444ad 100644 Binary files a/packages/eui/.loki/reference/chrome_desktop_Display_EuiPinnableListGroup_Playground.png and b/packages/eui/.loki/reference/chrome_desktop_Display_EuiPinnableListGroup_Playground.png differ diff --git a/packages/eui/.loki/reference/chrome_desktop_Display_EuiTimeline_EuiTimelineItem_Playground.png b/packages/eui/.loki/reference/chrome_desktop_Display_EuiTimeline_EuiTimelineItem_Playground.png index 15d957246d6..1c02936bed1 100644 Binary files a/packages/eui/.loki/reference/chrome_desktop_Display_EuiTimeline_EuiTimelineItem_Playground.png and b/packages/eui/.loki/reference/chrome_desktop_Display_EuiTimeline_EuiTimelineItem_Playground.png differ diff --git a/packages/eui/.loki/reference/chrome_desktop_Display_EuiTimeline_EuiTimeline_Playground.png b/packages/eui/.loki/reference/chrome_desktop_Display_EuiTimeline_EuiTimeline_Playground.png index 38293d03752..ce7ccc61c8f 100644 Binary files a/packages/eui/.loki/reference/chrome_desktop_Display_EuiTimeline_EuiTimeline_Playground.png and b/packages/eui/.loki/reference/chrome_desktop_Display_EuiTimeline_EuiTimeline_Playground.png differ diff --git a/packages/eui/.loki/reference/chrome_desktop_Display_EuiTimeline_Subcomponents_EuiTimelineItemEvent_Playground.png b/packages/eui/.loki/reference/chrome_desktop_Display_EuiTimeline_Subcomponents_EuiTimelineItemEvent_Playground.png index 517308bc5a2..c3e8f6b0c11 100644 Binary files a/packages/eui/.loki/reference/chrome_desktop_Display_EuiTimeline_Subcomponents_EuiTimelineItemEvent_Playground.png and b/packages/eui/.loki/reference/chrome_desktop_Display_EuiTimeline_Subcomponents_EuiTimelineItemEvent_Playground.png differ diff --git a/packages/eui/.loki/reference/chrome_desktop_Forms_EuiDualRange_Input.png b/packages/eui/.loki/reference/chrome_desktop_Forms_EuiDualRange_Input.png index 7d3fb2048af..75f27cd40b2 100644 Binary files a/packages/eui/.loki/reference/chrome_desktop_Forms_EuiDualRange_Input.png and b/packages/eui/.loki/reference/chrome_desktop_Forms_EuiDualRange_Input.png differ diff --git a/packages/eui/.loki/reference/chrome_desktop_Forms_EuiDualRange_Input_With_Popover.png b/packages/eui/.loki/reference/chrome_desktop_Forms_EuiDualRange_Input_With_Popover.png index e79e57f6576..f1f86cc1971 100644 Binary files a/packages/eui/.loki/reference/chrome_desktop_Forms_EuiDualRange_Input_With_Popover.png and b/packages/eui/.loki/reference/chrome_desktop_Forms_EuiDualRange_Input_With_Popover.png differ diff --git a/packages/eui/.loki/reference/chrome_desktop_Forms_EuiDualRange_Levels.png b/packages/eui/.loki/reference/chrome_desktop_Forms_EuiDualRange_Levels.png index 1c4dfa789a1..72062106e27 100644 Binary files a/packages/eui/.loki/reference/chrome_desktop_Forms_EuiDualRange_Levels.png and b/packages/eui/.loki/reference/chrome_desktop_Forms_EuiDualRange_Levels.png differ diff --git a/packages/eui/.loki/reference/chrome_desktop_Forms_EuiDualRange_Ticks.png b/packages/eui/.loki/reference/chrome_desktop_Forms_EuiDualRange_Ticks.png index 81c85e8ee02..3f7e8762949 100644 Binary files a/packages/eui/.loki/reference/chrome_desktop_Forms_EuiDualRange_Ticks.png and b/packages/eui/.loki/reference/chrome_desktop_Forms_EuiDualRange_Ticks.png differ diff --git a/packages/eui/.loki/reference/chrome_desktop_Forms_EuiFilterGroup_Multiple_Popovers.png b/packages/eui/.loki/reference/chrome_desktop_Forms_EuiFilterGroup_Multiple_Popovers.png index 554e7fac72d..d28e5d2082e 100644 Binary files a/packages/eui/.loki/reference/chrome_desktop_Forms_EuiFilterGroup_Multiple_Popovers.png and b/packages/eui/.loki/reference/chrome_desktop_Forms_EuiFilterGroup_Multiple_Popovers.png differ diff --git a/packages/eui/.loki/reference/chrome_desktop_Forms_EuiFilterGroup_Playground.png b/packages/eui/.loki/reference/chrome_desktop_Forms_EuiFilterGroup_Playground.png index e104fba7eb2..f6519b8cd17 100644 Binary files a/packages/eui/.loki/reference/chrome_desktop_Forms_EuiFilterGroup_Playground.png and b/packages/eui/.loki/reference/chrome_desktop_Forms_EuiFilterGroup_Playground.png differ diff --git a/packages/eui/.loki/reference/chrome_desktop_Forms_EuiFilterGroup_With_Popover.png b/packages/eui/.loki/reference/chrome_desktop_Forms_EuiFilterGroup_With_Popover.png index addc5e8e5d4..a87a6013d38 100644 Binary files a/packages/eui/.loki/reference/chrome_desktop_Forms_EuiFilterGroup_With_Popover.png and b/packages/eui/.loki/reference/chrome_desktop_Forms_EuiFilterGroup_With_Popover.png differ diff --git a/packages/eui/.loki/reference/chrome_desktop_Forms_EuiRange_Input.png b/packages/eui/.loki/reference/chrome_desktop_Forms_EuiRange_Input.png index 9a0e81649d4..96bdd2a783e 100644 Binary files a/packages/eui/.loki/reference/chrome_desktop_Forms_EuiRange_Input.png and b/packages/eui/.loki/reference/chrome_desktop_Forms_EuiRange_Input.png differ diff --git a/packages/eui/.loki/reference/chrome_desktop_Forms_EuiRange_Levels.png b/packages/eui/.loki/reference/chrome_desktop_Forms_EuiRange_Levels.png index dd549126cb3..780e8e5034a 100644 Binary files a/packages/eui/.loki/reference/chrome_desktop_Forms_EuiRange_Levels.png and b/packages/eui/.loki/reference/chrome_desktop_Forms_EuiRange_Levels.png differ diff --git a/packages/eui/.loki/reference/chrome_desktop_Forms_EuiRange_Ticks.png b/packages/eui/.loki/reference/chrome_desktop_Forms_EuiRange_Ticks.png index bfa99e190a6..4cf2664190a 100644 Binary files a/packages/eui/.loki/reference/chrome_desktop_Forms_EuiRange_Ticks.png and b/packages/eui/.loki/reference/chrome_desktop_Forms_EuiRange_Ticks.png differ diff --git a/packages/eui/.loki/reference/chrome_desktop_Forms_EuiRange_Value_Tooltip.png b/packages/eui/.loki/reference/chrome_desktop_Forms_EuiRange_Value_Tooltip.png index 4864dbf371d..f2cf78b4da5 100644 Binary files a/packages/eui/.loki/reference/chrome_desktop_Forms_EuiRange_Value_Tooltip.png and b/packages/eui/.loki/reference/chrome_desktop_Forms_EuiRange_Value_Tooltip.png differ diff --git a/packages/eui/.loki/reference/chrome_desktop_Navigation_EuiFacetButton_Playground.png b/packages/eui/.loki/reference/chrome_desktop_Navigation_EuiFacetButton_Playground.png index 4bb418eb234..73324dd4c15 100644 Binary files a/packages/eui/.loki/reference/chrome_desktop_Navigation_EuiFacetButton_Playground.png and b/packages/eui/.loki/reference/chrome_desktop_Navigation_EuiFacetButton_Playground.png differ diff --git a/packages/eui/.loki/reference/chrome_desktop_Navigation_EuiFacetGroup_Playground.png b/packages/eui/.loki/reference/chrome_desktop_Navigation_EuiFacetGroup_Playground.png index df18c9621d7..88e1ef969a5 100644 Binary files a/packages/eui/.loki/reference/chrome_desktop_Navigation_EuiFacetGroup_Playground.png and b/packages/eui/.loki/reference/chrome_desktop_Navigation_EuiFacetGroup_Playground.png differ diff --git a/packages/eui/.loki/reference/chrome_desktop_Navigation_EuiSteps_EuiStepsHorizontal_EuiStepHorizontal_Playground.png b/packages/eui/.loki/reference/chrome_desktop_Navigation_EuiSteps_EuiStepsHorizontal_EuiStepHorizontal_Playground.png index 3eb1f4d1329..268f6eb6e2b 100644 Binary files a/packages/eui/.loki/reference/chrome_desktop_Navigation_EuiSteps_EuiStepsHorizontal_EuiStepHorizontal_Playground.png and b/packages/eui/.loki/reference/chrome_desktop_Navigation_EuiSteps_EuiStepsHorizontal_EuiStepHorizontal_Playground.png differ diff --git a/packages/eui/.loki/reference/chrome_desktop_Navigation_EuiSteps_EuiStepsHorizontal_Playground.png b/packages/eui/.loki/reference/chrome_desktop_Navigation_EuiSteps_EuiStepsHorizontal_Playground.png index 07a077d060e..1dec7ce2bac 100644 Binary files a/packages/eui/.loki/reference/chrome_desktop_Navigation_EuiSteps_EuiStepsHorizontal_Playground.png and b/packages/eui/.loki/reference/chrome_desktop_Navigation_EuiSteps_EuiStepsHorizontal_Playground.png differ diff --git a/packages/eui/.loki/reference/chrome_desktop_Navigation_EuiSteps_EuiStepsHorizontal_Unordered_Steps.png b/packages/eui/.loki/reference/chrome_desktop_Navigation_EuiSteps_EuiStepsHorizontal_Unordered_Steps.png index 422b1ef9920..6518eecd9ee 100644 Binary files a/packages/eui/.loki/reference/chrome_desktop_Navigation_EuiSteps_EuiStepsHorizontal_Unordered_Steps.png and b/packages/eui/.loki/reference/chrome_desktop_Navigation_EuiSteps_EuiStepsHorizontal_Unordered_Steps.png differ diff --git a/packages/eui/.loki/reference/chrome_desktop_Navigation_EuiSteps_EuiSteps_EuiStep_Multiline_Title.png b/packages/eui/.loki/reference/chrome_desktop_Navigation_EuiSteps_EuiSteps_EuiStep_Multiline_Title.png index 694b893e800..4f2178884ba 100644 Binary files a/packages/eui/.loki/reference/chrome_desktop_Navigation_EuiSteps_EuiSteps_EuiStep_Multiline_Title.png and b/packages/eui/.loki/reference/chrome_desktop_Navigation_EuiSteps_EuiSteps_EuiStep_Multiline_Title.png differ diff --git a/packages/eui/.loki/reference/chrome_desktop_Navigation_EuiSteps_EuiSteps_EuiStep_Multiline_Title_XXS.png b/packages/eui/.loki/reference/chrome_desktop_Navigation_EuiSteps_EuiSteps_EuiStep_Multiline_Title_XXS.png index 45ebf7cec90..7f0380bd4f6 100644 Binary files a/packages/eui/.loki/reference/chrome_desktop_Navigation_EuiSteps_EuiSteps_EuiStep_Multiline_Title_XXS.png and b/packages/eui/.loki/reference/chrome_desktop_Navigation_EuiSteps_EuiSteps_EuiStep_Multiline_Title_XXS.png differ diff --git a/packages/eui/.loki/reference/chrome_desktop_Navigation_EuiSteps_EuiSteps_EuiStep_Playground.png b/packages/eui/.loki/reference/chrome_desktop_Navigation_EuiSteps_EuiSteps_EuiStep_Playground.png index 605102cbce7..69878193715 100644 Binary files a/packages/eui/.loki/reference/chrome_desktop_Navigation_EuiSteps_EuiSteps_EuiStep_Playground.png and b/packages/eui/.loki/reference/chrome_desktop_Navigation_EuiSteps_EuiSteps_EuiStep_Playground.png differ diff --git a/packages/eui/.loki/reference/chrome_desktop_Navigation_EuiSteps_EuiSteps_Playground.png b/packages/eui/.loki/reference/chrome_desktop_Navigation_EuiSteps_EuiSteps_Playground.png index 5860eed1d89..1bcb9f3f5e7 100644 Binary files a/packages/eui/.loki/reference/chrome_desktop_Navigation_EuiSteps_EuiSteps_Playground.png and b/packages/eui/.loki/reference/chrome_desktop_Navigation_EuiSteps_EuiSteps_Playground.png differ diff --git a/packages/eui/.loki/reference/chrome_desktop_Navigation_EuiSteps_EuiSteps_Unordered_Steps.png b/packages/eui/.loki/reference/chrome_desktop_Navigation_EuiSteps_EuiSteps_Unordered_Steps.png index 99d7017b6fc..d2aafd84071 100644 Binary files a/packages/eui/.loki/reference/chrome_desktop_Navigation_EuiSteps_EuiSteps_Unordered_Steps.png and b/packages/eui/.loki/reference/chrome_desktop_Navigation_EuiSteps_EuiSteps_Unordered_Steps.png differ diff --git a/packages/eui/.loki/reference/chrome_desktop_Navigation_EuiSteps_Subcomponents_EuiStepNumber_Playground.png b/packages/eui/.loki/reference/chrome_desktop_Navigation_EuiSteps_Subcomponents_EuiStepNumber_Playground.png index 0a441bebe7b..4caf604ce0d 100644 Binary files a/packages/eui/.loki/reference/chrome_desktop_Navigation_EuiSteps_Subcomponents_EuiStepNumber_Playground.png and b/packages/eui/.loki/reference/chrome_desktop_Navigation_EuiSteps_Subcomponents_EuiStepNumber_Playground.png differ diff --git a/packages/eui/.loki/reference/chrome_desktop_Navigation_EuiSteps_Subcomponents_EuiSubSteps_Playground.png b/packages/eui/.loki/reference/chrome_desktop_Navigation_EuiSteps_Subcomponents_EuiSubSteps_Playground.png index fdcd3e35ad2..630d94ef13b 100644 Binary files a/packages/eui/.loki/reference/chrome_desktop_Navigation_EuiSteps_Subcomponents_EuiSubSteps_Playground.png and b/packages/eui/.loki/reference/chrome_desktop_Navigation_EuiSteps_Subcomponents_EuiSubSteps_Playground.png differ diff --git a/packages/eui/.loki/reference/chrome_mobile_Display_EuiComment_EuiCommentEvent_Custom.png b/packages/eui/.loki/reference/chrome_mobile_Display_EuiComment_EuiCommentEvent_Custom.png index 90b1dbe21bc..163ba3d1935 100644 Binary files a/packages/eui/.loki/reference/chrome_mobile_Display_EuiComment_EuiCommentEvent_Custom.png and b/packages/eui/.loki/reference/chrome_mobile_Display_EuiComment_EuiCommentEvent_Custom.png differ diff --git a/packages/eui/.loki/reference/chrome_mobile_Display_EuiComment_EuiCommentEvent_Regular.png b/packages/eui/.loki/reference/chrome_mobile_Display_EuiComment_EuiCommentEvent_Regular.png index 3c55f4206b3..f15ca4e6363 100644 Binary files a/packages/eui/.loki/reference/chrome_mobile_Display_EuiComment_EuiCommentEvent_Regular.png and b/packages/eui/.loki/reference/chrome_mobile_Display_EuiComment_EuiCommentEvent_Regular.png differ diff --git a/packages/eui/.loki/reference/chrome_mobile_Display_EuiComment_EuiCommentEvent_Update.png b/packages/eui/.loki/reference/chrome_mobile_Display_EuiComment_EuiCommentEvent_Update.png index 1cd89b52a92..61c0628a0aa 100644 Binary files a/packages/eui/.loki/reference/chrome_mobile_Display_EuiComment_EuiCommentEvent_Update.png and b/packages/eui/.loki/reference/chrome_mobile_Display_EuiComment_EuiCommentEvent_Update.png differ diff --git a/packages/eui/.loki/reference/chrome_mobile_Display_EuiComment_EuiCommentList_Playground.png b/packages/eui/.loki/reference/chrome_mobile_Display_EuiComment_EuiCommentList_Playground.png index 4f86fcc10a8..bc0869a2331 100644 Binary files a/packages/eui/.loki/reference/chrome_mobile_Display_EuiComment_EuiCommentList_Playground.png and b/packages/eui/.loki/reference/chrome_mobile_Display_EuiComment_EuiCommentList_Playground.png differ diff --git a/packages/eui/.loki/reference/chrome_mobile_Display_EuiComment_EuiComment_Playground.png b/packages/eui/.loki/reference/chrome_mobile_Display_EuiComment_EuiComment_Playground.png index d8d72e3039d..0f794ff34b6 100644 Binary files a/packages/eui/.loki/reference/chrome_mobile_Display_EuiComment_EuiComment_Playground.png and b/packages/eui/.loki/reference/chrome_mobile_Display_EuiComment_EuiComment_Playground.png differ diff --git a/packages/eui/.loki/reference/chrome_mobile_Display_EuiListGroup_EuiListGroupItem_Playground.png b/packages/eui/.loki/reference/chrome_mobile_Display_EuiListGroup_EuiListGroupItem_Playground.png index ba3c7f641fc..9ceda46ea57 100644 Binary files a/packages/eui/.loki/reference/chrome_mobile_Display_EuiListGroup_EuiListGroupItem_Playground.png and b/packages/eui/.loki/reference/chrome_mobile_Display_EuiListGroup_EuiListGroupItem_Playground.png differ diff --git a/packages/eui/.loki/reference/chrome_mobile_Display_EuiListGroup_EuiListGroup_Playground.png b/packages/eui/.loki/reference/chrome_mobile_Display_EuiListGroup_EuiListGroup_Playground.png index 049f001180a..21693645272 100644 Binary files a/packages/eui/.loki/reference/chrome_mobile_Display_EuiListGroup_EuiListGroup_Playground.png and b/packages/eui/.loki/reference/chrome_mobile_Display_EuiListGroup_EuiListGroup_Playground.png differ diff --git a/packages/eui/.loki/reference/chrome_mobile_Display_EuiPinnableListGroup_Playground.png b/packages/eui/.loki/reference/chrome_mobile_Display_EuiPinnableListGroup_Playground.png index b0ca3e9f1d7..d09ec54f92d 100644 Binary files a/packages/eui/.loki/reference/chrome_mobile_Display_EuiPinnableListGroup_Playground.png and b/packages/eui/.loki/reference/chrome_mobile_Display_EuiPinnableListGroup_Playground.png differ diff --git a/packages/eui/.loki/reference/chrome_mobile_Display_EuiTimeline_EuiTimelineItem_Playground.png b/packages/eui/.loki/reference/chrome_mobile_Display_EuiTimeline_EuiTimelineItem_Playground.png index c8952125e56..5f814c44ea3 100644 Binary files a/packages/eui/.loki/reference/chrome_mobile_Display_EuiTimeline_EuiTimelineItem_Playground.png and b/packages/eui/.loki/reference/chrome_mobile_Display_EuiTimeline_EuiTimelineItem_Playground.png differ diff --git a/packages/eui/.loki/reference/chrome_mobile_Display_EuiTimeline_EuiTimeline_Playground.png b/packages/eui/.loki/reference/chrome_mobile_Display_EuiTimeline_EuiTimeline_Playground.png index 55ae5a7f7e2..a2eec73f935 100644 Binary files a/packages/eui/.loki/reference/chrome_mobile_Display_EuiTimeline_EuiTimeline_Playground.png and b/packages/eui/.loki/reference/chrome_mobile_Display_EuiTimeline_EuiTimeline_Playground.png differ diff --git a/packages/eui/.loki/reference/chrome_mobile_Display_EuiTimeline_Subcomponents_EuiTimelineItemEvent_Playground.png b/packages/eui/.loki/reference/chrome_mobile_Display_EuiTimeline_Subcomponents_EuiTimelineItemEvent_Playground.png index 248abcc1f5c..dda7d21a167 100644 Binary files a/packages/eui/.loki/reference/chrome_mobile_Display_EuiTimeline_Subcomponents_EuiTimelineItemEvent_Playground.png and b/packages/eui/.loki/reference/chrome_mobile_Display_EuiTimeline_Subcomponents_EuiTimelineItemEvent_Playground.png differ diff --git a/packages/eui/.loki/reference/chrome_mobile_Forms_EuiDualRange_Input.png b/packages/eui/.loki/reference/chrome_mobile_Forms_EuiDualRange_Input.png index 8f73613b183..9b0b9d8b20e 100644 Binary files a/packages/eui/.loki/reference/chrome_mobile_Forms_EuiDualRange_Input.png and b/packages/eui/.loki/reference/chrome_mobile_Forms_EuiDualRange_Input.png differ diff --git a/packages/eui/.loki/reference/chrome_mobile_Forms_EuiDualRange_Input_With_Popover.png b/packages/eui/.loki/reference/chrome_mobile_Forms_EuiDualRange_Input_With_Popover.png index cb8b4eb2974..22fd521123c 100644 Binary files a/packages/eui/.loki/reference/chrome_mobile_Forms_EuiDualRange_Input_With_Popover.png and b/packages/eui/.loki/reference/chrome_mobile_Forms_EuiDualRange_Input_With_Popover.png differ diff --git a/packages/eui/.loki/reference/chrome_mobile_Forms_EuiDualRange_Levels.png b/packages/eui/.loki/reference/chrome_mobile_Forms_EuiDualRange_Levels.png index b0223dfbd55..76ca99d9074 100644 Binary files a/packages/eui/.loki/reference/chrome_mobile_Forms_EuiDualRange_Levels.png and b/packages/eui/.loki/reference/chrome_mobile_Forms_EuiDualRange_Levels.png differ diff --git a/packages/eui/.loki/reference/chrome_mobile_Forms_EuiDualRange_Ticks.png b/packages/eui/.loki/reference/chrome_mobile_Forms_EuiDualRange_Ticks.png index 57cd818c303..815f24ac8ba 100644 Binary files a/packages/eui/.loki/reference/chrome_mobile_Forms_EuiDualRange_Ticks.png and b/packages/eui/.loki/reference/chrome_mobile_Forms_EuiDualRange_Ticks.png differ diff --git a/packages/eui/.loki/reference/chrome_mobile_Forms_EuiFilterGroup_Multiple_Popovers.png b/packages/eui/.loki/reference/chrome_mobile_Forms_EuiFilterGroup_Multiple_Popovers.png index fba5ca718d5..09ce0191855 100644 Binary files a/packages/eui/.loki/reference/chrome_mobile_Forms_EuiFilterGroup_Multiple_Popovers.png and b/packages/eui/.loki/reference/chrome_mobile_Forms_EuiFilterGroup_Multiple_Popovers.png differ diff --git a/packages/eui/.loki/reference/chrome_mobile_Forms_EuiFilterGroup_Playground.png b/packages/eui/.loki/reference/chrome_mobile_Forms_EuiFilterGroup_Playground.png index b8441ac74fd..76a318ea398 100644 Binary files a/packages/eui/.loki/reference/chrome_mobile_Forms_EuiFilterGroup_Playground.png and b/packages/eui/.loki/reference/chrome_mobile_Forms_EuiFilterGroup_Playground.png differ diff --git a/packages/eui/.loki/reference/chrome_mobile_Forms_EuiFilterGroup_With_Popover.png b/packages/eui/.loki/reference/chrome_mobile_Forms_EuiFilterGroup_With_Popover.png index 9df3cd6ede3..b65fca00b0a 100644 Binary files a/packages/eui/.loki/reference/chrome_mobile_Forms_EuiFilterGroup_With_Popover.png and b/packages/eui/.loki/reference/chrome_mobile_Forms_EuiFilterGroup_With_Popover.png differ diff --git a/packages/eui/.loki/reference/chrome_mobile_Forms_EuiRange_Input.png b/packages/eui/.loki/reference/chrome_mobile_Forms_EuiRange_Input.png index 7cd7f7e4681..dc6bdd0fee9 100644 Binary files a/packages/eui/.loki/reference/chrome_mobile_Forms_EuiRange_Input.png and b/packages/eui/.loki/reference/chrome_mobile_Forms_EuiRange_Input.png differ diff --git a/packages/eui/.loki/reference/chrome_mobile_Forms_EuiRange_Levels.png b/packages/eui/.loki/reference/chrome_mobile_Forms_EuiRange_Levels.png index 3f850c9d448..77a9fddb14d 100644 Binary files a/packages/eui/.loki/reference/chrome_mobile_Forms_EuiRange_Levels.png and b/packages/eui/.loki/reference/chrome_mobile_Forms_EuiRange_Levels.png differ diff --git a/packages/eui/.loki/reference/chrome_mobile_Forms_EuiRange_Ticks.png b/packages/eui/.loki/reference/chrome_mobile_Forms_EuiRange_Ticks.png index 5f4115f53d8..c18a999ca4a 100644 Binary files a/packages/eui/.loki/reference/chrome_mobile_Forms_EuiRange_Ticks.png and b/packages/eui/.loki/reference/chrome_mobile_Forms_EuiRange_Ticks.png differ diff --git a/packages/eui/.loki/reference/chrome_mobile_Forms_EuiRange_Value_Tooltip.png b/packages/eui/.loki/reference/chrome_mobile_Forms_EuiRange_Value_Tooltip.png index b6e46f3124b..d54fb313f73 100644 Binary files a/packages/eui/.loki/reference/chrome_mobile_Forms_EuiRange_Value_Tooltip.png and b/packages/eui/.loki/reference/chrome_mobile_Forms_EuiRange_Value_Tooltip.png differ diff --git a/packages/eui/.loki/reference/chrome_mobile_Navigation_EuiFacetButton_Playground.png b/packages/eui/.loki/reference/chrome_mobile_Navigation_EuiFacetButton_Playground.png index 31fe93885c6..f2ece81545c 100644 Binary files a/packages/eui/.loki/reference/chrome_mobile_Navigation_EuiFacetButton_Playground.png and b/packages/eui/.loki/reference/chrome_mobile_Navigation_EuiFacetButton_Playground.png differ diff --git a/packages/eui/.loki/reference/chrome_mobile_Navigation_EuiFacetGroup_Playground.png b/packages/eui/.loki/reference/chrome_mobile_Navigation_EuiFacetGroup_Playground.png index 36df8a1e7ee..6017ae01867 100644 Binary files a/packages/eui/.loki/reference/chrome_mobile_Navigation_EuiFacetGroup_Playground.png and b/packages/eui/.loki/reference/chrome_mobile_Navigation_EuiFacetGroup_Playground.png differ diff --git a/packages/eui/.loki/reference/chrome_mobile_Navigation_EuiSteps_EuiStepsHorizontal_EuiStepHorizontal_Playground.png b/packages/eui/.loki/reference/chrome_mobile_Navigation_EuiSteps_EuiStepsHorizontal_EuiStepHorizontal_Playground.png index 1a2c749526b..9c3d9742e2e 100644 Binary files a/packages/eui/.loki/reference/chrome_mobile_Navigation_EuiSteps_EuiStepsHorizontal_EuiStepHorizontal_Playground.png and b/packages/eui/.loki/reference/chrome_mobile_Navigation_EuiSteps_EuiStepsHorizontal_EuiStepHorizontal_Playground.png differ diff --git a/packages/eui/.loki/reference/chrome_mobile_Navigation_EuiSteps_EuiStepsHorizontal_Playground.png b/packages/eui/.loki/reference/chrome_mobile_Navigation_EuiSteps_EuiStepsHorizontal_Playground.png index 9b5b0c2e29a..20bb7b3bb4d 100644 Binary files a/packages/eui/.loki/reference/chrome_mobile_Navigation_EuiSteps_EuiStepsHorizontal_Playground.png and b/packages/eui/.loki/reference/chrome_mobile_Navigation_EuiSteps_EuiStepsHorizontal_Playground.png differ diff --git a/packages/eui/.loki/reference/chrome_mobile_Navigation_EuiSteps_EuiSteps_EuiStep_Multiline_Title.png b/packages/eui/.loki/reference/chrome_mobile_Navigation_EuiSteps_EuiSteps_EuiStep_Multiline_Title.png index a007c7cb121..80af16d3a64 100644 Binary files a/packages/eui/.loki/reference/chrome_mobile_Navigation_EuiSteps_EuiSteps_EuiStep_Multiline_Title.png and b/packages/eui/.loki/reference/chrome_mobile_Navigation_EuiSteps_EuiSteps_EuiStep_Multiline_Title.png differ diff --git a/packages/eui/.loki/reference/chrome_mobile_Navigation_EuiSteps_EuiSteps_EuiStep_Multiline_Title_XXS.png b/packages/eui/.loki/reference/chrome_mobile_Navigation_EuiSteps_EuiSteps_EuiStep_Multiline_Title_XXS.png index fc18ba36cec..6d1e4b190cb 100644 Binary files a/packages/eui/.loki/reference/chrome_mobile_Navigation_EuiSteps_EuiSteps_EuiStep_Multiline_Title_XXS.png and b/packages/eui/.loki/reference/chrome_mobile_Navigation_EuiSteps_EuiSteps_EuiStep_Multiline_Title_XXS.png differ diff --git a/packages/eui/.loki/reference/chrome_mobile_Navigation_EuiSteps_EuiSteps_EuiStep_Playground.png b/packages/eui/.loki/reference/chrome_mobile_Navigation_EuiSteps_EuiSteps_EuiStep_Playground.png index dabfbffe70a..eccafddefc6 100644 Binary files a/packages/eui/.loki/reference/chrome_mobile_Navigation_EuiSteps_EuiSteps_EuiStep_Playground.png and b/packages/eui/.loki/reference/chrome_mobile_Navigation_EuiSteps_EuiSteps_EuiStep_Playground.png differ diff --git a/packages/eui/.loki/reference/chrome_mobile_Navigation_EuiSteps_EuiSteps_Playground.png b/packages/eui/.loki/reference/chrome_mobile_Navigation_EuiSteps_EuiSteps_Playground.png index 66ac1f3036b..b01a35ef5b0 100644 Binary files a/packages/eui/.loki/reference/chrome_mobile_Navigation_EuiSteps_EuiSteps_Playground.png and b/packages/eui/.loki/reference/chrome_mobile_Navigation_EuiSteps_EuiSteps_Playground.png differ diff --git a/packages/eui/.loki/reference/chrome_mobile_Navigation_EuiSteps_EuiSteps_Unordered_Steps.png b/packages/eui/.loki/reference/chrome_mobile_Navigation_EuiSteps_EuiSteps_Unordered_Steps.png index 4d38e32e2b6..a03080c8ce9 100644 Binary files a/packages/eui/.loki/reference/chrome_mobile_Navigation_EuiSteps_EuiSteps_Unordered_Steps.png and b/packages/eui/.loki/reference/chrome_mobile_Navigation_EuiSteps_EuiSteps_Unordered_Steps.png differ diff --git a/packages/eui/.loki/reference/chrome_mobile_Navigation_EuiSteps_Subcomponents_EuiStepNumber_Playground.png b/packages/eui/.loki/reference/chrome_mobile_Navigation_EuiSteps_Subcomponents_EuiStepNumber_Playground.png index 9726d6a375f..c1a3fd896d3 100644 Binary files a/packages/eui/.loki/reference/chrome_mobile_Navigation_EuiSteps_Subcomponents_EuiStepNumber_Playground.png and b/packages/eui/.loki/reference/chrome_mobile_Navigation_EuiSteps_Subcomponents_EuiStepNumber_Playground.png differ diff --git a/packages/eui/.loki/reference/chrome_mobile_Navigation_EuiSteps_Subcomponents_EuiSubSteps_Playground.png b/packages/eui/.loki/reference/chrome_mobile_Navigation_EuiSteps_Subcomponents_EuiSubSteps_Playground.png index 9763626cfb0..dc8463fdfb3 100644 Binary files a/packages/eui/.loki/reference/chrome_mobile_Navigation_EuiSteps_Subcomponents_EuiSubSteps_Playground.png and b/packages/eui/.loki/reference/chrome_mobile_Navigation_EuiSteps_Subcomponents_EuiSubSteps_Playground.png differ diff --git a/packages/eui/src/components/comment_list/__snapshots__/comment.test.tsx.snap b/packages/eui/src/components/comment_list/__snapshots__/comment.test.tsx.snap index 8ade678a2de..a401090c3a6 100644 --- a/packages/eui/src/components/comment_list/__snapshots__/comment.test.tsx.snap +++ b/packages/eui/src/components/comment_list/__snapshots__/comment.test.tsx.snap @@ -10,19 +10,15 @@ exports[`EuiComment is rendered 1`] = ` class="emotion-euiTimelineItemIcon-center" >
{ }; }; -export const euiExpressionValueStyles = ({}: UseEuiTheme) => { - return { - euiExpression__value: css``, - truncate: css` - ${euiTextTruncate()} - display: inline-block; - vertical-align: bottom; - `, - columns: css` - flex-grow: 1; - `, - }; +export const euiExpressionValueStyles = { + euiExpression__value: css``, + truncate: css` + ${euiTextTruncate()} + display: inline-block; + vertical-align: bottom; + `, + columns: css` + flex-grow: 1; + `, }; export const euiExpressionIconStyles = ({ euiTheme }: UseEuiTheme) => { diff --git a/packages/eui/src/components/expression/expression.tsx b/packages/eui/src/components/expression/expression.tsx index 91f3b952dac..63a184e4aba 100644 --- a/packages/eui/src/components/expression/expression.tsx +++ b/packages/eui/src/components/expression/expression.tsx @@ -14,14 +14,15 @@ import React, { FunctionComponent, } from 'react'; import classNames from 'classnames'; + +import { useEuiMemoizedStyles } from '../../services'; import { CommonProps, ExclusiveUnion } from '../common'; import { EuiIcon } from '../icon'; -import { useEuiTheme } from '../../services'; import { euiExpressionStyles, euiExpressionDescriptionStyles, - euiExpressionValueStyles, + euiExpressionValueStyles as valueStyles, euiExpressionIconStyles, } from './expression.styles'; @@ -112,8 +113,7 @@ export const EuiExpression: FunctionComponent< }) => { const calculatedColor = isInvalid ? 'danger' : color; - const theme = useEuiTheme(); - const styles = euiExpressionStyles(theme); + const styles = useEuiMemoizedStyles(euiExpressionStyles); const cssStyles = [ styles.euiExpression, onClick && styles.isClickable, @@ -123,7 +123,9 @@ export const EuiExpression: FunctionComponent< display === 'columns' && styles.columns, textWrap === 'truncate' && styles.truncate, ]; - const descriptionStyles = euiExpressionDescriptionStyles(theme); + const descriptionStyles = useEuiMemoizedStyles( + euiExpressionDescriptionStyles + ); const cssDescriptionStyles = [ descriptionStyles.euiExpression__description, isInvalid ? descriptionStyles.danger : descriptionStyles[color], @@ -131,14 +133,13 @@ export const EuiExpression: FunctionComponent< textWrap === 'truncate' && descriptionStyles.truncate, display === 'columns' && descriptionStyles.columns, ]; - const valueStyles = euiExpressionValueStyles(theme); const cssValueStyles = [ valueStyles.euiExpression__value, textWrap === 'truncate' && valueStyles.truncate, display === 'columns' && valueStyles.columns, ]; - const iconStyles = euiExpressionIconStyles(theme); + const iconStyles = useEuiMemoizedStyles(euiExpressionIconStyles); const cssIconStyles = [ iconStyles.euiExpression__icon, display === 'columns' && iconStyles.columns, @@ -153,15 +154,6 @@ export const EuiExpression: FunctionComponent< ? { flexBasis: descriptionWidth } : undefined; - const invalidIcon = isInvalid ? ( - - ) : undefined; - return ( )} - {invalidIcon} + {isInvalid && ( + + )} ); }; diff --git a/packages/eui/src/components/facet/__snapshots__/facet_button.test.tsx.snap b/packages/eui/src/components/facet/__snapshots__/facet_button.test.tsx.snap index 248b3527d61..91b88a09a8a 100644 --- a/packages/eui/src/components/facet/__snapshots__/facet_button.test.tsx.snap +++ b/packages/eui/src/components/facet/__snapshots__/facet_button.test.tsx.snap @@ -31,7 +31,7 @@ exports[`EuiFacetButton props icon is rendered 1`] = ` class="emotion-euiButtonDisplayContent" > @@ -66,7 +66,7 @@ exports[`EuiFacetButton props isDisabled is rendered 1`] = ` Content 6 @@ -92,7 +92,7 @@ exports[`EuiFacetButton props isLoading is rendered 1`] = ` @@ -134,7 +134,7 @@ exports[`EuiFacetButton props quantity is rendered 1`] = ` Content 60 diff --git a/packages/eui/src/components/facet/facet_button.styles.ts b/packages/eui/src/components/facet/facet_button.styles.ts index b35e67dd78c..a3f2432b095 100644 --- a/packages/eui/src/components/facet/facet_button.styles.ts +++ b/packages/eui/src/components/facet/facet_button.styles.ts @@ -54,20 +54,7 @@ export const euiFacetButtonTextStyles = ({ euiTheme }: UseEuiTheme) => ({ unSelected: css``, }); -export const euiFacetButtonIconStyles = () => ({ - euiFacetButton__icon: css``, - isDisabled: css` - opacity: 0.5; - `, -}); - -export const euiFacetButtonLoadingSpinnerStyles = () => ({ - euiFacetButton__loadingSpinner: css``, -}); - -export const euiFacetButtonQuantityStyles = () => ({ - euiFacetButton__quantity: css``, - isDisabled: css` - opacity: 0.5; - `, -}); +// Used by both icon and quantity siblings +export const euiFacetButton__disabled = css` + opacity: 0.5; +`; diff --git a/packages/eui/src/components/facet/facet_button.tsx b/packages/eui/src/components/facet/facet_button.tsx index 5f6000659ae..2d058613345 100644 --- a/packages/eui/src/components/facet/facet_button.tsx +++ b/packages/eui/src/components/facet/facet_button.tsx @@ -11,7 +11,7 @@ import React, { HTMLAttributes, ReactNode, RefCallback, - ReactElement, + useMemo, } from 'react'; import classNames from 'classnames'; @@ -20,13 +20,11 @@ import { EuiNotificationBadge } from '../badge'; import { EuiLoadingSpinner } from '../loading'; import { EuiInnerText } from '../inner_text'; -import { useEuiTheme, cloneElementWithCss } from '../../services'; +import { useEuiMemoizedStyles, cloneElementWithCss } from '../../services'; import { euiFacetButtonStyles, euiFacetButtonTextStyles, - euiFacetButtonIconStyles, - euiFacetButtonQuantityStyles, - euiFacetButtonLoadingSpinnerStyles, + euiFacetButton__disabled, } from './facet_button.styles'; import { EuiButtonDisplay, @@ -79,63 +77,49 @@ export const EuiFacetButton: FunctionComponent = ({ const classes = classNames('euiFacetButton', className); - const theme = useEuiTheme(); - - const styles = euiFacetButtonStyles(theme); + const styles = useEuiMemoizedStyles(euiFacetButtonStyles); const cssStyles = [styles.euiFacetButton]; - const textStyles = euiFacetButtonTextStyles(theme); + const textStyles = useEuiMemoizedStyles(euiFacetButtonTextStyles); const cssTextStyles = [ textStyles.euiFacetButton__text, textStyles[selection], ]; - const quantityStyles = euiFacetButtonQuantityStyles(); - const cssQuantityStyles = [ - quantityStyles.euiFacetButton__quantity, - isDisabled && quantityStyles.isDisabled, - ]; - - const iconStyles = euiFacetButtonIconStyles(); - const cssIconStyles = [ - iconStyles.euiFacetButton__icon, - isDisabled && quantityStyles.isDisabled, - ]; - - const loadingSpinnerStyles = euiFacetButtonLoadingSpinnerStyles(); - const cssLoadingSpinnerStyles = [ - loadingSpinnerStyles.euiFacetButton__loadingSpinner, - ]; + // Spreading an obj/conditionally passing the `css` prop makes it so + // an empty `css-0` className isn't rendered in the DOM + const disabledStyles = useMemo( + () => (isDisabled ? { css: euiFacetButton__disabled } : undefined), + [isDisabled] + ); // Add quantity number if provided or loading indicator - let buttonQuantity: ReactElement; - - if (isLoading) { - buttonQuantity = ( - - ); - } else if (typeof quantity === 'number') { - buttonQuantity = ( - - {quantity} - - ); - } + const buttonQuantity = useMemo(() => { + if (isLoading) { + return ; + } else if (typeof quantity === 'number') { + return ( + + {quantity} + + ); + } + }, [quantity, isLoading, isDisabled, disabledStyles, isSelected]); // Add an icon to the button if one exists. - let buttonIcon: ReactElement; - - if (React.isValidElement<{ className?: string }>(icon)) { - buttonIcon = cloneElementWithCss(icon, { - css: cssIconStyles, - className: 'euiFacetButton__icon', - }); - } + const buttonIcon = useMemo(() => { + if (React.isValidElement(icon)) { + return cloneElementWithCss(icon, { + className: 'euiFacetButton__icon', + ...disabledStyles, + }); + } + }, [icon, disabledStyles]); return ( diff --git a/packages/eui/src/components/facet/facet_group.styles.ts b/packages/eui/src/components/facet/facet_group.styles.ts index 3ec589c56ef..0fd07bed4f0 100644 --- a/packages/eui/src/components/facet/facet_group.styles.ts +++ b/packages/eui/src/components/facet/facet_group.styles.ts @@ -7,66 +7,56 @@ */ import { css } from '@emotion/react'; -import { UseEuiTheme, useEuiTheme } from '../../services'; -import { EuiFacetGroupLayout } from './facet_group'; +import { UseEuiTheme } from '../../services'; +import { mathWithUnits } from '../../global_styling'; -const _facetGroupGutterSize = ({ - gutterSize, - layout, -}: { - gutterSize: string; - layout: EuiFacetGroupLayout; -}) => { - const { euiTheme } = useEuiTheme(); - const isHorizontalLayout = layout === 'horizontal'; - const gutterHorizontal = `calc(${euiTheme.size.m} + ${gutterSize})`; - const gutterVertical = gutterSize; +import type { EuiFacetGroupGutterSizes } from './facet_group'; - return isHorizontalLayout - ? `gap: ${gutterVertical} ${gutterHorizontal};` - : `gap: ${gutterVertical} 0;`; -}; +export const euiFacetGroupStyles = ({ euiTheme }: UseEuiTheme) => { + const gutterSizesMap = { + none: 0, + s: euiTheme.size.xs, + m: euiTheme.size.s, + l: euiTheme.size.m, + }; + const _getVerticalGutters = (sizeKey: EuiFacetGroupGutterSizes) => { + const size = gutterSizesMap[sizeKey]; + return `gap: ${size} 0;`; + }; + const _getHorizontalGutters = (sizeKey: EuiFacetGroupGutterSizes) => { + const size = gutterSizesMap[sizeKey]; + return ` + gap: ${size} ${mathWithUnits([size, euiTheme.size.m], (x, y) => x + y)}; + `; + }; -export const euiFacetGroupStyles = ( - { euiTheme }: UseEuiTheme, - layout: EuiFacetGroupLayout -) => ({ - // Base - euiFacetGroup: css` - display: flex; - flex-grow: 1; - `, - // Gutter sizes - none: css( - _facetGroupGutterSize({ - gutterSize: '0', - layout, - }) - ), - s: css( - _facetGroupGutterSize({ - gutterSize: euiTheme.size.xs, - layout, - }) - ), - m: css( - _facetGroupGutterSize({ - gutterSize: euiTheme.size.s, - layout, - }) - ), - l: css( - _facetGroupGutterSize({ - gutterSize: euiTheme.size.m, - layout, - }) - ), - // layouts - horizontal: css` - flex-direction: row; - flex-wrap: wrap; - `, - vertical: css` - flex-direction: column; - `, -}); + return { + // Base + euiFacetGroup: css` + display: flex; + flex-grow: 1; + `, + // layouts + horizontal: css` + flex-direction: row; + flex-wrap: wrap; + `, + vertical: css` + flex-direction: column; + `, + gutterSizes: { + vertical: { + none: css(_getVerticalGutters('none')), + s: css(_getVerticalGutters('s')), + m: css(_getVerticalGutters('m')), + l: css(_getVerticalGutters('l')), + }, + horizontal: { + none: css(_getHorizontalGutters('none')), + s: css(_getHorizontalGutters('s')), + m: css(_getHorizontalGutters('m')), + l: css(_getHorizontalGutters('l')), + }, + }, + }; +}; diff --git a/packages/eui/src/components/facet/facet_group.tsx b/packages/eui/src/components/facet/facet_group.tsx index 5fc33057574..b921310b929 100644 --- a/packages/eui/src/components/facet/facet_group.tsx +++ b/packages/eui/src/components/facet/facet_group.tsx @@ -11,7 +11,7 @@ import classNames from 'classnames'; import { CommonProps } from '../common'; -import { useEuiTheme } from '../../services'; +import { useEuiMemoizedStyles } from '../../services'; import { euiFacetGroupStyles } from './facet_group.styles'; export const LAYOUTS = ['vertical', 'horizontal'] as const; @@ -40,9 +40,12 @@ export const EuiFacetGroup: FunctionComponent = ({ gutterSize = 'm', ...rest }) => { - const theme = useEuiTheme(); - const styles = euiFacetGroupStyles(theme, layout); - const cssStyles = [styles.euiFacetGroup, styles[gutterSize], styles[layout]]; + const styles = useEuiMemoizedStyles(euiFacetGroupStyles); + const cssStyles = [ + styles.euiFacetGroup, + styles.gutterSizes[layout][gutterSize], + styles[layout], + ]; const classes = classNames('euiFacetGroup', className); diff --git a/packages/eui/src/components/filter_group/__snapshots__/filter_button.test.tsx.snap b/packages/eui/src/components/filter_group/__snapshots__/filter_button.test.tsx.snap index 49e6de6c254..fb5d70d5db0 100644 --- a/packages/eui/src/components/filter_group/__snapshots__/filter_button.test.tsx.snap +++ b/packages/eui/src/components/filter_group/__snapshots__/filter_button.test.tsx.snap @@ -110,7 +110,7 @@ exports[`EuiFilterButton props numActiveFilters and hasActiveFilters renders 1`] /> 5 @@ -132,7 +132,7 @@ exports[`EuiFilterButton props numFilters renders 1`] = ` /> 5 @@ -203,7 +203,7 @@ exports[`EuiFilterButton renders zero properly 1`] = ` /> 0 diff --git a/packages/eui/src/components/filter_group/filter_button.tsx b/packages/eui/src/components/filter_group/filter_button.tsx index 247e44e615b..db3e8b2f847 100644 --- a/packages/eui/src/components/filter_group/filter_button.tsx +++ b/packages/eui/src/components/filter_group/filter_button.tsx @@ -9,7 +9,7 @@ import React, { FunctionComponent } from 'react'; import classNames from 'classnames'; -import { useEuiTheme } from '../../services'; +import { useEuiMemoizedStyles } from '../../services'; import { useEuiI18n } from '../i18n'; import { useInnerText } from '../inner_text'; import { DistributiveOmit } from '../common'; @@ -78,8 +78,7 @@ export const EuiFilterButton: FunctionComponent = ({ const numActiveFiltersDefined = numActiveFilters != null && numActiveFilters > 0; - const euiTheme = useEuiTheme(); - const styles = euiFilterButtonStyles(euiTheme); + const styles = useEuiMemoizedStyles(euiFilterButtonStyles); const cssStyles = [ styles.euiFilterButton, withNext && styles.withNext, @@ -91,7 +90,7 @@ export const EuiFilterButton: FunctionComponent = ({ content: contentStyles, text: textStyles, notification: notificationStyles, - } = euiFilterButtonChildStyles(euiTheme); + } = useEuiMemoizedStyles(euiFilterButtonChildStyles); const classes = classNames( 'euiFilterButton', @@ -118,21 +117,10 @@ export const EuiFilterButton: FunctionComponent = ({ '{count} available filters', { count: badgeCount } ); - - const badgeContent = showBadge && ( - - {badgeCount} - - ); + const badgeStyles = [ + notificationStyles.euiFilterButton__notification, + isDisabled && notificationStyles.disabled, + ]; /** * Text @@ -152,19 +140,6 @@ export const EuiFilterButton: FunctionComponent = ({ const dataText = children && typeof children === 'string' ? children : innerText; - const textContent = ( - - {children} - - ); - return ( = ({ }} {...rest} > - {textContent} - {badgeContent} + + {children} + + + {showBadge && ( + + {badgeCount} + + )} ); }; diff --git a/packages/eui/src/components/filter_group/filter_group.tsx b/packages/eui/src/components/filter_group/filter_group.tsx index a7e2678d4ff..b3adf9485a2 100644 --- a/packages/eui/src/components/filter_group/filter_group.tsx +++ b/packages/eui/src/components/filter_group/filter_group.tsx @@ -9,7 +9,7 @@ import React, { HTMLAttributes, ReactNode, FunctionComponent } from 'react'; import classNames from 'classnames'; -import { useEuiTheme } from '../../services'; +import { useEuiMemoizedStyles } from '../../services'; import { CommonProps } from '../common'; import { euiFilterGroupStyles } from './filter_group.styles'; @@ -34,8 +34,7 @@ export const EuiFilterGroup: FunctionComponent = ({ compressed, ...rest }) => { - const euiTheme = useEuiTheme(); - const styles = euiFilterGroupStyles(euiTheme); + const styles = useEuiMemoizedStyles(euiFilterGroupStyles); const cssStyles = [ styles.euiFilterGroup, fullWidth && styles.fullWidth, diff --git a/packages/eui/src/components/form/range/range_highlight.tsx b/packages/eui/src/components/form/range/range_highlight.tsx index 620397b1b48..bebd6c4912a 100644 --- a/packages/eui/src/components/form/range/range_highlight.tsx +++ b/packages/eui/src/components/form/range/range_highlight.tsx @@ -9,7 +9,7 @@ import React, { FunctionComponent, useMemo } from 'react'; import classNames from 'classnames'; -import { useEuiTheme } from '../../../services'; +import { useEuiMemoizedStyles } from '../../../services'; import { logicalStyles } from '../../../global_styling'; import type { EuiRangeProps } from './types'; @@ -54,12 +54,10 @@ export const EuiRangeHighlight: FunctionComponent = ({ const classes = classNames('euiRangeHighlight', className); - const euiTheme = useEuiTheme(); - - const styles = euiRangeHighlightStyles(euiTheme); + const styles = useEuiMemoizedStyles(euiRangeHighlightStyles); const cssStyles = [styles.euiRangeHighlight, showTicks && styles.hasTicks]; - const progressStyles = euiRangeHighlightProgressStyles(euiTheme); + const progressStyles = useEuiMemoizedStyles(euiRangeHighlightProgressStyles); const cssProgressStyles = [progressStyles.euiRangeHighlight__progress]; const progressStyle = useMemo(() => { return logicalStyles({ @@ -69,7 +67,9 @@ export const EuiRangeHighlight: FunctionComponent = ({ }); }, [background, leftPosition, rangeWidth]); - const levelsWrapperStyles = euiRangeHighlightLevelsWrapperStyles(euiTheme); + const levelsWrapperStyles = useEuiMemoizedStyles( + euiRangeHighlightLevelsWrapperStyles + ); const cssLevelsWrapperStyles = [ levelsWrapperStyles.euiRangeHighlight__levelsWrapper, ]; @@ -80,7 +80,7 @@ export const EuiRangeHighlight: FunctionComponent = ({ }); }, [leftPosition, rangeWidth]); - const levelsStyles = euiRangeHighlightLevelsStyles(euiTheme); + const levelsStyles = useEuiMemoizedStyles(euiRangeHighlightLevelsStyles); const cssLevelsStyles = [levelsStyles.euiRangeHighlight__levels]; const levelsStyle = useMemo(() => { return logicalStyles({ diff --git a/packages/eui/src/components/form/range/range_input.tsx b/packages/eui/src/components/form/range/range_input.tsx index e0bed7c5495..2c12010daae 100644 --- a/packages/eui/src/components/form/range/range_input.tsx +++ b/packages/eui/src/components/form/range/range_input.tsx @@ -14,7 +14,11 @@ import React, { useRef, } from 'react'; -import { useEuiTheme, useCombinedRefs } from '../../../services'; +import { + useEuiTheme, + useEuiMemoizedStyles, + useCombinedRefs, +} from '../../../services'; import { logicalStyles } from '../../../global_styling'; import { euiFormVariables } from '../form.styles'; import { EuiFieldNumber, EuiFieldNumberProps } from '../field_number'; @@ -46,7 +50,7 @@ export const EuiRangeInput: FunctionComponent = ({ ...rest }) => { const euiTheme = useEuiTheme(); - const styles = euiRangeInputStyles(euiTheme); + const styles = useEuiMemoizedStyles(euiRangeInputStyles); const cssStyles = [styles.euiRangeInput]; // Determine whether an invalid icon is showing, which can come from diff --git a/packages/eui/src/components/form/range/range_label.tsx b/packages/eui/src/components/form/range/range_label.tsx index 2994891d1e6..5f9238c0a91 100644 --- a/packages/eui/src/components/form/range/range_label.tsx +++ b/packages/eui/src/components/form/range/range_label.tsx @@ -8,7 +8,7 @@ import React, { FunctionComponent } from 'react'; -import { useEuiTheme } from '../../../services'; +import { useEuiMemoizedStyles } from '../../../services'; import type { _SharedRangeInputProps, _SharedRangeInputSide } from './types'; import { euiRangeLabelStyles } from './range_label.styles'; @@ -26,8 +26,7 @@ export const EuiRangeLabel: FunctionComponent = ({ disabled, side = 'max', }) => { - const euiTheme = useEuiTheme(); - const styles = euiRangeLabelStyles(euiTheme); + const styles = useEuiMemoizedStyles(euiRangeLabelStyles); const cssStyles = [ styles.euiRangeLabel, styles[side], diff --git a/packages/eui/src/components/form/range/range_levels.tsx b/packages/eui/src/components/form/range/range_levels.tsx index 97e9a48d9f6..afdb363ec7b 100644 --- a/packages/eui/src/components/form/range/range_levels.tsx +++ b/packages/eui/src/components/form/range/range_levels.tsx @@ -14,7 +14,7 @@ import React, { } from 'react'; import classNames from 'classnames'; -import { useEuiTheme } from '../../../services'; +import { useEuiMemoizedStyles } from '../../../services'; import { logicalStyles } from '../../../global_styling'; import type { EuiRangeLevel, EuiRangeProps } from './types'; @@ -44,8 +44,7 @@ export const EuiRangeLevels: FunctionComponent = ({ trackWidth, ...rest }) => { - const euiTheme = useEuiTheme(); - const styles = euiRangeLevelsStyles(euiTheme); + const styles = useEuiMemoizedStyles(euiRangeLevelsStyles); const cssStyles = [ styles.euiRangeLevels, showTicks && styles.hasTicks, @@ -115,8 +114,7 @@ const EuiRangeLevelElement: FunctionComponent<{ const levelClasses = classNames('euiRangeLevel', className); - const euiTheme = useEuiTheme(); - const levelStyles = euiRangeLevelStyles(euiTheme); + const levelStyles = useEuiMemoizedStyles(euiRangeLevelStyles); const cssLevelStyles = [ levelStyles.euiRangeLevel, isNamedColor diff --git a/packages/eui/src/components/form/range/range_slider.tsx b/packages/eui/src/components/form/range/range_slider.tsx index b05033a167d..6c06925e877 100644 --- a/packages/eui/src/components/form/range/range_slider.tsx +++ b/packages/eui/src/components/form/range/range_slider.tsx @@ -15,7 +15,7 @@ import React, { import classNames from 'classnames'; import { CommonProps } from '../../common'; -import { useEuiTheme } from '../../../services'; +import { useEuiTheme, useEuiMemoizedStyles } from '../../../services'; import { logicalStyles } from '../../../global_styling'; import { EuiResizeObserver, @@ -75,9 +75,9 @@ export const EuiRangeSlider: FunctionComponent = ({ }) => { const classes = classNames('euiRangeSlider', className); - const euiTheme = useEuiTheme(); - const styles = euiRangeSliderStyles(euiTheme); - const thumbStyles = euiRangeSliderThumbStyles(euiTheme); + const { euiTheme } = useEuiTheme(); + const styles = useEuiMemoizedStyles(euiRangeSliderStyles); + const thumbStyles = useEuiMemoizedStyles(euiRangeSliderThumbStyles); const cssStyles = [ styles.euiRangeSlider, showTicks && styles.hasTicks, @@ -87,7 +87,7 @@ export const EuiRangeSlider: FunctionComponent = ({ const sliderStyle = useMemo(() => { return logicalStyles({ - color: thumbColor && euiRangeLevelColor(thumbColor, euiTheme.euiTheme), + color: thumbColor && euiRangeLevelColor(thumbColor, euiTheme), ...style, }); }, [thumbColor, euiTheme, style]); diff --git a/packages/eui/src/components/form/range/range_thumb.tsx b/packages/eui/src/components/form/range/range_thumb.tsx index b6c4bfe625f..b2882369df9 100644 --- a/packages/eui/src/components/form/range/range_thumb.tsx +++ b/packages/eui/src/components/form/range/range_thumb.tsx @@ -9,7 +9,7 @@ import React, { FunctionComponent, HTMLAttributes } from 'react'; import classNames from 'classnames'; -import { useEuiTheme } from '../../../services'; +import { useEuiMemoizedStyles } from '../../../services'; import { CommonProps, ExclusiveUnion } from '../../common'; import type { EuiRangeProps } from './types'; @@ -44,8 +44,7 @@ export const EuiRangeThumb: FunctionComponent = ({ }) => { const classes = classNames('euiRangeThumb', className); - const euiTheme = useEuiTheme(); - const styles = euiRangeThumbStyles(euiTheme); + const styles = useEuiMemoizedStyles(euiRangeThumbStyles); const cssStyles = [styles.euiRangeThumb, showTicks && styles.hasTicks]; const commonAttrs = { diff --git a/packages/eui/src/components/form/range/range_ticks.tsx b/packages/eui/src/components/form/range/range_ticks.tsx index fb7ebdbb461..7d933da961e 100644 --- a/packages/eui/src/components/form/range/range_ticks.tsx +++ b/packages/eui/src/components/form/range/range_ticks.tsx @@ -14,7 +14,7 @@ import React, { useMemo, } from 'react'; -import { useEuiTheme } from '../../../services'; +import { useEuiTheme, useEuiMemoizedStyles } from '../../../services'; import { logicalStyles } from '../../../global_styling'; import { useInnerText } from '../../inner_text'; @@ -54,8 +54,6 @@ const EuiTickValue: FunctionComponent< compressed, trackWidth, }) => { - const euiTheme = useEuiTheme(); - const hasCustomTicks = !!ticks; const tickObject = useMemo(() => { @@ -107,19 +105,20 @@ const EuiTickValue: FunctionComponent< ]); // Some ticks need an actual DOM element instead of using a ::before + const { euiTheme } = useEuiTheme(); const pseudoTick = tickObject && !!labelShiftVal && (isMinTick || isMaxTick); const pseudoShift = useMemo(() => { if (!labelShiftVal) return {}; const marginProperty = isMaxTick ? 'marginRight' : 'marginLeft'; - const tickOffset = euiTheme.euiTheme.size.xs; // xs derived from .euiRangeTicks left/right offset + const tickOffset = euiTheme.size.xs; // xs derived from .euiRangeTicks left/right offset return logicalStyles({ [marginProperty]: `calc(${labelShiftVal}em + ${tickOffset})`, }); - }, [labelShiftVal, isMaxTick, euiTheme.euiTheme.size.xs]); + }, [labelShiftVal, isMaxTick, euiTheme.size.xs]); - const styles = euiRangeTickStyles(euiTheme); + const styles = useEuiMemoizedStyles(euiRangeTickStyles); const cssTickStyles = [ styles.euiRangeTick, value === String(tickValue) && styles.selected, diff --git a/packages/eui/src/components/form/range/range_tooltip.tsx b/packages/eui/src/components/form/range/range_tooltip.tsx index e7a9a6c58c3..5e8743bbe37 100644 --- a/packages/eui/src/components/form/range/range_tooltip.tsx +++ b/packages/eui/src/components/form/range/range_tooltip.tsx @@ -8,7 +8,7 @@ import React, { FunctionComponent, useMemo } from 'react'; -import { useEuiTheme } from '../../../services'; +import { useEuiMemoizedStyles } from '../../../services'; import { logicalStyles } from '../../../global_styling'; import type { EuiRangeProps } from './types'; @@ -61,11 +61,10 @@ export const EuiRangeTooltip: FunctionComponent = ({ } }, [valuePosition, valuePositionSide]); - const euiTheme = useEuiTheme(); - const styles = euiRangeTooltipStyles(euiTheme); + const styles = useEuiMemoizedStyles(euiRangeTooltipStyles); const cssStyles = [styles.euiRangeTooltip]; - const valueStyles = euiRangeTooltipValueStyles(euiTheme); + const valueStyles = useEuiMemoizedStyles(euiRangeTooltipValueStyles); const cssValueStyles = [ valueStyles.euiRangeTooltip__value, valueStyles[valuePositionSide], diff --git a/packages/eui/src/components/form/range/range_track.tsx b/packages/eui/src/components/form/range/range_track.tsx index 5a9968d04af..e8f4d2e546f 100644 --- a/packages/eui/src/components/form/range/range_track.tsx +++ b/packages/eui/src/components/form/range/range_track.tsx @@ -17,7 +17,7 @@ import classNames from 'classnames'; import range from 'lodash/range'; -import { useEuiTheme, isEvenlyDivisibleBy } from '../../../services'; +import { useEuiMemoizedStyles, isEvenlyDivisibleBy } from '../../../services'; import { EuiRangeLevels } from './range_levels'; import { EuiRangeTicks } from './range_ticks'; @@ -98,8 +98,7 @@ export const EuiRangeTrack: FunctionComponent = ({ return sequence; }, [showTicks, ticks, min, max, tickInterval, step, trackWidth]); - const euiTheme = useEuiTheme(); - const styles = euiRangeTrackStyles(euiTheme); + const styles = useEuiMemoizedStyles(euiRangeTrackStyles); const cssStyles = [ styles.euiRangeTrack, disabled && styles.disabled, diff --git a/packages/eui/src/components/form/range/range_wrapper.tsx b/packages/eui/src/components/form/range/range_wrapper.tsx index 1ea52f76a39..d4c075d780a 100644 --- a/packages/eui/src/components/form/range/range_wrapper.tsx +++ b/packages/eui/src/components/form/range/range_wrapper.tsx @@ -9,7 +9,7 @@ import React, { HTMLAttributes, forwardRef } from 'react'; import classNames from 'classnames'; -import { useEuiTheme } from '../../../services'; +import { useEuiMemoizedStyles } from '../../../services'; import { CommonProps } from '../../common'; import { useFormContext } from '../eui_form_context'; @@ -34,8 +34,7 @@ export const EuiRangeWrapper = forwardRef( const classes = classNames('euiRangeWrapper', className); - const euiTheme = useEuiTheme(); - const styles = euiRangeWrapperStyles(euiTheme); + const styles = useEuiMemoizedStyles(euiRangeWrapperStyles); const cssStyles = [ styles.euiRangeWrapper, compressed ? styles.compressed : styles.uncompressed, diff --git a/packages/eui/src/components/header/header.tsx b/packages/eui/src/components/header/header.tsx index 985fb2bc294..2cee21c1266 100644 --- a/packages/eui/src/components/header/header.tsx +++ b/packages/eui/src/components/header/header.tsx @@ -16,7 +16,7 @@ import React, { } from 'react'; import classNames from 'classnames'; -import { useEuiTheme, useEuiThemeCSSVariables } from '../../services'; +import { useEuiMemoizedStyles, useEuiThemeCSSVariables } from '../../services'; import { mathWithUnits, logicalStyles } from '../../global_styling'; import { CommonProps } from '../common'; import { EuiBreadcrumb, EuiBreadcrumbsProps } from '../breadcrumbs'; @@ -84,46 +84,45 @@ export const EuiHeader: FunctionComponent = ({ }) => { const classes = classNames('euiHeader', className); - const euiTheme = useEuiTheme(); - const styles = euiHeaderStyles(euiTheme); + const styles = useEuiMemoizedStyles(euiHeaderStyles); const cssStyles = [styles.euiHeader, styles[position], styles[theme]]; - let contents; - if (sections) { - if (children) { - // In case both children and sections are passed, warn in the console that the children will be disregarded - console.warn( - 'EuiHeader cannot accept both `children` and `sections`. It will disregard the `children`.' - ); - } - - contents = sections.map((section, index) => { - const content = []; - if (section.items) { - // Items get wrapped in EuiHeaderSection and each item in a EuiHeaderSectionItem - content.push( - - {createHeaderSection(section.items)} - - ); - } - if (section.breadcrumbs) { - content.push( - // Breadcrumbs are separate and cannot be contained in a EuiHeaderSection - // in order for truncation to work - - ); - } - return content; - }); - } else { - contents = children; + if (sections && children) { + // In case both children and sections are passed, warn in the console that the children will be disregarded + console.warn( + 'EuiHeader cannot accept both `children` and `sections`. It will disregard the `children`.' + ); } + const contents = + useMemo(() => { + if (!sections || !sections.length) return null; + + return sections.map((section, index) => { + const content = []; + if (section.items) { + // Items get wrapped in EuiHeaderSection and each item in a EuiHeaderSectionItem + content.push( + + {createHeaderSection(section.items)} + + ); + } + if (section.breadcrumbs) { + content.push( + // Breadcrumbs are separate and cannot be contained in a EuiHeaderSection + // in order for truncation to work + + ); + } + return content; + }); + }, [sections]) || children; + return position === 'fixed' ? ( {contents} @@ -151,8 +150,7 @@ export const EuiFixedHeader: FunctionComponent = ({ ...rest }) => { const { setGlobalCSSVariables } = useEuiThemeCSSVariables(); - const euiTheme = useEuiTheme(); - const headerHeight = euiHeaderVariables(euiTheme).height; + const headerHeight = useEuiMemoizedStyles(euiHeaderVariables).height; const getHeaderOffset = useCallback( () => mathWithUnits(headerHeight, (x) => x * euiFixedHeadersCount), [headerHeight] diff --git a/packages/eui/src/components/header/header_alert/header_alert.tsx b/packages/eui/src/components/header/header_alert/header_alert.tsx index 2c7c15f6790..c237eb27f1e 100644 --- a/packages/eui/src/components/header/header_alert/header_alert.tsx +++ b/packages/eui/src/components/header/header_alert/header_alert.tsx @@ -12,7 +12,7 @@ import classNames from 'classnames'; import { CommonProps } from '../../common'; import { EuiFlexGroup, EuiFlexItem } from '../../flex'; -import { useEuiTheme, useGeneratedHtmlId } from '../../../services'; +import { useEuiMemoizedStyles, useGeneratedHtmlId } from '../../../services'; import { euiHeaderAlertStyles } from './header_alert.styles'; @@ -40,8 +40,7 @@ export const EuiHeaderAlert: FunctionComponent = ({ badge, ...rest }) => { - const euiTheme = useEuiTheme(); - const styles = euiHeaderAlertStyles(euiTheme); + const styles = useEuiMemoizedStyles(euiHeaderAlertStyles); const classes = classNames('euiHeaderAlert', className); diff --git a/packages/eui/src/components/header/header_links/header_links.tsx b/packages/eui/src/components/header/header_links/header_links.tsx index 50e38323da2..197638c4f32 100644 --- a/packages/eui/src/components/header/header_links/header_links.tsx +++ b/packages/eui/src/components/header/header_links/header_links.tsx @@ -17,7 +17,7 @@ import React, { } from 'react'; import classNames from 'classnames'; -import { useEuiTheme } from '../../../services'; +import { useEuiMemoizedStyles } from '../../../services'; import { CommonProps } from '../../common'; import { EuiIcon, IconType } from '../../icon'; import { EuiPopover, EuiPopoverProps } from '../../popover'; @@ -76,8 +76,7 @@ export const EuiHeaderLinks: FunctionComponent = ({ popoverProps, ...rest }) => { - const euiTheme = useEuiTheme(); - const styles = euiHeaderLinksStyles(euiTheme); + const styles = useEuiMemoizedStyles(euiHeaderLinksStyles); const { onClick, @@ -110,20 +109,6 @@ export const EuiHeaderLinks: FunctionComponent = ({ const classes = classNames('euiHeaderLinks', className); - const button = ( - - {(openNavigationMenu: string) => ( - - - - )} - - ); - const renderedChildren = typeof children === 'function' ? children(closeMenu) : children; @@ -150,7 +135,22 @@ export const EuiHeaderLinks: FunctionComponent = ({ + {(openNavigationMenu: string) => ( + + + + )} + + } isOpen={mobileMenuIsOpen} anchorPosition="downRight" closePopover={closeMenu} diff --git a/packages/eui/src/components/header/header_logo/header_logo.tsx b/packages/eui/src/components/header/header_logo/header_logo.tsx index 5ae0ee81af9..bf450e06f09 100644 --- a/packages/eui/src/components/header/header_logo/header_logo.tsx +++ b/packages/eui/src/components/header/header_logo/header_logo.tsx @@ -13,7 +13,7 @@ import React, { } from 'react'; import classNames from 'classnames'; -import { useEuiTheme, getSecureRelForTarget } from '../../../services'; +import { useEuiMemoizedStyles, getSecureRelForTarget } from '../../../services'; import { validateHref } from '../../../services/security/href_validator'; import { EuiIcon, IconType } from '../../icon'; import { CommonProps } from '../../common'; @@ -44,8 +44,7 @@ export const EuiHeaderLogo: FunctionComponent = ({ ...rest }) => { const classes = classNames('euiHeaderLogo', className); - const euiTheme = useEuiTheme(); - const styles = euiHeaderLogoStyles(euiTheme); + const styles = useEuiMemoizedStyles(euiHeaderLogoStyles); const secureRel = getSecureRelForTarget({ href, rel, target }); const isHrefValid = !href || validateHref(href); diff --git a/packages/eui/src/components/header/header_section/__snapshots__/header_section_item_button.test.tsx.snap b/packages/eui/src/components/header/header_section/__snapshots__/header_section_item_button.test.tsx.snap index 22466103cf0..4ce064e4728 100644 --- a/packages/eui/src/components/header/header_section/__snapshots__/header_section_item_button.test.tsx.snap +++ b/packages/eui/src/components/header/header_section/__snapshots__/header_section_item_button.test.tsx.snap @@ -79,7 +79,7 @@ exports[`EuiHeaderSectionItemButton renders notification as a badge 1`] = ` class="euiHeaderSectionItemButton__content emotion-euiHeaderSectionItemButton__content" /> 1 @@ -103,7 +103,7 @@ exports[`EuiHeaderSectionItemButton renders notification as a dot 1`] = ` class="euiHeaderSectionItemButton__content emotion-euiHeaderSectionItemButton__content" /> @@ -127,7 +127,7 @@ exports[`EuiHeaderSectionItemButton renders notification color 1`] = ` class="euiHeaderSectionItemButton__content emotion-euiHeaderSectionItemButton__content" /> 1 diff --git a/packages/eui/src/components/header/header_section/header_section_item.tsx b/packages/eui/src/components/header/header_section/header_section_item.tsx index 3302251fd66..157ae4f21a8 100644 --- a/packages/eui/src/components/header/header_section/header_section_item.tsx +++ b/packages/eui/src/components/header/header_section/header_section_item.tsx @@ -9,7 +9,7 @@ import React, { FunctionComponent, ReactNode } from 'react'; import classNames from 'classnames'; -import { useEuiTheme } from '../../../services'; +import { useEuiMemoizedStyles } from '../../../services'; import { CommonProps } from '../../common'; import { euiHeaderSectionItemStyles } from './header_section_item.styles'; @@ -27,8 +27,7 @@ export type EuiHeaderSectionItemProps = CommonProps & { export const EuiHeaderSectionItem: FunctionComponent< EuiHeaderSectionItemProps > = ({ children, className, ...rest }) => { - const euiTheme = useEuiTheme(); - const styles = euiHeaderSectionItemStyles(euiTheme); + const styles = useEuiMemoizedStyles(euiHeaderSectionItemStyles); const classes = classNames('euiHeaderSectionItem', className); diff --git a/packages/eui/src/components/header/header_section/header_section_item_button.tsx b/packages/eui/src/components/header/header_section/header_section_item_button.tsx index b4fe084f25c..7611be791f3 100644 --- a/packages/eui/src/components/header/header_section/header_section_item_button.tsx +++ b/packages/eui/src/components/header/header_section/header_section_item_button.tsx @@ -10,18 +10,21 @@ import React, { PropsWithChildren, forwardRef, useImperativeHandle, + useMemo, useRef, } from 'react'; import classNames from 'classnames'; -import { useEuiTheme } from '../../../services'; +import { + useEuiMemoizedStyles, + useIsWithinMaxBreakpoint, +} from '../../../services'; import { EuiNotificationBadgeProps, EuiNotificationBadge, } from '../../badge/notification_badge/badge_notification'; import { EuiIcon } from '../../icon'; import { EuiButtonEmpty, EuiButtonEmptyProps } from '../../button'; -import { EuiHideFor, EuiShowFor } from '../../responsive'; import { euiHeaderSectionItemButtonStyles } from './header_section_item_button.styles'; @@ -190,46 +193,41 @@ export const EuiHeaderSectionItemButton = forwardRef< [] ); - const euiTheme = useEuiTheme(); - const styles = euiHeaderSectionItemButtonStyles(euiTheme); - + const styles = useEuiMemoizedStyles(euiHeaderSectionItemButtonStyles); const classes = classNames('euiHeaderSectionItemButton', className); - const notificationDot = ( - - ); + const isSmallScreen = useIsWithinMaxBreakpoint('s'); + const shouldShowDot = + notification === true || !!(notification && isSmallScreen); + + const buttonNotification = useMemo(() => { + const cssStyles = [ + styles.notification.euiHeaderSectionItemButton__notification, + shouldShowDot ? styles.notification.dot : styles.notification.badge, + ]; - let buttonNotification; - if (notification === true) { - buttonNotification = notificationDot; - } else if (notification) { - buttonNotification = ( - <> - - - {notification} - - - {notificationDot} - - ); - } + if (shouldShowDot) { + return ( + + ); + } else if (notification) { + return ( + + {notification} + + ); + } + }, [notification, notificationColor, styles.notification, shouldShowDot]); return ( = ({ @@ -35,17 +34,13 @@ export const EuiImage: FunctionComponent = ({ onFullScreen, ...rest }) => { - const [isFullScreen, setIsFullScreen] = useState(false); - + const isFullWidth = size === 'fullWidth'; const isNamedSize = typeof size === 'string' && SIZES.includes(size as EuiImageSize); + const isCustomSize = !isNamedSize && size !== 'original'; const classes = classNames('euiImage', className); - - const euiTheme = useEuiTheme(); - - const styles = euiImageStyles(euiTheme); - + const styles = useEuiMemoizedStyles(euiImageStyles); const cssStyles = [ styles.euiImage, isNamedSize && styles[size as EuiImageSize], @@ -53,9 +48,9 @@ export const EuiImage: FunctionComponent = ({ hasShadow && styles.hasShadow, ]; + const [isFullScreen, setIsFullScreen] = useState(false); const cssIsFullScreenStyles = [styles.euiImage, styles.isFullScreen]; - const isCustomSize = !isNamedSize && size !== 'original'; const customSize = typeof size === 'string' ? size : `${size}px`; const imageStyleWithCustomSize = isCustomSize ? { @@ -65,8 +60,6 @@ export const EuiImage: FunctionComponent = ({ } : style; - const isFullWidth = size === 'fullWidth'; - const commonWrapperProps = { hasShadow, wrapperProps, diff --git a/packages/eui/src/components/image/image_button.tsx b/packages/eui/src/components/image/image_button.tsx index 304c4ae2197..2589170baf7 100644 --- a/packages/eui/src/components/image/image_button.tsx +++ b/packages/eui/src/components/image/image_button.tsx @@ -8,7 +8,7 @@ import React, { FunctionComponent } from 'react'; -import { useEuiTheme } from '../../services'; +import { useEuiMemoizedStyles } from '../../services'; import { useEuiI18n } from '../i18n'; import { EuiIcon } from '../icon'; import { EuiScreenReaderOnly } from '../accessibility'; @@ -40,9 +40,7 @@ export const EuiImageButton: FunctionComponent = ({ fullScreenIconColor = 'light', ...rest }) => { - const euiTheme = useEuiTheme(); - - const buttonStyles = euiImageButtonStyles(euiTheme); + const buttonStyles = useEuiMemoizedStyles(euiImageButtonStyles); const cssButtonStyles = [ buttonStyles.euiImageButton, @@ -50,7 +48,7 @@ export const EuiImageButton: FunctionComponent = ({ !isFullScreen && isFullWidth && buttonStyles.fullWidth, ]; - const iconStyles = euiImageButtonIconStyles(euiTheme); + const iconStyles = useEuiMemoizedStyles(euiImageButtonIconStyles); const cssIconStyles = [ iconStyles.euiImageButton__icon, iconStyles.openFullScreen, @@ -69,39 +67,37 @@ export const EuiImageButton: FunctionComponent = ({ fullScreenIconColorMap[fullScreenIconColor as EuiImageButtonIconColor]; return ( - <> - - + +
+ )} + ); }; diff --git a/packages/eui/src/components/image/image_caption.tsx b/packages/eui/src/components/image/image_caption.tsx index c1692566217..b5eae9d8509 100644 --- a/packages/eui/src/components/image/image_caption.tsx +++ b/packages/eui/src/components/image/image_caption.tsx @@ -8,15 +8,14 @@ import React, { forwardRef, Ref } from 'react'; -import { useEuiTheme } from '../../services'; +import { useEuiMemoizedStyles } from '../../services'; import { euiImageCaptionStyles } from './image_caption.styles'; import type { EuiImageCaptionProps } from './image_types'; export const EuiImageCaption = forwardRef( ({ caption, isOnOverlayMask = false }, ref: Ref) => { - const euiTheme = useEuiTheme(); - const styles = euiImageCaptionStyles(euiTheme); + const styles = useEuiMemoizedStyles(euiImageCaptionStyles); const cssStyles = [ styles.euiImageCaption, isOnOverlayMask && styles.isOnOverlayMask, diff --git a/packages/eui/src/components/image/image_fullscreen_wrapper.tsx b/packages/eui/src/components/image/image_fullscreen_wrapper.tsx index 93d5e8af039..66bc9241357 100644 --- a/packages/eui/src/components/image/image_fullscreen_wrapper.tsx +++ b/packages/eui/src/components/image/image_fullscreen_wrapper.tsx @@ -9,19 +9,17 @@ import React, { FunctionComponent } from 'react'; import classNames from 'classnames'; +import { useEuiMemoizedStyles, keys } from '../../services'; +import { useInnerText } from '../inner_text'; import { EuiFocusTrap } from '../focus_trap'; import { EuiOverlayMask } from '../overlay_mask'; import { EuiIcon } from '../icon'; -import { useEuiTheme, keys } from '../../services'; -import { useInnerText } from '../inner_text'; -import { euiImageFullscreenWrapperStyles } from './image_fullscreen_wrapper.styles'; import type { EuiImageWrapperProps } from './image_types'; - import { EuiImageButton } from './image_button'; import { euiImageButtonIconStyles } from './image_button.styles'; - import { EuiImageCaption } from './image_caption'; +import { euiImageFullscreenWrapperStyles } from './image_fullscreen_wrapper.styles'; export const EuiImageFullScreenWrapper: FunctionComponent< EuiImageWrapperProps @@ -36,24 +34,19 @@ export const EuiImageFullScreenWrapper: FunctionComponent< fullScreenIconColor, onFullScreen, }) => { - const euiTheme = useEuiTheme(); - - const styles = euiImageFullscreenWrapperStyles(euiTheme); - - const cssStyles = [styles.euiImageFullscreenWrapper, wrapperProps?.css]; - const classes = classNames( 'euiImageFullScreenWrapper', wrapperProps && wrapperProps.className ); - const onKeyDown = (event: React.KeyboardEvent) => { - if (event.key === keys.ESCAPE) { - event.preventDefault(); - event.stopPropagation(); - closeFullScreen(); - } - }; + const styles = useEuiMemoizedStyles(euiImageFullscreenWrapperStyles); + const cssStyles = [styles.euiImageFullscreenWrapper, wrapperProps?.css]; + + const iconStyles = useEuiMemoizedStyles(euiImageButtonIconStyles); + const cssIconStyles = [ + iconStyles.euiImageButton__icon, + iconStyles.closeFullScreen, + ]; const closeFullScreen = () => { setIsFullScreen(false); @@ -62,12 +55,6 @@ export const EuiImageFullScreenWrapper: FunctionComponent< const [optionalCaptionRef, optionalCaptionText] = useInnerText(); - const iconStyles = euiImageButtonIconStyles(euiTheme); - const cssIconStyles = [ - iconStyles.euiImageButton__icon, - iconStyles.closeFullScreen, - ]; - return ( - <> -
+ { + if (event.key === keys.ESCAPE) { + event.preventDefault(); + event.stopPropagation(); + closeFullScreen(); + } + }} + data-test-subj="deactivateFullScreenButton" + isFullScreen={true} + isFullWidth={isFullWidth} + fullScreenIconColor={fullScreenIconColor} > - - {children} - - -
- {/* Must be outside the `figure` element in order to escape the translateY transition. see https://www.w3.org/TR/css-transforms-1/#transform-rendering */} - - + {children} + + + + {/* Must be outside the `figure` element in order to escape the translateY transition. see https://www.w3.org/TR/css-transforms-1/#transform-rendering */} +
); diff --git a/packages/eui/src/components/image/image_wrapper.tsx b/packages/eui/src/components/image/image_wrapper.tsx index 71e4ad98906..c609ea488ff 100644 --- a/packages/eui/src/components/image/image_wrapper.tsx +++ b/packages/eui/src/components/image/image_wrapper.tsx @@ -9,11 +9,10 @@ import React, { FunctionComponent } from 'react'; import classNames from 'classnames'; -import { useEuiTheme } from '../../services'; +import { useEuiMemoizedStyles } from '../../services'; import { useInnerText } from '../inner_text'; import type { EuiImageWrapperProps } from './image_types'; - import { euiImageWrapperStyles } from './image_wrapper.styles'; import { EuiImageButton } from './image_button'; import { EuiImageCaption } from './image_caption'; @@ -32,19 +31,12 @@ export const EuiImageWrapper: FunctionComponent = ({ isFullWidth, onFullScreen, }) => { - const openFullScreen = () => { - setIsFullScreen(true); - onFullScreen?.(true); - }; - const classes = classNames( 'euiImageWrapper', wrapperProps && wrapperProps.className ); - const euiTheme = useEuiTheme(); - - const styles = euiImageWrapperStyles(euiTheme); + const styles = useEuiMemoizedStyles(euiImageWrapperStyles); const cssFigureStyles = [ styles.euiImageWrapper, float && styles[float], @@ -64,18 +56,19 @@ export const EuiImageWrapper: FunctionComponent = ({ css={cssFigureStyles} > {allowFullScreen ? ( - <> - - {children} - - + { + setIsFullScreen(true); + onFullScreen?.(true); + }} + data-test-subj="activateFullScreenButton" + isFullWidth={isFullWidth} + fullScreenIconColor={fullScreenIconColor} + > + {children} + ) : ( children )} diff --git a/packages/eui/src/components/list_group/list_group.tsx b/packages/eui/src/components/list_group/list_group.tsx index f55feae989a..55cf426abbd 100644 --- a/packages/eui/src/components/list_group/list_group.tsx +++ b/packages/eui/src/components/list_group/list_group.tsx @@ -6,14 +6,19 @@ * Side Public License, v 1. */ -import React, { FunctionComponent, HTMLAttributes, CSSProperties } from 'react'; +import React, { + FunctionComponent, + HTMLAttributes, + CSSProperties, + useMemo, +} from 'react'; import classNames from 'classnames'; -import { EuiListGroupItem, EuiListGroupItemProps } from './list_group_item'; -import { CommonProps } from '../common'; -import { useEuiTheme, cloneElementWithCss } from '../../services'; +import { useEuiMemoizedStyles, cloneElementWithCss } from '../../services'; import { logicalStyle } from '../../global_styling'; +import { CommonProps } from '../common'; +import { EuiListGroupItem, EuiListGroupItemProps } from './list_group_item'; import { euiListGroupStyles } from './list_group.styles'; export const GUTTER_SIZES = ['none', 's', 'm'] as const; @@ -89,17 +94,8 @@ export const EuiListGroup: FunctionComponent = ({ ariaLabelledby, ...rest }) => { - let newStyle = style; - - if (maxWidth && maxWidth !== true) { - newStyle = { ...newStyle, ...logicalStyle('max-width', maxWidth) }; - } - const classes = classNames('euiListGroup', className); - - const euiTheme = useEuiTheme(); - const styles = euiListGroupStyles(euiTheme); - + const styles = useEuiMemoizedStyles(euiListGroupStyles); const cssStyles = [ styles.euiListGroup, styles[gutterSize], @@ -108,11 +104,15 @@ export const EuiListGroup: FunctionComponent = ({ maxWidth === true && styles.maxWidthDefault, ]; - let childrenOrListItems = null; + const maxWidthStyle = useMemo(() => { + if (maxWidth && maxWidth !== true) { + return logicalStyle('max-width', maxWidth); + } + }, [maxWidth]); - if (listItems) { - childrenOrListItems = listItems.map((item, index) => { - return [ + const renderedListItems = useMemo(() => { + if (listItems && listItems.length) { + return listItems.map((item, index) => ( = ({ color={color} size={size} {...item} - />, - ]; - }); - } else { - const showToolTipObj = showToolTips && { showToolTip: true }; - - childrenOrListItems = React.Children.map(children, (child) => { + /> + )); + } + }, [listItems, color, size, wrapText, showToolTips]); + + const listItemsOrChildren = + renderedListItems || + // Note that there's no point in memoizing `children`, as JSX changes every rerender + React.Children.map(children, (child) => { if (React.isValidElement(child)) { return cloneElementWithCss(child, { // we're passing the parent `color` and `size` down to the children // so that they can inherit it if they don't have one color: color, size: size, - ...showToolTipObj, + ...(showToolTips && { showToolTip: true }), ...child.props, }); } }); - } return (
    - {childrenOrListItems} + {listItemsOrChildren}
); }; diff --git a/packages/eui/src/components/list_group/list_group_item.styles.ts b/packages/eui/src/components/list_group/list_group_item.styles.ts index d68dba8675f..94a86f140f5 100644 --- a/packages/eui/src/components/list_group/list_group_item.styles.ts +++ b/packages/eui/src/components/list_group/list_group_item.styles.ts @@ -169,17 +169,15 @@ export const euiListGroupItemInnerStyles = (euiThemeContext: UseEuiTheme) => { }; }; -export const euiListGroupItemLabelStyles = () => { - return { - // Base - euiListGroupItem__label: css``, - truncate: css` - ${euiTextTruncate()} - `, - wrapText: css` - ${euiTextBreakWord()} - `, - }; +export const euiListGroupItemLabelStyles = { + // Base + euiListGroupItem__label: css``, + truncate: css` + ${euiTextTruncate()} + `, + wrapText: css` + ${euiTextBreakWord()} + `, }; export const euiListGroupItemIconStyles = ({ euiTheme }: UseEuiTheme) => { @@ -193,12 +191,10 @@ export const euiListGroupItemIconStyles = ({ euiTheme }: UseEuiTheme) => { }; }; -export const euiListGroupItemTooltipStyles = () => { - return { - // Base - euiListGroupItem__tooltip: css` - display: inline-flex; /* Allows the wrapped button/text to grow */ - ${logicalCSS('width', '100%')} - `, - }; +export const euiListGroupItemTooltipStyles = { + // Base + euiListGroupItem__tooltip: css` + display: inline-flex; /* Allows the wrapped button/text to grow */ + ${logicalCSS('width', '100%')} + `, }; diff --git a/packages/eui/src/components/list_group/list_group_item.tsx b/packages/eui/src/components/list_group/list_group_item.tsx index f28301bdce9..c4ae085b2f5 100644 --- a/packages/eui/src/components/list_group/list_group_item.tsx +++ b/packages/eui/src/components/list_group/list_group_item.tsx @@ -7,7 +7,6 @@ */ import React, { - Fragment, HTMLAttributes, AnchorHTMLAttributes, ButtonHTMLAttributes, @@ -18,23 +17,22 @@ import React, { } from 'react'; import classNames from 'classnames'; -import { EuiIcon, IconType, EuiIconProps } from '../icon'; -import { EuiToolTip, EuiToolTipProps } from '../tool_tip'; -import { useInnerText } from '../inner_text'; -import { ExclusiveUnion, CommonProps } from '../common'; -import { - EuiListGroupItemExtraAction, - EuiListGroupItemExtraActionProps, -} from './list_group_item_extra_action'; - import { getSecureRelForTarget, - useEuiTheme, + useEuiMemoizedStyles, cloneElementWithCss, } from '../../services'; import { validateHref } from '../../services/security/href_validator'; +import { ExclusiveUnion, CommonProps } from '../common'; +import { useInnerText } from '../inner_text'; +import { EuiIcon, IconType, EuiIconProps } from '../icon'; +import { EuiToolTip, EuiToolTipProps } from '../tool_tip'; import { EuiExternalLinkIcon } from '../link/external_link_icon'; +import { + EuiListGroupItemExtraAction, + EuiListGroupItemExtraActionProps, +} from './list_group_item_extra_action'; import { euiListGroupItemStyles, euiListGroupItemIconStyles, @@ -185,9 +183,7 @@ export const EuiListGroupItem: FunctionComponent = ({ const isHrefValid = !href || validateHref(href); const isDisabled = _isDisabled || !isHrefValid; - const euiTheme = useEuiTheme(); - - const iconStyles = euiListGroupItemIconStyles(euiTheme); + const iconStyles = useEuiMemoizedStyles(euiListGroupItemIconStyles); const cssIconStyles = [iconStyles.euiListGroupItem__icon, iconProps?.css]; let iconNode; @@ -243,7 +239,7 @@ export const EuiListGroupItem: FunctionComponent = ({ ); } - const labelStyles = euiListGroupItemLabelStyles(); + const labelStyles = euiListGroupItemLabelStyles; const cssLabelStyles = [ labelStyles.euiListGroupItem__label, wrapText ? labelStyles.wrapText : labelStyles.truncate, @@ -271,7 +267,7 @@ export const EuiListGroupItem: FunctionComponent = ({ // Handle the variety of interaction behavior let itemContent; - const innerStyles = euiListGroupItemInnerStyles(euiTheme); + const innerStyles = useEuiMemoizedStyles(euiListGroupItemInnerStyles); const cssInnerStyles = [ innerStyles.euiListGroupItem__inner, innerStyles[size], @@ -321,7 +317,7 @@ export const EuiListGroupItem: FunctionComponent = ({ ); } - const styles = euiListGroupItemStyles(euiTheme); + const styles = useEuiMemoizedStyles(euiListGroupItemStyles); const cssStyles = [ styles.euiListGroupItem, !isDisabled && isActive && styles.colors.isActive[color], @@ -333,7 +329,7 @@ export const EuiListGroupItem: FunctionComponent = ({ const classes = classNames('euiListGroupItem', className); if (showToolTip) { - const tooltipStyles = euiListGroupItemTooltipStyles(); + const tooltipStyles = euiListGroupItemTooltipStyles; const cssTooltipStyles = [ tooltipStyles.euiListGroupItem__tooltip, toolTipProps?.anchorProps?.css, @@ -375,5 +371,5 @@ export const EuiListGroupItem: FunctionComponent = ({ ); } - return {itemContent}; + return <>{itemContent}; }; diff --git a/packages/eui/src/components/list_group/list_group_item_extra_action.test.tsx b/packages/eui/src/components/list_group/list_group_item_extra_action.test.tsx index 9ec5174d724..905ba109301 100644 --- a/packages/eui/src/components/list_group/list_group_item_extra_action.test.tsx +++ b/packages/eui/src/components/list_group/list_group_item_extra_action.test.tsx @@ -19,12 +19,10 @@ describe('EuiListGroupItem', () => { iconType: 'star', }; - shouldRenderCustomStyles(); + shouldRenderCustomStyles(); test('is rendered', () => { - const { container } = render( - - ); + const { container } = render(); expect(container.firstChild).toMatchSnapshot(); }); diff --git a/packages/eui/src/components/list_group/list_group_item_extra_action.tsx b/packages/eui/src/components/list_group/list_group_item_extra_action.tsx index 2506cb0a973..bb283b973f1 100644 --- a/packages/eui/src/components/list_group/list_group_item_extra_action.tsx +++ b/packages/eui/src/components/list_group/list_group_item_extra_action.tsx @@ -9,9 +9,9 @@ import React, { FunctionComponent } from 'react'; import classNames from 'classnames'; +import { useEuiMemoizedStyles } from '../../services'; import { EuiButtonIcon, EuiButtonIconPropsForButton } from '../button'; -import { useEuiTheme } from '../../services'; import { euiListGroupItemExtraActionStyles } from './list_group_item_extra_action.styles'; export type EuiListGroupItemExtraActionProps = { @@ -36,9 +36,9 @@ export const EuiListGroupItemExtraAction: FunctionComponent< className ); - const euiTheme = useEuiTheme(); - - const extraActionStyles = euiListGroupItemExtraActionStyles(euiTheme); + const extraActionStyles = useEuiMemoizedStyles( + euiListGroupItemExtraActionStyles + ); const cssExtraActionStyles = [ extraActionStyles.euiListGroupItemExtraAction, alwaysShow && extraActionStyles.alwaysShow, diff --git a/packages/eui/src/components/list_group/pinnable_list_group/pinnable_list_group.tsx b/packages/eui/src/components/list_group/pinnable_list_group/pinnable_list_group.tsx index 424e837281c..4c85c8d60f5 100644 --- a/packages/eui/src/components/list_group/pinnable_list_group/pinnable_list_group.tsx +++ b/packages/eui/src/components/list_group/pinnable_list_group/pinnable_list_group.tsx @@ -6,15 +6,15 @@ * Side Public License, v 1. */ -import React, { FunctionComponent } from 'react'; +import React, { FunctionComponent, useMemo } from 'react'; import classNames from 'classnames'; + +import { useEuiMemoizedStyles } from '../../../services'; import { CommonProps } from '../../common'; +import { useEuiI18n } from '../../i18n'; -import { EuiI18n } from '../../i18n'; import { EuiListGroup, EuiListGroupProps } from '../list_group'; import { EuiListGroupItemProps } from '../list_group_item'; -import { useEuiTheme } from '../../../services'; - import { euiPinnableListGroupItemExtraActionStyles } from './pinnable_list_group.styles'; export type EuiPinnableListGroupItemProps = EuiListGroupItemProps & { @@ -60,32 +60,22 @@ export const EuiPinnableListGroup: FunctionComponent< EuiPinnableListGroupProps > = ({ className, listItems, pinTitle, unpinTitle, onPinClick, ...rest }) => { const classes = classNames('euiPinnableListGroup', className); - const euiTheme = useEuiTheme(); - const itemExtraActionStyles = - euiPinnableListGroupItemExtraActionStyles(euiTheme); - - const pinExtraAction: EuiListGroupItemProps['extraAction'] = { - iconType: 'pinFilled', - iconSize: 's', - css: itemExtraActionStyles.euiPinnableListGroup__itemExtraAction, - }; + const styles = useEuiMemoizedStyles( + euiPinnableListGroupItemExtraActionStyles + ); - const pinnedExtraAction: EuiListGroupItemProps['extraAction'] = { - iconType: 'pinFilled', - iconSize: 's', - css: [ - itemExtraActionStyles.euiPinnableListGroup__itemExtraAction, - itemExtraActionStyles.pinned, - ], - alwaysShow: true, - }; + const pinExtraActionLabel = useEuiI18n( + 'euiPinnableListGroup.pinExtraActionLabel', + 'Pin item' + ); + const pinnedExtraActionLabel = useEuiI18n( + 'euiPinnableListGroup.pinnedExtraActionLabel', + 'Unpin item' + ); // Alter listItems object with extra props - const getNewListItems = ( - pinExtraActionLabel: string, - pinnedExtraActionLabel: string - ) => - listItems.map((item) => { + const pinnableListItems = useMemo(() => { + return listItems.map((item) => { const { pinned, pinnable = true, ...itemProps } = item; // Make some declarations of props for the nav implementation itemProps.className = classNames( @@ -93,22 +83,33 @@ export const EuiPinnableListGroup: FunctionComponent< item.className ); - // Add the pinning action unless the item has it's own extra action + // Add the pinning action unless the item has its own extra action if (pinnable && !itemProps.extraAction) { // Different displays for pinned vs unpinned + const sharedProps: EuiListGroupItemProps['extraAction'] = { + iconType: 'pinFilled', + iconSize: 's', + css: [ + styles.euiPinnableListGroup__itemExtraAction, + pinned && styles.pinned, + ], + }; if (pinned) { + const title = unpinTitle ? unpinTitle(item) : pinnedExtraActionLabel; + itemProps.extraAction = { - ...pinnedExtraAction, - title: unpinTitle ? unpinTitle(item) : pinnedExtraActionLabel, - 'aria-label': unpinTitle - ? unpinTitle(item) - : pinnedExtraActionLabel, + ...sharedProps, + alwaysShow: true, + 'aria-label': title, + title, }; } else { + const title = pinTitle ? pinTitle(item) : pinExtraActionLabel; + itemProps.extraAction = { - ...pinExtraAction, - title: pinTitle ? pinTitle(item) : pinExtraActionLabel, - 'aria-label': pinTitle ? pinTitle(item) : pinExtraActionLabel, + ...sharedProps, + 'aria-label': title, + title, }; } // Return the item on click @@ -117,28 +118,17 @@ export const EuiPinnableListGroup: FunctionComponent< return itemProps; }); + }, [ + listItems, + pinTitle, + pinExtraActionLabel, + unpinTitle, + pinnedExtraActionLabel, + onPinClick, + styles, + ]); return ( - - {([pinExtraActionLabel, pinnedExtraActionLabel]: string[]) => { - const newListItems = getNewListItems( - pinExtraActionLabel, - pinnedExtraActionLabel - ); - return ( - - ); - }} - + ); }; diff --git a/packages/eui/src/components/steps/step.tsx b/packages/eui/src/components/steps/step.tsx index a367460d775..2248e1b67aa 100644 --- a/packages/eui/src/components/steps/step.tsx +++ b/packages/eui/src/components/steps/step.tsx @@ -16,7 +16,7 @@ import React, { import { CommonProps } from '../common'; import { EuiTitle, EuiTitleProps } from '../title'; import { EuiStepNumber, EuiStepStatus } from './step_number'; -import { useEuiTheme } from '../../services'; +import { useEuiMemoizedStyles } from '../../services'; import { euiStepStyles, euiStepContentStyles, @@ -65,17 +65,16 @@ export const EuiStep: FunctionComponent = ({ }) => { const classes = classNames('euiStep', className); - const euiTheme = useEuiTheme(); - const styles = euiStepStyles(euiTheme); + const styles = useEuiMemoizedStyles(euiStepStyles); const cssStyles = [styles.euiStep, styles[titleSize]]; - const contentStyles = euiStepContentStyles(euiTheme); + const contentStyles = useEuiMemoizedStyles(euiStepContentStyles); const cssContentStyles = [ contentStyles.euiStep__content, contentStyles[titleSize], ]; - const titleStyles = euiStepTitleStyles(euiTheme); + const titleStyles = useEuiMemoizedStyles(euiStepTitleStyles); const cssStepTitleStyles = [ titleStyles.euiStep__title, status === 'disabled' && titleStyles.isDisabled, diff --git a/packages/eui/src/components/steps/step_horizontal.styles.ts b/packages/eui/src/components/steps/step_horizontal.styles.ts index ef1a7b11460..f5de6697890 100644 --- a/packages/eui/src/components/steps/step_horizontal.styles.ts +++ b/packages/eui/src/components/steps/step_horizontal.styles.ts @@ -102,43 +102,39 @@ export const euiStepHorizontalStyles = (euiThemeContext: UseEuiTheme) => { disabled: css` cursor: not-allowed; `, - }; -}; -export const euiStepHorizontalNumberStyles = (euiThemeContext: UseEuiTheme) => { - const { euiTheme } = euiThemeContext; - - return { - euiStepHorizontal__number: css` - position: relative; /* 1 */ - z-index: ${Number(euiTheme.levels.content) + 1}; /* 1 */ + /** + * Child elements + */ - ${euiCanAnimate} { - transition: all ${euiTheme.animation.fast} ease-in-out; - } - `, - }; -}; + number: { + euiStepHorizontal__number: css` + position: relative; /* 1 */ + z-index: ${Number(euiTheme.levels.content) + 1}; /* 1 */ -export const euiStepHorizontalTitleStyles = (euiThemeContext: UseEuiTheme) => { - const { euiTheme } = euiThemeContext; - - return { - euiStepHorizontal__title: css` - ${euiTitle(euiThemeContext, 'xs')} - margin-block-start: ${euiTheme.size.s}; - font-weight: ${euiTheme.font.weight.bold}; - text-align: center; - - /* Hide titles on small screens */ - ${euiBreakpoint(euiThemeContext, ['xs', 's'])} { - display: none; - } - `, - disabled: css` - color: ${makeHighContrastColor(euiTheme.colors.disabledText)( - euiTheme.colors.body - )}; - `, + ${euiCanAnimate} { + transition: all ${euiTheme.animation.fast} ease-in-out; + } + `, + }, + + title: { + euiStepHorizontal__title: css` + ${euiTitle(euiThemeContext, 'xs')} + margin-block-start: ${euiTheme.size.s}; + font-weight: ${euiTheme.font.weight.bold}; + text-align: center; + + /* Hide titles on small screens */ + ${euiBreakpoint(euiThemeContext, ['xs', 's'])} { + display: none; + } + `, + disabled: css` + color: ${makeHighContrastColor(euiTheme.colors.disabledText)( + euiTheme.colors.body + )}; + `, + }, }; }; diff --git a/packages/eui/src/components/steps/step_horizontal.tsx b/packages/eui/src/components/steps/step_horizontal.tsx index ef71467f8d1..4cc267e2104 100644 --- a/packages/eui/src/components/steps/step_horizontal.tsx +++ b/packages/eui/src/components/steps/step_horizontal.tsx @@ -10,11 +10,12 @@ import classNames from 'classnames'; import React, { ButtonHTMLAttributes, FunctionComponent, - MouseEvent as ReactMouseEvent, MouseEventHandler, } from 'react'; + +import { useEuiMemoizedStyles } from '../../services'; import { CommonProps } from '../common'; -import { useEuiTheme } from '../../services'; + import { EuiStepNumber, EuiStepNumberProps, @@ -31,11 +32,7 @@ import { useI18nErrorsStep, useI18nLoadingStep, } from './step_strings'; -import { - euiStepHorizontalStyles, - euiStepHorizontalNumberStyles, - euiStepHorizontalTitleStyles, -} from './step_horizontal.styles'; +import { euiStepHorizontalStyles } from './step_horizontal.styles'; export interface EuiStepHorizontalProps extends Omit, 'onClick'>, @@ -79,22 +76,15 @@ export const EuiStepHorizontal: FunctionComponent = ({ if (disabled) status = 'disabled'; const classes = classNames('euiStepHorizontal', className); - - const euiTheme = useEuiTheme(); - const styles = euiStepHorizontalStyles(euiTheme); + const styles = useEuiMemoizedStyles(euiStepHorizontalStyles); const cssStyles = [ styles.euiStepHorizontal, styles[size], status === 'disabled' ? styles.disabled : styles.enabled, ]; - - const numberStyles = euiStepHorizontalNumberStyles(euiTheme); - const cssNumberStyles = [numberStyles.euiStepHorizontal__number]; - - const titleStyles = euiStepHorizontalTitleStyles(euiTheme); const cssTitleStyles = [ - titleStyles.euiStepHorizontal__title, - status === 'disabled' && titleStyles.disabled, + styles.title.euiStepHorizontal__title, + status === 'disabled' && styles.title.disabled, ]; const titleAttrsMap: Record = { @@ -109,18 +99,14 @@ export const EuiStepHorizontal: FunctionComponent = ({ }; const titleAttr = titleAttrsMap[status || 'step']; - const onStepClick = ( - event: ReactMouseEvent - ) => { - if (!disabled) onClick(event); - }; - return (