PhlexUI / phlex_ui

Ruby gem for Phlex UI Components
https://phlexui.com/
MIT License
115 stars 11 forks source link

Support for Simplified PhlexUI Syntax using Phlex::Kit #54

Closed cirdes closed 1 week ago

cirdes commented 1 week ago

This issue is related to https://github.com/PhlexUI/phlex_ui/pull/53

Description

I would like to propose an enhancement to PhlexUI that simplifies the syntax for rendering components. The current syntax is verbose and can be made more concise and readable by utilizing Phlex::Kit.

Current Syntax

The current syntax for rendering an Accordion with an AccordionItem is as follows:

render PhlexUI::Accordion.new do
  render PhlexUI::Accordion::Item.new do
    render PhlexUI::AccordionDefaultTrigger.new { "Title" }
    render PhlexUI::AccordionDefaultContent.new { "Content" }
  end
end

Proposed Syntax

The proposed syntax aims to streamline the rendering process, making it more intuitive and easier to read:

PhlexUI.Accordion do
  PhlexUI.AccordionItem do
    PhlexUI.AccordionDefaultTrigger { "Title" }
    PhlexUI.AccordionDefaultContent { "Content" }
  end
end

Benefits

Implementation

The proposed change can be achieved by leveraging Phlex::Kit to define the components in a more concise manner. This would involve updating the component definitions and the way they are instantiated within PhlexUI.