element_component 0.10.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/lib/element_component/components/alert/heading.rb +2 -1
  3. data/lib/element_component/components/alert/link.rb +2 -1
  4. data/lib/element_component/components/alert.rb +2 -1
  5. data/lib/element_component/components/badge.rb +2 -1
  6. data/lib/element_component/components/breadcrumb/item.rb +2 -1
  7. data/lib/element_component/components/breadcrumb.rb +2 -1
  8. data/lib/element_component/components/button.rb +2 -1
  9. data/lib/element_component/components/button_group.rb +2 -1
  10. data/lib/element_component/components/card/body.rb +2 -1
  11. data/lib/element_component/components/card/footer.rb +2 -1
  12. data/lib/element_component/components/card/header.rb +2 -1
  13. data/lib/element_component/components/card/text.rb +2 -1
  14. data/lib/element_component/components/card/title.rb +2 -1
  15. data/lib/element_component/components/card.rb +2 -1
  16. data/lib/element_component/components/carousel/caption.rb +2 -1
  17. data/lib/element_component/components/carousel/item.rb +2 -1
  18. data/lib/element_component/components/carousel.rb +2 -1
  19. data/lib/element_component/components/dropdown/header.rb +2 -1
  20. data/lib/element_component/components/dropdown/item.rb +2 -1
  21. data/lib/element_component/components/dropdown/menu.rb +2 -1
  22. data/lib/element_component/components/dropdown.rb +2 -1
  23. data/lib/element_component/components/list_group/item.rb +2 -1
  24. data/lib/element_component/components/list_group.rb +2 -1
  25. data/lib/element_component/components/modal/body.rb +2 -1
  26. data/lib/element_component/components/modal/content.rb +2 -1
  27. data/lib/element_component/components/modal/dialog.rb +2 -1
  28. data/lib/element_component/components/modal/footer.rb +2 -1
  29. data/lib/element_component/components/modal/header.rb +2 -1
  30. data/lib/element_component/components/modal/title.rb +2 -1
  31. data/lib/element_component/components/nav/item.rb +2 -1
  32. data/lib/element_component/components/nav/link.rb +2 -1
  33. data/lib/element_component/components/nav.rb +2 -1
  34. data/lib/element_component/components/navbar/brand.rb +2 -1
  35. data/lib/element_component/components/navbar/collapse.rb +2 -1
  36. data/lib/element_component/components/navbar/nav.rb +2 -1
  37. data/lib/element_component/components/navbar.rb +2 -1
  38. data/lib/element_component/components/pagination/item.rb +2 -1
  39. data/lib/element_component/components/pagination.rb +2 -1
  40. data/lib/element_component/components/progress/bar.rb +2 -1
  41. data/lib/element_component/components/progress.rb +2 -1
  42. data/lib/element_component/components/spinner.rb +2 -1
  43. data/lib/element_component/components/table.rb +2 -1
  44. data/lib/element_component/version.rb +1 -1
  45. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 85eed5018abeec014030f5b5e766bd15bb22485e1e085071350829d9dd8979c6
4
- data.tar.gz: 65e106b1cb82eab8c0db53e65b09c396e5a85a16cffd8f46d548938503c6b122
3
+ metadata.gz: c74ab0abe47013ad19304fcd1ad108855de1c85fdb4d7406e141d1797343d038
4
+ data.tar.gz: 6b77e4cf5c1c73f90c251d45b6a83bde06aaf052452850bac7463f437c5c604e
5
5
  SHA512:
6
- metadata.gz: 40a635e98231ea288f2a865889f8a4814a2d6bd1d9fa37359320267bf506197049c615b90ee7719a8c5adbf76c984377330310904392e1b66c26f75082657377
7
- data.tar.gz: 0fdfafc6cb4933a1e56704d35befb3b933c253d9d888c34fd09ad243367806dd31a4cdebeb6985b05923ccc4874953ac0c890fcc439c415b785275683a4cb7b6
6
+ metadata.gz: dbf84809def7f1bd6b2ea85ebdafa81f217254bcba2505f123487063029d962cfd6c2379fe3dd308030cbb8ed97e800746fdbf2fe229888aaee53eeffa868d7c
7
+ data.tar.gz: '039a7ccd1efb00032379fc3465a4f9c4b52feb7df276ad581a92d57f4970d9c471e65c8e37d545bfc81889e98793e4d8c97b8bd296adbdb1f97fe269d84ae36a'
@@ -3,11 +3,12 @@
3
3
  module ElementComponent
