phlex-icons-lucide 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/lucide/battery_warning.rb +5 -5
- data/lib/phlex/icons/lucide/octagon_minus.rb +30 -0
- data/lib/phlex/icons/lucide.rb +1531 -6
- data/lib/phlex/icons/version.rb +1 -1
- data/lib/phlex_icons_lucide.rb +3 -1
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6682c5ee17e8a63f692c37629767886fcc101ab19d7753f9e2257c3bbf7c1d5c
|
4
|
+
data.tar.gz: f7d7f76bd5134ec792ae3d05ef549e0330e95aa1ca669cb0f08072675a2e0654
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f26add5d08b895fe577b5e400124ddab30853177d333776ed2d1bce0a7d0ec46d678cfd7f0d68b5fac77961c2032b42ebb3ec351353599b2ef22283f84f6fc1a
|
7
|
+
data.tar.gz: 00b7c4f2686d2e3741fd3db761aa5db200364ca45bdc610e0fd65f63a4b26077d22447f8d836ae691dd0f589ba23c02b862d5127148a32f051a0b147154522da
|
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
|
@@ -15,11 +15,11 @@ module Phlex
|
|
15
15
|
stroke_linecap: 'round',
|
16
16
|
stroke_linejoin: 'round'
|
17
17
|
) do |s|
|
18
|
-
s.path(d: '
|
19
|
-
s.path(d: '
|
20
|
-
s.
|
21
|
-
s.
|
22
|
-
s.
|
18
|
+
s.path(d: 'M10 17h.01')
|
19
|
+
s.path(d: 'M10 7v6')
|
20
|
+
s.path(d: 'M14 7h2a2 2 0 0 1 2 2v6a2 2 0 0 1-2 2h-2')
|
21
|
+
s.path(d: 'M22 11v2')
|
22
|
+
s.path(d: 'M6 7H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h2')
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# rubocop:disable Layout/LineLength
|
4
|
+
module Phlex
|
5
|
+
module Icons
|
6
|
+
module Lucide
|
7
|
+
class OctagonMinus < Base
|
8
|
+
def view_template
|
9
|
+
svg(
|
10
|
+
class: classes,
|
11
|
+
xmlns: 'http://www.w3.org/2000/svg',
|
12
|
+
viewbox: '0 0 24 24',
|
13
|
+
fill: 'none',
|
14
|
+
stroke: 'currentColor',
|
15
|
+
stroke_width: '2',
|
16
|
+
stroke_linecap: 'round',
|
17
|
+
stroke_linejoin: 'round'
|
18
|
+
) do |s|
|
19
|
+
s.path(
|
20
|
+
d:
|
21
|
+
'M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z'
|
22
|
+
)
|
23
|
+
s.path(d: 'M8 12h8')
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
# rubocop:enable Layout/LineLength
|