elm/libraries/Text.elm

111 lines
2.4 KiB
Elm
Raw Normal View History

2013-04-28 12:21:46 +00:00
module Text where
2013-09-10 03:57:06 +00:00
{-| Functions for displaying text
2013-09-10 06:07:49 +00:00
# Creating Text
2013-09-10 03:57:06 +00:00
@docs toText
2013-09-10 06:07:49 +00:00
# Creating Elements
@docs plainText, asText, text, centered, justified, righted
2013-09-10 03:57:06 +00:00
2013-09-10 06:07:49 +00:00
# Formatting
@docs color, typeface, height, link
# Simple Formatting
@docs monospace, bold, italic, underline, overline, strikeThrough
2013-09-10 03:57:06 +00:00
-}
import Basics (..)
2013-07-27 11:08:46 +00:00
import Color (Color)
import Graphics.Element (Element, Three, Pos, ElementPrim, Properties)
import Maybe (Maybe)
import JavaScript (JSString)
import Native.Text
2013-07-27 11:08:46 +00:00
data Text = Text
2013-09-10 03:57:06 +00:00
{-| Convert a string into text which can be styled and displayed. -}
toText : String -> Text
toText = Native.Text.toText
2013-09-10 03:57:06 +00:00
{-| Set the typeface of some text. The first argument should be a comma
2013-10-30 15:19:02 +00:00
separated listing of the desired typefaces:
2013-09-10 03:57:06 +00:00
"helvetica, arial, sans-serif"
Works the same as the CSS font-family property.
-}
typeface : String -> Text -> Text
typeface = Native.Text.typeface
2013-09-10 03:57:06 +00:00
{-| Switch to a monospace typeface. Good for code snippets. -}
monospace : Text -> Text
monospace = Native.Text.monospace
2013-09-10 03:57:06 +00:00
{-| Create a link. -}
2013-04-29 01:52:13 +00:00
link : String -> Text -> Text
link = Native.Text.link
2013-09-10 03:57:06 +00:00
{-| Set the height of text in pixels. -}
height : Float -> Text -> Text
height = Native.Text.height
2013-09-10 03:57:06 +00:00
{-| Set the color of a string. -}
color : Color -> Text -> Text
color = Native.Text.color
2013-09-10 03:57:06 +00:00
{-| Make a string bold. -}
bold : Text -> Text
bold = Native.Text.bold
2013-09-10 03:57:06 +00:00
{-| Italicize a string. -}
italic : Text -> Text
italic = Native.Text.italic
2013-09-10 03:57:06 +00:00
{-| Draw a line above a string. -}
overline : Text -> Text
overline = Native.Text.overline
2013-09-10 03:57:06 +00:00
{-| Underline a string. -}
underline : Text -> Text
underline = Native.Text.underline
2013-09-10 03:57:06 +00:00
{-| Draw a line through a string. -}
strikeThrough : Text -> Text
strikeThrough = Native.Text.strikeThrough
2013-09-10 03:57:06 +00:00
{-| Display justified, styled text. -}
justified : Text -> Element
justified = Native.Text.justified
2013-09-10 03:57:06 +00:00
{-| Display centered, styled text. -}
centered : Text -> Element
centered = Native.Text.centered
2013-09-10 03:57:06 +00:00
{-| Display right justified, styled text. -}
righted : Text -> Element
righted = Native.Text.righted
2013-09-10 03:57:06 +00:00
{-| Display styled text. -}
text : Text -> Element
text = Native.Text.text
2013-09-10 03:57:06 +00:00
{-| Display a plain string. -}
plainText : String -> Element
plainText = Native.Text.plainText
2013-09-10 03:57:06 +00:00
{-| for internal use only -}
markdown : Element
markdown = Native.Text.markdown
2013-10-30 15:19:02 +00:00
{-| Convert anything to its textual representation and make it displayable in
2013-10-30 15:37:28 +00:00
the browser:
2013-09-10 03:57:06 +00:00
asText == text . monospace . show
Excellent for debugging.
-}
asText : a -> Element
2013-10-30 15:19:02 +00:00
asText = Native.Text.asText