Sha256: 20780e57dc19550c42a2b2f3702e652e275123bdb974b6afeb73c7e801a1911d
Contents?: true
Size: 969 Bytes
Versions: 3
Compression:
Stored size: 969 Bytes
Contents
# frozen_string_literal: true module Ariadne # Creates a rounded label that resembles a medicine pill. class PillComponent < Ariadne::Component DEFAULT_TAG = :span TAG_OPTIONS = [DEFAULT_TAG].freeze DEFAULT_CLASSES = "flex-shrink-0 inline-block px-2 py-0.5 text-xs font-medium rounded-full" # @example Default # # <%= render(Ariadne::PillComponent.new(color: "FF0000")) { "Admin" } %> # # @param tag [Symbol, String] The rendered tag name. # @param color [String] The hex color of the pill. # @param classes [String] <%= link_to_classes_docs %> # @param attributes [Hash] <%= link_to_attributes_docs %> def initialize(tag: DEFAULT_TAG, color:, classes: "", attributes: {}) @tag = check_incoming_tag(DEFAULT_TAG, tag) @classes = class_names( DEFAULT_CLASSES, classes ) @attributes = attributes @attributes["style"] = "background-color: ##{color};" end end end
Version data entries
3 entries across 3 versions & 1 rubygems