OfficeSpaceCardComponent

InfoGenerateCreated ByPackages

The OfficeSpaceCardComponent code defines a custom component in Ruby on Rails, likely used in a web application to display information about an office space. The class inherits from ApplicationComponent and initializes with properties: name, address, desks, rent, and image_url. The template method constructs a card layout using HTML tags and CSS classes. The card includes an image, the office space's name, address, number of desks, rent price, and a contact button. The div, figure, img, h2, p, b, and button elements are typically part of a templating language.

# frozen_string_literal: true

class OfficeSpaceCardComponent < ApplicationComponent
  def initialize(name:, address:, desks:, rent:, image_url:)
    @name = name
    @address = address
    @desks = desks
    @rent = rent
    @image_url = image_url
  end

  def template
    div(class: "card card-compact w-96 bg-base-100 shadow-xl") do
      figure { img(src: @image_url, alt: @name) }
      div(class: "card-body") do
        h2(class: "card-title") { @name }
        p { @address }
        p { "Desks: "; b { @desks } }
        p { "Rent: "; b { "$#{@rent} per month" } }
        div(class: "card-actions justify-end") do
          button(class: "btn btn-primary") { "Contact" }
        end
      end
    end
  end
end