-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace Syntax.Linked with Syntax.SyntaxConfig
Expand Linked to support configurable syntax help tooltips with a builder pattern and rename it SyntaxConfig.
- Loading branch information
Showing
13 changed files
with
167 additions
and
116 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
module Code.Syntax.SyntaxConfig exposing (..) | ||
|
||
import Code.Definition.Reference exposing (Reference) | ||
import UI.Click exposing (Click) | ||
import UI.Tooltip exposing (Tooltip) | ||
|
||
|
||
type alias TooltipConfig msg = | ||
{ toHoverStart : Reference -> msg | ||
, toHoverEnd : Reference -> msg | ||
, toTooltip : Reference -> Maybe (Tooltip msg) | ||
} | ||
|
||
|
||
type alias ToClick msg = | ||
Reference -> Click msg | ||
|
||
|
||
type alias SyntaxConfig msg = | ||
{ toClick : Maybe (ToClick msg) | ||
, dependencyTooltip : Maybe (TooltipConfig msg) | ||
, showSyntaxHelpTooltip : Bool | ||
} | ||
|
||
|
||
|
||
-- CREATE | ||
|
||
|
||
empty : SyntaxConfig msg | ||
empty = | ||
{ toClick = Nothing, dependencyTooltip = Nothing, showSyntaxHelpTooltip = False } | ||
|
||
|
||
default : ToClick msg -> TooltipConfig msg -> SyntaxConfig msg | ||
default toClick tooltipConfig = | ||
empty | ||
|> withToClick toClick | ||
|> withDependencyTooltip tooltipConfig | ||
|> withSyntaxHelp | ||
|
||
|
||
|
||
-- MODIFY | ||
|
||
|
||
withToClick : ToClick msg -> SyntaxConfig msg -> SyntaxConfig msg | ||
withToClick toClick cfg = | ||
{ cfg | toClick = Just toClick } | ||
|
||
|
||
withDependencyTooltip : TooltipConfig msg -> SyntaxConfig msg -> SyntaxConfig msg | ||
withDependencyTooltip tooltipConfig cfg = | ||
{ cfg | dependencyTooltip = Just tooltipConfig } | ||
|
||
|
||
withSyntaxHelp : SyntaxConfig msg -> SyntaxConfig msg | ||
withSyntaxHelp cfg = | ||
{ cfg | showSyntaxHelpTooltip = True } | ||
|
||
|
||
withoutSyntaxHelp : SyntaxConfig msg -> SyntaxConfig msg | ||
withoutSyntaxHelp cfg = | ||
{ cfg | showSyntaxHelpTooltip = False } |
Oops, something went wrong.