DEV Community

artydev
artydev

Posted on • Edited on

If you miss Juris you will regret it for all the time you spend. Look at this : Reactive Props.

Juris is radical way of buildind web app, freeing you from all the heavy tooling.

If you want you can only use Vi and Notepad nothing more.

Reactive Properties

<!DOCTYPE html>
<html>
<head>
  <title>Juris.js Counter Demo</title>
  <script src="https://unpkg.com/juris@0.8.0/juris.js"></script>
</head>
<body>

  <div id="app"></div>

  <script>
    const Counter = (props, context) => ({
  div: {
    children: [
      { button: {
          text: '-',
          onclick: () => context.setState('count', context.getState('count') - 1)
      }},
      { button: {
          text: '+',
          onclick: () => context.setState('count', context.getState('count') + 1)
      }}
    ]
  }
});

const Display = (props, context) => ({
  div: {
    className: 'display',
    text: () => props.count()
  }
});

const juris = new Juris({
  states: {
    count: 0
  },
  components: {
    Counter: Counter,
    Display: Display
  },
  layout: {
    div: {
      children: [
        { Display: { count: () => juris.getState('count') } },
        { Counter: {} }
      ]
    }
  }
});

juris.render('#app');
  </script>

</body>
</html>
Enter fullscreen mode Exit fullscreen mode

Top comments (0)