-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an input for color picker Browser support for color picker is still limited but I don't see a reason not to support it within simple_form
- Loading branch information
Gustavo Bazan
committed
Nov 13, 2018
1 parent
f5758fc
commit 7595be6
Showing
5 changed files
with
27 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# frozen_string_literal: true | ||
module SimpleForm | ||
module Inputs | ||
class ColorInput < Base | ||
def input(wrapper_options = nil) | ||
input_html_options[:type] ||= "color" if html5? | ||
|
||
merged_input_options = merge_wrapper_options(input_html_options, wrapper_options) | ||
|
||
@builder.text_field(attribute_name, merged_input_options) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'test_helper' | ||
|
||
class ColorInputTest < ActionView::TestCase | ||
test 'input generates a color field' do | ||
with_input_for @user, :favorite_color, :color | ||
assert_select 'input[type=color].color#user_favorite_color' | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters