Created
October 15, 2016 04:26
-
-
Save cwsaylor/66563ce5346c1c97b13eb14ef7a67799 to your computer and use it in GitHub Desktop.
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
module FlashHelper | |
DEFAULT_KEY_MATCHING = { | |
# Rails | |
:notice => :success, | |
:error => :alert, | |
# Foundation | |
:primary => :primary, | |
:secondary => :secondary, | |
:success => :success, | |
:warning => :warning, | |
:alert => :alert | |
} | |
def display_flash(key_matching = {}, size = "") | |
key_matching = DEFAULT_KEY_MATCHING.merge(key_matching) | |
flash.inject "" do |message, (key, value)| | |
# TODO: Set a motion ui class on closable | |
message += content_tag :div, data: { closable: "" }, class: ["callout", size, key_matching[key.to_sym] || :primary] do | |
(value + close_button).html_safe | |
end | |
end.html_safe | |
end | |
def close_button | |
button_tag(type: "button", class: "close-button", aria: { label: "Dismiss alert" }, data: { close: "" }) do | |
content_tag(:span, "×".html_safe, aria: { hidde: "true" }) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment