diff --git a/src/components/Input.js b/src/components/Input.js index 0bec7bcf..4d8ff262 100644 --- a/src/components/Input.js +++ b/src/components/Input.js @@ -5,7 +5,7 @@ import { color, typography, spacing } from './shared/styles'; import { jiggle } from './shared/animation'; import { Icon } from './Icon'; import { Link } from './Link'; -import WithTooltip from './tooltip/WithTooltip'; +import WithTooltip, { validPlacements as validTooltipPlacements } from './tooltip/WithTooltip'; import { TooltipMessage } from './tooltip/TooltipMessage'; // prettier-ignore @@ -268,6 +268,7 @@ export const PureInput = forwardRef( icon, error, appearance, + errorTooltipPlacement, className, lastErrorValue, startingType, @@ -327,7 +328,7 @@ export const PureInput = forwardRef( */} ( placeholder="Error with icon" icon="email" error="There's a snake in my boots" + errorTooltipPlacement="left" onChange={onChange} appearance={appearance} /> diff --git a/src/components/tooltip/WithTooltip.js b/src/components/tooltip/WithTooltip.js index eb908e57..9aeb5e6a 100644 --- a/src/components/tooltip/WithTooltip.js +++ b/src/components/tooltip/WithTooltip.js @@ -169,11 +169,17 @@ function WithTooltip({ ); } +const placementVariations = ['start', 'end']; +export const validPlacements = ['auto', 'top', 'right', 'left', 'bottom'].flatMap((placement) => [ + placement, + ...placementVariations.map((variation) => `${placement}-${variation}`), +]); + WithTooltip.propTypes = { tagName: PropTypes.string, trigger: PropTypes.string, closeOnClick: PropTypes.bool, - placement: PropTypes.string, + placement: PropTypes.oneOf(validPlacements), modifiers: PropTypes.shape({}), hasChrome: PropTypes.bool, tooltip: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),