on e3c3d21 help sign in
elk/libraries/Text.elm
114 lines 2.6 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, header, bold, italic, underline, overline, strikeThrough
17-}
19import open Basics
20import Color (Color)
21import Graphics.Element (Element, Three, Pos, ElementPrim, Properties)
22import Maybe (Maybe)
23import JavaScript (JSString)
24import Native.Text
26data Text = Text
28{-| Convert a string into text which can be styled and displayed. -}
29toText : String -> Text
30toText = Native.Text.toText
32{-| Set the typeface of some text. The first argument should be a comma
33separated listing of the desired typefaces:
35 "helvetica, arial, sans-serif"
37Works the same as the CSS font-family property.
38-}
39typeface : String -> Text -> Text
40typeface = Native.Text.typeface
42{-| Switch to a monospace typeface. Good for code snippets. -}
43monospace : Text -> Text
44monospace = Native.Text.monospace
46{-| Make text big and noticable. -}
47header : Text -> Text
48header = Native.Text.header
50{-| Create a link. -}
51link : String -> Text -> Text
52link = Native.Text.link
54{-| Set the height of text in pixels. -}
55height : Float -> Text -> Text
56height = Native.Text.height
58{-| Set the color of a string. -}
59color : Color -> Text -> Text
60color = Native.Text.color
62{-| Make a string bold. -}
63bold : Text -> Text
64bold = Native.Text.bold
66{-| Italicize a string. -}
67italic : Text -> Text
68italic = Native.Text.italic
70{-| Draw a line above a string. -}
71overline : Text -> Text
72overline = Native.Text.overline
74{-| Underline a string. -}
75underline : Text -> Text
76underline = Native.Text.underline
78{-| Draw a line through a string. -}
79strikeThrough : Text -> Text
80strikeThrough = Native.Text.strikeThrough
82{-| Display justified, styled text. -}
83justified : Text -> Element
84justified = Native.Text.justified
86{-| Display centered, styled text. -}
87centered : Text -> Element
88centered = Native.Text.centered
90{-| Display right justified, styled text. -}
91righted : Text -> Element
92righted = Native.Text.righted
94{-| Display styled text. -}
95text : Text -> Element
96text = Native.Text.text
98{-| Display a plain string. -}
99plainText : String -> Element
100plainText = Native.Text.plainText
102{-| for internal use only -}
103markdown : Element
104markdown = Native.Text.markdown
106{-| Convert anything to its textual representation and make it displayable in
107the browser:
109 asText == text . monospace . show
111Excellent for debugging.
112-}
113asText : a -> Element
114asText = Native.Text.asText