maxmarcon / live_select

Dynamic (multi)selection field for LiveView
https://hex.pm/packages/live_select
Apache License 2.0
185 stars 35 forks source link

Global config for base classes? #45

Closed nathan-yuen closed 12 months ago

nathan-yuen commented 1 year ago

Thank you for this awesome library Was wondering if there's chance to support setting all the default classes in config.exs?

Something like this

config :live_select,
  app: :some_app, #opitional: for specific umbrella app?
  active_option_class: "text-white bg-red-800",
  ...

Thanks!

maxmarcon commented 12 months ago

Hi @nathan-yuen and thanks!

What you're proposing is not a good idea in my opinion, because configuration is global and shared by all applications. The live_select options that you specify in your config will be used by other applications included in your project.

Let's imagine for example that Phoenix LiveDashboard started to use live_select internally. Then, if you include LiveDashboard in your project, it will immediately inherit your global configuration, which might lead to unexpected issues.

If you want to specify some application-wide defaults for live_select I suggest that you wrap it into a function component. For example you could add it to core_components.ex as described here and specify the default options there.

Does this make sense?

nathan-yuen commented 12 months ago

Yea, it make sense. Wrapping live_select was definitely one of my option.

The idea mostly stemmed from using flop_phoenix 's config