phlex-icons-remix 0.11.0 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +15 -1
- data/generators/helper.rb +30 -9
- data/generators/tabler.rb +69 -0
- data/lib/phlex/icons/helper.rb +11 -0
- data/lib/phlex/icons/remix.rb +2898 -6
- data/lib/phlex/icons/version.rb +1 -1
- data/lib/phlex_icons_remix.rb +3 -1
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7cf2b64a8685617389bf8871e4e60aae2cf18593ee1168c68ee66f72d0976a55
|
4
|
+
data.tar.gz: 82d3ddd0ce3fc7a2642f6e8d4c5c6df7dbc5dca38f64086a5a9377f46fd0bd03
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56f7e12b49efe37a43c2926598a09b2f8a9bedab2a276c9d92a58258679d0466b08162cf7859c3a91b7e931327063905c97c0627f4fe6094d53418e8b298b49a
|
7
|
+
data.tar.gz: c95dc2e5f3939461d769d44fcf180865d72863cff2fcac047193679ce050639ded2037c45fab5008d8f2edf1f53d075d105aa63442b2084e093ac4267ed0c38b
|
data/README.md
CHANGED
@@ -10,13 +10,14 @@
|
|
10
10
|
|
11
11
|
# Phlex::Icons
|
12
12
|
|
13
|
-
General icons extension for [Phlex](https://phlex.fun). Includes more than 🎨
|
13
|
+
General icons extension for [Phlex](https://phlex.fun). Includes more than 🎨 12,000 icons from:
|
14
14
|
- [Bootstrap Icons](https://icons.getbootstrap.com) (2,000+)
|
15
15
|
- [Flag Icons](https://flagicons.lipis.dev) (250+)
|
16
16
|
- [Heroicons](https://heroicons.com) (300+)
|
17
17
|
- [Lucide Icons](https://lucide.dev/icons) (1,500+)
|
18
18
|
- [RadixUI Icons](https://radix-ui.com/icons) (300+)
|
19
19
|
- [Remix Icons](https://remixicon.com) (2,800+)
|
20
|
+
- [Tabler Icons](https://tabler.io/icons) (4,800+)
|
20
21
|
|
21
22
|
And happy to extend to other icon packs!
|
22
23
|
|
@@ -96,6 +97,18 @@ Nothing to configure for RadixUI Icons.
|
|
96
97
|
|
97
98
|
Nothing to configure for Remix Icons.
|
98
99
|
|
100
|
+
### Tabler Icons configuration
|
101
|
+
|
102
|
+
```ruby
|
103
|
+
Phlex::Icons::Tabler.configure do |config|
|
104
|
+
config.default_variant = :outline # or :filled
|
105
|
+
end
|
106
|
+
|
107
|
+
# OR
|
108
|
+
|
109
|
+
Phlex::Icons::Tabler.configuration.default_variant = :outline # or :filled
|
110
|
+
```
|
111
|
+
|
99
112
|
## Usage
|
100
113
|
|
101
114
|
```ruby
|
@@ -110,6 +123,7 @@ class PhlexIcons < Phlex::HTML
|
|
110
123
|
render Phlex::Icons::Lucide::House.new(classes: 'size-4')
|
111
124
|
render Phlex::Icons::Radix::Home.new(classes: 'size-4')
|
112
125
|
render Phlex::Icons::Remix::HomeLine.new(classes: 'size-4')
|
126
|
+
render Phlex::Icons::Tabler::Home.new(variant: :filled, classes: 'size-4')
|
113
127
|
end
|
114
128
|
end
|
115
129
|
end
|
data/generators/helper.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'erb'
|
4
4
|
require 'fileutils'
|
5
|
+
require 'zeitwerk' # Needed by Phlexing
|
5
6
|
require 'phlexing'
|
6
7
|
require 'tqdm'
|
7
8
|
|
@@ -19,8 +20,9 @@ def run_generator(&block)
|
|
19
20
|
|
20
21
|
print '⌛ Creating icon components...'
|
21
22
|
yield block
|
22
|
-
puts "\r🎉 Icon components created successfully!"
|
23
|
+
puts "\e[2K\r🎉 Icon components created successfully!"
|
23
24
|
|
25
|
+
make_components_lazy_loadable(ICONS_PACK_PATH)
|
24
26
|
run_rubocop(ICONS_PACK_PATH)
|
25
27
|
delete_repo(REPO_NAME)
|
26
28
|
end
|
@@ -29,14 +31,14 @@ def clone_repo(repo_url, repo_name)
|
|
29
31
|
print "⌛ Cloning '#{repo_name}' repo..."
|
30
32
|
|
31
33
|
if Dir.exist?("generators/#{repo_name}")
|
32
|
-
puts "\r✅ '#{repo_name}' repo already exists"
|
34
|
+
puts "\e[2K\r✅ '#{repo_name}' repo already exists"
|
33
35
|
|
34
36
|
return
|
35
37
|
end
|
36
38
|
|
37
39
|
system!("git clone #{repo_url} generators/#{repo_name}")
|
38
40
|
|
39
|
-
puts "\r🎉 '#{repo_name}' repo cloned successfully!"
|
41
|
+
puts "\e[2K\r🎉 '#{repo_name}' repo cloned successfully!"
|
40
42
|
end
|
41
43
|
|
42
44
|
def prepare_phlex_icons_pack_directory(icons_pack_path)
|
@@ -50,13 +52,13 @@ def prepare_phlex_icons_pack_directory(icons_pack_path)
|
|
50
52
|
File.delete(file)
|
51
53
|
end
|
52
54
|
|
53
|
-
puts "\r🎉 '#{icons_pack_path}' directory prepared successfully!"
|
55
|
+
puts "\e[2K\r🎉 '#{icons_pack_path}' directory prepared successfully!"
|
54
56
|
end
|
55
57
|
|
56
58
|
def component_file_name(icon_file_name, replacements = nil)
|
57
59
|
replacements ||= {}
|
58
60
|
|
59
|
-
icon_name = File.basename(icon_file_name,
|
61
|
+
icon_name = File.basename(icon_file_name, File.extname(icon_file_name))
|
60
62
|
|
61
63
|
replacements.each do |key, value|
|
62
64
|
icon_name = icon_name.gsub(key, value) if icon_name.start_with?(key)
|
@@ -68,13 +70,32 @@ end
|
|
68
70
|
def component_class_name(icon_file_name, replacements = nil)
|
69
71
|
replacements ||= {}
|
70
72
|
|
71
|
-
icon_name = File.basename(icon_file_name,
|
73
|
+
icon_name = File.basename(icon_file_name, File.extname(icon_file_name))
|
72
74
|
|
73
75
|
replacements.each do |key, value|
|
74
76
|
icon_name = icon_name.gsub(key, value) if icon_name.start_with?(key)
|
75
77
|
end
|
76
78
|
|
77
|
-
icon_name.gsub(
|
79
|
+
icon_name.gsub(/[-_]/, ' ').split.map(&:capitalize).join
|
80
|
+
end
|
81
|
+
|
82
|
+
def make_components_lazy_loadable(path)
|
83
|
+
print '⌛ Making components lazy-loadable...'
|
84
|
+
|
85
|
+
autoload_lines = Dir.glob("#{path}/*.rb").map do |file|
|
86
|
+
next if ['base.rb', 'configuration.rb'].include?(File.basename(file))
|
87
|
+
|
88
|
+
" autoload :#{component_class_name(file)}, '#{file.split('/', 2).last.chomp(File.extname(file))}'"
|
89
|
+
end.compact.join("\n")
|
90
|
+
|
91
|
+
new_content = File.read("#{path}.rb").gsub(
|
92
|
+
/# auto-generated autoload: start.*# auto-generated autoload: end/m,
|
93
|
+
"# auto-generated autoload: start\n#{autoload_lines}\n # auto-generated autoload: end"
|
94
|
+
)
|
95
|
+
|
96
|
+
File.write("#{path}.rb", new_content)
|
97
|
+
|
98
|
+
puts "\e[2K\r🎉 Components are lazy-loadable!"
|
78
99
|
end
|
79
100
|
|
80
101
|
def run_rubocop(path)
|
@@ -86,7 +107,7 @@ def run_rubocop(path)
|
|
86
107
|
File.write(file, File.read(file).gsub('rubocop:enable ,', 'rubocop:enable '))
|
87
108
|
end
|
88
109
|
|
89
|
-
puts "\r🎉 RuboCop ran successfully!"
|
110
|
+
puts "\e[2K\r🎉 RuboCop ran successfully!"
|
90
111
|
end
|
91
112
|
|
92
113
|
def delete_repo(repo_name)
|
@@ -94,7 +115,7 @@ def delete_repo(repo_name)
|
|
94
115
|
|
95
116
|
FileUtils.rm_rf("generators/#{repo_name}")
|
96
117
|
|
97
|
-
puts "\r🎉 '#{repo_name}' repo deleted successfully!"
|
118
|
+
puts "\e[2K\r🎉 '#{repo_name}' repo deleted successfully!"
|
98
119
|
end
|
99
120
|
|
100
121
|
def system!(command)
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'helper'
|
4
|
+
|
5
|
+
REPO_URL = 'https://github.com/tabler/tabler-icons.git'
|
6
|
+
REPO_NAME = 'tabler-tabler-icons'
|
7
|
+
ICONS_PACK_PATH = 'lib/phlex/icons/tabler'
|
8
|
+
|
9
|
+
TEMPLATE = ERB.new <<~TEMPLATE
|
10
|
+
# frozen_string_literal: true
|
11
|
+
|
12
|
+
# rubocop:disable #{ROBOCOP_DISABLE_WARNINGS}
|
13
|
+
module Phlex
|
14
|
+
module Icons
|
15
|
+
module Tabler
|
16
|
+
class <%= icon_name %> < Base
|
17
|
+
def filled
|
18
|
+
<%= filled_icon %>
|
19
|
+
end
|
20
|
+
|
21
|
+
def outline
|
22
|
+
<%= outline_icon %>
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
# rubocop:enable #{ROBOCOP_DISABLE_WARNINGS}
|
29
|
+
TEMPLATE
|
30
|
+
|
31
|
+
def main
|
32
|
+
run_generator { icon_file_names.tqdm.each { create_icon_component(_1) } }
|
33
|
+
end
|
34
|
+
|
35
|
+
def icon_file_names
|
36
|
+
Dir.glob("generators/#{REPO_NAME}/icons/outline/*").map { |file| File.basename(file) }
|
37
|
+
end
|
38
|
+
|
39
|
+
def create_icon_component(icon_file_name)
|
40
|
+
File.write(
|
41
|
+
File.join(ICONS_PACK_PATH, component_file_name(icon_file_name)),
|
42
|
+
TEMPLATE.result_with_hash(
|
43
|
+
icon_name: component_class_name(icon_file_name),
|
44
|
+
filled_icon: read_and_convert_icon(filled_icon_file_path(icon_file_name)),
|
45
|
+
outline_icon: read_and_convert_icon(outline_icon_file_path(icon_file_name))
|
46
|
+
)
|
47
|
+
)
|
48
|
+
end
|
49
|
+
|
50
|
+
def read_and_convert_icon(icon_file_path)
|
51
|
+
return 'raise NotImplementedError' unless File.exist?(icon_file_path)
|
52
|
+
|
53
|
+
icon_file_content = File.read(icon_file_path)
|
54
|
+
.gsub!(/<!--.*?-->/m, '')
|
55
|
+
.sub('width="24"', '')
|
56
|
+
.sub('height="24"', '')
|
57
|
+
|
58
|
+
Phlexing::Converter.convert(icon_file_content).sub('svg(', "svg(\nclass: classes,")
|
59
|
+
end
|
60
|
+
|
61
|
+
def filled_icon_file_path(icon_file_name)
|
62
|
+
"generators/#{REPO_NAME}/icons/filled/#{icon_file_name}"
|
63
|
+
end
|
64
|
+
|
65
|
+
def outline_icon_file_path(icon_file_name)
|
66
|
+
"generators/#{REPO_NAME}/icons/outline/#{icon_file_name}"
|
67
|
+
end
|
68
|
+
|
69
|
+
main if __FILE__ == $PROGRAM_NAME
|