Single Stat Display Component

InfoGeneratePackages

This Ruby code defines a `StatComponent` class that inherits from `ApplicationView`. The class has a `template` method which returns a nested structure of HTML-like `divs` creating a component to display a single statistic. This component includes a title (`Total Page Views`), a value (`89,400`), and a description (`21% more than last month`). The components are styled with `class` attributes (`stats`, `stat`, `stat-title`, `stat-value`, `stat-desc`) to apply CSS styles, probably for layout and appearance such as shadow effect for the `stats` class. The description also suggests potential modifications for layout orientations (`stats-horizontal` and `stats-vertical`), though they are not implemented in this code snippet.

# frozen_string_literal: true

# Stats component can be modified to be:
# stats-horizontal and stats-vertical
class StatComponent < ApplicationView
  def template
    div(class: "stats shadow") do
      div(class: "stat") do
        div(class: "stat-title") { "Total Page Views" }
        div(class: "stat-value") { "89,400" }
        div(class: "stat-desc") { "21% more than last month" }
      end
    end
  end
end