Module: Iron::AvatarHelper
- Included in:
- ApplicationHelper
- Defined in:
- app/helpers/iron/avatar_helper.rb
Constant Summary collapse
- SYSTEM_AVATAR_CLASSES =
"bg-sky-100 text-sky-600 dark:bg-sky-500/20 dark:text-sky-400"
Instance Method Summary collapse
- #avatar(user, options = {}) ⇒ Object
- #system_icon(**options) ⇒ Object
- #user_icon(user, **options) ⇒ Object
Instance Method Details
#avatar(user, options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/helpers/iron/avatar_helper.rb', line 5 def avatar(user, = {}) variant = .delete(:variant) || "circle" alt = .delete(:alt) || "" css_class = tw( .delete(:class), # Basic layout "inline-grid shrink-0 align-middle [--avatar-radius:20%] [--ring-opacity:20%] *:col-start-1 *:row-start-1", "outline outline-1 -outline-offset-1 outline-black/(--ring-opacity) dark:outline-white/(--ring-opacity)", # Add the correct border radius variant == "square" ? "rounded-(--avatar-radius) *:rounded-(--avatar-radius)" : "rounded-full *:rounded-full", # The system user wears the accent treatment instead of the caller's palette user.iron_system? ? SYSTEM_AVATAR_CLASSES : nil ) tag.span class: css_class, data: { slot: "avatar" } do user.iron_system? ? system_glyph : initials_glyph(user, alt) end end |
#system_icon(**options) ⇒ Object
28 29 30 |
# File 'app/helpers/iron/avatar_helper.rb', line 28 def system_icon(**) icon "bot", ** end |
#user_icon(user, **options) ⇒ Object
24 25 26 |
# File 'app/helpers/iron/avatar_helper.rb', line 24 def user_icon(user, **) user.iron_system? ? system_icon(**) : icon("circle-user", **) end |