Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Ascona loads your SVG icons into memory at boot. Fast lookups, simple helper.

License

Notifications You must be signed in to change notification settings

samuenti/ascona

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ascona

Use SVG icons in Ruby.

Ascona loads your SVG icons into memory at boot. Fast lookups, simple helper.

Installation

gem 'ascona'

Then bundle install.

Setup

Generate the initializer:

rails generate ascona:install

Or create config/initializers/ascona.rb manually:

Ascona.configure do |config|
  config.icon_path = "app/assets/icons"
  config.default_library = :lucide
end

Supported Libraries

Library Link
Lucide lucide.dev

Downloading Icons

ascona list                          # Show available libraries
ascona download lucide               # Download all icons
ascona download heroicons --variant=outline  # Download specific variant

Folder Structure

Each SVG library should be stored in separate folders (create custom libraries by adding a new folder):

app/assets/icons/
  lucide/
    star.svg
    arrow-left.svg
  heroicons/
    outline/
      check.svg
    solid/
      check.svg

The name of the folder will be used as the library name.

Usage

<%= icon "star" %>
<%= icon "star", size: 5 %>
<%= icon "star", class: "w-5 h-5" %>
<%= icon "star", library: :heroicons, variant: :outline %>

The size option adds Tailwind classes w-{size} h-{size}.

Default Size

Set a default size for all icons:

config.default_size = 5

Icons without an explicit size will use this default.

Variants

Some libraries have variants. Set defaults per library (for rendering only):

config.default_variants = { heroicons: :outline }

Note: Some libraries have no default variant. You must specify one when downloading (--variant=outline) and when rendering (variant: :outline) unless set in config.

Non-Rails

Include the helper manually:

include Ascona::Helper

Call Ascona.load before using icons.

License

MIT

About

Ascona loads your SVG icons into memory at boot. Fast lookups, simple helper.

Resources

License

Stars

Watchers

Forks

Packages

No packages published