feat(components): add primitive btns and fix useHover on disabled buttons #5972
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
overview
A very common pattern that comes up when using our buttons is: "display a tooltip when this button is disabled". There are two problems that prevent us from doing this easily with out current button components:
pointer-events: none
to the button node, preventing enter and leave events<button>
is disabled, React will not triggermouseleave
events (normouseenter
events, starting at React v16.13), even ifpointer-events
aren't touched and sometimes even if the handlers are attached to the button's parentThis PR tackles both of these issues so that we can easily display tooltips on disabled buttons:
primitives
that don't come with any of our existing button baggage:<Btn>
-<button>
with CSS reset and defaulttype="button"
<PrimaryBtn>
-<Btn>
styled to look like a "Primary Button" from the Zeplin components guide<SecondaryBtn>
-<Btn>
styled to look like a "Secondary Button" from the Zeplin components guide<LightSecondaryBtn>
-<Btn>
styled to look like a "Light Secondary Button" from the Zeplin components guide<TertiaryBtn>
-<Btn>
styled to look like a "Tertiary Button" from the Zeplin components guideuseHover
hook from MouseEvents to PointerEventschangelog
<OutlineButton>
components to<SecondaryBtn>
components to demonstrate usage and tooltipsreview requests
Components where
useHoverTooltip
is used and smoke testing is neededapp/src/components/CheckCalibration/EndOfStepComparisons.js
app/src/components/CheckCalibration/PipetteComparisons.js
app/src/components/RobotSettings/CheckCalibrationControl.js
protocol-designer/src/components/StepCreationButton.js
protocol-designer/src/components/modals/EditModulesModal/index.js
protocol-designer/src/components/modules/ModuleRow.js
protocol-designer/src/components/StepEditForm/fields/ProfileItemRows.js
protocol-designer/src/components/StepEditForm/fields/ChangeTipField/ChangeTip.js
protocol-designer/src/components/StepEditForm/fields/TipPositionField/index.js
protocol-designer/src/components/StepEditForm/fields/WellOrderField/index.js
protocol-designer/src/components/steplist/AspirateDispenseHeader.js
protocol-designer/src/components/steplist/MixHeader.js
protocol-designer/src/components/steplist/ModuleStepItems.js
protocol-designer/src/components/steplist/SubstepRow.js
risk assessment
Button are important and this changes the handlers used for all existing usages of
useHoverTooltip
, so this is medium risk. The following mitigation steps were taken:<Button>
components