app/demo/components/time_fields.pom
require 'date'
Voom::Presenters.define(:time_fields) do
helpers Demo::Helpers::IndentedGrid
attach :top_nav
attach :component_drawer
page_title 'Time Field'
indented_grid do
body <<~DOC
A time field separates user display format from the value format.
The default time user display [format](/formatting_tokens#time) can be configured globally using the following:
````
Voom::Presenters::Settings.configure do |config|
config.presenters.components.defaults.time.format = 'h:i K'
end
````
The value format for date times can be the following, they are expected to be in 24 hour time:
* Ruby Time/DateTime objects.
* Chronologically Time Strings, e.g., HH:MM
DOC
grid do
column 6 do
time_field name: :skydive_at,
format: 'H:i' do
label 'Select your time to skydive'
icon :event
event :change do
replaces :context_list, :context_list
end
end
end
column 6 do
attach :context_list
end
end
grid do
column 6 do
title 'Min Time'
time_field min_time: "9:00"
title 'Max Time'
time_field max_time: "20:00"
title 'Range'
time_field min_time: "16:00", max_time: "20:00"
title '24 hour time'
time_field time_24hr: true
end
end
end
attach :code, file: __FILE__
end