onvardgmbh / inline-svg

MIT License
1 stars 2 forks source link

Add a generic icon function that can return icons from all supported sets #4

Open ght opened 5 years ago

ght commented 5 years ago

Current behavior

If support for multiple icon sets is wanted, it is necessary for the code to handle this at each call site, e.g. like this:

@if (!empty($fontawesome)) // e.g. 'calendar'
  {!! \Onvardgmbh\InlineSVG::fontawesome($fontawesome)->get() !!}
@elseif (!empty($ionicon)) // e.g. 'attach'
  {!! \Onvardgmbh\InlineSVG::ionicons($boxicon)->get() !!}
@elseif (!empty($boxicon)) // e.g. 'bx-map'
  {!! \Onvardgmbh\InlineSVG::boxicons($boxicon)->get() !!}
@endif

Desired behavior

It should be possible to use icons from all supported sets, without the code at the call site even knowing which sets exist.

A possible implementation could be used like this (comments welcome):

@if (!empty($icon)) // e.g. 'fa/calendar', 'ion/attach', 'box/bx-map'
  {!! \Onvardgmbh\InlineSVG::icon($icon) !!}}
@endif

Pros

bjoernhasse commented 5 years ago

Agree :+1:

Furthermore we then should add a unified method for returning the options (getOptionsFontAwesome, getOptionsIonicons, getOptionsBoxicon.) The new getOptions method should return the icon options in the new 'ion/attach' format.