kozenet_ui 0.1.3 → 0.1.5

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: a1e2e8b54a360d5a3d0e6adb313c7b622f95d604d45313f05bd4f11dcb80546b
4
- data.tar.gz: c112ab997c36542a6b7ae9e1c2e16687948b1cbd6d3e4176ba5be6cf17087524
3
+ metadata.gz: 630f1277f958277505d69a7087f698c54772615ce49b5e461127f252a18d532f
4
+ data.tar.gz: 826562e84fcc99ae538683cbdf7685dd0065908eed308c6a58ec0ed9261a1371
5
5
  SHA512:
6
- metadata.gz: e792e18445663e57457a3f459f35141cad5609b6358d75b7856d22aef034be4b810bad6de2131a3226d4e7c53f6d0f0493c8b4b8e9c967bd2741640b1eff05c5
7
- data.tar.gz: '029ab38c64adb66d73c59a4cb7915d95124b943f36d118c69e2600224e3367587f1177bfbd08e7c3e28208943d41cebf26efc43b23d18e24a1407c2b877685a0'
6
+ metadata.gz: 7c06c46de9012183f644f314cfc60f58099369696a30b25b83ab5a10aff6fdb5f62f9d6f27c988002a7c36ad44d796b83fa9a721b63d36a727bf85fba0bc6910
7
+ data.tar.gz: 356c12469d4f01569fc86ea4e46b036fd78f3c051c60daa0a1cc26e70761039f59f414bf60cde3fb9a215b7f8ee2a261fd9f833bb0d6a4e3a841c5aca485a843
data/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.1.5] - 2025-10-31
4
+
5
+ - Feature: Robust icon helper now supports both heroicon and asset-based SVGs, with automatic fallback and variant/class support
6
+ - Fix: Header/action button icon rendering is now more flexible and compatible with heroicon
7
+ - Chore: Improved test coverage for icon rendering
8
+
9
+
10
+ ## [0.1.4] - 2025-01-01
11
+
12
+ - Fix: better stylesheet management
13
+
3
14
  ## [0.1.1] - 2025-10-31
4
15
 
5
16
  - Fix: Ensure all Kozenet UI CSS files are available in the asset pipeline for all Rails setups (improved asset paths and precompile logic in engine).
@@ -22,7 +22,10 @@ module KozenetUi
22
22
  end
23
23
 
24
24
  def render_icon(icon)
25
- ApplicationController.helpers.kozenet_ui_icon(icon, class: "kz-action-btn-icon") if icon
25
+ return unless icon
26
+
27
+ icon_name = icon.to_s.tr("_", "-").to_sym
28
+ ApplicationController.helpers.kozenet_ui_icon(icon_name, class: "kz-action-btn-icon")
26
29
  end
27
30
  end
28
31
  end
@@ -3,9 +3,26 @@
3
3
  module KozenetUi
4
4
  # Helper methods for rendering SVG icons in Kozenet UI
5
5
  module IconHelper
6
- # Renders a Heroicon SVG from the gem's assets
7
- # Usage: kozenet_ui_icon(:cart, class: "w-5 h-5 text-gray-500")
8
6
  def kozenet_ui_icon(name, options = {})
7
+ heroicon_name = normalize_icon_name(name)
8
+ return render_heroicon(heroicon_name, options) if defined?(heroicon)
9
+
10
+ render_fallback_icon(name, options)
11
+ end
12
+
13
+ private
14
+
15
+ def normalize_icon_name(name)
16
+ name.to_s.tr("_", "-").to_sym
17
+ end
18
+
19
+ def render_heroicon(name, options)
20
+ heroicon(name, **options)
21
+ rescue StandardError
22
+ render_fallback_icon(name, options)
23
+ end
24
+
25
+ def render_fallback_icon(name, options)
9
26
  app_path = "icons/#{name}.svg"
10
27
  gem_path = "kozenet_ui/icons/#{name}.svg"
11
28
  app_full_path = Rails.root.join("app/assets/images", app_path)
@@ -5,6 +5,7 @@ require "rails/generators/base"
5
5
  module KozenetUi
6
6
  module Generators
7
7
  # Generator for installing Kozenet UI into a Rails application
