joystick icon indicating copy to clipboard operation
joystick copied to clipboard

Add a render method for responsively rendering elements

Open rglover opened this issue 2 years ago • 0 comments

Fun idea. In some layouts, it'd be helpful to have the same content move physically in the page depending on screen dimensions. We could add a render method responsive() to help with this and dynamically update the render relative to screen size.

import ui from '@joystick.js/ui';

const Component = ui.component({
  render: ({ responsive }) => {
    return `
      <div>
        ${responsive({ min_width: 1920, max_width: 1400 }, `
          ${component(Sidebar)}
        `)}
        <aside>
          ${responsive({ min_width: 740, max_width: 1140 }, `
            ${component(Sidebar)}
          `)}
        </aside>
      </div>
    `;
  },
});

export default Component;	

rglover avatar Sep 03 '23 18:09 rglover