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

[Idea] component for the wormhole output #39

Closed
knownasilya opened this issue Jan 1, 2016 · 6 comments
Closed

[Idea] component for the wormhole output #39

knownasilya opened this issue Jan 1, 2016 · 6 comments

Comments

@knownasilya
Copy link
Contributor

Basically the wormhole would know when the receiver is rendered, and only then would it transfer the yielded content.

Something like the following:

<!-- application/template.hbs -->
{{#if menuOpen}}
  {{#ember-wormhole-receiver 'sidebar-menu'}}
    Default application wide menus here
  {{/ember-wormhole-receiver}}
{{/if}}
<!-- some/route/template.hbs -->
{{#ember-wormhole 'sidebar-menu'}}
  Route menu items here with their own actions and context
{{/ember-wormhole}}

This would allow for easier implementations (not when trying to integrate with third-party libs) when working in an ember app. Think a sidebar that has a header (defined in application/template.hbs) with a dropdown menu. The sidebar content could be in any route, so we have a receiver in the header and any route can now manipulate that menu easily without having to wire up a service with a boolean.

Underneath, the two components would communicate via a service based on the identifier shared by the two.

@knownasilya
Copy link
Contributor Author

You could do things like:

<div class="profile-header">
  {{#ember-wormhole-receiver header}}
    <!-- default content if no wormhole has used this area yet -->
    User Profile
  {{/ember-wormhole-receiver}}
</div>

<div class="profile-body">
  {{yield (hash
    header=(component 'ember-wormhole' header)
    footer=(component 'ember-wormhole' footer)
  )}}
  <!--
    might even be nice to pass down additional arguments
    so (component 'ember-wormhole' 'footer' footerLinks)
    which could be used with {{#area.footer as |links|}}
  -->
</div>

<!-- might be useful to know if an area was used outside of the receiver -->
<div class="profile-footer">
  {{ember-wormhole-receiver footer}}
</div>

which could be used like:

{{#user-profile data=profile as |areas|}}
  {{#areas.header}}
    My Profile
  {{/areas.header}}

  Otherwise it's just the body where we yielded.

  {{#areas.footer}}
    Last Updated: {{dateUpdated}}
  {{/areas.footer}}
{{/user-profile}}

This way the user doesn't have to know if the footer is toggled for this to work. Their content just shows up when it should.

@knownasilya
Copy link
Contributor Author

This might be better as another addon that uses ember-wormhole.

@lukemelia
Copy link
Contributor

@knownasilya sounds a lot like https://github.com/minutebase/ember-portal which is built on top of wormhole.

@knownasilya
Copy link
Contributor Author

Nice, didn't know about that.

@knownasilya
Copy link
Contributor Author

For anyone interested, here's a working example with ember-portal, https://github.com/knownasilya/ember-yielded-portals

@knownasilya
Copy link
Contributor Author

Here's another interesting implementation I came up with: https://github.com/knownasilya/ember-receive

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

2 participants