openaustralia/planningalerts

View on GitHub
app/components/tailwind/share_button.rb

Summary

Maintainability
A
0 mins
Test Coverage
# typed: strict
# frozen_string_literal: true

module Tailwind
  class ShareButton < ViewComponent::Base
    extend T::Sig

    sig { params(url: String, title: String, color: Symbol).void }
    def initialize(url:, title:, color:)
      super
      @url = url
      @title = title
      case color
      when :green
        @text_class = T.let("text-green hover:text-dark-green focus:outline-none focus:bg-sun-yellow", String)
      when :lavender
        # TODO: Add hover state
        @text_class = "text-lavender focus:outline-none focus:bg-sun-yellow"
      else
        raise "Unexpected color: #{color}"
      end
    end
  end
end