Whant to add some dynamics to your stories?
Knob of a String value.
storyButton : Bulletproof.Story
storyButton =
Bulletproof.story "Button"
(\title ->
button
[]
[ text title ]
|> Bulletproof.fromHtml
)
|> Bulletproof.Knob.string "Title" "Sign In"Specific property to configurate numeric knobs.
Set minimum value for numeric knobs.
Note: Default for
intandfloatranges is0
storyInput : Bulletproof.Story
storyInput =
Bulletproof.story "Input"
(\int float ->
input
[ size int
, style "width" (pct float)
]
[]
|> Bulletproof.fromHtml
)
|> Bulletproof.Knob.int "Size"
200
[ Bulletproof.Knob.min 100
]
|> Bulletproof.Knob.float "Width"
0.5
[ Bulletproof.Knob.min 0.25
]Set maximum value for numeric knobs.
Note: Defaults for
intandfloatranges are100and1respectively.
storyInput : Bulletproof.Story
storyInput =
Bulletproof.story "Input"
(\int float ->
input
[ size int
, style "width" (pct float)
]
[]
|> Bulletproof.fromHtml
)
|> Bulletproof.Knob.int "Size"
200
[ Bulletproof.Knob.max 1000
]
|> Bulletproof.Knob.float "Width"
0.5
[ Bulletproof.Knob.max 0.75
]Set step for numeric knobs.
Note: Defaults for
intandfloatranges are1and0.01respectively.
storyInput : Bulletproof.Story
storyInput =
Bulletproof.story "Input"
(\int float ->
input
[ size int
, style "width" (pct float)
]
[]
|> Bulletproof.fromHtml
)
|> Bulletproof.Knob.int "Size"
200
[ Bulletproof.Knob.step 100
]
|> Bulletproof.Knob.float "Width"
0.5
[ Bulletproof.Knob.step 0.1
]Represent numeric knob as range but not input.
storyInput : Bulletproof.Story
storyInput =
Bulletproof.story "Input"
(\int float ->
input
[ size int
, style "width" (pct float)
]
[]
|> Bulletproof.fromHtml
)
|> Bulletproof.Knob.int "Size"
10
[ Bulletproof.Knob.range
]
|> Bulletproof.Knob.float "Width"
0.5
[ Bulletproof.Knob.range
]Knob of a Int value.
storyInput : Bulletproof.Story
storyInput =
Bulletproof.story "Input"
(\int ->
input
[ size int
]
[]
|> Bulletproof.fromHtml
)
|> Bulletproof.Knob.int "Size" 10 []Knob of a Float value.
storyInput : Bulletproof.Story
storyInput =
Bulletproof.story "Input"
(\float ->
input
[ style "width" (pct float)
]
[]
|> Bulletproof.fromHtml
)
|> Bulletproof.Knob.float "Width" 0.5 []Knob of a custom value represented as radio group. The first option is selected by default.
storyInput : Bulletproof.Story
storyInput =
Bulletproof.story "Input"
(\inputType ->
input
[ type_ (Maybe.withDefault "text" inputType)
]
[]
|> Bulletproof.fromHtml
)
|> Bulletproof.Knob.radio "Type"
[ ( "none", Nothing )
, ( "email", Just "email" )
, ( "password", Just "password" )
]Knob of a custom value represented as select element. The first option is selected by default.
storyInput : Bulletproof.Story
storyInput =
Bulletproof.story "Input"
(\inputType ->
input
[ type_ (Maybe.withDefault "text" inputType)
]
[]
|> Bulletproof.fromHtml
)
|> Bulletproof.Knob.select "Type"
[ ( "none", Nothing )
, ( "email", Just "email" )
, ( "password", Just "password" )
]Simple shape contains both hex and rgb components.
Knob of a Color value.
storyButton : Bulletproof.Story
storyButton =
Bulletproof.story "Button"
(\bgcolor ->
button
[ style "background" bgcolor.hex ]
[ text "Sign In" ]
|> Bulletproof.fromHtml
)
|> Bulletproof.Knob.color "Background" "#444"Simple shape contains year, month, day and Time.Posix values.
Knob of a Date value.
storyToday : Bulletproof.Story
storyToday =
Bulletproof.story "Today"
(\date ->
div
[]
[ text "Today is: "
, text (String.fromInt date.day ++ " / ")
, text (String.fromInt date.month ++ " / ")
, text (String.fromInt date.year)
]
|> Bulletproof.fromHtml
)
|> Bulletproof.Knob.date "Date" "31-12-1999"Simple shape contains hours and minutes
Knob of a Time value.
storyNow : Bulletproof.Story
storyNow =
Bulletproof.story "Now"
(\time ->
div
[]
[ text ("Minutes: " ++ String.fromInt time.minutes)
, text " | "
, text ("Hours: " String.fromInt time.hours)
]
|> Bulletproof.fromHtml
)
|> Bulletproof.Knob.time "Time" "14:01"Alias for Elm File representation.
Knob of a List File value.
storyCountFiles : Bulletproof.Story
storyCountFiles =
Bulletproof.story "Count Files"
(\files ->
text (String.fromInt (List.length files) ++ " files are ready to upload")
|> Bulletproof.fromHtml
)
|> Bulletproof.Knob.files "Files"
Knob of a
Boolvalue.