Sha256: 5b7ba9802766fb950dcbedab0f0868e0ec1384a0980c9da4ceb34c84b0742643
Contents?: true
Size: 1.01 KB
Versions: 24
Compression:
Stored size: 1.01 KB
Contents
# frozen_string_literal: true module Ariadne # Creates a ariadne-rounded label that resembles a medicine pill. class PillComponent < Ariadne::Component DEFAULT_TAG = :span TAG_OPTIONS = [DEFAULT_TAG].freeze DEFAULT_CLASSES = "ariadne-flex-shrink-0 ariadne-inline-block ariadne-px-2 ariadne-py-0.5 ariadne-text-xs ariadne-font-medium ariadne-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
24 entries across 24 versions & 1 rubygems