on 63243ca help sign in
elk/libraries/Text.elm
110 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 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{-| Create a link. -}
47link : String -> Text -> Text
48link = Native.Text.link
50{-| Set the height of text in pixels. -}
51height : Float -> Text -> Text
52height = Native.Text.height
54{-| Set the color of a string. -}
55color : Color -> Text -> Text
56color = Native.Text.color
58{-| Make a string bold. -}
59bold : Text -> Text
60bold = Native.Text.bold
62{-| Italicize a string. -}
63italic : Text -> Text
64italic = Native.Text.italic
66{-| Draw a line above a string. -}
67overline : Text -> Text
68overline = Native.Text.overline
70{-| Underline a string. -}
71underline : Text -> Text
72underline = Native.Text.underline
74{-| Draw a line through a string. -}
75strikeThrough : Text -> Text
76strikeThrough = Native.Text.strikeThrough
78{-| Display justified, styled text. -}
79justified : Text -> Element
80justified = Native.Text.justified
82{-| Display centered, styled text. -}
83centered : Text -> Element
84centered = Native.Text.centered
86{-| Display right justified, styled text. -}
87righted : Text -> Element
88righted = Native.Text.righted
90{-| Display styled text. -}
91text : Text -> Element
92text = Native.Text.text
94{-| Display a plain string. -}
95plainText : String -> Element
96plainText = Native.Text.plainText
98{-| for internal use only -}
99markdown : Element
100markdown = Native.Text.markdown
102{-| Convert anything to its textual representation and make it displayable in
103the browser:
105 asText == text . monospace . show
107Excellent for debugging.
108-}
109asText : a -> Element
110asText = Native.Text.asText