4
4
  module Components
5
5
  class AlertHeading < Element
6
- def initialize(**attributes)
6
+ def initialize(content = nil, **attributes)
7
7
  super("h4")
8
8
 
9
9
  add_attribute(class: "alert-heading")
10
10
  add_attribute(attributes) unless attributes.empty?
11
+ add_content(content) if content
11
12
  end
12
13
  end
13
14
  end
@@ -3,12 +3,13 @@
3
3
  module ElementComponent
4
4
  module Components
5
5
  class AlertLink < Element
6
- def initialize(href: "#", **attributes)
6
+ def initialize(content = nil, href: "#", **attributes)
7
7
  super("a")
8
8
 
9
9
  add_attribute(class: "alert-link")
10
10
  add_attribute(href: href)
11
11
  add_attribute(attributes) unless attributes.empty?
12
+ add_content(content) if content
12
13
  end
13
14
  end
14
15
  end
@@ -9,7 +9,7 @@ module ElementComponent
9
9
  class Alert < Element
10
10
  VALID_VARIANTS = %i[primary secondary success danger warning info light dark].freeze
11
11
 
12
- def initialize(variant: :primary, dismissible: false, **attributes, &block)
12
+ def initialize(content = nil, variant: :primary, dismissible: false, **attributes, &block)
13
13
  super("div", &block)
14
14
 
15
15
  add_attribute(class: "alert")
@@ -18,6 +18,7 @@ module ElementComponent
18
18
  add_attribute(role: "alert")
19
19
 
20
20
  add_attribute(attributes) unless attributes.empty?
21
+ add_content(content) if content
21
22
  add_content(AlertCloseButton.new) if dismissible
22
23
  end
23
24
  end
@@ -5,13 +5,14 @@ module ElementComponent
5
5
  class Badge < Element
6
6
  VALID_VARIANTS = %i[primary secondary success danger warning info light dark].freeze
7
7
 
8
- def initialize(variant: :primary, pill: false, **attributes, &block)
8
+ def initialize(content = nil, variant: :primary, pill: false, **attributes, &block)
9
9
  super("span", &block)
10
10
 
11
11
  add_attribute(class: "badge")
12
12
  add_attribute(class: "bg-#{variant}")
13
13
  add_attribute(class: "rounded-pill") if pill
14
14
  add_attribute(attributes) unless attributes.empty?
15
+ add_content(content) if content
15
16
  end
16
17
  end
17
18
  end
@@ -3,7 +3,7 @@
3
3
  module ElementComponent
4
4
  module Components
5
5
  class BreadcrumbItem < Element
6
- def initialize(href: nil, active: false, **attributes, &block)
6
+ def initialize(content = nil, href: nil, active: false, **attributes, &block)
7
7
  super("li", &block)
8
8
 
9
9
  add_attribute(class: "breadcrumb-item")
@@ -12,6 +12,7 @@ module ElementComponent
12
12
  add_attribute(attributes) unless attributes.empty?
13
13
 
14
14
  @href = href
15
+ add_content(content) if content
15
16
  end
16
17
 
17
18
  private
@@ -5,11 +5,12 @@ require_relative "breadcrumb/item"
5
5
  module ElementComponent
6
6
  module Components
7
7
  class Breadcrumb < Element
8
- def initialize(**attributes, &)
8
+ def initialize(content = nil, **attributes, &)
9
9
  super("nav", &)
10
10
 
11
11
  add_attribute("aria-label": "breadcrumb")
12
12
  add_attribute(attributes) unless attributes.empty?
13
+ add_content(content) if content
13
14
  end
14
15
 
15
16
  def build
@@ -6,7 +6,7 @@ module ElementComponent
6
6
  VALID_VARIANTS = %i[primary secondary success danger warning info light dark link].freeze
7
7
  VALID_SIZES = %i[sm lg].freeze
8
8
 
9
- def initialize(variant: :primary, outline: false, size: nil, href: nil, **attributes, &block)
9
+ def initialize(content = nil, variant: :primary, outline: false, size: nil, href: nil, **attributes, &block)
10
10
  if href
11
11
  super("a", &block)
12
12
  add_attribute(href: href)
@@ -19,6 +19,7 @@ module ElementComponent
19
19
  add_attribute(class: outline ? "btn-outline-#{variant}" : "btn-#{variant}")
