Sha256: bfa5133cb421d783caf8064b900a7a991ff05176d5cb4c33bb1f44ea2a5c87e0

Contents?: true

Size: 1.04 KB

Versions: 4

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

module Maquina
  module Navbar
    class Notification < Phlex::HTML
      include ApplicationView

      def initialize(desktop: true)
        @desktop = desktop
      end

      def view_template(&block)
        button(**button_attributes) do
          span(class: "sr-only") { "View notifications" }
          svg_icon(:fill, icon: notification_icon)
        end
      end

      private

      def notification_icon
        "M15 17h5l-1.405-1.405A2.032 2.032 0 0118 14.158V11a6.002 6.002 0 00-4-5.659V5a2 2 0 10-4 0v.341C7.67 6.165 6 8.388 6 11v3.159c0 .538-.214 1.055-.595 1.436L4 17h5m6 0v1a3 3 0 11-6 0v-1m6 0H9"
      end

      def button_attributes
        Rails.logger.warn "[#{self.class}] Notification is hidden"
        attrs = {type: "button"}

        # Hidden by default
        # attrs[:class] = @desktop ? "hidden lg:block notification-icon" : "ml-auto notification-icon"
        attrs[:class] = @desktop ? "hidden notification-icon" : "hidden ml-auto notification-icon"

        attrs
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
maquina-0.7.2 app/views/maquina/navbar/notification.rb
maquina-0.7.1 app/views/maquina/navbar/notification.rb
maquina-0.5.2 app/views/maquina/navbar/notification.rb
maquina-0.5.1 app/views/maquina/navbar/notification.rb