billstclair/elm-chat/1.0.0

NOTE: this package is not compatible with Elm 0.19.1

ElmChat

This module contains a simple chat component that you can easily add to your Elm user interface.

Types

type alias Settings msg =
{ fontSize : Int
, text : String
, input : String
, scroll : Float
, attributes : ExtraAttributes msg
, id : String
, defaultFontSize : Int
, showSizeControls : Bool
, updater : TheUpdater msg
}

Settings for the chat component. Make one of these with makeSettings.

type alias ExtraAttributes msg =
{ chatTable : List (Attribute msg)
, sizeButtons : List (Attribute msg)
, sizeColumn : List (Attribute msg)
, textColumn : List (Attribute msg)
, textArea : List (Attribute msg)
}

Extra attributes for the UI components. This is the value of Settings.attributes. You'll usually create one by changing defaultAttributes.

Functions

makeSettings : String -> Int -> Bool -> Updater msg -> Settings msg

Make a Settings record to add to your Model. id is the Html id for the textarea showing the chat. initialFontSize is the initial font size of the textarea in pt. updater will be called to generate messages to update the Settings in your Model.

chat : Settings msg -> Html msg

Create a chat component.

addChat : Settings msg -> String -> ( Settings msg, Cmd msg )

Add a line to the chat box.

inputBox : Int -> String -> Sender msg -> Settings msg -> Html msg

Create a text input area of the given textSize (characters), with a send button with the given buttonText.

Variables

defaultExtraAttributes : ExtraAttributes msg

The default value of the Settings.attributes property.