20
20
  add_attribute(class: "btn-#{size}") if size
21
21
  add_attribute(attributes) unless attributes.empty?
22
+ add_content(content) if content
22
23
  end
23
24
  end
24
25
  end
@@ -5,13 +5,14 @@ module ElementComponent
5
5
  class ButtonGroup < Element
6
6
  VALID_SIZES = %i[sm lg].freeze
7
7
 
8
- def initialize(size: nil, vertical: false, **attributes, &block)
8
+ def initialize(content = nil, size: nil, vertical: false, **attributes, &block)
9
9
  super("div", &block)
10
10
 
11
11
  add_attribute(class: vertical ? "btn-group-vertical" : "btn-group")
12
12
  add_attribute(class: "btn-group-#{size}") if size
13
13
  add_attribute(role: "group")
14
14
  add_attribute(attributes) unless attributes.empty?
15
+ add_content(content) if content
15
16
  end
16
17
  end
17
18
  end
@@ -3,11 +3,12 @@
3
3
  module ElementComponent
4
4
  module Components
5
5
  class CardBody < Element
6
- def initialize(**attributes, &)
6
+ def initialize(content = nil, **attributes, &)
7
7
  super("div", &)
8
8
 
9
9
  add_attribute(class: "card-body")
10
10
  add_attribute(attributes) unless attributes.empty?
11
+ add_content(content) if content
11
12
  end
12
13
  end
13
14
  end
@@ -3,11 +3,12 @@
3
3
  module ElementComponent
4
4
  module Components
5
5
  class CardFooter < Element
6
- def initialize(**attributes, &)
6
+ def initialize(content = nil, **attributes, &)
7
7
  super("div", &)
8
8
 
9
9
  add_attribute(class: "card-footer")
10
10
  add_attribute(attributes) unless attributes.empty?
11
+ add_content(content) if content
11
12
  end
12
13
  end
13
14
  end
@@ -3,11 +3,12 @@
3
3
  module ElementComponent
4
4
  module Components
5
5
  class CardHeader < Element
6
- def initialize(**attributes, &)
6
+ def initialize(content = nil, **attributes, &)
7
7
  super("div", &)
8
8
 
9
9
  add_attribute(class: "card-header")
10
10
  add_attribute(attributes) unless attributes.empty?
11
+ add_content(content) if content
11
12
  end
12
13
  end
13
14
  end
@@ -3,11 +3,12 @@
3
3
  module ElementComponent
4
4
  module Components
5
5
  class CardText < Element
6
- def initialize(**attributes, &)
6
+ def initialize(content = nil, **attributes, &)
7
7
  super("p", &)
8
8
 
9
9
  add_attribute(class: "card-text")
10
10
  add_attribute(attributes) unless attributes.empty?
11
+ add_content(content) if content
11
12
  end
12
13
  end
13
14
  end
@@ -3,11 +3,12 @@
3
3
  module ElementComponent
4
4
  module Components
5
5
  class CardTitle < Element
6
- def initialize(**attributes, &)
6
+ def initialize(content = nil, **attributes, &)
7
7
  super("h5", &)
8
8
 
9
9
  add_attribute(class: "card-title")
10
10
  add_attribute(attributes) unless attributes.empty?
11
+ add_content(content) if content
11
12
  end
12
13
  end
13
14
  end
@@ -10,11 +10,12 @@ require_relative "card/image"
10
10
  module ElementComponent
11
11
  module Components
12
12
  class Card < Element
13
- def initialize(**attributes, &)
13
+ def initialize(content = nil, **attributes, &)
14
14
  super("div", &)
15
15
 
16
16
  add_attribute(class: "card")
17
17
  add_attribute(attributes) unless attributes.empty?
18
+ add_content(content) if content
18
19
  end
19
20
  end
20
21
  end
@@ -3,11 +3,12 @@
3
3
  module ElementComponent
4
4
  module Components
5
5
  class CarouselCaption < Element
6
- def initialize(**attributes, &)
6
+ def initialize(content = nil, **attributes, &)
7
7
  super("div", &)
8
8
 
9
9
  add_attribute(class: "carousel-caption")
10
10
  add_attribute(attributes) unless attributes.empty?
11
+ add_content(content) if content
11
12
  end
12
13
  end
13
14
  end
@@ -3,13 +3,14 @@
3
3
  module ElementComponent
4
4
  module Components
5
5
  class CarouselItem < Element
