daisyui_on_phlex 0.3.0 → 0.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 24ac5156bc91427821a11f2108b2c032509111ab15d992dda5d51b65124b400c
4
- data.tar.gz: dee06d63293a83653935f57ce78e0f9f032a6c039b5db5e78683cc8e818237bf
3
+ metadata.gz: 1e9055e975f76616e36477a2ea3059883373a49075d372ad51f60558736f6314
4
+ data.tar.gz: d7db288599b6b4b5d3de7f177536c2aca03fee43fee2fabaf927219029c2aa00
5
5
  SHA512:
6
- metadata.gz: '08175ac9c264c255c2e4968332e31f7a9ee242c5b7f7af9c99bacad2e6e9ae929015f17e5935a193b289f94c9500b8ec5f6ec272a7361ab0587cf36b057c915f'
7
- data.tar.gz: 64b6b0b51988acb8fb926fc84bb2d45f7dd9f80381b775f447236f0dbb54bda85160a96ea6fd5270027293c0fd3d8b936c8c399f894f7f317f4a1ce3e1066ad8
6
+ metadata.gz: 49605f81a46a56a2f9a577bb664e3232dfd0aa4f888c5246186d356c8048a2d544d08f0a3a4f0472c6eda77fafbc6fe6def330fc2f18053f154da3e9ed3a399f
7
+ data.tar.gz: 5f2c9c05cef94935aa95b7f8dab039ddf695cc917363269542b997f43c3a8d677b745d3862f5dca9edb6c27da1ed2955493bb5a7931ed9be35238689ab56bd81
@@ -21,12 +21,34 @@ module DaisyuiOnPhlex
21
21
  end
22
22
  end
23
23
 
24
+ def install_daisyui_npm
25
+ if File.exist?("package.json")
26
+ say "Installing DaisyUI via NPM...", :green
27
+
28
+ # Check if daisyui is already installed
29
+ package_json = File.read("package.json")
30
+ unless package_json.include?('"daisyui"')
31
+ if system("which npm > /dev/null")
32
+ run "npm install daisyui"
33
+ say "DaisyUI installed via NPM", :green
34
+ elsif system("which yarn > /dev/null")
35
+ run "yarn add daisyui"
36
+ say "DaisyUI installed via Yarn", :green
37
+ else
38
+ say "Neither NPM nor Yarn found. Please install DaisyUI manually: npm install daisyui", :yellow
39
+ end
40
+ else
41
+ say "DaisyUI already installed in package.json", :yellow
42
+ end
43
+ else
44
+ say "No package.json found. Skipping NPM installation.", :yellow
45
+ say "Please install DaisyUI manually: npm install daisyui", :yellow
46
+ end
47
+ end
48
+
24
49
  def copy_daisyui_files
25
- say "Installing DaisyUI files...", :green
26
-
27
- # Download DaisyUI files
28
- run "curl -sLo app/assets/tailwind/daisyui.js https://github.com/saadeghi/daisyui/releases/latest/download/daisyui.js" rescue nil
29
- run "curl -sLo app/assets/tailwind/daisyui-theme.js https://github.com/saadeghi/daisyui/releases/latest/download/daisyui-theme.js" rescue nil
50
+ say "DaisyUI assets are now provided automatically via Rails Engine! 🎉", :green
51
+ say "CSS and JS files are included automatically in your application.", :blue
30
52
  end
31
53
 
32
54
  def copy_components_to_vendor
@@ -38,7 +60,7 @@ module DaisyuiOnPhlex
38
60
 
39
61
  component_files.each do |component_path|
40
62
  component_file_name = File.basename(component_path)
41
- # Używamy relatywnej ścieżki względem source_root
63
+ # We are using relative path from source_root
42
64
  relative_path = File.join("components", component_file_name)
43
65
  destination_path = Rails.root.join("vendor/daisyui_on_phlex/components", component_file_name)
44
66
 
@@ -48,46 +70,54 @@ module DaisyuiOnPhlex
48
70
 
49
71
  def copy_base_class
50
72
  say "Copying base class...", :green
51
- # Używamy relatywnej ścieżki względem source_root
73
+ # We are using relative path from source_root
52
74
  copy_file "base.rb", Rails.root.join("vendor/daisyui_on_phlex/base.rb"), force: options["force"]
53
75
  end
54
76
 
55
77
  def create_vendor_initializer
56
- vendor_initializer_path = Rails.root.join("config/initializers/daisyui_on_phlex_vendor.rb")
78
+ vendor_initializer_path = Rails.root.join("config/initializers/daisyui_on_phlex.rb")
57
79
 
58
80
  create_file vendor_initializer_path, <<~RUBY, force: options["force"]
59
81
  # frozen_string_literal: true
60
82
 
