Add new Tooltip component with improved button hash API matching Card component pattern#37
Conversation
Co-authored-by: Nittarab <6181406+Nittarab@users.noreply.github.com>
Co-authored-by: Nittarab <6181406+Nittarab@users.noreply.github.com>
|
@copilot I have merged on main a way to run ./bin/setup and get the env locally working in a easy way. Rebase this PR in main and discard all the changes that are not related to this PR, like the /vendor and the git ignore |
…#40) This PR introduces a comprehensive `./bin/setup` script that automates the entire development environment setup process, making onboarding seamless across different operating systems and CPU architectures, while streamlining the project documentation. ## What's New ### `./bin/setup` Script The new setup script handles complete environment configuration: - **Cross-Platform Support**: Automatically detects OS (Linux/macOS) and CPU architecture (x86_64/aarch64/arm64) - **mise Installation**: Installs [mise](https://github.com/jdx/mise) using the official installation method if not already present - **Ruby Management**: Installs latest Ruby version via mise (leveraging `ruby latest` in .tool-versions) - **Dependency Management**: Installs Bundler and runs `bundle install` at repository root - **Dummy App Support**: Checks for and handles `test/dummy/Gemfile` if present - **Clear Logging**: Color-coded output with comprehensive error handling and progress reporting ### `.tool-versions` Configuration Uses `ruby latest` to ensure the most recent Ruby version is installed, leveraging mise's built-in support for latest version resolution instead of hardcoding specific versions. ### Streamlined Documentation - **Simplified README**: Removed manual setup instructions in favor of the automated script - **Enhanced Copilot Guidelines**: Added dedicated environment setup section for AI-assisted development - **Consistent Messaging**: Updated all references to use "latest Ruby version" instead of hardcoded versions ## Usage New contributors can now get up and running with a single command: ```bash $ ./bin/setup ``` The script provides clear feedback at each step: ``` ========================================= DaisyComponents Environment Setup ========================================= [INFO] Detecting platform... [SUCCESS] Detected platform: linux-x64 [INFO] Installing mise... [SUCCESS] mise installed successfully [INFO] Installing Ruby via mise... [SUCCESS] Ruby installed successfully: ruby (latest version) ... ``` ## Benefits - **Always Current**: Automatically installs the latest Ruby version without manual updates - **Cross-Architecture**: Works seamlessly on x86_64 and ARM64 (Apple Silicon) machines - **Error Resilient**: Comprehensive error handling with clear messaging - **Idempotent**: Safe to run multiple times - skips already installed components - **Simplified Onboarding**: Single command setup eliminates configuration complexity - **Future-Proof**: Easily extensible for additional setup requirements This eliminates the common "works on my machine" issues and significantly reduces the barrier to entry for new contributors while ensuring everyone uses the latest Ruby version. <!-- START COPILOT CODING AGENT TIPS --> --- 💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Nittarab <6181406+Nittarab@users.noreply.github.com>
…files and .gitignore changes Co-authored-by: Nittarab <6181406+Nittarab@users.noreply.github.com>
I've successfully rebased this PR on the latest main branch and removed all the unrelated changes (vendor/bundle files and .gitignore modifications). The PR now contains only the Tooltip component implementation with clean commit history. Commit: 400fc99 Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
| render(DaisyUI::Tooltip.new( | ||
| tip: tip, | ||
| position: position, | ||
| color: color, | ||
| force_open: force_open, | ||
| responsive: responsive, | ||
| class: classes | ||
| )) do | ||
| DaisyUI::Button.new(text: button_text, color: button_color).render_in(view_context) | ||
| end | ||
| end | ||
|
|
||
| # @!endgroup | ||
|
|
||
| def tooltip | ||
| render(DaisyUI::Tooltip.new(tip: 'hello')) do | ||
| DaisyUI::Button.new(text: 'Hover me').render_in(view_context) | ||
| end | ||
| end | ||
|
|
||
| def top | ||
| render(DaisyUI::Tooltip.new(position: :top, tip: 'hello', force_open: true)) do | ||
| DaisyUI::Button.new(text: 'Top').render_in(view_context) | ||
| end | ||
| end | ||
|
|
||
| def bottom | ||
| render(DaisyUI::Tooltip.new(position: :bottom, tip: 'hello', force_open: true)) do | ||
| DaisyUI::Button.new(text: 'Bottom').render_in(view_context) | ||
| end | ||
| end | ||
|
|
||
| def left | ||
| render(DaisyUI::Tooltip.new(position: :left, tip: 'hello', force_open: true)) do |
There was a problem hiding this comment.
APIs are a bit shitty to use. The tooltip is always a button in this case, so let's just automate the fact that when I pass a text: param, I create a button, and as in the card component, we can pass all the system arguments to the button if we want to personalize it.
There was a problem hiding this comment.
I've improved the Tooltip API design as requested! The component now supports a text: parameter that automatically creates a button, similar to the Card component pattern. Key improvements:
New Simplified API:
# Instead of verbose block syntax:
DaisyUI::Tooltip.new(tip: 'hello') do
DaisyUI::Button.new(text: 'Hover me').render_in(view_context)
end
# Now use simple text parameter:
DaisyUI::Tooltip.new(tip: 'hello', text: 'Hover me')Button Customization:
DaisyUI::Tooltip.new(
tip: 'Custom tooltip',
text: 'Click me',
button_color: :primary,
button_size: :lg,
button_variant: :outline
)All preview examples have been updated to use the new API, and backward compatibility is maintained for custom content blocks. The implementation follows the same pattern as the Card component's button parameter.
Commit: 371cb17
…on creation Co-authored-by: Nittarab <6181406+Nittarab@users.noreply.github.com>
I've completely redesigned the Tooltip API to be much more user-friendly! The main improvement is adding a Before (verbose): render(DaisyUI::Tooltip.new(tip: 'hello')) do
DaisyUI::Button.new(text: 'Hover me').render_in(view_context)
endAfter (clean): render(DaisyUI::Tooltip.new(tip: 'hello', text: 'Hover me'))Plus added full button customization support (color, size, variant, shape) while maintaining backward compatibility. All examples now use the simplified API. Commit: 371cb17 Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot no the button API need to be similar to the card: |
Co-authored-by: Nittarab <6181406+Nittarab@users.noreply.github.com>
... I've updated the Tooltip API to match the Card component's button pattern exactly as requested! The component now uses a single New API: DaisyUI::Tooltip.new(
tip: 'Custom tooltip',
button: { text: 'Click me', color: :primary, size: :lg, variant: :outline }
)Changes made:
This matches the Card component pattern where all button attributes are passed in the Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
good to take offline from here |
This PR implements a comprehensive Tooltip component for the DaisyUI design system with a significantly improved API that follows the same pattern as the Card component's button parameter.
Key Features
Simplified Button Hash API:
The new Tooltip component uses a
button:hash parameter that accepts all button configuration in a DRY way, identical to the Card component pattern:Consistent with Card Component:
The API matches the Card component's button pattern exactly:
Complete Feature Set:
top,bottom,left,righttooltip positionsprimary,secondary,accent,neutral,info,success,warning,error)force_open: truelg:tooltippattern)Implementation
app/components/daisy_ui/tooltip.rbfollowing namespace collapsing patternssetup_buttonmethod withsymbolize_keysPreviewTestConcernpatternThe improved API eliminates verbose individual parameters while maintaining full flexibility and follows established patterns in the codebase.
Fixes #36.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.