Class: Pulse::Label

Inherits:
Component
  • Object
show all
Defined in:
app/components/pulse/label.rb

Overview

A kind of badge. Used for displaying github labels. Perhaps could be consolidated with badges? Accepts Hex color value for bg_color, with or without a leading "#"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title:, bg_color: 'ffffff', **options) ⇒ Label

Returns a new instance of Label.



10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/components/pulse/label.rb', line 10

def initialize(title:, bg_color: 'ffffff', **options)
  @title = title
  @bg_color = bg_color || 'ffffff'
  @options = options
  @options[:classes] = merge_classes(
    'pulse-px-2 pulse-inline-flex pulse-text-xs print:pulse-text-2xs',
    'pulse-leading-5 pulse-font-semibold pulse-rounded-full',
    text_color,
    options[:classes]
  )
  @options[:tag] ||= :span
end

Instance Attribute Details

#bg_colorObject (readonly)

Returns the value of attribute bg_color.



8
9
10
# File 'app/components/pulse/label.rb', line 8

def bg_color
  @bg_color
end

#titleObject (readonly)

Returns the value of attribute title.



8
9
10
# File 'app/components/pulse/label.rb', line 8

def title
  @title
end