ExIcon.Provider behaviour (ExIcon v0.4.0)

Copy Markdown View Source

Behaviour for icon providers.

Summary

Callbacks

Returns the download URL for the release with the given version.

Returns the folder that contains the SVG files in the unpacked release.

Returns the folder of each variant of the icon library.

Callbacks

release_url(version)

@callback release_url(version) :: url when version: String.t(), url: String.t()

Returns the download URL for the release with the given version.

The URL must point to a zip file.

svg_folder(version)

@callback svg_folder(version) :: String.t() when version: String.t()

Returns the folder that contains the SVG files in the unpacked release.

For a provider with variants, this is the folder of the variant to use when the configuration does not select any.

variants(version)

(optional)
@callback variants(version) :: %{required(atom()) => Path.t()} when version: String.t()

Returns the folder of each variant of the icon library.

Some icon libraries ship the same icons in multiple styles, such as outlined and filled. Providers for such libraries implement this callback, which allows the variants configuration option to select them. Each variant is generated into a module of its own.

This callback is optional. Without it, the library has a single variant, and the variants option cannot be used.

Example

def variants(version) do
  %{
    outline: "heroicons-#{version}/optimized/24/outline",
    solid: "heroicons-#{version}/optimized/24/solid"
  }
end