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

Add ability for renderers to toggle the visibility of rendered elements #495

Closed
1 of 6 tasks
dclaux opened this issue Jul 19, 2017 · 7 comments
Closed
1 of 6 tasks

Comments

@dclaux
Copy link
Member

dclaux commented Jul 19, 2017

Implementation status

Problem

Multiple scenarios call for dynamically showing/hiding areas of a card as the user clicks a button. Currently, the closest way to do this is by using Action.ShowCard. However, Action.ShowCard is tied to an action set (be it an explicit ActionSet or the actions collection of a card) which make it impossible, for instance, to toggle the visibility of a portion of the card via a Container's selectAction.

Design

All renderers should make it possible to do the following:

In turn, the above capabilities make it possible for hosts to implement a custom Action.ToggleVisibility action that can be used as the selectAction on a container (for instance) to toggle the visibility of one or more elements in the card.

This issue doesn't call for any specific way the above capabilities should be exposed in the various renderers. What matter is that the capabilities exist.

In the TypeScript HTML renderer however, they will be exposed as follows:

  • onParseElement event invoked every time any element is parsed. This allows a host to parse additional properties, such as, in this case, an isVisible property. This is necessary so a card author can set the initial visibility of a particular element.
  • isVisible boolean property on the CardElement class
@andrewleader
Copy link
Contributor

Would we want targetElementId to actually be an array of ids? A.k.a would any scenarios need to toggle the visibility of multiple separate elements? Or is just one id enough?

Feels like there'll be requests to toggle multiple, although I haven't thought through the scenarios to know for sure.

@dclaux
Copy link
Member Author

dclaux commented Jul 28, 2017

That would make it possible to toggle the visibility of non-contiguous elements, and I am not sure that's desirable. The target scenario really is "show more details" and it seems to me it's better if we constrain to making it possible to show/hide a single element. Plus I think that if we do see an array of Ids is desirable in the future we could definitely support it as well; I would however start with a single Id.

@andrewleader
Copy link
Contributor

But you could do some really neat things with toggling multiple. For example, you could have two images in the left column, one hidden and one visible, and then when you click the main area, it toggles those images and also shows the area below. Thus you can have an "expand" and "collapse" image

image

image

@dclaux
Copy link
Member Author

dclaux commented Jul 28, 2017

True and great example. Unfortunately this feature is a hard sell already, and I fear making it even more powerful will make it even harder.

@andrewleader
Copy link
Contributor

Was a decision made about toggling one vs multiple ids?

@dclaux
Copy link
Member Author

dclaux commented Aug 4, 2017

At this stage it looks like the only thing we'll actually do will be to add the isVisible property and an API in renderers to get an element by Id. With that, Action.ToggleVisibility can be achieved via extensibility, and at that point the decision to support multiple target element Ids or not belongs to the host.

@dclaux
Copy link
Member Author

dclaux commented Aug 7, 2017

The issue has been updated to only call for renderers to have the ability to toggle the visibility of rendererd elements at runtime. With what's proposed in this issue, Action.ToggleVisibility can be implemented through extensibility.

The issue was discussed and approved today.

@dclaux dclaux changed the title Add new Action.ToggleVisibility action and isVisible property on all elements Add ability for renderers to toggle the visibility of rendered elements Aug 7, 2017
@matthidinger matthidinger modified the milestones: v1.1, v1.0 Aug 15, 2017
@khouzam khouzam removed this from the v1.1 milestone Nov 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants