Class: NitroKit::CommandPalette::Results
- Inherits:
-
NitroKit::Component
- Object
- Phlex::HTML
- NitroKit::Component
- NitroKit::CommandPalette::Results
- Defined in:
- app/components/nitro_kit/command_palette.rb
Constant Summary
Constants inherited from NitroKit::Component
NitroKit::Component::ADDITIVE_DATA_ATTRIBUTES, NitroKit::Component::COMPONENT_OWNED_DATA_ATTRIBUTES, NitroKit::Component::FORBIDDEN_ATTRIBUTES, NitroKit::Component::RESERVED_DATA_ATTRIBUTES
Instance Method Summary collapse
- #destination(label, href:, description: nil, html: {}, aria: {}, data: {}, desperately_need_a_class: nil) ⇒ Object
-
#initialize(id:, html: {}, aria: {}, data: {}, desperately_need_a_class: nil) ⇒ Results
constructor
A new instance of Results.
- #view_template(&block) ⇒ Object
Constructor Details
#initialize(id:, html: {}, aria: {}, data: {}, desperately_need_a_class: nil) ⇒ Results
Returns a new instance of Results.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'app/components/nitro_kit/command_palette.rb', line 38 def initialize( id:, html: {}, aria: {}, data: {}, desperately_need_a_class: nil ) @identifier = component_id(id) @destinations = [] super( component: :command_palette_results, attributes: { id: frame_id, target: "_top", data: { nk__command_palette_target: "frame", action: [ "turbo:before-fetch-request->nk--command-palette#loading", "turbo:frame-load->nk--command-palette#loaded" ].join(" ") } }, html:, aria:, data:, desperately_need_a_class: ) end |
Instance Method Details
#destination(label, href:, description: nil, html: {}, aria: {}, data: {}, desperately_need_a_class: nil) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'app/components/nitro_kit/command_palette.rb', line 68 def destination( label, href:, description: nil, html: {}, aria: {}, data: {}, desperately_need_a_class: nil ) ensure_collecting! @destinations << Destination.new( label: required_text(:label, label), href: required_text(:href, href), description: validate_optional_text!(:description, description), html:, aria:, data:, css_class: desperately_need_a_class ) nil end |
#view_template(&block) ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'app/components/nitro_kit/command_palette.rb', line 91 def view_template(&block) @collecting = true yield(self) if block tag(:"turbo-frame", **root_attributes) do nav( id: results_id, aria: { labelledby: title_id }, data: { slot: "command-palette-results" } ) do @destinations.each_with_index { |destination, index| render_destination(destination, index) } end end ensure @collecting = false end |