8
+ # Copies stylesheets, creates initializer, and updates application CSS
8
9
  class InstallGenerator < Rails::Generators::Base
9
10
  source_root File.expand_path("templates", __dir__)
10
11
 
@@ -14,53 +15,130 @@ module KozenetUi
14
15
  template "kozenet_ui.rb", "config/initializers/kozenet_ui.rb"
15
16
  end
16
17
 
17
- def copy_css_files_to_app
18
- # do NOT copy CSS files to the app. Let the gem expose them via the asset pipeline.
19
- say "Kozenet UI stylesheets are now available via the asset pipeline. " \
20
- "Import them in your Tailwind/application.css:", :green
21
- say "\n@import 'kozenet_ui/tokens.css';\n@import 'kozenet_ui/base.css';" \
22
- "\n@import 'kozenet_ui/components.css';\n", :cyan
18
+ def copy_stylesheets
19
+ say "šŸ“¦ Copying Kozenet UI stylesheets...", :blue
20
+ setup_directories
21
+ copy_main_stylesheets
22
+ copy_component_stylesheets
23
+ say "āœ… Stylesheets copied successfully!", :green
23
24
  end
24
25
 
25
- # rubocop:disable Metrics/MethodLength
26
26
  def add_stylesheets_to_application
27
- tailwind_css = nil
28
- tailwind_css = "app/assets/stylesheets/application.css" if File.exist?("app/assets/stylesheets/application.css")
29
-
30
- if tailwind_css
31
- content = File.read(tailwind_css)
32
- kozenet_imports = "\n/* Kozenet UI Styles */\n" \
33
- "@import 'kozenet_ui/tokens.css';\n" \
34
- "@import 'kozenet_ui/base.css';\n" \
35
- "@import 'kozenet_ui/components.css';\n"
36
-
37
- if content.include?("kozenet_ui/base.css")
38
- say "File unchanged! Kozenet UI styles already present in #{tailwind_css}", :yellow
39
- else
40
- append_to_file tailwind_css, kozenet_imports
41
- say "Appended Kozenet UI styles to #{tailwind_css}", :green
42
- end
27
+ css_file = find_application_css
28
+ return warn_no_css_file unless css_file
29
+
30
+ update_css_file(css_file)
31
+ end
32
+
33
+ def show_readme
34
+ display_success_message
35
+ end
36
+
37
+ private
38
+
39
+ def setup_directories
40
+ dest_dir = Rails.root.join("app/assets/stylesheets/kozenet_ui")
41
+ FileUtils.mkdir_p(dest_dir)
42
+ FileUtils.mkdir_p(dest_dir.join("components"))
43
+ end
44
+
45
+ def copy_main_stylesheets
46
+ %w[tokens.css base.css components.css].each do |file|
47
+ copy_stylesheet_file(file)
48
+ end
49
+ end
50
+
51
+ def copy_component_stylesheets
52
+ component_files = Dir.glob(File.join(gem_stylesheets_path, "components", "*.css"))
53
+ component_files.each { |src| copy_component_file(src) }
54
+ end
55
+
56
+ def copy_stylesheet_file(filename)
57
+ src = File.join(gem_stylesheets_path, filename)
58
+ dest = Rails.root.join("app/assets/stylesheets/kozenet_ui", filename)
59
+
60
+ if File.exist?(src)
61
+ FileUtils.cp(src, dest)
62
+ say " āœ“ Copied #{filename}", :green
43
63
  else
44
- say "Could not find app/assets/stylesheets/application.css. " \
45
- "Please manually import Kozenet UI stylesheets.", :yellow
64
+ say " āœ— #{filename} not found!", :red
46
65
  end
47
66
  end
48
- # rubocop:enable Metrics/MethodLength
49
67
 
