Class: Flowbite::Avatar::Dot
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Flowbite::Avatar::Dot
- Defined in:
- app/components/flowbite/avatar/dot.rb
Overview
Renders a status dot indicator positioned on top of an avatar.
Usually added through the top_dot or bottom_dot slots of
Flowbite::Avatar, which set the position and size. When rendered on its
own, the dot must be placed inside a relatively positioned container
together with the avatar.
Constant Summary collapse
- POSITIONS =
{ bottom: ["bottom-0"], top: ["top-0"] }.freeze
- SIZES =
Horizontal offsets placing the dot at the right edge of an avatar of the given size.
{ xs: ["left-1.5"], sm: ["left-3"], base: ["left-5"], default: ["left-7"], lg: ["left-8"], xl: ["left-11"], "2xl": ["left-13"] }.freeze
Instance Attribute Summary collapse
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#position ⇒ Object
readonly
Returns the value of attribute position.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#style ⇒ Object
readonly
Returns the value of attribute style.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(label: nil, position: :top, size: :default, style: :success) ⇒ Dot
constructor
A new instance of Dot.
Constructor Details
#initialize(label: nil, position: :top, size: :default, style: :success) ⇒ Dot
Returns a new instance of Dot.
71 72 73 74 75 76 |
# File 'app/components/flowbite/avatar/dot.rb', line 71 def initialize(label: nil, position: :top, size: :default, style: :success) @label = label @position = position @size = size @style = style end |
Instance Attribute Details
#label ⇒ Object (readonly)
Returns the value of attribute label.
64 65 66 |
# File 'app/components/flowbite/avatar/dot.rb', line 64 def label @label end |
#position ⇒ Object (readonly)
Returns the value of attribute position.
64 65 66 |
# File 'app/components/flowbite/avatar/dot.rb', line 64 def position @position end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
64 65 66 |
# File 'app/components/flowbite/avatar/dot.rb', line 64 def size @size end |
#style ⇒ Object (readonly)
Returns the value of attribute style.
64 65 66 |
# File 'app/components/flowbite/avatar/dot.rb', line 64 def style @style end |
Class Method Details
.classes(position: :top, size: :default, style: :success) ⇒ Object
43 44 45 46 47 48 |
# File 'app/components/flowbite/avatar/dot.rb', line 43 def classes(position: :top, size: :default, style: :success) POSITIONS.fetch(position) + sizes.fetch(size) + ["absolute", "w-3.5", "h-3.5"] + styles.fetch(style).fetch(:default) + ["border-2", "border-buffer", "rounded-full"] end |
.sizes ⇒ Object
50 51 52 |
# File 'app/components/flowbite/avatar/dot.rb', line 50 def sizes SIZES end |
Instance Method Details
#call ⇒ Object
78 79 80 81 82 |
# File 'app/components/flowbite/avatar/dot.rb', line 78 def call content_tag(:span, class: self.class.classes(position: position, size: size, style: style)) do content_tag(:span, label, class: "sr-only") if label.present? end end |