Sha256: fc634834a7aab15a3fd12a6f5b3f688914226497af7fb0f96ebfde0c3f199be8

Contents?: true

Size: 822 Bytes

Versions: 25

Compression:

Stored size: 822 Bytes

Contents

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

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
coveragebook_components-0.7.10 app/components/coco/app/elements/system_banner/system_banner.rb
coveragebook_components-0.7.9 app/components/coco/app/elements/system_banner/system_banner.rb
coveragebook_components-0.7.8 app/components/coco/app/elements/system_banner/system_banner.rb
coveragebook_components-0.7.7 app/components/coco/app/elements/system_banner/system_banner.rb
coveragebook_components-0.7.6 app/components/coco/app/elements/system_banner/system_banner.rb
coveragebook_components-0.7.5 app/components/coco/app/elements/system_banner/system_banner.rb
coveragebook_components-0.7.4 app/components/coco/app/elements/system_banner/system_banner.rb
coveragebook_components-0.7.3 app/components/coco/app/elements/system_banner/system_banner.rb
coveragebook_components-0.7.2 app/components/coco/app/elements/system_banner/system_banner.rb
coveragebook_components-0.7.1 app/components/coco/app/elements/system_banner/system_banner.rb
coveragebook_components-0.7.0 app/components/coco/app/elements/system_banner/system_banner.rb
coveragebook_components-0.6.5 app/components/coco/app/elements/system_banner/system_banner.rb
coveragebook_components-0.6.4 app/components/coco/app/elements/system_banner/system_banner.rb
coveragebook_components-0.6.3 app/components/coco/app/elements/system_banner/system_banner.rb
coveragebook_components-0.6.2 app/components/coco/app/elements/system_banner/system_banner.rb
coveragebook_components-0.6.1 app/components/coco/app/elements/system_banner/system_banner.rb
coveragebook_components-0.6.0 app/components/coco/app/elements/system_banner/system_banner.rb
coveragebook_components-0.5.7 app/components/coco/app/elements/system_banner/system_banner.rb
coveragebook_components-0.5.6 app/components/coco/app/elements/system_banner/system_banner.rb
coveragebook_components-0.5.5 app/components/coco/app/elements/system_banner/system_banner.rb