Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Transition component to allow to be renderless #179

Open
barryofguilder opened this issue May 25, 2023 · 4 comments
Open

Update Transition component to allow to be renderless #179

barryofguilder opened this issue May 25, 2023 · 4 comments

Comments

@barryofguilder
Copy link

I've noticed that the Transition component always renders an element (div by default). There are a lot of Tailwind UI examples that pass a React Fragment component to Transition so it doesn't render anything. Is that possible with Ember? I mainly ask because it's more difficult to implement Tailwind UI code examples with the Ember version since you end up with an extra element in the hierarchy that messes with styling.

Here is an example from Tailwind UI for building a select menu:

<Transition
  show={open}
  as={Fragment}
  leave="transition ease-in duration-100"
  leaveFrom="opacity-100"
  leaveTo="opacity-0"
>
@far-fetched
Copy link
Contributor

hey 👋
You can pass tagName argument to override the default div element:
https://github.com/GavinJoyce/ember-headlessui/blob/master/ember-headlessui/addon/components/transition.js#L39-L41

@roomman
Copy link

roomman commented May 26, 2023

I raised a similar point in this PR with code examples of how the Ember invocation differs the official docs: #129 (comment)

I feel like someone needs to decide if we are mirroring the official implementation or not. 🧐

@NullVoxPopuli
Copy link
Collaborator

NullVoxPopuli commented May 26, 2023

I think we should mirror the output and behavior, but not necessarily the implementation. There are a ton of anti patterns in the react implementation, for example.

That said, we don't need a div in a component, but then what do you animate?
Animations in ember are what you'd find on MDN, which need an element to animate.

The implementation i think would be best would be for Transition to yield a modifier that you can then place on the element you want to animate. That way it's clear what is being animated.

@barryofguilder
Copy link
Author

@NullVoxPopuli oh, I like the idea of it yielding a modifier! I'm not exactly sure how the React implementation works when it doesn't render an element. I'm assuming that it applies the transitions to the child element.

hey 👋 You can pass tagName argument to override the default div element: https://github.com/GavinJoyce/ember-headlessui/blob/master/ember-headlessui/addon/components/transition.js#L39-L41

Yeah, but that doesn't work if you try to pass something like an empty string to mimic the React Fragment (which doesn't render an element).

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

No branches or pull requests

4 participants