diff --git a/lib/bitstyles_phoenix.ex b/lib/bitstyles_phoenix.ex index 62a3a65..f120e11 100644 --- a/lib/bitstyles_phoenix.ex +++ b/lib/bitstyles_phoenix.ex @@ -48,7 +48,7 @@ defmodule BitstylesPhoenix do ### Bitstyles version - BitstylesPhoenix will generate classes #{BitstylesPhoenix.Bitstyles.version(:string)} of bitstyles. + BitstylesPhoenix will generate classes #{BitstylesPhoenix.Bitstyles.version_string()} of bitstyles. You can set older versions with a configuration: ```elixir diff --git a/lib/bitstyles_phoenix/bitstyles.ex b/lib/bitstyles_phoenix/bitstyles.ex index de881b3..f72b384 100644 --- a/lib/bitstyles_phoenix/bitstyles.ex +++ b/lib/bitstyles_phoenix/bitstyles.ex @@ -8,17 +8,17 @@ defmodule BitstylesPhoenix.Bitstyles do when target_version < version and current_version >= version def cdn_url do - "#{@cdn_url}@#{version(:string)}" + "#{@cdn_url}@#{version_string()}" end @doc """ Returns the classnames for the configured version. Input classnames are assumed to be from the #{@default_version} version of bitstyles. """ - def classname(name), do: classname(name, version(:tuple)) + def classname(name), do: classname(name, version()) def classname(class, version) when is_tuple(version) do - downgrade_classname(class, version, default_version(:tuple)) + downgrade_classname(class, version, default_version()) end # Note about class renaming: @@ -162,25 +162,23 @@ defmodule BitstylesPhoenix.Bitstyles do """) end - def version(format \\ :tuple) do - bitstyles_version_override = Process.get(:bitstyles_phoenix_bistyles_version) + def version() do + version_to_tuple(version_string()) + end - version = - bitstyles_version_override || - Application.get_env(:bitstyles_phoenix, :bitstyles_version, @default_version) + def version_string() do + bitstyles_version_override = Process.get(:bitstyles_phoenix_bistyles_version) - get_version_in_format(version, format) + bitstyles_version_override || + Application.get_env(:bitstyles_phoenix, :bitstyles_version, @default_version) end - def default_version(format \\ :tuple) do - get_version_in_format(@default_version, format) + def default_version() do + version_to_tuple(@default_version) end - defp get_version_in_format(version, format) do - case format do - :tuple -> version_to_tuple(version) - :string -> version_to_string(version) - end + def default_version_string do + @default_version end defp version_to_tuple(version) when is_tuple(version), do: version diff --git a/lib/bitstyles_phoenix/component/button.ex b/lib/bitstyles_phoenix/component/button.ex index 1b2594f..f4f36bb 100644 --- a/lib/bitstyles_phoenix/component/button.ex +++ b/lib/bitstyles_phoenix/component/button.ex @@ -287,7 +287,7 @@ defmodule BitstylesPhoenix.Component.Button do extra = assigns_to_attributes(assigns, [:icon, :class, :color, :shape, :variant]) assigns = - if Bitstyles.version(:tuple) >= {5, 0, 0} && assigns[:variant] do + if Bitstyles.version() >= {5, 0, 0} && assigns[:variant] do IO.warn("Attribute `variant` is deprecated in ui_button/1! Change to `color` and `shape`") assigns @@ -298,7 +298,7 @@ defmodule BitstylesPhoenix.Component.Button do end classes = - if Bitstyles.version(:tuple) >= {5, 0, 0} do + if Bitstyles.version() >= {5, 0, 0} do color_and_shape_classes(assigns[:color], assigns[:shape]) else variant_classes(assigns[:variant]) @@ -538,7 +538,7 @@ defmodule BitstylesPhoenix.Component.Button do extra = assigns_to_attributes(assigns, [:icon, :label, :reversed, :color, :title]) extra = - if Bitstyles.version(:tuple) >= {5, 0, 0} do + if Bitstyles.version() >= {5, 0, 0} do if assigns[:reversed] do Keyword.put_new(extra, :"data-theme", "dark") else diff --git a/lib/bitstyles_phoenix/component/description_list.ex b/lib/bitstyles_phoenix/component/description_list.ex index ab92a47..cbddfab 100644 --- a/lib/bitstyles_phoenix/component/description_list.ex +++ b/lib/bitstyles_phoenix/component/description_list.ex @@ -161,7 +161,7 @@ defmodule BitstylesPhoenix.Component.DescriptionList do # u-gap-l and u-gap-xl in 5.0.0 are equivalent to respectively u-gap-m and u-gap-l in 4.3.0 gap_class = - if Bitstyles.version(:tuple) >= {5, 0, 0} do + if Bitstyles.version() >= {5, 0, 0} do "u-gap-l" else "u-gap-m" diff --git a/lib/bitstyles_phoenix/component/dropdown.ex b/lib/bitstyles_phoenix/component/dropdown.ex index 72c8d70..eda22b0 100644 --- a/lib/bitstyles_phoenix/component/dropdown.ex +++ b/lib/bitstyles_phoenix/component/dropdown.ex @@ -456,7 +456,7 @@ defmodule BitstylesPhoenix.Component.Dropdown do assigns_from_single_slot(assigns, :button, exclude: [:label, :icon_file]) button_extra = - if Bitstyles.version(:tuple) >= {5, 0, 0} do + if Bitstyles.version() >= {5, 0, 0} do button_extra |> Keyword.put_new(:color, :secondary) else @@ -516,7 +516,7 @@ defmodule BitstylesPhoenix.Component.Dropdown do |> assigns_to_attributes() extra = - if Bitstyles.version(:tuple) >= {5, 0, 0} do + if Bitstyles.version() >= {5, 0, 0} do extra |> Keyword.put_new(:shape, "menu") |> Keyword.put_new(:color, "transparent") diff --git a/lib/bitstyles_phoenix/showcase.ex b/lib/bitstyles_phoenix/showcase.ex index 5c2964f..daf9723 100644 --- a/lib/bitstyles_phoenix/showcase.ex +++ b/lib/bitstyles_phoenix/showcase.ex @@ -6,7 +6,7 @@ defmodule BitstylesPhoenix.Showcase do defmacro story(name, doctest_iex_code, doctest_expected_results, opts \\ []) do default_version = - BitstylesPhoenix.Bitstyles.default_version(:string) + BitstylesPhoenix.Bitstyles.default_version_string() |> String.to_atom() doctest_expected_results =