This repository has been archived by the owner on Mar 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6a0d064
commit e6dedfb
Showing
11 changed files
with
117 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ | |
"hygen", | ||
"lunarbox", | ||
"micromodal", | ||
"microtip", | ||
"monospace", | ||
"neumorphism", | ||
"oxanium", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,40 @@ | ||
module Lunarbox.Component.Tooltip where | ||
|
||
import Prelude | ||
import Control.MonadZero (guard) | ||
import Data.Array ((:)) | ||
import Data.Maybe (Maybe, fromMaybe, isJust) | ||
import Halogen.HTML (ClassName(..), HTML) | ||
import Halogen.HTML as HH | ||
import Halogen.HTML.Properties (classes) | ||
import Lunarbox.Component.Utils (className) | ||
import Halogen.HTML (AttrName(..), IProp, attr) | ||
import Halogen.HTML.Properties.ARIA as HA | ||
|
||
-- Tooltip visible when passing true as an argument | ||
tooltip :: forall a b. Boolean -> HTML a b -> HTML a b -> HTML a b | ||
tooltip active child content = | ||
HH.div [ classes $ ClassName <$> "tooltip" : ("tooltip--active" <$ guard active) ] | ||
[ child | ||
, HH.div | ||
[ className "tooltip__content" | ||
] | ||
[ content ] | ||
] | ||
data TooltipPosition | ||
= Top | ||
| TopLeft | ||
| TopRight | ||
| Bottom | ||
| BottomLeft | ||
| BottomRight | ||
| Left | ||
| Right | ||
|
||
-- Tooltip visible on hover | ||
hoverTooltip :: forall a b. HTML a b -> HTML a b -> HTML a b | ||
hoverTooltip child content = | ||
HH.div [ className "tooltip tooltip--hoverable" ] | ||
[ child | ||
, HH.div | ||
[ className "tooltip__content" | ||
] | ||
[ content ] | ||
] | ||
instance showTooltipPosition :: Show TooltipPosition where | ||
show Top = "top" | ||
show TopLeft = "top-left" | ||
show TopRight = "top-right" | ||
show Bottom = "bottom" | ||
show BottomLeft = "bottom-left" | ||
show BottomRight = "bottom-right" | ||
show Left = "left" | ||
show Right = "right" | ||
|
||
-- Toolip which might or might not have some content | ||
maybeTooltip :: forall a b. Maybe (HTML a b) -> HTML a b -> HTML a b | ||
maybeTooltip content child = tooltip (isJust content) child (fromMaybe (HH.text "") content) | ||
-- | Wrapper around microtip.css | ||
tooltip :: | ||
forall r i h. | ||
String -> | ||
TooltipPosition -> | ||
(Array (IProp r i) -> h) -> Array (IProp r i) -> h | ||
tooltip text position element extraAttribs = element attribs | ||
where | ||
attribs = | ||
[ HA.role "tooltip" | ||
, HA.label text | ||
, attr (AttrName "data-microtip-position") $ show position | ||
] | ||
<> extraAttribs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters