billstclair/elm-chat/1.1.1

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, and store it in your model.

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 initial value of Settings.attributes.

You'll usually create one by changing defaultAttributes.

type alias Updater msg =
Settings msg -> Cmd msg -> msg

A function to turn a Settings record and a Cmd into a Msg.

type alias Sender msg =
String -> Settings msg -> msg

A function to turn an input string and a Settings record into a Msg.

Functions

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

Make a Settings record to add to your Model.

Args are id initialFontSize showSizeControls updater.

id is the Html id for the textarea showing the chat.

initialFontSize is the initial font size of the textarea in pt.

showSizeControls is True to show the font size controls to the left of the text area.

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 control.

Args are textSize buttonText sender settings.

textSize is the width in characters of the input control.

buttonText is the text for the button that sends the input.

sender is a function to turn an input string and settings into a Msg`.

settings is your Settings record.

Variables

defaultExtraAttributes : ExtraAttributes msg

The default value of the Settings.attributes property.