element_component 0.9.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.
- checksums.yaml +4 -4
- data/AGENTS.md +92 -11
- data/lib/element_component/components/alert/heading.rb +2 -1
- data/lib/element_component/components/alert/link.rb +2 -1
- data/lib/element_component/components/alert.rb +2 -1
- data/lib/element_component/components/badge.rb +2 -1
- data/lib/element_component/components/breadcrumb/item.rb +2 -1
- data/lib/element_component/components/breadcrumb.rb +2 -1
- data/lib/element_component/components/button.rb +2 -1
- data/lib/element_component/components/button_group.rb +2 -1
- data/lib/element_component/components/card/body.rb +2 -1
- data/lib/element_component/components/card/footer.rb +2 -1
- data/lib/element_component/components/card/header.rb +2 -1
- data/lib/element_component/components/card/text.rb +2 -1
- data/lib/element_component/components/card/title.rb +2 -1
- data/lib/element_component/components/card.rb +2 -1
- data/lib/element_component/components/carousel/caption.rb +2 -1
- data/lib/element_component/components/carousel/item.rb +2 -1
- data/lib/element_component/components/carousel.rb +2 -1
- data/lib/element_component/components/dropdown/header.rb +2 -1
- data/lib/element_component/components/dropdown/item.rb +2 -1
- data/lib/element_component/components/dropdown/menu.rb +2 -1
- data/lib/element_component/components/dropdown.rb +2 -1
- data/lib/element_component/components/list_group/item.rb +2 -1
- data/lib/element_component/components/list_group.rb +2 -1
- data/lib/element_component/components/modal/body.rb +2 -1
- data/lib/element_component/components/modal/content.rb +2 -1
- data/lib/element_component/components/modal/dialog.rb +2 -1
- data/lib/element_component/components/modal/footer.rb +2 -1
- data/lib/element_component/components/modal/header.rb +2 -1
- data/lib/element_component/components/modal/title.rb +2 -1
- data/lib/element_component/components/nav/item.rb +2 -1
- data/lib/element_component/components/nav/link.rb +2 -1
- data/lib/element_component/components/nav.rb +2 -1
- data/lib/element_component/components/navbar/brand.rb +2 -1
- data/lib/element_component/components/navbar/collapse.rb +2 -1
- data/lib/element_component/components/navbar/nav.rb +2 -1
- data/lib/element_component/components/navbar.rb +2 -1
- data/lib/element_component/components/pagination/item.rb +2 -1
- data/lib/element_component/components/pagination.rb +2 -1
- data/lib/element_component/components/progress/bar.rb +2 -1
- data/lib/element_component/components/progress.rb +2 -1
- data/lib/element_component/components/spinner.rb +2 -1
- data/lib/element_component/components/table.rb +2 -1
- data/lib/element_component/element.rb +2 -1
- data/lib/element_component/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c74ab0abe47013ad19304fcd1ad108855de1c85fdb4d7406e141d1797343d038
|
|
4
|
+
data.tar.gz: 6b77e4cf5c1c73f90c251d45b6a83bde06aaf052452850bac7463f437c5c604e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dbf84809def7f1bd6b2ea85ebdafa81f217254bcba2505f123487063029d962cfd6c2379fe3dd308030cbb8ed97e800746fdbf2fe229888aaee53eeffa868d7c
|
|
7
|
+
data.tar.gz: '039a7ccd1efb00032379fc3465a4f9c4b52feb7df276ad581a92d57f4970d9c471e65c8e37d545bfc81889e98793e4d8c97b8bd296adbdb1f97fe269d84ae36a'
|
data/AGENTS.md
CHANGED
|
@@ -18,12 +18,82 @@ lib/
|
|
|
18
18
|
heading.rb # AlertHeading component
|
|
19
19
|
link.rb # AlertLink component
|
|
20
20
|
close_button.rb # AlertCloseButton component
|
|
21
|
+
badge.rb # Badge component
|
|
22
|
+
breadcrumb.rb # Breadcrumb component
|
|
23
|
+
breadcrumb/
|
|
24
|
+
item.rb # BreadcrumbItem component
|
|
25
|
+
button.rb # Button component
|
|
26
|
+
button_group.rb # ButtonGroup component
|
|
27
|
+
card.rb # Card component
|
|
28
|
+
card/
|
|
29
|
+
header.rb # CardHeader component
|
|
30
|
+
body.rb # CardBody component
|
|
31
|
+
footer.rb # CardFooter component
|
|
32
|
+
title.rb # CardTitle component
|
|
33
|
+
text.rb # CardText component
|
|
34
|
+
image.rb # CardImage component
|
|
35
|
+
carousel.rb # Carousel component
|
|
36
|
+
carousel/
|
|
37
|
+
item.rb # CarouselItem component
|
|
38
|
+
caption.rb # CarouselCaption component
|
|
39
|
+
close_button.rb # CloseButton component
|
|
40
|
+
dropdown.rb # Dropdown component
|
|
41
|
+
dropdown/
|
|
42
|
+
menu.rb # DropdownMenu component
|
|
43
|
+
item.rb # DropdownItem component
|
|
44
|
+
divider.rb # DropdownDivider component
|
|
45
|
+
header.rb # DropdownHeader component
|
|
46
|
+
list_group.rb # ListGroup component
|
|
47
|
+
list_group/
|
|
48
|
+
item.rb # ListGroupItem component
|
|
49
|
+
modal.rb # Modal component
|
|
50
|
+
modal/
|
|
51
|
+
dialog.rb # ModalDialog component
|
|
52
|
+
content.rb # ModalContent component
|
|
53
|
+
header.rb # ModalHeader component
|
|
54
|
+
title.rb # ModalTitle component
|
|
55
|
+
body.rb # ModalBody component
|
|
56
|
+
footer.rb # ModalFooter component
|
|
57
|
+
nav.rb # Nav component
|
|
58
|
+
nav/
|
|
59
|
+
item.rb # NavItem component
|
|
60
|
+
link.rb # NavLink component
|
|
61
|
+
navbar.rb # Navbar component
|
|
62
|
+
navbar/
|
|
63
|
+
brand.rb # NavbarBrand component
|
|
64
|
+
toggler.rb # NavbarToggler component
|
|
65
|
+
collapse.rb # NavbarCollapse component
|
|
66
|
+
nav.rb # NavbarNav component
|
|
67
|
+
pagination.rb # Pagination component
|
|
68
|
+
pagination/
|
|
69
|
+
item.rb # PageItem component
|
|
70
|
+
progress.rb # Progress component
|
|
71
|
+
progress/
|
|
72
|
+
bar.rb # ProgressBar component
|
|
73
|
+
spinner.rb # Spinner component
|
|
74
|
+
table.rb # Table component
|
|
21
75
|
spec/
|
|
22
76
|
element_component_spec.rb # Version check
|
|
23
77
|
lib/
|
|
24
78
|
element_spec.rb # Element unit tests
|
|
25
79
|
components/
|
|
26
80
|
alert_spec.rb # Alert component tests
|
|
81
|
+
badge_spec.rb # Badge component tests
|
|
82
|
+
breadcrumb_spec.rb # Breadcrumb component tests
|
|
83
|
+
button_spec.rb # Button component tests
|
|
84
|
+
button_group_spec.rb # ButtonGroup component tests
|
|
85
|
+
card_spec.rb # Card component tests
|
|
86
|
+
carousel_spec.rb # Carousel component tests
|
|
87
|
+
close_button_spec.rb # CloseButton component tests
|
|
88
|
+
dropdown_spec.rb # Dropdown component tests
|
|
89
|
+
list_group_spec.rb # ListGroup component tests
|
|
90
|
+
modal_spec.rb # Modal component tests
|
|
91
|
+
nav_spec.rb # Nav component tests
|
|
92
|
+
navbar_spec.rb # Navbar component tests
|
|
93
|
+
pagination_spec.rb # Pagination component tests
|
|
94
|
+
progress_spec.rb # Progress component tests
|
|
95
|
+
spinner_spec.rb # Spinner component tests
|
|
96
|
+
table_spec.rb # Table component tests
|
|
27
97
|
spec_helper.rb # RSpec config
|
|
28
98
|
examples/
|
|
29
99
|
alert_example.rb # Complete Alert usage examples
|
|
@@ -34,7 +104,7 @@ examples/
|
|
|
34
104
|
### `ElementComponent::Element`
|
|
35
105
|
- **Attributes**: `element` (tag name), `attributes` (Hash), `contents` (Array), `html` (rendered output)
|
|
36
106
|
- **Constructor**: `Element.new(tag_name, closing_tag: true, **attributes)`
|
|
37
|
-
- **Content methods**: `add_content`, `add_content!`, `add_content(&block)`
|
|
107
|
+
- **Content methods**: `add_content`, `add_content!`, `add_content(&block)` — `content` can be a single value or an Array of values
|
|
38
108
|
- **Attribute methods**: `add_attribute`, `add_attribute!`, `remove_attribute`, `remove_attribute_value`
|
|
39
109
|
- **Render**: `render` (with hooks: `before_render`, `after_render`, `around_render`)
|
|
40
110
|
|
|
@@ -42,12 +112,25 @@ examples/
|
|
|
42
112
|
|
|
43
113
|
Components live under `ElementComponent::Components`. Each component folder contains the main class and its sub-components in separate files.
|
|
44
114
|
|
|
45
|
-
| Component | Class |
|
|
46
|
-
|
|
47
|
-
| Alert | `
|
|
48
|
-
|
|
|
49
|
-
|
|
|
50
|
-
|
|
|
115
|
+
| Component | Class | Tag | Key Options |
|
|
116
|
+
|---|---|---|---|
|
|
117
|
+
| Alert | `Alert` | `<div>` | `variant`, `dismissible` |
|
|
118
|
+
| Badge | `Badge` | `<span>` | `variant`, `pill` |
|
|
119
|
+
| Breadcrumb | `Breadcrumb` | `<nav>` → `<ol>` | `BreadcrumbItem` (`href`, `active`) |
|
|
120
|
+
| Button | `Button` | `<button>` / `<a>` | `variant`, `outline`, `size`, `href` |
|
|
121
|
+
| ButtonGroup | `ButtonGroup` | `<div>` | `size`, `vertical` |
|
|
122
|
+
| Card | `Card` | `<div>` | Sub-components: Header, Body, Footer, Title, Text, Image |
|
|
123
|
+
| Carousel | `Carousel` | `<div>` | `fade`, `indicators`, `controls`; `CarouselItem`, `CarouselCaption` |
|
|
124
|
+
| CloseButton | `CloseButton` | `<button>` (self-closing) | `disabled` |
|
|
125
|
+
| Dropdown | `Dropdown` | `<div>` | `direction`; `DropdownMenu`, `DropdownItem`, `DropdownDivider`, `DropdownHeader` |
|
|
126
|
+
| ListGroup | `ListGroup` | `<ul>` | `flush`, `numbered`; `ListGroupItem` (`variant`, `active`, `disabled`, `href`) |
|
|
127
|
+
| Modal | `Modal` | `<div>` | `fade`, `static`, `scrollable`, `centered`, `size`; `ModalContent`, `ModalHeader`, `ModalBody`, `ModalFooter` |
|
|
128
|
+
| Nav | `Nav` | `<ul>` | `type` (tabs/pills/underline), `fill`, `justified`, `vertical` |
|
|
129
|
+
| Navbar | `Navbar` | `<nav>` | `expand`, `theme`, `background`, `fixed`, `sticky`; `NavbarBrand`, `NavbarNav`, `NavbarToggler` |
|
|
130
|
+
| Pagination | `Pagination` | `<nav>` → `<ul>` | `size`; `PageItem` (`active`, `disabled`) |
|
|
131
|
+
| Progress | `Progress` | `<div>` | `ProgressBar` (`value`, `variant`, `striped`, `animated`) |
|
|
132
|
+
| Spinner | `Spinner` | `<div>` | `type` (border/grow), `variant` |
|
|
133
|
+
| Table | `Table` | `<table>` | `striped`, `bordered`, `hover`, `small`, `variant` |
|
|
51
134
|
|
|
52
135
|
**Alert constructor**: `Alert.new(variant: :primary, dismissible: false, **attributes, &block)`
|
|
53
136
|
- `variant`: one of `:primary`, `:secondary`, `:success`, `:danger`, `:warning`, `:info`, `:light`, `:dark`
|
|
@@ -113,7 +196,8 @@ ruby examples/alert_example.rb # Run Alert examples
|
|
|
113
196
|
## Key Design Decisions
|
|
114
197
|
|
|
115
198
|
- Attributes stored as Hash of Symbol => Array of values (supports multiple values per attribute)
|
|
116
|
-
- Contents stored as Array (supports strings, Elements,
|
|
199
|
+
- Contents stored as Array (supports strings, Elements, Procs/blocks, and Arrays of any of these)
|
|
200
|
+
- `add_content(content)` accepts a single value or an Array; Arrays are spread into `@contents`
|
|
117
201
|
- `!` suffix methods reset state before adding (e.g., `add_content!` clears then adds)
|
|
118
202
|
- Hooks (`before_render`, `after_render`, `around_render`) are optional, detected via `respond_to?`
|
|
119
203
|
- Self-closing tags controlled by `closing_tag:` parameter
|
|
@@ -121,6 +205,3 @@ ruby examples/alert_example.rb # Run Alert examples
|
|
|
121
205
|
|
|
122
206
|
## Roadmap Features (from README)
|
|
123
207
|
- Caching support
|
|
124
|
-
- Pre-built Bulma components
|
|
125
|
-
- Pre-built Bootstrap components
|
|
126
|
-
- Enhanced DSL for nested structures
|
|
@@ -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
|
|
@@ -4,13 +4,14 @@ module ElementComponent
|
|
|
4
4
|
class Element
|
|
5
5
|
attr_reader :element, :attributes, :contents, :html
|
|
6
6
|
|
|
7
|
-
def initialize(element, closing_tag: true, **attribute, &block)
|
|
7
|
+
def initialize(element, content = nil, closing_tag: true, **attribute, &block)
|
|
8
8
|
@element = element
|
|
9
9
|
@closing_tag = closing_tag
|
|
10
10
|
@html = String.new
|
|
11
11
|
|
|
12
12
|
add_attribute!(attribute)
|
|
13
13
|
reset_contents!
|
|
14
|
+
add_content(content) if content
|
|
14
15
|
block&.call(self)
|
|
15
16
|
end
|
|
16
17
|
|