61
- # Load vendor DaisyUI components
62
- Rails.autoloaders.main.push_dir(
63
- Rails.root.join("vendor/daisyui_on_phlex"), namespace: DaisyuiOnPhlex
64
- )
83
+ module DaisyuiOnPhlex
84
+ extend Phlex::Kit
85
+ end
86
+
87
+ # Require base.rb first
88
+ require Rails.root.join("vendor/daisyui_on_phlex/base.rb")
89
+
90
+ # Load all DaisyUI components from vendor directory
91
+ Dir[Rails.root.join("vendor/daisyui_on_phlex/components/*.rb")].each do |file|
92
+ require file
93
+ end
94
+
95
+ # Configure TailwindMerge for CSS class merging
96
+ if defined?(TailwindMerge) && defined?(ClassVariants)
97
+ ClassVariants.configure do |config|
98
+ merger = TailwindMerge::Merger.new
99
+ config.process_classes_with do |classes|
100
+ merger.merge(classes)
101
+ end
102
+ end
103
+ end
65
104
  RUBY
105
+
106
+ say "Created vendor initializer: config/initializers/daisyui_on_phlex.rb", :green
66
107
  end
67
108
 
68
109
  def update_tailwind_config
69
- tailwind_config_path = "app/assets/tailwind/application.css"
70
-
71
- if File.exist?(tailwind_config_path)
72
- say "Updating Tailwind CSS configuration...", :green
73
-
74
- content = File.read(tailwind_config_path)
75
-
76
- unless content.include?("@plugin \"./daisyui.js\"")
77
- # Add DaisyUI plugin line after @import "tailwindcss"
78
- updated_content = content.gsub(
79
- /@import "tailwindcss" source\(none\);/,
80
- "@import \"tailwindcss\" source(none);\n@plugin \"./daisyui.js\";"
81
- )
82
-
83
- File.write(tailwind_config_path, updated_content)
84
- say "Added DaisyUI plugin to Tailwind CSS configuration", :green
85
- else
86
- say "DaisyUI plugin already configured in Tailwind CSS", :yellow
87
- end
88
- else
89
- say "Tailwind CSS configuration not found. Please add @plugin \"./daisyui.js\"; to your Tailwind CSS configuration manually.", :yellow
90
- end
110
+ say "📝 To include DaisyUI styles in your application:", :green
111
+ say ""
112
+ say "1. Add to your main CSS file (application.css or application.tailwind.css):", :yellow
113
+ say " //= require daisyui_on_phlex", :cyan
114
+ say ""
115
+ say "2. Or in your JavaScript file (application.js):", :yellow
116
+ say " //= require daisyui_on_phlex", :cyan
117
+ say ""
118
+ say "3. For Tailwind CSS, ensure your tailwind.config.js includes:", :yellow
119
+ say ' content: ["./vendor/daisyui_on_phlex/**/*.rb"]', :cyan
120
+ say ""
91
121
  end
92
122
 
93
123
  def show_readme
@@ -99,10 +129,20 @@ module DaisyuiOnPhlex
99
129
  DaisyUI On Phlex has been installed! 🎉
100
130
 
101
131
  ✅ All #{component_count} components have been copied to vendor/daisyui_on_phlex/
102
- ✅ DaisyUI plugin configured for Tailwind CSS
132
+ ✅ DaisyUI CSS & JS automatically provided via Rails Engine
133
+ ✅ Vendor initializer created (config/initializers/daisyui_on_phlex.rb)
103
134
  ✅ Ready to use in your Phlex views
104
135
 
105
- You can now use DaisyUI components in your Phlex views:
136
+ 📦 Optional: Install DaisyUI via NPM for latest features:
137
+ npm install daisyui
138
+ # or
139
+ yarn add daisyui
140
+
141
+ 🎨 Recommended gems for better CSS handling:
142
+ gem 'tailwind_merge'
143
+ gem 'class_variants'
144
+
145
+ 🚀 You can now use DaisyUI components in your Phlex views:
106
146
 
107
147
  # In your Phlex view
108
148
  class MyView < Phlex::HTML
@@ -117,16 +157,15 @@ module DaisyuiOnPhlex
117
157
  end
118
158
  end
119
159
 
120
- All 61+ components are now available:
160
+ 🎯 All 61+ components are now available:
121
161
  - Button, Alert, Card, Badge, Modal, Input
122
162
  - Navigation: Navbar, Menu, Breadcrumbs, Tabs
123
163
  - Data Display: Table, Stat, Timeline, Avatar
124
164
  - Forms: Checkbox, Radio, Select, Toggle
125
165
  - And many more...
126
166
 
127
- Components are in vendor/daisyui_on_phlex/components/ and can be customized.
128
-
129
- For documentation: https://github.com/jacob/daisyui-on-phlex
167
+ 📁 Components are in vendor/daisyui_on_phlex/components/ and can be customized.
168
+ 📚 For documentation: https://github.com/jacob/daisyui-on-phlex
130
169
 
131
170
  TEXT
132
171
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DaisyuiOnPhlex
4
- VERSION = "0.3.0"
4
+ VERSION = "0.4.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: daisyui_on_phlex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - JacobAlexander