Split alignment and tail

This commit is contained in:
Tessa Kelly 2021-11-01 12:29:42 -07:00
parent 5d816d8f73
commit 91bcc8f9a4

View File

@ -26,6 +26,7 @@ Post-release patches:
- mark customTriggerAttributes as deprecated
- add containerCss
- adds `nriDescription` and `testId`
- fix <https://github.com/NoRedInk/noredink-ui/issues/766>
Changes from V1:
@ -106,6 +107,7 @@ type Attribute msg
type alias Tooltip msg =
{ direction : Direction
, alignment : Alignment
, tail : Tail
, content : List (Html msg)
, attributes : List (Html.Attribute Never)
@ -126,7 +128,8 @@ buildAttributes =
defaultTooltip : Tooltip msg
defaultTooltip =
{ direction = OnTop
, tail = WithTail Middle
, alignment = Middle
, tail = WithTail
, content = []
, attributes = []
, containerStyles =
@ -160,7 +163,7 @@ html content =
type Tail
= WithTail Alignment
= WithTail
| WithoutTail
@ -173,10 +176,6 @@ type Alignment
{-| Makes it so that the tooltip does not have a tail!
This will center the tooltip relative to the trigger content, superseding any
custom alignment set by `alignStart` and `alignEnd`.
-}
withoutTail : Attribute msg
withoutTail =
@ -185,17 +184,7 @@ withoutTail =
withAligment : Alignment -> Attribute msg
withAligment alignment =
Attribute (\config -> { config | tail = WithTail alignment })
tailAlignment : Tail -> Alignment
tailAlignment tail =
case tail of
WithTail alignment ->
alignment
WithoutTail ->
Middle
Attribute (\config -> { config | alignment = alignment })
{-| Put the tail at the "start" of the tooltip.
@ -664,7 +653,7 @@ viewOpenTooltip tooltipId config =
Html.div
[ Attributes.css
[ Css.position Css.absolute
, positionTooltip config.direction (tailAlignment config.tail)
, positionTooltip config.direction config.alignment
, Css.boxSizing Css.borderBox
]
]
@ -684,7 +673,7 @@ viewOpenTooltip tooltipId config =
]
++ config.tooltipStyleOverrides
)
, pointerBox config.tail config.direction (tailAlignment config.tail)
, pointerBox config.tail config.direction config.alignment
-- We need to keep this animation in tests to make it pass: check out
-- the NoAnimations middleware. So if you change the name here, please
@ -771,7 +760,7 @@ pointerBox tail direction alignment =
, Css.border3 (Css.px 1) Css.solid Colors.navy
, positioning direction alignment
, case tail of
WithTail _ ->
WithTail ->
tailForDirection direction
WithoutTail ->