Class: NitroKit::Component
- Inherits:
-
Phlex::HTML
- Object
- Phlex::HTML
- NitroKit::Component
- Defined in:
- app/components/nitro_kit/component.rb
Direct Known Subclasses
Accordion, Alert, Avatar, AvatarStack, Badge, Button, ButtonGroup, Card, Checkbox, CheckboxGroup, Combobox, Datepicker, Dialog, Dropdown, Field, FieldGroup, Fieldset, Icon, Input, Label, Pagination, RadioButton, RadioButtonGroup, Select, Switch, Table, Tabs, Textarea, Toast, Toast::FlashMessages, Toast::Item, Tooltip
Instance Attribute Summary collapse
-
#attrs ⇒ Object
readonly
Returns the value of attribute attrs.
Class Method Summary collapse
-
.builder_method(method_name) ⇒ Object
Class-level helper method for builder style components.
- .from_template(*args, **attrs, &block) ⇒ Object
Instance Method Summary collapse
- #builder(&block) ⇒ Object
-
#initialize(attrs = {}, **defaults) ⇒ Component
constructor
A new instance of Component.
Constructor Details
#initialize(attrs = {}, **defaults) ⇒ Component
Returns a new instance of Component.
5 6 7 |
# File 'app/components/nitro_kit/component.rb', line 5 def initialize(attrs = {}, **defaults) @attrs = merge_attrs(attrs, **defaults) end |
Instance Attribute Details
#attrs ⇒ Object (readonly)
Returns the value of attribute attrs.
9 10 11 |
# File 'app/components/nitro_kit/component.rb', line 9 def attrs @attrs end |
Class Method Details
.builder_method(method_name) ⇒ Object
Class-level helper method for builder style components. When called from erb or templates, we need to wrap the return value in capture so we don’t write to the output buffer immediately. However when called from other components, we don’t.
25 26 27 28 29 30 31 |
# File 'app/components/nitro_kit/component.rb', line 25 def self.builder_method(method_name) warn( "[DEPRECATION] builder_method is deprecated. Please migrate to using the builder(&) pattern. See https://github.com/mikker/nitro_kit/issues/35 for details." ) nil end |
.from_template(*args, **attrs, &block) ⇒ Object
11 12 13 |
# File 'app/components/nitro_kit/component.rb', line 11 def self.from_template(*args, **attrs, &block) new(*args, **attrs, &block).tap { |instance| instance.instance_variable_set(:@_nk_from_template, true) } end |