6
- def initialize(active: false, interval: nil, **attributes, &block)
6
+ def initialize(content = nil, active: false, interval: nil, **attributes, &block)
7
7
  super("div", &block)
8
8
 
9
9
  add_attribute(class: "carousel-item")
10
10
  add_attribute(class: "active") if active
11
11
  add_attribute("data-bs-interval": interval.to_s) if interval
12
12
  add_attribute(attributes) unless attributes.empty?
13
+ add_content(content) if content
13
14
  end
14
15
  end
15
16
  end
@@ -6,7 +6,7 @@ require_relative "carousel/caption"
6
6
  module ElementComponent
7
7
  module Components
8
8
  class Carousel < Element
9
- def initialize(id: "carousel", fade: false, indicators: true, controls: true, **attributes, &block)
9
+ def initialize(content = nil, id: "carousel", fade: false, indicators: true, controls: true, **attributes, &block)
10
10
  @carousel_id = id
11
11
  @show_indicators = indicators
12
12
  @show_controls = controls
@@ -17,6 +17,7 @@ module ElementComponent
17
17
  add_attribute(class: "slide")
18
18
  add_attribute(class: "carousel-fade") if fade
19
19
  add_attribute(attributes) unless attributes.empty?
20
+ add_content(content) if content
20
21
  end
21
22
 
22
23
  private
@@ -3,11 +3,12 @@
3
3
  module ElementComponent
4
4
  module Components
5
5
  class DropdownHeader < Element
6
- def initialize(**attributes, &)
6
+ def initialize(content = nil, **attributes, &)
7
7
  super("li", &)
8
8
 
9
9
  inner = Element.new("h6", class: "dropdown-header", **attributes)
10
10
  @inner_header = inner
11
+ add_content(content) if content
11
12
  end
12
13
 
13
14
  private
@@ -5,7 +5,7 @@ module ElementComponent
5
5
  class DropdownItem < Element
6
6
  VALID_TYPES = %i[button link].freeze
7
7
 
8
- def initialize(type: :link, href: "#", active: false, disabled: false, **attributes, &block)
8
+ def initialize(content = nil, type: :link, href: "#", active: false, disabled: false, **attributes, &block)
9
9
  tag = type == :button ? "button" : "a"
10
10
  super("li", &block)
11
11
 
@@ -19,6 +19,7 @@ module ElementComponent
19
19
  inner.add_content(&block) if block
20
20
 
21
21
  @inner_item = inner
22
+ add_content(content) if content
22
23
  end
23
24
 
24
25
  private
@@ -3,12 +3,13 @@
3
3
  module ElementComponent
4
4
  module Components
5
5
  class DropdownMenu < Element
6
- def initialize(align: nil, **attributes, &block)
6
+ def initialize(content = nil, align: nil, **attributes, &block)
7
7
  super("ul", &block)
8
8
 
9
9
  add_attribute(class: "dropdown-menu")
10
10
  add_attribute(class: "dropdown-menu-#{align}") if align
11
11
  add_attribute(attributes) unless attributes.empty?
12
+ add_content(content) if content
12
13
  end
13
14
  end
14
15
  end
@@ -10,12 +10,13 @@ module ElementComponent
10
10
  class Dropdown < Element
11
11
  VALID_DIRECTIONS = %i[dropup dropend dropstart].freeze
12
12
 
13
- def initialize(direction: nil, **attributes, &block)
13
+ def initialize(content = nil, direction: nil, **attributes, &block)
14
14
  super("div", &block)
15
15
 
16
16
  add_attribute(class: "dropdown")
17
17
  add_attribute(class: direction.to_s) if direction
18
18
  add_attribute(attributes) unless attributes.empty?
19
+ add_content(content) if content
19
20
  end
20
21
 
21
22
  def toggle_button(label: "Dropdown", variant: :secondary, split: false, **btn_attributes, &block)
@@ -5,7 +5,7 @@ module ElementComponent
5
5
  class ListGroupItem < Element
6
6
  VALID_VARIANTS = %i[primary secondary success danger warning info light dark].freeze
7
7
 
8
- def initialize(variant: nil, active: false, disabled: false, href: nil, **attributes, &block)
8
+ def initialize(content = nil, variant: nil, active: false, disabled: false, href: nil, **attributes, &block)
9
9
  tag = href ? "a" : "li"
10
10
  super(tag, &block)
11
11
 
