DaisyComponents
DaisyComponents is a Ruby gem that provides a collection of ViewComponents implementing the DaisyUI design system for Rails applications. It combines the power of ViewComponent, TailwindCSS, and DaisyUI to create reusable, maintainable UI components.
Features
- Built on top of ViewComponent for component-based architecture
- Implements DaisyUI's design system, based on TailwindCSS
- Live preview and documentation with Lookbook
- Comprehensive test coverage with Minitest
Installation
Automated Setup (Recommended)
For new contributors or fresh environments, use the automated setup script:
$ ./bin/setup
This script will:
- Detect your OS and CPU architecture
- Install mise if not already present
- Install the latest Ruby version
- Install Bundler if needed
- Run
bundle install
to install dependencies - Provide clear instructions for using the environment
Add this line to your application's Gemfile:
gem "daisy_components"
And then execute to install the gem and other dependencies:
$ bundle install
Usage
The component library includes Lookbook for development and documentation:
- Start the development server:
$ bin/rails server
- Visit http://localhost:3000/lookbook to see the component documentation and playground.
Testing
Run the test suite:
$ bin/rails test
With coverage:
$ COVERAGE=true bin/rails test
Code Quality
Trailing Newlines
Use the dedicated script to check and fix trailing newline issues:
# Check all files (excludes vendor/, node_modules/, tmp/, log/, coverage/, etc.)
$ ./bin/fix_trailing_newlines.sh --check-only
# Fix all files
$ ./bin/fix_trailing_newlines.sh
# Check only staged files (used by git hooks)
$ ./bin/fix_trailing_newlines.sh --staged-only
Git Hooks
A pre-commit hook is available that automatically performs code quality checks:
$ ./bin/setup_hooks.sh
The hook will run before each commit and will:
- ✅ Fix trailing newlines automatically in staged files
- 🔧 Run RuboCop on staged Ruby files (will block commit if issues found)
Note: Git hooks are not automatically shared when cloning a repository. Each developer needs to run the setup script once after cloning.
Contributing
- Fork it
- Create your feature branch (
git checkout -b feature/my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin feature/my-new-feature
) - Create new Pull Request
License
The gem is available as open source under the terms of the MIT License.