Skip to content

Commit

Permalink
Rename Phlex::Icons to PhlexIcons
Browse files Browse the repository at this point in the history
  • Loading branch information
AliOsm committed Dec 6, 2024
1 parent 774799f commit a032e49
Show file tree
Hide file tree
Showing 24,920 changed files with 428,273 additions and 453,285 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
2 changes: 1 addition & 1 deletion .github/scripts/check-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Checking if current tag matches the package version.
current_tag=$(echo $GITHUB_REF | cut -d '/' -f 3 | sed -r 's/^v//')
file_tag=$(grep 'VERSION = ' lib/phlex/icons/version.rb | cut -d '=' -f 2- | tr -d ' ' | tr -d \')
file_tag=$(grep 'VERSION = ' lib/phlex-icons/version.rb | cut -d '=' -f 2- | tr -d ' ' | tr -d \')
if [ "$current_tag" != "$file_tag" ]; then
echo "Error: the current tag does not match the version in package file(s)."
echo "$current_tag vs $file_tag"
Expand Down
6 changes: 3 additions & 3 deletions .github/scripts/prepare-new-gem.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ packs="bootstrap flag hero lucide radix remix tabler"
# Remove all packs except the one to keep
for pack in $packs; do
if [ "$pack" != "$pack_to_keep" ]; then
rm -rf "lib/phlex/icons/$pack"
rm -f "lib/phlex/icons/$pack.rb"
sed -i "/require_relative 'phlex\/icons\/$pack'/d" lib/phlex-icons.rb
rm -rf "lib/phlex-icons/$pack"
rm -f "lib/phlex-icons/$pack.rb"
sed -i "/require_relative 'phlex-icons\/$pack'/d" lib/phlex-icons.rb
fi
done

Expand Down
34 changes: 17 additions & 17 deletions .github/workflows/update-packs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,75 +28,75 @@ jobs:
- name: Re-generate Bootstrap icon pack
run: |
bundle exec ruby generators/bootstrap.rb
if [ -n "$(git status --porcelain lib/phlex/icons/bootstrap lib/phlex/icons/bootstrap.rb)" ]; then
git add lib/phlex/icons/bootstrap lib/phlex/icons/bootstrap.rb
if [ -n "$(git status --porcelain lib/phlex-icons/bootstrap lib/phlex-icons/bootstrap.rb)" ]; then
git add lib/phlex-icons/bootstrap lib/phlex-icons/bootstrap.rb
git commit -m "Re-generate Bootstrap icon pack"
echo "🔔 Icons were updated/added to Bootstrap icon pack"
fi
- name: Re-generate Flag icon pack
run: |
bundle exec ruby generators/flag.rb
if [ -n "$(git status --porcelain lib/phlex/icons/flag lib/phlex/icons/flag.rb)" ]; then
git add lib/phlex/icons/flag lib/phlex/icons/flag.rb
if [ -n "$(git status --porcelain lib/phlex-icons/flag lib/phlex-icons/flag.rb)" ]; then
git add lib/phlex-icons/flag lib/phlex-icons/flag.rb
git commit -m "Re-generate Flag icon pack"
echo "🔔 Icons were updated/added to Flag icon pack"
fi
- name: Re-generate Hero icon pack
run: |
bundle exec ruby generators/hero.rb
if [ -n "$(git status --porcelain lib/phlex/icons/hero lib/phlex/icons/hero.rb)" ]; then
git add lib/phlex/icons/hero lib/phlex/icons/hero.rb
if [ -n "$(git status --porcelain lib/phlex-icons/hero lib/phlex-icons/hero.rb)" ]; then
git add lib/phlex-icons/hero lib/phlex-icons/hero.rb
git commit -m "Re-generate Hero icon pack"
echo "🔔 Icons were updated/added to Hero icon pack"
fi
- name: Re-generate Lucide icon pack
run: |
bundle exec ruby generators/lucide.rb
if [ -n "$(git status --porcelain lib/phlex/icons/lucide lib/phlex/icons/lucide.rb)" ]; then
git add lib/phlex/icons/lucide lib/phlex/icons/lucide.rb
if [ -n "$(git status --porcelain lib/phlex-icons/lucide lib/phlex-icons/lucide.rb)" ]; then
git add lib/phlex-icons/lucide lib/phlex-icons/lucide.rb
git commit -m "Re-generate Lucide icon pack"
echo "🔔 Icons were updated/added to Lucide icon pack"
fi
- name: Re-generate Remix icon pack
run: |
bundle exec ruby generators/remix.rb
if [ -n "$(git status --porcelain lib/phlex/icons/remix lib/phlex/icons/remix.rb)" ]; then
git add lib/phlex/icons/remix lib/phlex/icons/remix.rb
if [ -n "$(git status --porcelain lib/phlex-icons/remix lib/phlex-icons/remix.rb)" ]; then
git add lib/phlex-icons/remix lib/phlex-icons/remix.rb
git commit -m "Re-generate Remix icon pack"
echo "🔔 Icons were updated/added to Remix icon pack"
fi
- name: Re-generate Radix icon pack
run: |
bundle exec ruby generators/radix.rb
if [ -n "$(git status --porcelain lib/phlex/icons/radix lib/phlex/icons/radix.rb)" ]; then
git add lib/phlex/icons/radix lib/phlex/icons/radix.rb
if [ -n "$(git status --porcelain lib/phlex-icons/radix lib/phlex-icons/radix.rb)" ]; then
git add lib/phlex-icons/radix lib/phlex-icons/radix.rb
git commit -m "Re-generate Radix icon pack"
echo "🔔 Icons were updated/added to Radix icon pack"
fi
- name: Re-generate Tabler icon pack
run: |
bundle exec ruby generators/tabler.rb
if [ -n "$(git status --porcelain lib/phlex/icons/tabler lib/phlex/icons/tabler.rb)" ]; then
git add lib/phlex/icons/tabler lib/phlex/icons/tabler.rb
if [ -n "$(git status --porcelain lib/phlex-icons/tabler lib/phlex-icons/tabler.rb)" ]; then
git add lib/phlex-icons/tabler lib/phlex-icons/tabler.rb
git commit -m "Re-generate Tabler icon pack"
echo "🔔 Icons were updated/added to Tabler icon pack"
fi
- name: Update gem version and push new changes
run: |
if [ -n "$(git log origin/main..HEAD --oneline)" ]; then
current_version=$(grep 'VERSION = ' lib/phlex/icons/version.rb | cut -d '=' -f 2- | tr -d ' ' | tr -d \')
current_version=$(grep 'VERSION = ' lib/phlex-icons/version.rb | cut -d '=' -f 2- | tr -d ' ' | tr -d \')
new_version=$(echo $current_version | awk -F. -v OFS=. '{$2++; $3=0; print}')
sed -i "s/VERSION = '$current_version'/VERSION = '$new_version'/" lib/phlex/icons/version.rb
sed -i "s/VERSION = '$current_version'/VERSION = '$new_version'/" lib/phlex-icons/version.rb
bundle config set frozen false
bundle install
git add lib/phlex/icons/version.rb Gemfile.lock
git add lib/phlex-icons/version.rb Gemfile.lock
git commit -m "Update version to $new_version"
git push
echo "🔔 Version was updated to $new_version"
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
phlex-icons (1.8.0)
phlex-icons (2.0.0)
phlex (>= 1.11)

GEM
Expand Down
74 changes: 35 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

</div>

# Phlex::Icons
# PhlexIcons

General icons extension for [Phlex](https://phlex.fun). Includes more than 🎨 12,000 icons from:
- [Bootstrap Icons](https://icons.getbootstrap.com) (2,000+)
Expand Down Expand Up @@ -58,13 +58,13 @@ The gem provides global configuration options, and per icons pack configuration
### Global configuration

```ruby
Phlex::Icons.configure do |config|
PhlexIcons.configure do |config|
config.default_classes = 'size-6'
end

# OR

Phlex::Icons.configuration.default_classes = 'size-6'
PhlexIcons.configuration.default_classes = 'size-6'
```

### Bootstrap Icons configuration
Expand All @@ -74,25 +74,25 @@ Nothing to configure for Bootstrap Icons.
### Flag Icons configuration

```ruby
Phlex::Icons::Flag.configure do |config|
PhlexIcons::Flag.configure do |config|
config.default_variant = :square # or :rectangle
end

# OR

Phlex::Icons::Flag.configuration.default_variant = :square # or :rectangle
PhlexIcons::Flag.configuration.default_variant = :square # or :rectangle
```

### Heroicons configuration

```ruby
Phlex::Icons::Hero.configure do |config|
PhlexIcons::Hero.configure do |config|
config.default_variant = :solid # or :outline
end

# OR

Phlex::Icons::Hero.configuration.default_variant = :solid # or :outline
PhlexIcons::Hero.configuration.default_variant = :solid # or :outline
```

### Lucide Icons configuration
Expand All @@ -110,13 +110,13 @@ Nothing to configure for Remix Icons.
### Tabler Icons configuration

```ruby
Phlex::Icons::Tabler.configure do |config|
PhlexIcons::Tabler.configure do |config|
config.default_variant = :outline # or :filled
end

# OR

Phlex::Icons::Tabler.configuration.default_variant = :outline # or :filled
PhlexIcons::Tabler.configuration.default_variant = :outline # or :filled
```

## Usage
Expand All @@ -127,7 +127,7 @@ Phlex::Icons::Tabler.configuration.default_variant = :outline # or :filled
require 'phlex-icons' # No need to require the gem if you are using it in a Rails application.

class PhlexIcons < Phlex::HTML
include Phlex::Icons
include PhlexIcons

def view_template
div do
Expand All @@ -151,13 +151,13 @@ require 'phlex-icons' # No need to require the gem if you are using it in a Rail
class PhlexIcons < Phlex::HTML
def view_template
div do
render Phlex::Icons::Bootstrap::House.new(class: 'size-4')
render Phlex::Icons::Flag::Sa.new(variant: :rectangle, class: 'size-4')
render Phlex::Icons::Hero::Home.new(variant: :solid, class: 'size-4')
render Phlex::Icons::Lucide::House.new(class: 'size-4')
render Phlex::Icons::Radix::Home.new(class: 'size-4')
render Phlex::Icons::Remix::HomeLine.new(class: 'size-4')
render Phlex::Icons::Tabler::Home.new(variant: :filled, class: 'size-4')
render PhlexIcons::Bootstrap::House.new(class: 'size-4')
render PhlexIcons::Flag::Sa.new(variant: :rectangle, class: 'size-4')
render PhlexIcons::Hero::Home.new(variant: :solid, class: 'size-4')
render PhlexIcons::Lucide::House.new(class: 'size-4')
render PhlexIcons::Radix::Home.new(class: 'size-4')
render PhlexIcons::Remix::HomeLine.new(class: 'size-4')
render PhlexIcons::Tabler::Home.new(variant: :filled, class: 'size-4')
end
end
end
Expand All @@ -176,7 +176,7 @@ require 'phlex-icons-flag' # No need to require the gem if you are using it in a
require 'phlex-icons-hero' # No need to require the gem if you are using it in a Rails application.

class PhlexIcons < Phlex::HTML
include Phlex::Icons # If you want to use Phlex::Kit.
include PhlexIcons # If you want to use Phlex::Kit.

def view_template
div do
Expand All @@ -185,43 +185,39 @@ class PhlexIcons < Phlex::HTML
Hero::Home(variant: :solid, class: 'size-4')

# Without Phlex::Kit.
render Phlex::Icons::Flag::Sa.new(variant: :rectangle, class: 'size-4')
render Phlex::Icons::Hero::Home.new(variant: :solid, class: 'size-4')
render PhlexIcons::Flag::Sa.new(variant: :rectangle, class: 'size-4')
render PhlexIcons::Hero::Home.new(variant: :solid, class: 'size-4')
end
end
end
```

### Add custom icons to your Rails application

You can extend the gem in your Rails application to add new icons by creating a `phlex/icons/custom` directory inside `views/components` directory. Then, you can create a new component for each icon you want to add. For example:
You can extend the gem in your Rails application to add new icons by creating a `phlex-icons/custom` directory inside `views/components` directory. Then, you can create a new component for each icon you want to add. For example:

```ruby
# app/views/components/phlex/icons/custom/icon_class_name.rb

module Phlex
module Icons
module Custom
class IconClassName < Phlex::Icons::Base
def view_template
# SVG code here.
end
# app/views/components/phlex-icons/custom/icon_class_name.rb

module PhlexIcons
module Custom
class IconClassName < PhlexIcons::Base
def view_template
# SVG code here.
end
end
end
end
```

Finally, you will need to create a `Phlex::Icons::Custom` module in `phlex/icons/custom.rb` file to include your custom icons and make them a `Phlex::Kit`:
Finally, you will need to create a `PhlexIcons::Custom` module in `phlex-icons/custom.rb` file to include your custom icons and make them a `Phlex::Kit`:

```ruby
# app/views/components/phlex/icons/custom.rb
# app/views/components/phlex-icons/custom.rb

module Phlex
module Icons
module Custom
extend Phlex::Kit
end
module PhlexIcons
module Custom
extend Phlex::Kit
end
end
```
Expand All @@ -234,7 +230,7 @@ All icon packs provided in this gem are auto-generated by their generator under

## What is the icon pack version used in the gem?

Each icon pack contains a `VERSION` constant in its module represents the version of the icon pack used in the gem. So, for example, to get the Bootstrap version used in the gem you can access it by `Phlex::Icons::Bootstrap::VERSION`.
Each icon pack contains a `VERSION` constant in its module represents the version of the icon pack used in the gem. So, for example, to get the Bootstrap version used in the gem you can access it by `PhlexIcons::Bootstrap::VERSION`.

## Development

Expand All @@ -252,4 +248,4 @@ The gem is available as open source under the terms of the [MIT License](https:/

## Code of Conduct

Everyone interacting in the Phlex::Icons project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/AliOsm/phlex-icons/blob/master/CODE_OF_CONDUCT.md).
Everyone interacting in the PhlexIcons project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/AliOsm/phlex-icons/blob/master/CODE_OF_CONDUCT.md).
16 changes: 7 additions & 9 deletions generators/bootstrap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,18 @@

REPO_URL = 'https://github.com/twbs/icons.git'
REPO_NAME = 'twbs-icons'
ICONS_PACK_MODULE_PATH = 'lib/phlex/icons/bootstrap.rb'
ICONS_PACK_PATH = 'lib/phlex/icons/bootstrap'
ICONS_PACK_MODULE_PATH = 'lib/phlex-icons/bootstrap.rb'
ICONS_PACK_PATH = 'lib/phlex-icons/bootstrap'

TEMPLATE = ERB.new <<~TEMPLATE
# frozen_string_literal: true
# rubocop:disable #{ROBOCOP_DISABLE_WARNINGS}
module Phlex
module Icons
module Bootstrap
class <%= icon_name %> < Base
def view_template
<%= icon %>
end
module PhlexIcons
module Bootstrap
class <%= icon_name %> < Base
def view_template
<%= icon %>
end
end
end
Expand Down
22 changes: 10 additions & 12 deletions generators/flag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,22 @@

REPO_URL = 'https://github.com/lipis/flag-icons.git'
REPO_NAME = 'lipis-flag-icons'
ICONS_PACK_MODULE_PATH = 'lib/phlex/icons/flag.rb'
ICONS_PACK_PATH = 'lib/phlex/icons/flag'
ICONS_PACK_MODULE_PATH = 'lib/phlex-icons/flag.rb'
ICONS_PACK_PATH = 'lib/phlex-icons/flag'

TEMPLATE = ERB.new <<~TEMPLATE
# frozen_string_literal: true
# rubocop:disable #{ROBOCOP_DISABLE_WARNINGS}
module Phlex
module Icons
module Flag
class <%= icon_name %> < Base
def square
<%= square_icon %>
end
module PhlexIcons
module Flag
class <%= icon_name %> < Base
def square
<%= square_icon %>
end
def rectangle
<%= rectangle_icon %>
end
def rectangle
<%= rectangle_icon %>
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion generators/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def make_components_lazy_loadable(path)
autoload_lines = Dir.glob("#{path}/*.rb").map do |file|
next if ['base.rb', 'configuration.rb'].include?(File.basename(file))

" autoload :#{component_class_name(file)}, '#{file.split('/', 2).last.chomp(File.extname(file))}'"
" autoload :#{component_class_name(file)}, '#{file.split('/', 2).last.chomp(File.extname(file))}'"
end.compact.join("\n")

new_content = File.read("#{path}.rb").gsub(
Expand Down
Loading

0 comments on commit a032e49

Please sign in to comment.