@@ -17,6 +17,7 @@ module ElementComponent
17
17
  add_attribute(href: href) if href
18
18
  add_attribute("aria-current": "true") if active
19
19
  add_attribute(attributes) unless attributes.empty?
20
+ add_content(content) if content
20
21
  end
21
22
  end
22
23
  end
@@ -5,13 +5,14 @@ require_relative "list_group/item"
5
5
  module ElementComponent
6
6
  module Components
7
7
  class ListGroup < Element
8
- def initialize(flush: false, numbered: false, **attributes, &block)
8
+ def initialize(content = nil, flush: false, numbered: false, **attributes, &block)
9
9
  super("ul", &block)
10
10
 
11
11
  add_attribute(class: "list-group")
12
12
  add_attribute(class: "list-group-flush") if flush
13
13
  add_attribute(class: "list-group-numbered") if numbered
14
14
  add_attribute(attributes) unless attributes.empty?
15
+ add_content(content) if content
15
16
  end
16
17
  end
17
18
  end
@@ -3,11 +3,12 @@
3
3
  module ElementComponent
4
4
  module Components
5
5
  class ModalBody < Element
6
- def initialize(**attributes, &)
6
+ def initialize(content = nil, **attributes, &)
7
7
  super("div", &)
8
8
 
9
9
  add_attribute(class: "modal-body")
10
10
  add_attribute(attributes) unless attributes.empty?
11
+ add_content(content) if content
11
12
  end
12
13
  end
13
14
  end
@@ -3,11 +3,12 @@
3
3
  module ElementComponent
4
4
  module Components
5
5
  class ModalContent < Element
6
- def initialize(**attributes, &)
6
+ def initialize(content = nil, **attributes, &)
7
7
  super("div", &)
8
8
 
9
9
  add_attribute(class: "modal-content")
10
10
  add_attribute(attributes) unless attributes.empty?
11
+ add_content(content) if content
11
12
  end
12
13
  end
13
14
  end
@@ -6,7 +6,7 @@ module ElementComponent
6
6
  VALID_SIZES = %i[sm lg xl].freeze
7
7
  VALID_FULLSCREEN = %i[always sm md lg xl xxl].freeze
8
8
 
9
- def initialize(scrollable: false, centered: false, size: nil, fullscreen: nil, **attributes, &block)
9
+ def initialize(content = nil, scrollable: false, centered: false, size: nil, fullscreen: nil, **attributes, &block)
10
10
  super("div", &block)
11
11
 
12
12
  add_attribute(class: "modal-dialog")
@@ -15,6 +15,7 @@ module ElementComponent
15
15
  add_attribute(class: "modal-#{size}") if size
