Class: NitroKit::Component
- Inherits:
-
Phlex::HTML
- Object
- Phlex::HTML
- NitroKit::Component
- Defined in:
- app/components/nitro_kit/component.rb
Direct Known Subclasses
Accordion, Alert, AppNavigation, AppShell, AppearancePicker, AuthShell, Avatar, AvatarStack, Badge, Button, ButtonGroup, ButtonTo, Card, Checkbox, CheckboxGroup, Combobox, CommandPalette, NitroKit::CommandPalette::Results, Container, ControlGroup, DangerZone, DataSection, DetailsTable, Dialog, Dropdown, Dropzone, EmptyState, Field, FieldGroup, Fieldset, Flex, FormSection, Grid, Icon, Input, Label, PageHeader, Pagination, PaginationBar, ProgressiveImage, RadioButton, RadioButtonGroup, RichTextArea, Select, SettingsLayout, Sheet, StatGrid, Switch, Table, Tabs, Textarea, Toast, Toast::Item, Toolbar, Tooltip, Typeset
Constant Summary collapse
- COMPONENT_OWNED_DATA_ATTRIBUTES =
Data keys a component sets for itself through
attributes:. %w[ state disabled required orientation presentation placement layout side field-type ].freeze
- RESERVED_DATA_ATTRIBUTES =
Every data key Nitro owns. Applications may not pass any of them through
data:. ( %w[nk slot variant size nk-escape enhanced] + COMPONENT_OWNED_DATA_ATTRIBUTES ).freeze
- ADDITIVE_DATA_ATTRIBUTES =
%w[action controller].freeze
- FORBIDDEN_ATTRIBUTES =
%w[class style].freeze
Instance Method Summary collapse
-
#initialize(component:, attributes: {}, html: {}, aria: {}, data: {}, variant: nil, size: nil, desperately_need_a_class: nil) ⇒ Component
constructor
A new instance of Component.
Constructor Details
#initialize(component:, attributes: {}, html: {}, aria: {}, data: {}, variant: nil, size: nil, desperately_need_a_class: nil) ⇒ Component
Returns a new instance of Component.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/components/nitro_kit/component.rb', line 18 def initialize( component:, attributes: {}, html: {}, aria: {}, data: {}, variant: nil, size: nil, desperately_need_a_class: nil ) @component_name = normalize_identity(component, name: "component") @attrs = owned_attributes( attributes:, html:, aria:, data:, owned_data: { nk: @component_name, variant: variant && normalize_identity(variant, name: "variant"), size: size && normalize_identity(size, name: "size") }.compact, desperately_need_a_class: ) end |