Skip to content

Commit 2395c68

Browse files
committed
Add textarea component, closes #25
1 parent f16093f commit 2395c68

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/Flare.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,19 @@ exports.cRadioGroup = function(xs) {
296296
};
297297
};
298298

299+
exports.cTextarea = createComponent("textarea",
300+
function(initial) {
301+
var textarea = document.createElement("textarea");
302+
textarea.value = initial;
303+
return textarea;
304+
},
305+
"input",
306+
function(t, initial) {
307+
return t.value;
308+
}
309+
);
310+
311+
299312
exports.toFieldset = function(label) {
300313
return function(elements) {
301314
var fieldset = document.createElement("fieldset");

src/Flare.purs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ module Flare
2929
, select_
3030
, radioGroup
3131
, radioGroup_
32+
, textarea
33+
, textarea_
3234
, color
3335
, color_
3436
, date
@@ -138,6 +140,7 @@ foreign import cBoolean :: CreateComponent Boolean
138140
foreign import cButton :: forall a. a -> CreateComponent a
139141
foreign import cSelect :: forall a. Array a -> (a -> String) -> CreateComponent a
140142
foreign import cRadioGroup :: forall a. Array a -> (a -> String) -> CreateComponent a
143+
foreign import cTextarea :: CreateComponent String
141144
foreign import cColor :: CreateComponent String
142145

143146
type DateRec = { year :: Int, month :: Int, day :: Int }
@@ -286,6 +289,15 @@ radioGroup label (default :| xs) toString =
286289
radioGroup_ :: forall e f a. Foldable f => NonEmpty f a -> (a -> String) -> UI e a
287290
radioGroup_ = radioGroup ""
288291

292+
-- | Creates a textarea field for a `String` input from a given label and
293+
-- | default value.
294+
textarea :: forall e. Label -> String -> UI e String
295+
textarea = createUI cTextarea
296+
297+
-- | Like `textarea`, but without a label.
298+
textarea_ :: forall e. String -> UI e String
299+
textarea_ = textarea ""
300+
289301
-- | Creates a color picker input field from a label and default `Color`.
290302
color :: forall e. Label -> Color -> UI e Color
291303
color label default = (fromMaybe default <<< fromHexString) <$>

0 commit comments

Comments
 (0)