Class: Shadcn::Pagination::Link::Component
- Inherits:
-
ApplicationViewComponent
- Object
- ViewComponent::Base
- ApplicationViewComponent
- Shadcn::Pagination::Link::Component
- Defined in:
- app/components/shadcn/pagination/link/component.rb
Overview
PaginationLink — styled with the button's own variants, like the TSX
does via buttonVariants({ variant: isActive ? "outline" : "ghost", size }).
Direct Known Subclasses
Constant Summary
Constants inherited from ApplicationViewComponent
ApplicationViewComponent::CONTENTS_STYLE, ApplicationViewComponent::VOID_TAGS
Instance Attribute Summary collapse
-
#active ⇒ Object
readonly
Returns the value of attribute active.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
Attributes inherited from ApplicationViewComponent
Instance Method Summary collapse
- #css_classes(extra = nil) ⇒ Object
- #element_attributes(**defaults) ⇒ Object
-
#initialize(active: false, size: :icon, **attributes) ⇒ Component
constructor
A new instance of Component.
Methods inherited from ApplicationViewComponent
#call, default_tag, #merged_style, #render_element, #shadcn_t, slot_name, #style_variants, #tag_name
Constructor Details
#initialize(active: false, size: :icon, **attributes) ⇒ Component
Returns a new instance of Component.
14 15 16 17 18 |
# File 'app/components/shadcn/pagination/link/component.rb', line 14 def initialize(active: false, size: :icon, **attributes) @active = active @size = size&.to_sym || :icon super(**attributes) end |
Instance Attribute Details
#active ⇒ Object (readonly)
Returns the value of attribute active.
12 13 14 |
# File 'app/components/shadcn/pagination/link/component.rb', line 12 def active @active end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
12 13 14 |
# File 'app/components/shadcn/pagination/link/component.rb', line 12 def size @size end |
Instance Method Details
#css_classes(extra = nil) ⇒ Object
27 28 29 30 31 32 33 |
# File 'app/components/shadcn/pagination/link/component.rb', line 27 def css_classes(extra = nil) Button::Component.variant_classes( variant: active ? :outline : :ghost, size:, class: extra ) end |
#element_attributes(**defaults) ⇒ Object
20 21 22 23 24 25 |
# File 'app/components/shadcn/pagination/link/component.rb', line 20 def element_attributes(**defaults) super(**{ "aria-current" => ("page" if active), "data-active" => active }.merge(defaults)) end |