50
- def show_readme
51
- say "\nāœ… Kozenet UI installed successfully!", :green
68
+ def copy_component_file(src_path)
69
+ filename = File.basename(src_path)
70
+ dest = Rails.root.join("app/assets/stylesheets/kozenet_ui/components", filename)
71
+ FileUtils.cp(src_path, dest)
72
+ say " āœ“ Copied components/#{filename}", :green
73
+ end
74
+
75
+ def gem_stylesheets_path
76
+ @gem_stylesheets_path ||= begin
77
+ gem_spec = Gem::Specification.find_by_name("kozenet_ui")
78
+ File.join(gem_spec.gem_dir, "app/assets/stylesheets/kozenet_ui")
79
+ end
80
+ end
81
+
82
+ def find_application_css
83
+ %w[
84
+ app/assets/stylesheets/application.tailwind.css
85
+ app/assets/stylesheets/application.css
86
+ ].find { |path| File.exist?(path) }
87
+ end
88
+
89
+ def update_css_file(css_file)
90
+ content = File.read(css_file)
91
+
92
+ if content.include?("kozenet_ui/base.css")
93
+ say "File unchanged! Kozenet UI styles already present", :yellow
94
+ else
95
+ append_to_file css_file, stylesheet_imports
96
+ say "āœ… Added imports to #{css_file}", :green
97
+ end
98
+ end
99
+
100
+ def stylesheet_imports
101
+ <<~CSS
102
+
103
+ /* Kozenet UI Styles */
104
+ @import "kozenet_ui/tokens.css";
105
+ @import "kozenet_ui/base.css";
106
+ @import "kozenet_ui/components.css";
107
+ CSS
108
+ end
109
+
110
+ def warn_no_css_file
111
+ say "āš ļø Could not find application CSS file", :yellow
112
+ say "Add these imports manually:", :yellow
113
+ say stylesheet_imports.strip, :cyan
114
+ end
115
+
116
+ def display_success_message
117
+ say_header
118
+ say_next_steps
119
+ say_documentation
120
+ end
121
+
122
+ def say_header
123
+ say "\n#{"=" * 60}", :green
124
+ say "āœ… Kozenet UI installed successfully!", :green
125
+ say ("=" * 60).to_s, :green
126
+ end
127
+
128
+ def say_next_steps
52
129
  say "\nNext steps:", :cyan
53
- say " 1. Add <%= kozenet_ui_theme_variables_tag %> to your layout <head>"
54
- say " 2. Customize colors in config/initializers/kozenet_ui.rb"
55
- say " 3. Start using components: <%= kz_button { 'Click me' } %>"
56
- say "\nDocumentation: https://github.com/kozenetpro/kozenet_ui\n"
130
+ say " 1. Add to layout <head>:", :white
131
+ say " <%= kozenet_ui_theme_variables_tag %>", :yellow
132
+ say "\n 2. Restart server:", :white
133
+ say " bin/dev", :yellow
134
+ say "\n 3. Use components:", :white
135
+ say " <%= kz_button { 'Click me' } %>", :yellow
136
+ say "\n 4. Customize colors:", :white
137
+ say " config/initializers/kozenet_ui.rb", :yellow
57
138
  end
58
139
 
59
- def install
60
- create_initializer
61
- copy_css_files_to_app
62
- add_stylesheets_to_application
63
- show_readme
140
+ def say_documentation
141
+ say "\nšŸ“š Documentation: https://github.com/kozenetpro/kozenet_ui\n\n", :blue
64
142
  end
65
143
  end
66
144
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KozenetUi
4
- VERSION = "0.1.3"
4
+ VERSION = "0.1.5"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kozenet_ui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kozenet Pro
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-10-31 00:00:00.000000000 Z
11
+ date: 2025-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: color
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.9'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rails_heroicon
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 2.3.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 2.3.0
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: railties
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -218,10 +232,11 @@ dependencies:
218
232
  - - "~>"
219
233
  - !ruby/object:Gem::Version
220
234
  version: '4.0'
221
- description: "Kozenet UI is a modern, production-ready component library for Ruby
222
- on Rails. \nBuilt with ViewComponent and Tailwind CSS, it provides beautiful, accessible,
223
- \nand customizable UI components with dynamic theming support. Features CSP-compliant
224
- \nstyling, dark mode, and smooth animations.\n"
235
+ description: |
236
+ Kozenet UI is a modern, production-ready component library for Ruby on Rails.
237
+ Built with ViewComponent and Tailwind CSS, it provides beautiful, accessible,
238
+ and customizable UI components with dynamic theming support. Features CSP-compliant
239
+ styling, dark mode, and smooth animations.
225
240
  email:
226
241
  - kozenetpro@gmail.com
227
242
  executables: []