on f20fa4e help sign in
elk/libraries/Text.elm
115 lines 2.6 kB history raw
2module Text where
4{-| Functions for displaying text
6# Creating Text
7@docs toText
9# Creating Elements
10@docs plainText, asText, text, centered, justified, righted
12# Formatting
13@docs color, typeface, height, link
15# Simple Formatting
16@docs monospace, header, bold, italic, underline, overline, strikeThrough
18-}
20import open Basics
21import Color (Color)
22import Graphics.Element (Element, Three, Pos, ElementPrim, Properties)
23import Maybe (Maybe)
24import JavaScript (JSString)
25import Native.Text
27data Text = Text
29{-| Convert a string into text which can be styled and displayed. -}
30toText : String -> Text
31toText = Native.Text.toText
33{-| Set the typeface of some text. The first argument should be a comma
34separated listing of the desired typefaces
36 "helvetica, arial, sans-serif"
38Works the same as the CSS font-family property.
39-}
40typeface : String -> Text -> Text
41typeface = Native.Text.typeface
43{-| Switch to a monospace typeface. Good for code snippets. -}
44monospace : Text -> Text
45monospace = Native.Text.monospace
47{-| Make text big and noticable. -}
48header : Text -> Text
49header = Native.Text.header
51{-| Create a link. -}
52link : String -> Text -> Text
53link = Native.Text.link
55{-| Set the height of text in pixels. -}
56height : Float -> Text -> Text
57height = Native.Text.height
59{-| Set the color of a string. -}
60color : Color -> Text -> Text
61color = Native.Text.color
63{-| Make a string bold. -}
64bold : Text -> Text
65bold = Native.Text.bold
67{-| Italicize a string. -}
68italic : Text -> Text
69italic = Native.Text.italic
71{-| Draw a line above a string. -}
72overline : Text -> Text
73overline = Native.Text.overline
75{-| Underline a string. -}
76underline : Text -> Text
77underline = Native.Text.underline
79{-| Draw a line through a string. -}
80strikeThrough : Text -> Text
81strikeThrough = Native.Text.strikeThrough
83{-| Display justified, styled text. -}
84justified : Text -> Element
85justified = Native.Text.justified
87{-| Display centered, styled text. -}
88centered : Text -> Element
89centered = Native.Text.centered
91{-| Display right justified, styled text. -}
92righted : Text -> Element
93righted = Native.Text.righted
95{-| Display styled text. -}
96text : Text -> Element
97text = Native.Text.text
99{-| Display a plain string. -}
100plainText : String -> Element
101plainText = Native.Text.plainText
103{-| for internal use only -}
104markdown : Element
105markdown = Native.Text.markdown
107{-| Convert anything to it's textual representation and make it displayable in
108browser
110 asText == text . monospace . show
112Excellent for debugging.
113-}
114asText : a -> Element
115asText = Native.Text.asText