Class: Flowbite::Rating::Star
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Flowbite::Rating::Star
- Defined in:
- app/components/flowbite/rating/star.rb
Overview
Renders a single star of a rating.
Constant Summary collapse
- SIZES =
{ default: ["w-5", "h-5"], md: ["w-6", "h-6"], lg: ["w-7", "h-7"] }.freeze
Instance Attribute Summary collapse
-
#size ⇒ Object
readonly
Returns the value of attribute size.
Class Method Summary collapse
Instance Method Summary collapse
- #classes ⇒ Object
- #filled? ⇒ Boolean
-
#initialize(filled: true, size: :default) ⇒ Star
constructor
A new instance of Star.
- #state ⇒ Object
Constructor Details
#initialize(filled: true, size: :default) ⇒ Star
Returns a new instance of Star.
41 42 43 44 |
# File 'app/components/flowbite/rating/star.rb', line 41 def initialize(filled: true, size: :default) @filled = filled @size = size end |
Instance Attribute Details
#size ⇒ Object (readonly)
Returns the value of attribute size.
39 40 41 |
# File 'app/components/flowbite/rating/star.rb', line 39 def size @size end |
Class Method Details
.classes(size: :default, state: :filled, style: :default) ⇒ Object
19 20 21 |
# File 'app/components/flowbite/rating/star.rb', line 19 def classes(size: :default, state: :filled, style: :default) sizes.fetch(size) + styles.fetch(style).fetch(state) end |
.sizes ⇒ Object
23 24 25 |
# File 'app/components/flowbite/rating/star.rb', line 23 def sizes SIZES end |
Instance Method Details
#classes ⇒ Object
46 47 48 |
# File 'app/components/flowbite/rating/star.rb', line 46 def classes self.class.classes(size: size, state: state) end |
#filled? ⇒ Boolean
50 51 52 |
# File 'app/components/flowbite/rating/star.rb', line 50 def filled? !!@filled end |
#state ⇒ Object
54 55 56 |
# File 'app/components/flowbite/rating/star.rb', line 54 def state filled? ? :filled : :empty end |