diff --git a/CHANGELOG.md b/CHANGELOG.md index 645d06a..808fbf9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ ## Unreleased +### Removed + +- The `fab` component was removed. It might have made sense to have it as a + separate component before components could be customized, but since the + semantics are the same as a regular button, you can just make one with + `build_button(name: :fab, base_class: "fab")` if you need it. + ## [0.8.2] - 2024-07-28 ### Fixed diff --git a/demo/lib/demo_web/components/core_components.ex b/demo/lib/demo_web/components/core_components.ex index 7eab031..0a5c750 100644 --- a/demo/lib/demo_web/components/core_components.ex +++ b/demo/lib/demo_web/components/core_components.ex @@ -23,7 +23,6 @@ defmodule DemoWeb.CoreComponents do build_datetime() build_disclosure_button() build_drawer() - build_fab() build_fallback() build_field() build_field_group() diff --git a/demo/storybook/buttons/fab.story.exs b/demo/storybook/buttons/fab.story.exs deleted file mode 100644 index eb9d070..0000000 --- a/demo/storybook/buttons/fab.story.exs +++ /dev/null @@ -1,4 +0,0 @@ -defmodule Storybook.Components.Fab do - use PhoenixStorybook.Story, :component - use Doggo.Storybook, module: DemoWeb.CoreComponents, name: :fab -end diff --git a/lib/doggo/components.ex b/lib/doggo/components.ex index 29f3888..aabe13e 100644 --- a/lib/doggo/components.ex +++ b/lib/doggo/components.ex @@ -41,7 +41,6 @@ defmodule Doggo.Components do build_datetime() build_disclosure_button() build_drawer() - build_fab() build_fallback() build_field_group() build_frame() @@ -147,7 +146,6 @@ defmodule Doggo.Components do component(:datetime) component(:disclosure_button) component(:drawer) - component(:fab) component(:fallback) component(:field) component(:field_group) diff --git a/lib/doggo/components/button.ex b/lib/doggo/components/button.ex index 629603e..7982915 100644 --- a/lib/doggo/components/button.ex +++ b/lib/doggo/components/button.ex @@ -17,8 +17,7 @@ defmodule Doggo.Components.Button do current page and want to style the link like a button, use `button_link/1` instead. - See also `button_link/1`, `toggle_button/1`, `disclosure_button/1`, and - `fab/1`. + See also `button_link/1`, `toggle_button/1`, and `disclosure_button/1`. """ end diff --git a/lib/doggo/components/fab.ex b/lib/doggo/components/fab.ex deleted file mode 100644 index c040223..0000000 --- a/lib/doggo/components/fab.ex +++ /dev/null @@ -1,83 +0,0 @@ -defmodule Doggo.Components.Fab do - @moduledoc false - - @behaviour Doggo.Component - - use Phoenix.Component - - @impl true - def doc do - """ - Renders a floating action button. - """ - end - - @impl true - def usage do - """ - ```heex - <.fab label="Add item" phx-click={JS.patch(to: "/items/new")}> - <.icon> - - ``` - """ - end - - @impl true - def config do - [ - type: :buttons, - since: "0.6.0", - maturity: :developing, - modifiers: [ - variant: [ - values: [ - "primary", - "secondary", - "info", - "success", - "warning", - "danger" - ], - default: "primary" - ], - size: [ - values: ["small", "normal", "medium", "large"], - default: "normal" - ], - shape: [values: [nil, "circle", "pill"], default: "circle"] - ] - ] - end - - @impl true - def attrs_and_slots do - quote do - attr :label, :string, required: true - attr :disabled, :boolean, default: false - attr :rest, :global, include: ~w(autofocus form name value) - - slot :inner_block, required: true - end - end - - @impl true - def init_block(_opts, _extra) do - [] - end - - @impl true - def render(assigns) do - ~H""" - - """ - end -end diff --git a/lib/doggo/storybook/fab.ex b/lib/doggo/storybook/fab.ex deleted file mode 100644 index 86e08d8..0000000 --- a/lib/doggo/storybook/fab.ex +++ /dev/null @@ -1,36 +0,0 @@ -defmodule Doggo.Storybook.Fab do - @moduledoc false - - alias Doggo.Storybook.Shared - alias PhoenixStorybook.Stories.Variation - - def dependent_components, do: [:icon] - - def variations(opts) do - [ - %Variation{ - id: :default, - attributes: %{label: "Add item"}, - slots: slots(opts) - }, - %Variation{ - id: :disabled, - attributes: %{label: "Add item", disabled: true}, - slots: slots(opts) - } - ] - end - - def modifier_variation_base(_id, _name, _value, opts) do - %{ - attributes: %{label: "Add item"}, - slots: slots(opts) - } - end - - defp slots(opts) do - [ - Shared.icon(:add, opts[:dependent_components]) - ] - end -end diff --git a/test/doggo/components_test.exs b/test/doggo/components_test.exs index bc9cb4e..2852644 100644 --- a/test/doggo/components_test.exs +++ b/test/doggo/components_test.exs @@ -36,7 +36,6 @@ defmodule Doggo.ComponentsTest do build_datetime() build_disclosure_button() build_drawer() - build_fab() build_fallback() build_field(gettext_module: Doggo.Gettext) build_field_group() @@ -2268,61 +2267,6 @@ defmodule Doggo.ComponentsTest do end end - describe "fab/1" do - test "default" do - assigns = %{} - - html = - parse_heex(~H""" - add-icon - """) - - button = find_one(html, "button:root") - assert attribute(button, "type") == "button" - assert attribute(button, "class") == "fab is-primary is-normal is-circle" - assert attribute(button, "aria-label") == "Add toy" - assert text(button) == "add-icon" - end - - test "disabled" do - assigns = %{} - - html = - parse_heex(~H""" - add-icon - """) - - assert attribute(html, "button:root", "disabled") == "disabled" - end - - test "with variant" do - assigns = %{} - - html = - parse_heex(~H""" - - add-icon - - """) - - assert attribute(html, "button:root", "class") == - "fab is-success is-normal is-circle" - end - - test "with global attribute" do - assigns = %{} - - html = - parse_heex(~H""" - - add-icon - - """) - - assert attribute(html, "button:root", "phx-click") == "add" - end - end - describe "icon/1" do test "default" do assigns = %{} diff --git a/test/doggo/storybook_test.exs b/test/doggo/storybook_test.exs index 8cd7e94..5348133 100644 --- a/test/doggo/storybook_test.exs +++ b/test/doggo/storybook_test.exs @@ -47,7 +47,6 @@ defmodule Doggo.StorybookTest do ) build_drawer(modifiers: [variant: [values: [nil, "yes"], default: nil]]) - build_fab(modifiers: [variant: [values: [nil, "yes"], default: nil]]) build_fallback(modifiers: [variant: [values: [nil, "yes"], default: nil]]) build_field()