on dc795ca help sign in
elk/libraries/Text.elm
109 lines 2.5 kB history raw
1module Text where
3{-| Functions for displaying text
5# Creating Text
6@docs toText
8# Creating Elements
9@docs plainText, asText, text, centered, justified, righted
11# Formatting
12@docs color, typeface, height, link
14# Simple Formatting
15@docs monospace, bold, italic, underline, overline, strikeThrough
17-}
19import Basics (..)
20import Color (Color)
21import Graphics.Element (Element, Three, Pos, ElementPrim, Properties)
22import Maybe (Maybe)
23import Native.Text
25data Text = Text
27{-| Convert a string into text which can be styled and displayed. -}
28toText : String -> Text
29toText = Native.Text.toText
31{-| Set the typeface of some text. The first argument should be a comma
32separated listing of the desired typefaces:
34 "helvetica, arial, sans-serif"
36Works the same as the CSS font-family property.
37-}
38typeface : String -> Text -> Text
39typeface = Native.Text.typeface
41{-| Switch to a monospace typeface. Good for code snippets. -}
42monospace : Text -> Text
43monospace = Native.Text.monospace
45{-| Create a link. -}
46link : String -> Text -> Text
47link = Native.Text.link
49{-| Set the height of text in pixels. -}
50height : Float -> Text -> Text
51height = Native.Text.height
53{-| Set the color of a string. -}
54color : Color -> Text -> Text
55color = Native.Text.color
57{-| Make a string bold. -}
58bold : Text -> Text
59bold = Native.Text.bold
61{-| Italicize a string. -}
62italic : Text -> Text
63italic = Native.Text.italic
65{-| Draw a line above a string. -}
66overline : Text -> Text
67overline = Native.Text.overline
69{-| Underline a string. -}
70underline : Text -> Text
71underline = Native.Text.underline
73{-| Draw a line through a string. -}
74strikeThrough : Text -> Text
75strikeThrough = Native.Text.strikeThrough
77{-| Display justified, styled text. -}
78justified : Text -> Element
79justified = Native.Text.justified
81{-| Display centered, styled text. -}
82centered : Text -> Element
83centered = Native.Text.centered
85{-| Display right justified, styled text. -}
86righted : Text -> Element
87righted = Native.Text.righted
89{-| Display styled text. -}
90text : Text -> Element
91text = Native.Text.text
93{-| Display a plain string. -}
94plainText : String -> Element
95plainText = Native.Text.plainText
97{-| for internal use only -}
98markdown : Element
99markdown = Native.Text.markdown
101{-| Convert anything to its textual representation and make it displayable in
102the browser:
104 asText == text . monospace . show
106Excellent for debugging.
107-}
108asText : a -> Element
109asText = Native.Text.asText