Class: Shadcn::Sheet::Content::Component
- Inherits:
-
ApplicationViewComponent
- Object
- ViewComponent::Base
- ApplicationViewComponent
- Shadcn::Sheet::Content::Component
- Defined in:
- app/components/shadcn/sheet/content/component.rb
Overview
SheetContent — slides in from one of the four edges.
Constant Summary collapse
- CLOSE_CLASSES =
"absolute top-4 right-4 rounded-xs opacity-70 ring-offset-background " \ "transition-opacity hover:opacity-100 focus:ring-2 focus:ring-ring " \ "focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none " \ "data-[state=open]:bg-secondary"
Constants inherited from ApplicationViewComponent
ApplicationViewComponent::CONTENTS_STYLE, ApplicationViewComponent::VOID_TAGS
Instance Attribute Summary collapse
-
#show_close_button ⇒ Object
readonly
Returns the value of attribute show_close_button.
-
#side ⇒ Object
readonly
Returns the value of attribute side.
Attributes inherited from ApplicationViewComponent
Instance Method Summary collapse
- #call ⇒ Object
- #element_attributes(**defaults) ⇒ Object
-
#initialize(side: :right, show_close_button: true, **attributes) ⇒ Component
constructor
A new instance of Component.
- #style_variants ⇒ Object
Methods inherited from ApplicationViewComponent
#css_classes, default_tag, #merged_style, #render_element, #shadcn_t, slot_name, #tag_name
Constructor Details
#initialize(side: :right, show_close_button: true, **attributes) ⇒ Component
Returns a new instance of Component.
53 54 55 56 57 |
# File 'app/components/shadcn/sheet/content/component.rb', line 53 def initialize(side: :right, show_close_button: true, **attributes) @side = side&.to_sym || :right @show_close_button = super(**attributes) end |
Instance Attribute Details
#show_close_button ⇒ Object (readonly)
Returns the value of attribute show_close_button.
51 52 53 |
# File 'app/components/shadcn/sheet/content/component.rb', line 51 def @show_close_button end |
#side ⇒ Object (readonly)
Returns the value of attribute side.
51 52 53 |
# File 'app/components/shadcn/sheet/content/component.rb', line 51 def side @side end |
Instance Method Details
#call ⇒ Object
74 75 76 77 78 79 80 81 |
# File 'app/components/shadcn/sheet/content/component.rb', line 74 def call tag.div("data-slot": "sheet-portal", style: CONTENTS_STYLE) do safe_join([ render(Overlay::Component.new), render_element(body: safe_join([ header, content, , ].compact)) ]) end end |
#element_attributes(**defaults) ⇒ Object
63 64 65 66 67 68 69 70 71 72 |
# File 'app/components/shadcn/sheet/content/component.rb', line 63 def element_attributes(**defaults) super(**{ role: "dialog", "aria-modal" => "true", tabindex: "-1", "data-state" => "closed", hidden: true, "data-shadcn--dialog-target" => "content" }.merge(defaults)) end |
#style_variants ⇒ Object
59 60 61 |
# File 'app/components/shadcn/sheet/content/component.rb', line 59 def style_variants { side: } end |