Skip to content
This repository has been archived by the owner on Oct 2, 2024. It is now read-only.

Variants not picked correctly in some cases #29

Open
sezaru opened this issue Aug 12, 2024 · 0 comments
Open

Variants not picked correctly in some cases #29

sezaru opened this issue Aug 12, 2024 · 0 comments

Comments

@sezaru
Copy link

sezaru commented Aug 12, 2024

I have the following variant:

  def button do
    [
      slots: [
        base: """
        focus:ring-2 font-medium
        """,
        left_icon: "text-white me-2 block"
      ],
      variants: [
        loading?: [
          true: "SOME_CLASS"
        ]
      ],
      default_variants: [
        loading?: false
      ]
    ]
  end

When I run:

 Turboprop.Variants.variant(UI.Button.button(), slot: :base, loading?: true)

I correctly get:

"focus:ring-2 font-medium SOME_CLASS"

But, if i try to do the same with the :left_icon slot, the SOME_CLASS will not be present:

Turboprop.Variants.variant(UI.Button.button(), slot: :left_icon, loading?: true)
"text-white me-2 block"

Now, if I change the loading? variant to this:

        loading?: [
          true: [
            base: "SOME_CLASS",
            left_icon: "SOME_OTHER_CLASS"
          ]
        ]

Now the :base slot will not contain the loading? variant:

Turboprop.Variants.variant(UI.Button.button(), slot: :base, loading?: true)
"focus:ring-2 font-medium"

And the :left_icon slot will contain it:

Turboprop.Variants.variant(UI.Button.button(), slot: :left_icon, loading?: true)
"text-white me-2 block SOME_OTHER_CLASS"

I expect that in both cases, the loading? variant would be present in both slots.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant