News for hackers. Stuff that matters.
Re:Writing Less Code by tracker1 on Wednesday August 17, 2016 @02:58PM (#12307355)
If your content won't flow/flex into a grid well, then those parts should have custom CSS @media queries to begin with.. it's a matter of learning that.

Alternatively, you can use something like react with event triggering on window resize, and use the actual window size as part of your rendering... for example, I'll put the event to trigger my redux store so that state.window.size.height/width are set, I'll sometimes also do the window.scrollTop in the events as well.. this way I can use that in code for my components...

    render(props) {
      if (props.window.size.width < 600) return null;
      if (props.window.size.width < 1024) return <div>...</div>;
      ...
    }
Or similar changes in rendering... assuming something like redux with react-redux's connect. It's actually a pretty slick way to handle this. In this example, [1] I'm using the value to also adjust visual configuration from inputted configuration.

[1] https://github.com/tracker1/md-datepicker/blob/master/_src/D...

There are no comments on this comment yet.