Sha256: 74c7205297ac4d28b29f2217b16d88739006546edf83aa616c390a3264a18426
Contents?: true
Size: 1.01 KB
Versions: 7
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
7 entries across 7 versions & 1 rubygems