module Coco module App module Elements class SystemBanner < Coco::Component include Concerns::AcceptsOptions include Concerns::WrapsComponent wraps_component :alert do |args| theme = vivid_theme_name(args.fetch(:theme, nil)) || :info_vivid Coco::App::Elements::Alert.new(**args, theme: theme, banner: true, single_line: true) end %i[title action secondary_action link].each do |slot_name| renders_one slot_name, ->(**kwargs, &block) do alert.send("with_#{slot_name}".to_sym, **kwargs, &block) end end private def vivid_theme_name(theme) if theme.present? "#{theme.to_s.underscore.gsub("_vivid", "")}_vivid".to_sym end end end end end end