daisyui_on_phlex 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.github/copilot-instructions.md +54 -0
- data/CHANGELOG.md +41 -0
- data/INSTALLATION.md +129 -0
- data/LICENSE +21 -0
- data/README.md +227 -0
- data/Rakefile +12 -0
- data/example.rb +117 -0
- data/lib/daisyui_on_phlex/base.rb +14 -0
- data/lib/daisyui_on_phlex/components/alert.rb +77 -0
- data/lib/daisyui_on_phlex/components/badge.rb +59 -0
- data/lib/daisyui_on_phlex/components/button.rb +94 -0
- data/lib/daisyui_on_phlex/components/card.rb +78 -0
- data/lib/daisyui_on_phlex/components/input.rb +62 -0
- data/lib/daisyui_on_phlex/components/modal.rb +69 -0
- data/lib/daisyui_on_phlex/generators/install_generator.rb +79 -0
- data/lib/daisyui_on_phlex/railtie.rb +21 -0
- data/lib/daisyui_on_phlex/stylesheets/daisyui_on_phlex.css +116 -0
- data/lib/daisyui_on_phlex/version.rb +5 -0
- data/lib/daisyui_on_phlex.rb +13 -0
- data/sig/daisyui_on_phlex.rbs +4 -0
- metadata +178 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b9390f396480907ba67e526f4f80f63340d8252e4e35b2ee2b7e3fd9db80f40e
|
4
|
+
data.tar.gz: 3fd4df6af9e64ac586ccafd93e85771201eddba2d1ac84dfd5f2f9cf69123675
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b83d7bf8d7e39370e3323ba5166d7d490b7f9a37d73d3ea93cc6a0e8e7c4ccc195c4466eed79f2e68752c25fd5a1c1e53bafe188c50697ff66cb70987b91d961
|
7
|
+
data.tar.gz: eb980cea2627e1e8334532fdc193820766d706ff7a0bcda6ae3cd78b9dc4128e3b3673501c4a88d181444c5b9386bbbb9ff77fde3b023bf6685e9acff84222b4
|
@@ -0,0 +1,54 @@
|
|
1
|
+
<!-- Use this file to provide workspace-specific custom instructions to Copilot. For more details, visit https://code.visualstudio.com/docs/copilot/copilot-customization#_use-a-githubcopilotinstructionsmd-file -->
|
2
|
+
|
3
|
+
# DaisyUI On Phlex Development Instructions
|
4
|
+
|
5
|
+
This is a Ruby gem that provides DaisyUI components as Phlex components for Rails applications.
|
6
|
+
|
7
|
+
## Code Guidelines
|
8
|
+
|
9
|
+
- All components should extend `DaisyuiOnPhlex::Base` class
|
10
|
+
- Components should be placed in `lib/daisyui_on_phlex/components/` directory
|
11
|
+
- Follow DaisyUI naming conventions for CSS classes
|
12
|
+
- Use keyword arguments for component options
|
13
|
+
- Provide sensible defaults for all options
|
14
|
+
- All components should support additional HTML attributes via `**attributes`
|
15
|
+
- Use `merge_classes` helper method for combining CSS classes
|
16
|
+
|
17
|
+
## Component Structure
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
module DaisyuiOnPhlex
|
21
|
+
module Components
|
22
|
+
class ComponentName < DaisyuiOnPhlex::Base
|
23
|
+
def initialize(option: default_value, **attributes)
|
24
|
+
@option = option
|
25
|
+
@attributes = attributes
|
26
|
+
end
|
27
|
+
|
28
|
+
def view_template(&block)
|
29
|
+
# Component implementation
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def component_classes
|
35
|
+
# Build CSS classes based on options
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
```
|
41
|
+
|
42
|
+
## DaisyUI Integration
|
43
|
+
|
44
|
+
- Reference official DaisyUI documentation for component APIs
|
45
|
+
- Maintain consistency with DaisyUI class naming conventions
|
46
|
+
- Support all variants and modifiers that DaisyUI provides
|
47
|
+
- Include proper accessibility attributes where applicable
|
48
|
+
|
49
|
+
## Testing
|
50
|
+
|
51
|
+
- Write RSpec tests for all components
|
52
|
+
- Test different variants and options
|
53
|
+
- Verify generated HTML structure and CSS classes
|
54
|
+
- Test edge cases and error conditions
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
|
+
|
8
|
+
## [0.1.0] - 2025-07-31
|
9
|
+
|
10
|
+
### Added
|
11
|
+
- Initial release of DaisyUI On Phlex gem
|
12
|
+
- Button component with full DaisyUI variant support
|
13
|
+
- Alert component with success, error, warning, and info variants
|
14
|
+
- Card component with body, title, and actions methods
|
15
|
+
- Badge component with size and variant options
|
16
|
+
- Modal component with CSS-only modal implementation
|
17
|
+
- Input component with different types and styling variants
|
18
|
+
- Rails generator for easy installation (`rails generate daisyui_on_phlex:install`)
|
19
|
+
- Automatic DaisyUI setup with Tailwind CSS integration
|
20
|
+
- Comprehensive documentation and usage examples
|
21
|
+
- RSpec test suite for all components
|
22
|
+
- Base class with helper methods for component development
|
23
|
+
|
24
|
+
### Changed
|
25
|
+
- N/A (initial release)
|
26
|
+
|
27
|
+
### Deprecated
|
28
|
+
- N/A (initial release)
|
29
|
+
|
30
|
+
### Removed
|
31
|
+
- N/A (initial release)
|
32
|
+
|
33
|
+
### Fixed
|
34
|
+
- N/A (initial release)
|
35
|
+
|
36
|
+
### Security
|
37
|
+
- N/A (initial release)
|
38
|
+
|
39
|
+
## [0.1.0] - 2025-07-31
|
40
|
+
|
41
|
+
- Initial release
|
data/INSTALLATION.md
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
# DaisyUI on Phlex Installation
|
2
|
+
|
3
|
+
After installing the gem, follow these steps to set up DaisyUI styles in your Rails application:
|
4
|
+
|
5
|
+
## 1. Import the main CSS file
|
6
|
+
|
7
|
+
Add the following import to your `app/assets/stylesheets/application.css` (or `app/assets/stylesheets/application.tailwind.css` if using tailwindcss-rails):
|
8
|
+
|
9
|
+
```css
|
10
|
+
@import "tailwindcss";
|
11
|
+
@import "daisyui_on_phlex/stylesheets/daisyui_on_phlex.css";
|
12
|
+
```
|
13
|
+
|
14
|
+
## 2. Configure your HTML layout
|
15
|
+
|
16
|
+
Make sure your HTML layout supports theme switching by adding the `data-theme` attribute to your `<html>` tag:
|
17
|
+
|
18
|
+
```erb
|
19
|
+
<!DOCTYPE html>
|
20
|
+
<html data-theme="light">
|
21
|
+
<head>
|
22
|
+
<!-- Your head content -->
|
23
|
+
</head>
|
24
|
+
<body>
|
25
|
+
<!-- Your body content -->
|
26
|
+
</body>
|
27
|
+
</html>
|
28
|
+
```
|
29
|
+
|
30
|
+
## 3. Theme Configuration
|
31
|
+
|
32
|
+
The CSS file includes the most popular DaisyUI themes by default:
|
33
|
+
- `light` (default)
|
34
|
+
- `dark` (prefers dark mode)
|
35
|
+
- `cupcake`, `dracula`, `emerald`, `corporate`, `synthwave`, `retro`, `cyberpunk`
|
36
|
+
- `valentine`, `halloween`, `garden`, `forest`, `aqua`, `lofi`, `pastel`
|
37
|
+
- `fantasy`, `wireframe`, `black`, `luxury`, `autumn`, `business`
|
38
|
+
- `acid`, `lemonade`, `night`, `coffee`, `winter`, `dim`, `nord`, `sunset`
|
39
|
+
|
40
|
+
## 4. Theme Switching
|
41
|
+
|
42
|
+
To enable theme switching, you can use the `data-theme` attribute:
|
43
|
+
|
44
|
+
```erb
|
45
|
+
<select data-choose-theme>
|
46
|
+
<option value="light">Light</option>
|
47
|
+
<option value="dark">Dark</option>
|
48
|
+
<option value="cupcake">Cupcake</option>
|
49
|
+
<option value="dracula">Dracula</option>
|
50
|
+
<!-- Add more themes as needed -->
|
51
|
+
</select>
|
52
|
+
```
|
53
|
+
|
54
|
+
For automatic theme switching, consider using the [theme-change](https://github.com/saadeghi/theme-change) library:
|
55
|
+
|
56
|
+
```bash
|
57
|
+
npm install theme-change
|
58
|
+
```
|
59
|
+
|
60
|
+
Then initialize it in your JavaScript:
|
61
|
+
|
62
|
+
```javascript
|
63
|
+
import { themeChange } from 'theme-change'
|
64
|
+
themeChange()
|
65
|
+
```
|
66
|
+
|
67
|
+
## 5. Custom Themes
|
68
|
+
|
69
|
+
If you want to add custom themes or modify the theme list, you can create your own CSS file that overrides the default configuration:
|
70
|
+
|
71
|
+
```css
|
72
|
+
@import "tailwindcss";
|
73
|
+
|
74
|
+
@plugin "daisyui" {
|
75
|
+
themes: light --default, dark --prefersdark, your-custom-theme;
|
76
|
+
}
|
77
|
+
|
78
|
+
@plugin "daisyui/theme" {
|
79
|
+
name: "your-custom-theme";
|
80
|
+
default: false;
|
81
|
+
color-scheme: light;
|
82
|
+
|
83
|
+
--color-primary: oklch(55% 0.3 240);
|
84
|
+
--color-primary-content: oklch(98% 0.01 240);
|
85
|
+
/* Add more custom colors */
|
86
|
+
}
|
87
|
+
|
88
|
+
@import "daisyui_on_phlex/stylesheets/daisyui_on_phlex.css";
|
89
|
+
```
|
90
|
+
|
91
|
+
## 6. Component Usage
|
92
|
+
|
93
|
+
Now you can use DaisyUI on Phlex components in your views:
|
94
|
+
|
95
|
+
```ruby
|
96
|
+
# In your view or component
|
97
|
+
render DaisyuiOnPhlex::Components::Button.new(variant: :primary) do
|
98
|
+
"Click me!"
|
99
|
+
end
|
100
|
+
|
101
|
+
render DaisyuiOnPhlex::Components::Card.new(class: "w-96") do |card|
|
102
|
+
card.with_body do
|
103
|
+
"This is a card with DaisyUI styling"
|
104
|
+
end
|
105
|
+
end
|
106
|
+
```
|
107
|
+
|
108
|
+
## Features Included
|
109
|
+
|
110
|
+
The main CSS file provides:
|
111
|
+
|
112
|
+
- **Theme Configuration**: 25+ popular DaisyUI themes enabled
|
113
|
+
- **Accessibility Enhancements**: Better focus styles, high contrast support
|
114
|
+
- **Responsive Design**: Mobile-first approach with responsive utilities
|
115
|
+
- **Animation Support**: Smooth transitions and micro-interactions
|
116
|
+
- **Print Styles**: Optimized printing experience
|
117
|
+
- **Performance**: Reduced motion support for accessibility
|
118
|
+
- **Developer Experience**: Enhanced component integration
|
119
|
+
|
120
|
+
## Troubleshooting
|
121
|
+
|
122
|
+
If you encounter issues:
|
123
|
+
|
124
|
+
1. **Styles not loading**: Ensure the import is after `@import "tailwindcss";`
|
125
|
+
2. **Themes not working**: Check that your HTML has the `data-theme` attribute
|
126
|
+
3. **Build errors**: Make sure you have Tailwind CSS properly configured in your Rails app
|
127
|
+
4. **Missing components**: Verify that the gem is properly installed and required
|
128
|
+
|
129
|
+
For more help, check the [project repository](https://github.com/jacob/daisyui-on-phlex) or open an issue.
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2025 Jacob
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,227 @@
|
|
1
|
+
# DaisyUI On Phlex
|
2
|
+
|
3
|
+
[](https://badge.fury.io/rb/daisyui_on_phlex)
|
4
|
+
|
5
|
+
A Ruby gem that provides [DaisyUI](https://daisyui.com) components as [Phlex](https://phlex.fun) components for Rails applications. This gem makes it easy to use DaisyUI's beautiful components in your Ruby on Rails projects with the power and simplicity of Phlex.
|
6
|
+
|
7
|
+
## Features
|
8
|
+
|
9
|
+
- 🎨 **Beautiful Components**: All DaisyUI components wrapped as Phlex components
|
10
|
+
- 🚀 **Easy Integration**: Simple setup with Rails applications
|
11
|
+
- 🔧 **Customizable**: Full access to DaisyUI's theming and customization options
|
12
|
+
- 📦 **Lightweight**: Only includes the components you use
|
13
|
+
- 🎯 **Type Safe**: Written with Ruby best practices
|
14
|
+
- 🎭 **Theme Support**: 25+ built-in themes with easy switching
|
15
|
+
- ♿ **Accessible**: Enhanced accessibility features and ARIA support
|
16
|
+
|
17
|
+
## Installation
|
18
|
+
|
19
|
+
Add this line to your application's Gemfile:
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
gem 'daisyui_on_phlex'
|
23
|
+
```
|
24
|
+
|
25
|
+
And then execute:
|
26
|
+
|
27
|
+
```bash
|
28
|
+
$ bundle install
|
29
|
+
```
|
30
|
+
|
31
|
+
Or install it yourself as:
|
32
|
+
|
33
|
+
```bash
|
34
|
+
$ gem install daisyui_on_phlex
|
35
|
+
```
|
36
|
+
|
37
|
+
## Quick Setup
|
38
|
+
|
39
|
+
After installation, add the CSS import to your `app/assets/stylesheets/application.css`:
|
40
|
+
|
41
|
+
```css
|
42
|
+
@import "tailwindcss";
|
43
|
+
@import "daisyui_on_phlex/stylesheets/daisyui_on_phlex.css";
|
44
|
+
```
|
45
|
+
|
46
|
+
Make sure your HTML layout supports themes:
|
47
|
+
|
48
|
+
```erb
|
49
|
+
<!DOCTYPE html>
|
50
|
+
<html data-theme="light">
|
51
|
+
<!-- Your app content -->
|
52
|
+
</html>
|
53
|
+
```
|
54
|
+
|
55
|
+
For detailed setup instructions, see [INSTALLATION.md](INSTALLATION.md).
|
56
|
+
|
57
|
+
## Setup
|
58
|
+
|
59
|
+
Run the install generator to set up DaisyUI in your Rails application:
|
60
|
+
|
61
|
+
```bash
|
62
|
+
$ rails generate daisyui_on_phlex:install
|
63
|
+
```
|
64
|
+
|
65
|
+
This will:
|
66
|
+
1. Download the latest DaisyUI JavaScript files
|
67
|
+
2. Configure your Tailwind CSS to include the DaisyUI plugin
|
68
|
+
3. Provide usage instructions
|
69
|
+
|
70
|
+
## Usage
|
71
|
+
|
72
|
+
Use DaisyUI components in your Phlex views:
|
73
|
+
|
74
|
+
### Button Component
|
75
|
+
|
76
|
+
```ruby
|
77
|
+
class MyView < Phlex::HTML
|
78
|
+
def view_template
|
79
|
+
# Basic button
|
80
|
+
render DaisyuiOnPhlex::Components::Button.new(variant: :primary) do
|
81
|
+
"Click me!"
|
82
|
+
end
|
83
|
+
|
84
|
+
# Button with options
|
85
|
+
render DaisyuiOnPhlex::Components::Button.new(
|
86
|
+
variant: :secondary,
|
87
|
+
size: :lg,
|
88
|
+
outline: true
|
89
|
+
) do
|
90
|
+
"Large Outline Button"
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
```
|
95
|
+
|
96
|
+
### Alert Component
|
97
|
+
|
98
|
+
```ruby
|
99
|
+
render DaisyuiOnPhlex::Components::Alert.new(variant: :success) do
|
100
|
+
"Operation completed successfully!"
|
101
|
+
end
|
102
|
+
|
103
|
+
render DaisyuiOnPhlex::Components::Alert.new(variant: :error) do
|
104
|
+
"Something went wrong!"
|
105
|
+
end
|
106
|
+
```
|
107
|
+
|
108
|
+
### Card Component
|
109
|
+
|
110
|
+
```ruby
|
111
|
+
render DaisyuiOnPhlex::Components::Card.new(bordered: true) do |card|
|
112
|
+
card.body do
|
113
|
+
card.title { "Card Title" }
|
114
|
+
p { "This is the card content" }
|
115
|
+
card.actions do
|
116
|
+
render DaisyuiOnPhlex::Components::Button.new(variant: :primary) { "Action" }
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
```
|
121
|
+
|
122
|
+
### Badge Component
|
123
|
+
|
124
|
+
```ruby
|
125
|
+
render DaisyuiOnPhlex::Components::Badge.new(variant: :primary) { "New" }
|
126
|
+
render DaisyuiOnPhlex::Components::Badge.new(variant: :success, outline: true) { "Success" }
|
127
|
+
```
|
128
|
+
|
129
|
+
### Modal Component
|
130
|
+
|
131
|
+
```ruby
|
132
|
+
render DaisyuiOnPhlex::Components::Modal.new(id: "my-modal") do |modal|
|
133
|
+
modal.title { "Modal Title" }
|
134
|
+
p { "Modal content goes here" }
|
135
|
+
modal.action do
|
136
|
+
modal.close_button("Close")
|
137
|
+
render DaisyuiOnPhlex::Components::Button.new(variant: :primary) { "Save" }
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
# To open the modal, use a button or link that targets the modal ID
|
142
|
+
render DaisyuiOnPhlex::Components::Button.new do
|
143
|
+
label for: "my-modal" do
|
144
|
+
"Open Modal"
|
145
|
+
end
|
146
|
+
end
|
147
|
+
```
|
148
|
+
|
149
|
+
### Input Component
|
150
|
+
|
151
|
+
```ruby
|
152
|
+
render DaisyuiOnPhlex::Components::Input.new(
|
153
|
+
type: :text,
|
154
|
+
placeholder: "Enter your name",
|
155
|
+
variant: :primary
|
156
|
+
)
|
157
|
+
|
158
|
+
render DaisyuiOnPhlex::Components::Input.new(
|
159
|
+
type: :email,
|
160
|
+
size: :lg,
|
161
|
+
bordered: true
|
162
|
+
)
|
163
|
+
```
|
164
|
+
|
165
|
+
## Available Components
|
166
|
+
|
167
|
+
Currently implemented components:
|
168
|
+
|
169
|
+
- **Button** - Interactive buttons with multiple variants and sizes
|
170
|
+
- **Alert** - Notification messages with different types
|
171
|
+
- **Card** - Content containers with optional borders and layouts
|
172
|
+
- **Badge** - Small status indicators and labels
|
173
|
+
- **Modal** - Overlay dialogs and modals
|
174
|
+
- **Input** - Form input fields with styling variants
|
175
|
+
|
176
|
+
More components are being added regularly. Check the [DaisyUI documentation](https://daisyui.com/components/) for the full list of available components.
|
177
|
+
|
178
|
+
## Component Options
|
179
|
+
|
180
|
+
### Button Options
|
181
|
+
- `variant`: `:primary`, `:secondary`, `:accent`, `:neutral`, `:info`, `:success`, `:warning`, `:error`, `:ghost`, `:link`
|
182
|
+
- `size`: `:xs`, `:sm`, `:md`, `:lg`
|
183
|
+
- `outline`: `true/false`
|
184
|
+
- `ghost`: `true/false`
|
185
|
+
- `active`: `true/false`
|
186
|
+
- `disabled`: `true/false`
|
187
|
+
- `loading`: `true/false`
|
188
|
+
- `wide`: `true/false`
|
189
|
+
- `block`: `true/false`
|
190
|
+
- `circle`: `true/false`
|
191
|
+
- `square`: `true/false`
|
192
|
+
|
193
|
+
### Alert Options
|
194
|
+
- `variant`: `:info`, `:success`, `:warning`, `:error`
|
195
|
+
|
196
|
+
### Card Options
|
197
|
+
- `compact`: `true/false`
|
198
|
+
- `bordered`: `true/false`
|
199
|
+
- `image_full`: `true/false`
|
200
|
+
- `side`: `true/false`
|
201
|
+
|
202
|
+
## Requirements
|
203
|
+
|
204
|
+
- Ruby >= 3.0.0
|
205
|
+
- Rails >= 6.0
|
206
|
+
- Phlex >= 1.0
|
207
|
+
- Tailwind CSS configured in your Rails application
|
208
|
+
|
209
|
+
## Development
|
210
|
+
|
211
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
212
|
+
|
213
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
214
|
+
|
215
|
+
## Contributing
|
216
|
+
|
217
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/jacob/daisyui-on-phlex.
|
218
|
+
|
219
|
+
1. Fork it
|
220
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
221
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
222
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
223
|
+
5. Create new Pull Request
|
224
|
+
|
225
|
+
## License
|
226
|
+
|
227
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/example.rb
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Example usage of DaisyUI On Phlex components
|
4
|
+
# This file demonstrates how to use the various components
|
5
|
+
|
6
|
+
require_relative "lib/daisyui_on_phlex"
|
7
|
+
|
8
|
+
class ExampleView < Phlex::HTML
|
9
|
+
def view_template
|
10
|
+
html do
|
11
|
+
head do
|
12
|
+
title { "DaisyUI On Phlex Example" }
|
13
|
+
# In a real Rails app, you would have Tailwind CSS and DaisyUI configured
|
14
|
+
link rel: "stylesheet", href: "https://cdn.tailwindcss.com"
|
15
|
+
script src: "https://cdn.jsdelivr.net/npm/daisyui@4.12.10/dist/full.min.css"
|
16
|
+
end
|
17
|
+
|
18
|
+
body(class: "p-8 space-y-8") do
|
19
|
+
h1(class: "text-3xl font-bold mb-8") { "DaisyUI On Phlex Components Demo" }
|
20
|
+
|
21
|
+
# Button examples
|
22
|
+
section(class: "space-y-4") do
|
23
|
+
h2(class: "text-2xl font-semibold") { "Buttons" }
|
24
|
+
div(class: "space-x-4") do
|
25
|
+
render DaisyuiOnPhlex::Components::Button.new(variant: :primary) { "Primary" }
|
26
|
+
render DaisyuiOnPhlex::Components::Button.new(variant: :secondary) { "Secondary" }
|
27
|
+
render DaisyuiOnPhlex::Components::Button.new(variant: :accent, outline: true) { "Accent Outline" }
|
28
|
+
render DaisyuiOnPhlex::Components::Button.new(variant: :success, size: :lg) { "Large Success" }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# Alert examples
|
33
|
+
section(class: "space-y-4") do
|
34
|
+
h2(class: "text-2xl font-semibold") { "Alerts" }
|
35
|
+
render DaisyuiOnPhlex::Components::Alert.new(variant: :info) do
|
36
|
+
"This is an info alert with an icon!"
|
37
|
+
end
|
38
|
+
render DaisyuiOnPhlex::Components::Alert.new(variant: :success) do
|
39
|
+
"Success! Your operation completed successfully."
|
40
|
+
end
|
41
|
+
render DaisyuiOnPhlex::Components::Alert.new(variant: :warning) do
|
42
|
+
"Warning! Please check your input."
|
43
|
+
end
|
44
|
+
render DaisyuiOnPhlex::Components::Alert.new(variant: :error) do
|
45
|
+
"Error! Something went wrong."
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# Card example
|
50
|
+
section(class: "space-y-4") do
|
51
|
+
h2(class: "text-2xl font-semibold") { "Card" }
|
52
|
+
render DaisyuiOnPhlex::Components::Card.new(bordered: true, class: "w-96") do |card|
|
53
|
+
card.body do
|
54
|
+
card.title { "Card Title" }
|
55
|
+
p { "This is a beautiful card component with DaisyUI styling." }
|
56
|
+
card.actions do
|
57
|
+
render DaisyuiOnPhlex::Components::Button.new(variant: :primary) { "Action" }
|
58
|
+
render DaisyuiOnPhlex::Components::Button.new(variant: :ghost) { "Cancel" }
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
# Badge examples
|
65
|
+
section(class: "space-y-4") do
|
66
|
+
h2(class: "text-2xl font-semibold") { "Badges" }
|
67
|
+
div(class: "space-x-2") do
|
68
|
+
render DaisyuiOnPhlex::Components::Badge.new(variant: :primary) { "Primary" }
|
69
|
+
render DaisyuiOnPhlex::Components::Badge.new(variant: :secondary, outline: true) { "Secondary" }
|
70
|
+
render DaisyuiOnPhlex::Components::Badge.new(variant: :success, size: :lg) { "Success" }
|
71
|
+
render DaisyuiOnPhlex::Components::Badge.new(variant: :error, size: :sm) { "Error" }
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
# Input examples
|
76
|
+
section(class: "space-y-4") do
|
77
|
+
h2(class: "text-2xl font-semibold") { "Inputs" }
|
78
|
+
div(class: "space-y-2 max-w-md") do
|
79
|
+
render DaisyuiOnPhlex::Components::Input.new(
|
80
|
+
placeholder: "Enter your name",
|
81
|
+
variant: :primary
|
82
|
+
)
|
83
|
+
render DaisyuiOnPhlex::Components::Input.new(
|
84
|
+
type: :email,
|
85
|
+
placeholder: "Enter your email",
|
86
|
+
variant: :secondary,
|
87
|
+
size: :lg
|
88
|
+
)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
# Modal example
|
93
|
+
section(class: "space-y-4") do
|
94
|
+
h2(class: "text-2xl font-semibold") { "Modal" }
|
95
|
+
|
96
|
+
# Button to open modal
|
97
|
+
label(for: "demo-modal", class: "btn btn-primary") { "Open Modal" }
|
98
|
+
|
99
|
+
# Modal component
|
100
|
+
render DaisyuiOnPhlex::Components::Modal.new(id: "demo-modal") do |modal|
|
101
|
+
modal.title { "Example Modal" }
|
102
|
+
p(class: "py-4") { "This is a modal dialog created with DaisyUI On Phlex components." }
|
103
|
+
modal.action do
|
104
|
+
modal.close_button("Close")
|
105
|
+
render DaisyuiOnPhlex::Components::Button.new(variant: :primary) { "Save Changes" }
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
# Generate the example HTML
|
115
|
+
if __FILE__ == $0
|
116
|
+
puts ExampleView.new.call
|
117
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "phlex"
|
4
|
+
require "tailwind_merge"
|
5
|
+
|
6
|
+
module DaisyuiOnPhlex
|
7
|
+
class Base < Phlex::HTML
|
8
|
+
private
|
9
|
+
|
10
|
+
def merge_classes(*classes)
|
11
|
+
TailwindMerge::Merger.new.merge(classes.compact.join(" "))
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|