Skip to content

Commit

Permalink
feat: add micro icons (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
abeidahmed committed Dec 20, 2023
1 parent 430cb30 commit 828a72e
Show file tree
Hide file tree
Showing 1,183 changed files with 4,170 additions and 3,121 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## Unreleased

- Add micro icons

## 2.1.2

- Remove `stroke-width` from `svg` path if it is present
Expand Down
49 changes: 25 additions & 24 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,64 +1,65 @@
PATH
remote: .
specs:
rails_heroicon (2.1.1)
rails_heroicon (2.1.2)
actionview
railties

GEM
remote: https://rubygems.org/
specs:
actionpack (7.0.4)
actionview (= 7.0.4)
activesupport (= 7.0.4)
rack (~> 2.0, >= 2.2.0)
actionpack (7.0.5)
actionview (= 7.0.5)
activesupport (= 7.0.5)
rack (~> 2.0, >= 2.2.4)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actionview (7.0.4)
activesupport (= 7.0.4)
actionview (7.0.5)
activesupport (= 7.0.5)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
activesupport (7.0.4)
activesupport (7.0.5)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
ast (2.4.2)
builder (3.2.4)
byebug (11.1.3)
concurrent-ruby (1.1.10)
concurrent-ruby (1.2.2)
crass (1.0.6)
diff-lcs (1.5.0)
erubi (1.12.0)
i18n (1.12.0)
i18n (1.14.1)
concurrent-ruby (~> 1.0)
json (2.6.3)
language_server-protocol (3.17.0.2)
loofah (2.19.1)
loofah (2.21.3)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
nokogiri (>= 1.12.0)
method_source (1.0.0)
minitest (5.17.0)
minitest (5.18.1)
nokogiri (1.13.10-x86_64-linux)
racc (~> 1.4)
parallel (1.22.1)
parser (3.2.0.0)
ast (~> 2.4.1)
racc (1.6.2)
rack (2.2.5)
rack-test (2.0.2)
rack (2.2.7)
rack-test (2.1.0)
rack (>= 1.3)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
rails-dom-testing (2.1.1)
activesupport (>= 5.0.0)
minitest
nokogiri (>= 1.6)
rails-html-sanitizer (1.4.4)
rails-html-sanitizer (1.5.0)
loofah (~> 2.19, >= 2.19.1)
railties (7.0.4)
actionpack (= 7.0.4)
activesupport (= 7.0.4)
railties (7.0.5)
actionpack (= 7.0.5)
activesupport (= 7.0.5)
method_source
rake (>= 12.2)
thor (~> 1.0)
Expand Down Expand Up @@ -100,11 +101,11 @@ GEM
language_server-protocol (~> 3.17.0.2)
rubocop (= 1.42.0)
rubocop-performance (= 1.15.2)
thor (1.2.1)
tzinfo (2.0.5)
thor (1.2.2)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.4.2)
zeitwerk (2.6.6)
zeitwerk (2.6.8)

PLATFORMS
x86_64-linux
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ Ruby on Rails views helper for the awesome heroicons by Steve Schoger. To see
all the icons visit [heroicons](https://heroicons.com/).

The latest version of this gem is built with heroicons
[v2.0.16](https://github.com/tailwindlabs/heroicons/releases/tag/v2.0.16) (292
icons).
[v2.1.1](https://github.com/tailwindlabs/heroicons/releases/tag/v2.1.1) (288 icons).

> This gem has no official affiliation with [Tailwind Labs](https://github.com/tailwindlabs),
> yet.
Expand Down Expand Up @@ -68,7 +67,7 @@ This will generate the following html:
### Variant

`rails_heroicon` provides 3 variants, `outline`, `solid`, and `mini`, `outline` being
`rails_heroicon` provides 4 variants, `outline`, `solid`, `mini`, and `micro`, `outline` being
the default.

To change the variant `<%= heroicon "user", variant: "solid" %>`.
Expand All @@ -92,8 +91,9 @@ need to set the `size` attribute on the helper method.
```

If the `variant` is set as `outline` or `solid`, `size` automatically defaults to `24`,
and if the `variant` is set as `mini`, `size` automatically defaults to `20`.
However, this can be over-written with the `size` attribute.
if the `variant` is set as `mini`, `size` automatically defaults to `20`, and if the `variant`
is set as `micro`, `size` automatically defaults to `16`. However, this can be over-written with
the `size` attribute.

### Accessibility

Expand Down
8 changes: 4 additions & 4 deletions bin/compress
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module Compress

def self.start!
icons_count = Hash.new(0)
icons = Dir[File.join(File.dirname(__FILE__), "../icons/**/*.svg")]
icons = Dir[File.join(File.dirname(__FILE__), "../icons/**/*.svg")].sort

FileUtils.mkdir_p(DIRECTORY)
FileUtils.rm_rf(Dir.glob("#{DIRECTORY}/*"))
Expand All @@ -26,16 +26,16 @@ module Compress
# Issue: https://github.com/abeidahmed/rails-heroicon/issues/37
doc.css("path").remove_attr("stroke-width")
doc.css("path").remove_attr("stroke") if variant == "outline"
doc.css("path").remove_attr("fill") if %w[solid mini].include?(variant)
doc.css("path").remove_attr("fill") if %w[solid mini micro].include?(variant)

icon_name = File.basename(file_name, ".svg")
hash[variant][icon_name] = doc.at_css("svg").inner_html.gsub(/^[\s\t]*|[\s\t]*\n/, "").strip
icons_count[variant.to_sym] += 1
end
end.sort.to_h

File.write("#{DIRECTORY}/#{FILE_NAME}", JSON.pretty_generate(icon_hash))

puts "Finished compressing #{icons_count[:outline]} outline, #{icons_count[:solid]} solid, and #{icons_count[:mini]} mini icons."
puts "Finished compressing #{icons_count[:outline]} outline, #{icons_count[:solid]} solid, #{icons_count[:mini]} mini icons, and #{icons_count[:micro]} micro icons."
end
end

Expand Down
Loading

0 comments on commit 828a72e

Please sign in to comment.