Picture of Chris Jones
Component switch-out
by Chris Jones - Wednesday, 22 January 2014, 12:57 PM
 

I've been thinking about the way that components switch out when device size changes.

My feelings are that the responsibility for changing one component for another is not the responsibility of the component but the framework.

A component should be able to declare, "at small device size use a narrative/text/ but otherwise use me"

It then can just handle its own rendering.

So  HotgraphicView would exposes a _controls property containing
{

       small: 'narrative'

}

Then the framework can subscribe to the device:changed event and perform the replacement automatically at the appropriate size.

This would mean we can build any future component and make it replace its UI dynamically at a give size with any other component and back again automatically.

What do you think?

 

 

 

 

 

 

Picture of Ryan Adams
Re: Component switch-out
by Ryan Adams - Wednesday, 22 January 2014, 10:36 PM
 

Hi Chris,

I actually think the opposite (or sort of the opposite).  I think we should be clear that a component doesn't switch itself out for another at different sizes, rather a component may have a representation at one size that happens to look the same as the representation of another component.

A hotgraphic is always a hotgraphic, but when the screen size is too small it appears in a different form, a form that looks the same as a narrative.

The type of thing never changes, its appearance adjusts to best take advantage of the device it is being rendered on...

I think an important design constraint (something that defines whether we accept a component as being supported by the framework) is that the component has optimised views for all screen sizes (say 320 to 1024 wide). I'd prefer a component be self-contained (or at least not depend on the presence of another component in the package)

Picture of Chris Jones
Re: Component switch-out
by Chris Jones - Thursday, 23 January 2014, 9:49 AM
 

I don't think that is a great idea I'm afraid... for all the reasons why code re-use and modular design are important.

Picture of Ryan Adams
Re: Component switch-out
by Ryan Adams - Thursday, 23 January 2014, 2:26 PM
 

Yes, code re-use and modularity are important. But linking two components like this means that the content format for a hot graphic has to be the same as that for a narrative (and their behaviours). If I need to change the narrative in future then I can't change its data input because I might have lots of hotgraphic objects that need it to be in a specific form.