16
16
  add_attribute(class: "modal-fullscreen#{"-#{fullscreen}-down" unless fullscreen == :always}") if fullscreen
17
17
  add_attribute(attributes) unless attributes.empty?
18
+ add_content(content) if content
18
19
  end
19
20
  end
20
21
  end
@@ -3,11 +3,12 @@
3
3
  module ElementComponent
4
4
  module Components
5
5
  class ModalFooter < Element
6
- def initialize(**attributes, &)
6
+ def initialize(content = nil, **attributes, &)
7
7
  super("div", &)
8
8
 
9
9
  add_attribute(class: "modal-footer")
10
10
  add_attribute(attributes) unless attributes.empty?
11
+ add_content(content) if content
11
12
  end
12
13
  end
13
14
  end
@@ -3,12 +3,13 @@
3
3
  module ElementComponent
4
4
  module Components
5
5
  class ModalHeader < Element
6
- def initialize(close_button: true, **attributes, &block)
6
+ def initialize(content = nil, close_button: true, **attributes, &block)
7
7
  super("div", &block)
8
8
 
9
9
  add_attribute(class: "modal-header")
10
10
  add_attribute(attributes) unless attributes.empty?
11
11
 
12
+ add_content(content) if content
12
13
  add_content(CloseButton.new) if close_button
13
14
  end
14
15
  end
@@ -3,11 +3,12 @@
3
3
  module ElementComponent
4
4
  module Components
5
5
  class ModalTitle < Element
6
- def initialize(**attributes, &)
6
+ def initialize(content = nil, **attributes, &)
7
7
  super("h5", &)
8
8
 
9
9
  add_attribute(class: "modal-title")
10
10
  add_attribute(attributes) unless attributes.empty?
11
+ add_content(content) if content
11
12
  end
12
13
  end
13
14
  end
@@ -3,11 +3,12 @@
3
3
  module ElementComponent
4
4
  module Components
5
5
  class NavItem < Element
6
- def initialize(**attributes, &)
6
+ def initialize(content = nil, **attributes, &)
7
7
  super("li", &)
8
8
 
9
9
  add_attribute(class: "nav-item")
10
10
  add_attribute(attributes) unless attributes.empty?
11
+ add_content(content) if content
11
12
  end
12
13
  end
13
14
  end
@@ -3,7 +3,7 @@
3
3
  module ElementComponent
4
4
  module Components
5
5
  class NavLink < Element
6
- def initialize(href: "#", active: false, disabled: false, **attributes, &block)
6
+ def initialize(content = nil, href: "#", active: false, disabled: false, **attributes, &block)
7
7
  super("a", &block)
8
8
 
9
9
  add_attribute(class: "nav-link")
@@ -12,6 +12,7 @@ module ElementComponent
12
12
  add_attribute(href: href)
13
13
  add_attribute("aria-current": "page") if active
14
14
  add_attribute(attributes) unless attributes.empty?
15
+ add_content(content) if content
15
16
  end
16
17
  end
17
18
  end
@@ -8,7 +8,7 @@ module ElementComponent
8
8
  class Nav < Element
9
9
  VALID_TYPES = %i[tabs pills underline].freeze
10
10
 
11
- def initialize(type: nil, fill: false, justified: false, vertical: false, **attributes, &block)
11
+ def initialize(content = nil, type: nil, fill: false, justified: false, vertical: false, **attributes, &block)
12
12
  super("ul", &block)
13
13
 
14
14
  add_attribute(class: "nav")
@@ -17,6 +17,7 @@ module ElementComponent
17
17
  add_attribute(class: "nav-justified") if justified
18
18
  add_attribute(class: "flex-column") if vertical
19
19
  add_attribute(attributes) unless attributes.empty?
20
+ add_content(content) if content
20
21
  end
21
22
  end
22
23
  end
@@ -3,12 +3,13 @@
3
3
  module ElementComponent
4
4
  module Components
5
5
  class NavbarBrand < Element
6
- def initialize(href: "#", **attributes, &block)
6
+ def initialize(content = nil, href: "#", **attributes, &block)
7
7
  super("a", &block)
8
8
 
9
9
  add_attribute(class: "navbar-brand")
10
10
  add_attribute(href: href)
11
11
  add_attribute(attributes) unless attributes.empty?
12
+ add_content(content) if content
12
13
  end
13
14
  end
14
15
  end
@@ -3,13 +3,14 @@
3
3
  module ElementComponent
4
4
  module Components
5
5
  class NavbarCollapse < Element
6
- def initialize(id: nil, **attributes, &block)
6
+ def initialize(content = nil, id: nil, **attributes, &block)
7
7
  super("div", &block)
8
8
 
9
9
  add_attribute(class: "collapse")
10
10
  add_attribute(class: "navbar-collapse")
11
11
  add_attribute(id: id) if id
12
12
  add_attribute(attributes) unless attributes.empty?
13
+ add_content(content) if content
13
14
  end
14
15
  end
15
16
  end
@@ -3,11 +3,12 @@
3
3
  module ElementComponent
4
4
  module Components
5
5
  class NavbarNav < Element
6
- def initialize(**attributes, &)
6
+ def initialize(content = nil, **attributes, &)
7
7
  super("ul", &)
8
8
 
9
9
  add_attribute(class: "navbar-nav")
10
10
  add_attribute(attributes) unless attributes.empty?
11
+ add_content(content) if content
11
12
  end
12
13
  end
13
14
  end
@@ -13,7 +13,7 @@ module ElementComponent
13
13
  VALID_FIXED = %i[top bottom].freeze
14
14
  VALID_STICKY = %i[top bottom].freeze
15
15
 
16
- def initialize(expand: :lg, theme: :light, background: nil, fixed: nil, sticky: nil, container: true, **attributes,
16
+ def initialize(content = nil, expand: :lg, theme: :light, background: nil, fixed: nil, sticky: nil, container: true, **attributes,
17
17
  &block)
18
18
  super("nav", &block)
19
19
 
@@ -26,6 +26,7 @@ module ElementComponent
26
26
  add_attribute(attributes) unless attributes.empty?
27
27
 
28
28
  @use_container = container
29
+ add_content(content) if content
29
30
  end
30
31
 
31
32
  private
@@ -3,7 +3,7 @@
3
3
  module ElementComponent
4
4
  module Components
5
5
  class PageItem < Element
6
- def initialize(active: false, disabled: false, href: "#", **attributes, &block)
6
+ def initialize(content = nil, active: false, disabled: false, href: "#", **attributes, &block)
7
7
  super("li", &block)
8
8
 
9
9
  add_attribute(class: "page-item")
@@ -14,6 +14,7 @@ module ElementComponent
14
14
 
15
15
  @page_href = href
16
16
  @page_disabled = disabled
17
+ add_content(content) if content
17
18
  end
18
19
 
19
20
  private
@@ -7,12 +7,13 @@ module ElementComponent
7
7
  class Pagination < Element
8
8
  VALID_SIZES = %i[sm lg].freeze
9
9
 
10
- def initialize(size: nil, **attributes, &block)
10
+ def initialize(content = nil, size: nil, **attributes, &block)
11
11
  @pagination_size = size
12
12
  super("nav", &block)
13
13
 
14
14
  add_attribute("aria-label": "Pagination")
15
15
  add_attribute(attributes) unless attributes.empty?
16
+ add_content(content) if content
16
17
  end
17
18
 
18
19
  private
@@ -5,7 +5,7 @@ module ElementComponent
5
5
  class ProgressBar < Element
6
6
  VALID_VARIANTS = %i[primary secondary success danger warning info light dark].freeze
7
7
 
8
- def initialize(value: 0, variant: nil, striped: false, animated: false, **attributes, &block)
8
+ def initialize(content = nil, value: 0, variant: nil, striped: false, animated: false, **attributes, &block)
9
9
  super("div", &block)
10
10
 
11
11
  add_attribute(class: "progress-bar")
@@ -18,6 +18,7 @@ module ElementComponent
18
18
  add_attribute("aria-valuemax": "100")
19
19
  add_attribute(style: "width: #{value}%")
20
20
  add_attribute(attributes) unless attributes.empty?
21
+ add_content(content) if content
21
22
  end
22
23
  end
23
24
  end
@@ -5,12 +5,13 @@ require_relative "progress/bar"
5
5
  module ElementComponent
6
6
  module Components
7
7
  class Progress < Element
8
- def initialize(**attributes, &)
8
+ def initialize(content = nil, **attributes, &)
9
9
  super("div", &)
10
10
 
11
11
  add_attribute(class: "progress")
12
12
  add_attribute(role: "progressbar")
13
13
  add_attribute(attributes) unless attributes.empty?
14
+ add_content(content) if content
14
15
  end
15
16
  end
16
17
  end
@@ -6,13 +6,14 @@ module ElementComponent
6
6
  VALID_VARIANTS = %i[primary secondary success danger warning info light dark].freeze
7
7
  VALID_TYPES = %i[border grow].freeze
8
8
 
9
- def initialize(type: :border, variant: nil, **attributes, &block)
9
+ def initialize(content = nil, type: :border, variant: nil, **attributes, &block)
10
10
  super("div", &block)
11
11
 
12
12
  add_attribute(class: "spinner-#{type}")
13
13
  add_attribute(class: "text-#{variant}") if variant
14
14
  add_attribute(role: "status")
15
15
  add_attribute(attributes) unless attributes.empty?
16
+ add_content(content) if content
16
17
  end
17
18
  end
18
19
  end
@@ -5,7 +5,7 @@ module ElementComponent
5
5
  class Table < Element
6
6
  VALID_VARIANTS = %i[primary secondary success danger warning info light dark].freeze
7
7
 
8
- def initialize(striped: false, bordered: false, hover: false, small: false, variant: nil, **attributes, &block)
8
+ def initialize(content = nil, striped: false, bordered: false, hover: false, small: false, variant: nil, **attributes, &block)
9
9
  super("table", &block)
10
10
 
11
11
  add_attribute(class: "table")
@@ -15,6 +15,7 @@ module ElementComponent
15
15
  add_attribute(class: "table-sm") if small
16
16
  add_attribute(class: "table-#{variant}") if variant
17
17
  add_attribute(attributes) unless attributes.empty?
18
+ add_content(content) if content
18
19
  end
19
20
  end
20
21
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ElementComponent
4
- VERSION = "0.10.0"
4
+ VERSION = "0.11.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: element_component
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - João Paulo Correia