Simple and elegant component-based UI library

Overview

Riot logo

Simple and elegant component-based UI library

Build Status MIT License Join the discord community channel Join the chat (ja) at https://riot-jp-slackin.herokuapp.com/ OpenCollective Backers OpenCollective Sponsors

NPM version NPM downloads jsDelivr Hits Coverage Status Riot Size Code Quality

Sauce Test Status

Custom components • Concise syntax • Simple API • Tiny Size

Riot brings custom components to all modern browsers. It is designed to offer you everything you wished the native web components API provided.

Tag definition

<timer>
  <p>Seconds Elapsed: { state.time }</p>

  <script>
    export default {
      tick() {
        this.update({ time: ++this.state.time })
      },
      onBeforeMount(props) {
        // create the component initial state
        this.state = {
          time: props.start
        }

        this.timer = setInterval(this.tick, 1000)
      },
      onUnmounted() {
        clearInterval(this.timer)
      }
    }
  </script>
</timer>

Open this example on Plunker

Mounting

// mount the timer with its initial props
riot.mount('timer', { start: 0 })

Nesting

Custom components let you build complex views with HTML.

<timetable>
  <timer start="0"></timer>
  <timer start="10"></timer>
  <timer start="20"></timer>
</timetable>

HTML syntax is the de facto language on the web and it's designed for building user interfaces. The syntax is explicit, nesting is inherent to the language and attributes offer a clean way to provide options for custom tags.

Performant and predictable

  • Absolutely the smallest possible amount of DOM updates and reflows.
  • Fast expressions bindings instead of virtual DOM memory performance issues and drawbacks.
  • One way data flow: updates and unmounts are propagated downwards from parent to children.
  • No "magic" or "smart" reactive properties or hooks
  • Expressions are pre-compiled and cached for high performance.
  • Lifecycle methods for more control.

Close to standards

  • No proprietary event system.
  • Future proof thanks to the javascript module syntax.
  • The rendered DOM can be freely manipulated with other tools.
  • No extra HTML root elements, data- attributes or fancy custom attributes.
  • No new syntax to learn.
  • Plays well with any frontend framework.

Use your dearest language and tools

Powerful and modular ecosystem

The Riot.js ecosystem is completely modular, it's designed to let you pick only the stuff you really need:

CDN hosting

How to contribute

If you are reading this it's already a good sign and I am thankful for it! I try my best working as much as I can on riot but your help is always appreciated.

If you want to contribute to riot helping the project maintenance please check first the list of open issues to understand whether there is a task where you could help.

Riot is mainly developed on UNIX systems so you will be able to run all the commands necessary to build and test the library using our Makefile. If you are on a Microsoft machine it could be harder to set up your development environment properly.

Following the steps below you should be able to properly submit your patch to the project

1) Clone the repo and browse to the riot folder

$ git clone [email protected]:riot/riot.git && cd riot

2) Set up your git branch

$ git checkout -b feature/my-awesome-patch

3) Install the npm dependencies

$ npm i

4) Build and test riot using the Makefile

# To build and test riot
$ make riot

# To build without testing
$ make raw

5) Pull request only against the dev branch making sure you have read our pull request template

6) Be patient

Credits

Riot is actively maintained with ❤️ by:


Gianluca Guarini

Many thanks to all smart people from all over the world who helped improving it.

Official Website

https://riot.js.org

Backers

Support us with a monthly donation and help us continue our activities. Become a backer

Backers

Sponsors

Become a sponsor to get your logo on our README. Become a sponsor

Sponsors

Thanks

Special thanks to Browserstack and JetBrains for their support

jetbrains browser stack
Comments
  • When updating a tag with a loop, rendered result doesn't always reflect the updated data

    When updating a tag with a loop, rendered result doesn't always reflect the updated data

    The below fiddle recreates the issue. Checking an item should remove it. However, checking any but the last item with riot 2.2.2, while the item is removed, the item below becomes checked. It works fine with 2.1.0 and 2.0.15.

    http://jsfiddle.net/cdanielw/bkw5ommu/4/

    bug discussion 
    opened by cdanielw 153
  • 8-10x slower than React at 10k item list reversal

    8-10x slower than React at 10k item list reversal

    I was very interested in seeing how fast Riot was compared to React based on the intro docs.

    So I put together these simple demos to help me learn and compare.

    10k item list with reverse button. After you click the button, you'll see the time it took to reverse and finish rendering. (Actually, in a separate issue, I don't understand why you have to click the button twice on the Riot version before the timing text appears.)

    React: http://jsfiddle.net/brianmfranklin/w674Lv7p/ Riot2: http://jsfiddle.net/brianmfranklin/j05ukz2r/

    On my MacBook Pro, I consistently get about 2500 ms for Riot, and only 250-350ms for React.

    I thought maybe this was a quirk of how I was having to measure the timing. But it DOES seem to actually take longer to do the re-render.

    Is this expected? Or are there more optimizations to do?

    bug fixed enhancement 
    opened by brianmfranklin 145
  • Riot next - roadmap to v4

    Riot next - roadmap to v4

    Roadmap proposal for the future riot major release:

    (this list just a draft and it's going to grow)

    • [ ] Complete rewrite of the compiler simplifying the sourcecode allowing also sourcemaps
    • [ ] Fix all the yield issues introducing the use of <slot> deprecating the <yield>
    • [ ] Make the use of riot-observable optional
    • [ ] Remove this.tags from the tags instances in favor of ref https://github.com/riot/riot/issues/2360
    • [ ] Automounted components deprecating the riot.mount method
    • [ ] Add support for shadow DOM or at least support the :root selector instead of :scope
    • [ ] Make the tags options explicit avoiding to pick per default all the custom tags attributes
    • [ ] Avoid the use of riot.csp in favor of a simpler solution
    • [ ] Cleanup the readme file removing dead links to tutorials or old riot stuff
    • [ ] Simplify the mixin logic avoid the use of es6 classes and functions instances
    • [ ] Remove the shouldUpdate method in favor of a smarter DOM updates strategy
    • [ ] Drop IE9/10/11 support
    • [ ] Use new ES6 features like Proxies and template strings
    • [ ] Drop the use of each={ items } in favor of each={ item in items }
    • [ ] Reduce the source code simplifying a lot the api
    • [ ] Update the api simplifying the core methods arguments handling
    • [ ] Prefer a functional approach over the current objects extension strategy

    We will track the progress here

    ✌️

    discussion 
    opened by GianlucaGuarini 125
  • Riot next - roadmap to riot 2.3

    Riot next - roadmap to riot 2.3

    Riot 2.2.3

    The next riot release the 2.2.3 (maybe we could split it also in 2 releases 2.2.4) will fix the mainly the issues raised up by our users

    • Bugs
      • [x] #1055
      • [x] #1048
      • [x] #1040 #974 #995
      • [x] #1016 #984
      • [x] #976
      • [x] #907
      • [x] #1071

    Riot 2.2.4

    bugs list

    Riot 2.3.0

    I would like also to discuss here the updates I've planned for riot 2.3.*

    • [x] rethink/refactore the riot loops to keep them fast but also updating the DOM node correctly
    • [x] remove the compiler, router, observable (maybe also the cli).. from the riot repo. We could publish all these scripts as separate npm modules riot-* and use them to build riot in this repo (or even extend the basic riot functionalities like the router 4 ex.). This solution allows us to split and test all the riot core modules in their own repos avoiding to pollute this repo with too many unrelated tests. Indeed we could also track better the issues related to small parts of our code base. I have already prepared riot-observable containing the folder structure I would like to use also for the other riot modules. Notice that the doc folder could be used to update the whole riot documentation/website here avoiding to rely on @tipiirai on any new riot release. The submodules versioning should be in sync with riot at least for the major releases
    • [x] remove the ie8 support as one of the main riot pros from the doc, I would like explain the hacks about how to use eventually riot on IE8 only in our FAQ section
    • [ ] remove the dist folder from the .gitignore to easily debug the release in the dev branch
    • [x] decide whether we want to optimize our build using webpack or keep using smash
      • with smash we could only include the index.js files of all our riot submodules
        • Pros: It will keep the riot codebase small
        • Pros/Cons: Our source files will not be processed by any other tool, they will be only concatenated in riot.js
        • Cons: Use of a deprecated technology
        • Cons: We will lose control over the global variables, functions risking global namespace conflicts
      • with webpack
        • Pros: We can get only the methods exported from our riot submodules keeping, the riot context clean
        • Pros/Cons: We could parse our modules, using babeljs using also es2015 features
        • Cons: Our output will not match the codestyle used in the sourcecode
        • Cons: Our output will be bigger containing extra code generated by webpack to handle the commonjs calls
    • [x] merge the new tmpl.js https://github.com/riot/riot/pull/954 version (maybe it could also be a riot submodule riot-tmpl?! )
    • [x] update the riot website automatically on any new riot release enhancing the code [here].(https://github.com/riot/riot.github.io) Do we need to redesign it? Or do you want to keep the current template?
    • [x] enhance the riot-router using the HTML5 history API

    Your feedback is really appreciated @tipiirai @cognitom @rsbondi @aMarCruz

    :v:

    discussion 
    opened by GianlucaGuarini 98
  • Feature request: Specify transclusion position

    Feature request: Specify transclusion position

    It would be great to specify where to include the content of a parent tag. Ie:

    <!-- form-group.tag -->
    <form-group>
      <div class="form-group">
        <label>{ opts.label }</label>
        { innerHTML } <!-- somehow transclude given content here (there is probably a better name than "innerHTML" ;) -->
      </div>
    </form-group>
    
    <!-- index.html -->
    <form>
      <form-group label="Field 1">
        <input type="text" name="field-1"/>
      </form-group>
    </form>
    

    .... producing ....

    <div class="form-group">
      <label>Field 1</label>
      <input type="text" name="field 1"/>
    </div>
    
    opened by johngeorgewright 95
  • Riot 3.0.0 roadmap

    Riot 3.0.0 roadmap

    3.0.0 will be quite a big release for riot. @rsbondi and the new member of the team @rogueg are already working on the next branch fixing many of the important issues that we can solve only by introducing breaking changes. Here you can check the list of the issues we want to close for the next major release:

    • [x] improve the loop performances using the @pakastin's hint http://jsfiddle.net/paldepind/rju8rzmn/4/
    • [ ] ~~switch from makefile to a more crossplatform solution #2024~~
    • [ ] add sourcemaps generation in the compiler compiler/56
    • [x] use the ref attribute instead of names and ids riot/1185
    • [x] allow the es6 import also inside the tags compiler/69
    • [x] build riot using rollup+babel instead of smash using the new es6 modules syntax
    • [x] remove riot-route from the core making it optional https://github.com/riot/riot/issues/1485
    • [x] fix all the issues related to the if conditions https://github.com/riot/riot/issues/1477 https://github.com/riot/riot/pull/1658
    • [x] avoid that the update and the updated events get triggered before any tag has been mounted https://github.com/riot/riot/issues/1661
    • [x] decision regarding how the input/select tags should react on the updates https://github.com/riot/riot/issues/1642
    • [x] remove the automatic preventDefault from the riot DOM events https://github.com/riot/riot/issues/1770 https://github.com/riot/riot/issues/1718 https://github.com/riot/riot/issues/526
    • [x] avoid to inherit properties from the parent in loops of custom children tags https://github.com/riot/riot/issues/1697
    • [x] avoid to update the parent tag on the events generated from a child tags https://github.com/riot/riot/issues/1319
    • [x] remove the __ prefix for the "boolean" html attributes https://github.com/riot/riot/issues/276
    • [x] clean up the tests splitting them into several files
    • [x] Add the shouldUpdate method to the tags to emulate componentShouldUpdate in react

    I also hope to have enough time to add a blog section on our site describing the riot status on any release.

    I would like also to mention that we started a pledgie donation campaign and if you would like to sustain us and you like riot it might be nice to consider a donation at least to let us paying the costs of the riot maintenance (domain, saucelabs, browserstack.. )

    :v:

    discussion 
    opened by GianlucaGuarini 77
  • Riot next

    Riot next

    Bugs:

    • [x] https://github.com/muut/riotjs/issues/766
    • [x] https://github.com/muut/riotjs/issues/764
    • [ ] ~~https://github.com/riot/riot/issues/810~~ in the next release
    • [ ] ~~https://github.com/riot/riot/issues/334~~ in the next release
    • [x] https://github.com/riot/riot/issues/809
    • [x] https://github.com/muut/riotjs/issues/700
    • [x] https://github.com/muut/riotjs/issues/484 ( probably the most important )
    • [x] https://github.com/muut/riotjs/issues/763

    Features/Enhancements

    • [x] faster each rendering ( related to #484 )
    • [x] fix the saucelabs tests on the iPhone/iPad (I have removed them)
    • [x] increase the code coverage
    • [x] enable use strict

    p.s. This list could change at anytime, new ideas and suggestions are welcome Your contribute to riot is precious :v:

    opened by GianlucaGuarini 72
  • Looping is at the wrong level

    Looping is at the wrong level

    I think looping through element is at the wrong tag level. Specially when you have this case you need to write twice the each to get it work as expected.

    <dl class="dl-horizontal" >
        <dt each={name in opts.data.metrics}>{name}</dt>
        <dd each={name, value in opts.data.metrics}>{value}</dd>
    </dl>
    

    It iterates the same list twice right?

    Shouldn't that be like this? And more efficient.

    <dl class="dl-horizontal" each={name, value in opts.data.metrics}>
        <dt>{name}</dt>
        <dd>{value}</dd>
    </dl>
    

    It feels more natural too. If you base on templating engines such as Jinja http://jinja.pocoo.org/docs/dev/templates/#for

    enhancement feature request 
    opened by assertnotnull 70
  • Riot 4 roadmap

    Riot 4 roadmap

    Recap

    It's almost one year that we didn't release updates about Riot v4 so I think opening a new roadmap issue (closing the old one https://github.com/riot/riot/issues/2283) is the cleanest way to keep our community updated regarding the upcoming news.

    Riot v3

    Riot v3 is feature complete and bug free so we will update the source code just in case of security vulnerabilities. All the enhancements and the yield problems submitted by some users will introduce breaking changes so I would like to keep the current API/behavior stable as it is and move forward.

    Core Contributors

    Please see here

    Riot v4

    Riot and Simulacra.js will join forces

    Riot 4 will use Simulacra.js as default rendering engine. Simulacra.js is currently one of the fastest and smartest rendering engine available and its creator @daliwali is now a riot core member. Dali will actively be part of the riot 4 rewrite and we started already working on a new parser/compiler.

    Components Structure

    The riot components structure will be a bit refreshed but it will not be a radical change. We will avoid the current ambiguities in favor of a cleaner and nicer structure.

    Old

    <my-component>
      <h1 if={ title }>{ title }</h1>
      <ul>
        <li onclick={ onClick } each={ items }>{ value }</li>
      </ul>
    
      var goodbye = 'goodbye'
    
      this.on('mount', function() {
        console.log('mounted!')
      })
    
      onClick() {
        this.title = goodbye
      }
    
      <style>
        :scope {
          color: red;
        }
      </style>
    </my-component>
    

    New

    <my-component>
      <h1 if={ title }>{ title }</h1>
      
      <ul>
        <li onclick={ onClick } each={ item in items }>{ item.value }</li>
      </ul>
    
      <script>
        var goodbye = 'goodbye'
    
        export default {
          onMount() {
            console.log('mounted!')
          },
          onClick() {
            this.title = goodbye
          }
        }
      </script>
    
      <style>
        :root {
          color: red;
        }
      </style>
    </my-component>
    

    New Ideas

    We got many new ideas for the rewrite but we need to test them first so you will be informed when the compiler will be in a functional prototype state.

    Release date

    At moment we don't have any fixed release date, we only know that a full rewrite of the framework in 2 of us (working only during our spare time) will take quite some time. We will inform you about a plausible release date when a first prototype will be released. Please donate to our open collective campaign if you want to actively support the development of the new Riot.js major release

    API changes 🚧

    • [ ] Complete rewrite of the compiler simplifying the sourcecode and the parsing
    • [ ] Switch to Simulcra.js as default rendering engine
    • [ ] Remove riot-observable in favor of callbacks lifecycle methods
    • [ ] Remove this.tags from the tags instances in favor of ref https://github.com/riot/riot/issues/2360
    • [ ] Add support for shadow DOM or at least support the :root selector instead of :scope
    • [ ] Remove riot.csp.js in favor of a single version compatible for any environement
    • [ ] Cleanup the readme file removing dead links to tutorials or old riot stuff
    • [ ] Simplify the mixin logic allowing only object
    • [ ] Make the use of <script> and <style> obligatory
    • [ ] Remove the shouldUpdate method
    • [ ] Drop the use of each={ items } in favor of each={ item in items }
    • [ ] Update the API simplifying the arguments overload issue for many riot methods

    ✌️

    discussion 
    opened by GianlucaGuarini 66
  • Test suite with mocha, travis, karma & saucelabs

    Test suite with mocha, travis, karma & saucelabs

    I would like to make a unit test with mocha to check that the code pushed on any pull request does not break. Another advantage could be to check the crossbrowser compatibility on any release automatically. We need to create an account on saucelabs ( email + psw ) and @tipiirai you should create also the travis hook

    opened by GianlucaGuarini 51
  • Super Powerful Routes

    Super Powerful Routes

    This PR introduces a huge improvement in our routes making it easy to define different callbacks for each path. Below I am adding some examples, check the tests for more details.

    // Defining several routes at once
    riot.route({
       // static route
       "/home":  function(params) { ... },
    
       // RegEx route 
       ".*/something": function(params) { ... }, 
    
       // Passing params
       "/items/{item}": function(params) { ... },
    
       // With RegEx and several params 
       ".*/{type}/{id}?.*q={q}.*": function(params) { ... }
    });
    
    // Defining a single route
    riot.route("/somepage", function(params) { ... });
    
    // Trigger a route, this will execute the the callback of this route
    riot.route("/somepage");
    
    opened by 3den 47
  • The draggable attribute isn't handled right

    The draggable attribute isn't handled right

    The issue:

    1. The draggable attribute isn't handled right by riot when you assign it a boolean expression.
    2. The HTML standard (and the browser) expects values of "true" or "false" (unlike, "checked", for example, which expects "checked" value or non).
    3. Riot translate a truthy value into the string "draggable" - which doesn't make it draggable.

    Reproduction https://codesandbox.io/embed/riot-js-7-bug-template-forked-1mco0f?fontsize=14&hidenavigation=1&theme=dark

    Test context browsers: Chrome and Firefox, linux OS, riot version 7

    Issue type Bug

    enhancement discussion breaking change 
    opened by dharmax 1
  • Using riot components in an Angular application

    Using riot components in an Angular application

    Help us to manage our issues by answering the following:

    1. Describe your issue:

    In my company we are working on a huge and terrible legacy code written in Angular 11 and we'd like to gradually migrate out of it into Riot, with which we have a good experience in other project. We thought about building an angular component which will function as a bridge between the containing application to the riot component. So far, we managed to do so only when we precompile the riot file into a js file. However, this method would be pretty cumbersome. We didn't manage to properly configure the webpack to do that compilation for us. If you have any ideas how to solve this "bridging problem" we'd be grateful.

    1. Can you reproduce the issue? n/a
    2. On which browser/OS does the issue appear? all
    3. Which version of Riot does it affect? latest (7)
    4. How would you tag this issue?
    • [ ] Question
    question needs repro 
    opened by AndrewPetrishin 3
  • Storybook Support on latest Riot version.

    Storybook Support on latest Riot version.

    Help us to manage our issues by answering the following:

    1. Describe your issue:

    There is an issue in Storybook repository, Storybook does not seem to support the latest Riot.js.

    https://github.com/storybookjs/riot/issues/1

    1. Can you reproduce the issue?
    1. On which browser/OS does the issue appear?
    1. Which version of Riot does it affect?

    v4 and later

    1. How would you tag this issue?
    • [ ] Question
    • [ ] Bug
    • [ ] Discussion
    • [x] Feature request
    • [ ] Tip
    • [ ] Enhancement
    • [ ] Performance
    enhancement 
    opened by nibushibu 3
Releases(v7.1.0)
  • v7.1.0(Nov 7, 2022)

    • Fix https://github.com/riot/riot/issues/2972
    • Fix https://github.com/riot/riot/issues/2967 (enhance the previous patch)
    • Fix https://github.com/riot/riot/issues/2969
    • Update Riot.js has now 0 dependencies. All the needed dependencies will be bundled before the publishing on npm
    • Update dev dependencies
    Source code(tar.gz)
    Source code(zip)
  • v7.0.7(Nov 1, 2022)

    • Fix https://github.com/riot/riot/issues/2971
    • Fix https://github.com/riot/riot/issues/2967 adding support for css complex pseudo selectors
    • Fix riot.version wrong value in the esm export
    • Fix circular dependencies
    • Update improve rendering performance preferring loops over recursion for DOM manipulations
    Source code(tar.gz)
    Source code(zip)
  • v7.0.6(Sep 9, 2022)

  • v7.0.5(Sep 2, 2022)

  • v7.0.4(Aug 23, 2022)

  • v7.0.3(Aug 14, 2022)

  • v7.0.2(Aug 4, 2022)

  • v7.0.1(Aug 3, 2022)

  • v7.0.0(Aug 2, 2022)

    • Update: code cleanup to improve the esm bundle and treeshaking
      • Remove: riot.esm.js in favor of the esm folder
    • Add: runtime slots https://github.com/riot/riot/discussions/2917
      • The runtime slots are available in the riot+compiler.js bundle (A documentation update will be available soon)
    • Update: reduced bundle size to 5kb riot.min.js gzipped
    • Update: new Compiler (riot+compiler.js) bundle 50% lighter than the previous one

    Important: The documentation will be updated during the next few weeks, however no API breaking changes were introduced.

    Source code(tar.gz)
    Source code(zip)
  • v6.1.2(Jan 24, 2022)

  • v6.1.1(Dec 17, 2021)

  • v6.1.0(Dec 11, 2021)

    • Update compiler
      • Components output code will use modern javascript (like arrow functions) reducing heavily their size
      • Components code output will be smaller due to compiler optimizations
    • Update dependencies
    Source code(tar.gz)
    Source code(zip)
  • v6.0.4(Sep 19, 2021)

  • v6.0.3(Aug 6, 2021)

    • Fix tags with only named export statements. Their javascript will be properly generated also without an export default
    • Update @riotjs/dom-bindings types adding better typescript support
    Source code(tar.gz)
    Source code(zip)
  • v6.0.2(Jul 29, 2021)

  • v6.0.1(Jul 14, 2021)

    • Update: update the @riotjs/compiler improving the typescript support for type aliases like export type ComponentInterface = RiotComponent<MyComponentProps, MyComponentState>
    Source code(tar.gz)
    Source code(zip)
  • v6.0.0(Jul 11, 2021)

    • Add strict typescript support https://github.com/riot/riot/pull/2912 Breaking Change: the Riot.js types have been updated
    • Add fallback rendering for slots https://github.com/riot/riot/issues/2920
    • Add typescript Parser as default compiler parser https://github.com/riot/compiler/pull/149
    • Fix https://github.com/riot/riot/issues/2925
    • Fix typescript compilation https://github.com/riot/riot/issues/2926

    If you are not a typescript user this release doesn't introduce any braking change. If you are a typescript user you can start writing Riot.js components as follows

    <my-component>
      <p>{ state.greeting }{ props.username }</p>
    
      <!--
        Notice that lang="ts" does actually nothing.
        It's just needed to let your IDE interpret the below code as typescript.
        The riot compiler will ignore it
      -->
      <script lang="ts">
        import {withTypes, RiotComponent} from 'riot'
    
        export type MyComponentProps = {
          username: string
        }
    
        export type MyComponentState = {
          message: string
        }
    
        export type MyComponent = RiotComponent<MyComponentProps, MyComponentState>
    
        export default withTypes<MyComponent>({
          state: {
            message: 'hello'
          }
        })
      </script>
    </my-component>
    

    Many thanks to https://github.com/kachurun for his help on this major release

    Source code(tar.gz)
    Source code(zip)
  • v5.4.5(Jun 13, 2021)

    • Fix https://github.com/riot/riot/issues/2914 many thanks to @kachurun
    • Fix template tags rendering with empty DOM https://github.com/riot/dom-bindings/pull/19
    Source code(tar.gz)
    Source code(zip)
  • v5.4.4(Jun 5, 2021)

  • v5.4.3(May 29, 2021)

  • v5.4.2(May 15, 2021)

    • Fix mountand unmount type declarations https://github.com/riot/riot/pull/2909 @kachurun
    • Fix Parent Tag access in lifecycle events https://github.com/riot/riot/pull/2910 @kachurun
    Source code(tar.gz)
    Source code(zip)
  • v5.4.1(May 4, 2021)

  • v5.4.0(May 4, 2021)

    • Update: replace the compiler acorn javascript parser with the (bigger but more modern) @babel/parser
    • Add: typescript syntax support in Riot.js <script> tags

    Notice: Riot.js will not type check your components scripts nor transpile them. This version allows you to use the typescript syntax without forcing the use of a typescript preprocessor, but type checking and transpilation should be handled with tools like babel or ts-loader You can check the new compiler here with the following demo component:

    <random>
      <h3>{ props.title }</h3>
    
      <button onclick={ generate }>
        Generate
      </button>
    
      <h1>
        { state.number }
      </h1>
    
      <logs logs={ state.logs } onclear={ clearLogs }></logs>
    
      <script lang="ts">
        import Logs from '../logs/logs.riot'
        import {RandomComponent} from './types'
    
        function Random(): RandomComponent {
          return {
            state: {
              number: null,
              logs: []
            },
            generate(event: MouseEvent): void {
              this.update({
                number: Math.floor(Math.random() * 10000),
                logs: this.state.logs.concat({
                  text: `Generate button clicked. Event type is ${event.type}`
                })
              })
            },
            clearLogs(): void {
              this.update({
                logs: []
              })
            }
          }
        }
    
        Random.components = {
          Logs
        }
    
        export default Random
      </script>
    </random>
    
    
    Source code(tar.gz)
    Source code(zip)
  • v5.3.3(Apr 5, 2021)

  • v5.3.2(Apr 5, 2021)

  • v5.3.1(Feb 28, 2021)

    • Fix https://github.com/riot/riot/issues/2895
    • Update improve compiler legacy syntax support. The following syntax is now also supported
    <my-component>
      <p>{ state.message }</p>
      <button onclick={onClick}>Click Me</button>
    
      <script>
        const context = this
    
        context.state = {
          message: ''
        }
        
        context.onBeforeMount = () => {
          context.state.message = 'Hello'
        }
    
        context.onClick = () => {
          context.update({
            message: 'Goodbye'
          })
        }
      </script>
    </my-component>
    
    Source code(tar.gz)
    Source code(zip)
  • v5.3.0(Feb 13, 2021)

    • Update improve support for legacy Riot.js syntax fixing some edge cases
    • Update improve support for recursive tags

    Now you can recursively render tags without having to register them globally

    <recursive-tree>
      <p>{ props.name }</p>
      <recursive-tree 
        if={ props.children.length && props.children } 
        each={ child in props.children } { ...child }/>
    </recursive-tree>
    
    Source code(tar.gz)
    Source code(zip)
  • v5.2.0(Jan 31, 2021)

    • Add support for old style Riot.js syntax

    Some liked more the old RIot.js syntax so you can now write components also as follows

    <old-syntax>
      <p>{ state.message }</p>
      <button onclick={onClick}>Click Me</button>
    
      <script>
        this.onBeforeMount = () => {
          this.state.message = 'Hello'
        }
    
        this.onClick = () => {
          this.update({
            message: 'Goodbye'
          })
        }
      </script>
    </old-syntax>
    
    Source code(tar.gz)
    Source code(zip)
  • v5.1.4(Jan 23, 2021)

  • v5.1.3(Jan 17, 2021)

Owner
Riot.js
Simple and elegant component-based UI library
Riot.js
Maple.js is a React webcomponents based framework mixing ES6 with Custom Elements, HTML Imports and Shadow DOM. It has in-built support for SASS and JSX, including a Gulp task for vulcanizing your project.

Heroku: http://maple-app.herokuapp.com/ npm: npm install maple.js Bower: bower install maple.js Maple is a seamless module that allows you to organise

Adam Timberlake 430 Dec 23, 2022
A reactive filesystem interface based on Vue 3 reactivity system.

A reactive filesystem interface based on Vue 3 reactivity system.

Guillaume Chau 37 Oct 8, 2022
Demo app for refine.dev integration, a react-based framework for rapid building of internal tools.

Demo app for refine.dev integration, a react-based framework for rapid building of internal tools.

Permify 7 Apr 28, 2022
An event-based global state management tool for vue, react, mini-program, ect.

hy-event-store An event-based global state management tool for vue, react, mini-program, etc. 一个基于事件的全局状态管理工具,可以在Vue、React、小程序等任何地方使用。 设计灵感 在项目中找到一个更加

null 260 Jan 2, 2023
RTConnect is an easy-to-use React component library that enables developers to set up live, real-time video calls, between multiple connected peers on different computers

RTConnect is an easy-to-use React component library that enables developers to set up live, real-time video calls, between multiple connected peers on different computers in a React app.

OSLabs Beta 64 Dec 27, 2022
Fire7 is a small library that implements real-time data binding between Firebase Cloud Firestore and your Framework7 app.

Fire7 is a small library that implements real-time data binding between Firebase Cloud Firestore and your Framework7 app.

Sergei Voroshilov 6 May 15, 2022
A tiny library aims to parse HTML to Figma Layer Notation and do it well.

TSDX User Guide Congrats! You just saved yourself hours of work by bootstrapping this project with TSDX. Let’s get you oriented with what’s here and h

青岚 5 Dec 28, 2022
A tiny, reactive JavaScript library for structured state and tabular data.

A JavaScript library for structured state. Using plain old JavaScript objects to manage data gets old very quickly. It's error-prone, tricky to track

tinyplex 1.4k Dec 30, 2022
Lightweight react-like library. Support for asynchronous rendering and hooks.

Recept · Lightweight react-like library. Like the name, this project is mainly based on the architectural idea of react, which can feel react more int

RuiLin Dong 52 Sep 17, 2022
:postbox: A simple and customizable React notifications system

Reapop A simple and customizable React notifications system Summary Compatibility Demo Installation Integration & usage With React & Redux With React

Louis Barranqueiro 1.4k Jan 5, 2023
A tiny ( 1KB) reactivity library

influer A tiny (< 1KB) reactivity library yarn add influer Introduction influer is a tiny reactivity library. Exported in ESM, CJS, and IIFE, all < 1K

Tom Lienard 7 Jul 13, 2022
React library for ux4iot for easily building IoT web applications

React library for ux4iot for easily building IoT web applications

Device Insight 15 Oct 31, 2022
A lightweight library to create reactive objects

Reactivity As the name says, Reactivity is a lightweight javascript library to create simple reactive objects. Inspired in Redux and Vuex Get started

David Linarez 2 Oct 28, 2021
react-pdf-highlighter is a React library that provides annotation experience for PDF documents on web.

☕️ Buy me a coffee react-pdf-highlighter react-pdf-highlighter is a React library that provides annotation experience for PDF documents on web. It is

Vladyslav 9 Dec 2, 2022
A blazing fast, dependency free, 1kb runtime type-checking library written entirely in typescript, meant to be used with it.

A blazing fast, dependency free, 1kb runtime type-checking library written entirely in typescript, meant to be used with it.

Gabriel Vaquer 90 Dec 9, 2022
A library for react that can easily manipulate integers like adding a comma every 3 digits

A library for react that can easily manipulate integers like adding a comma every 3 digits

udinesia325 1 Nov 21, 2021
A tiny, blazing fast view library that creates reactive Web Components

dlite A tiny, blazing fast view library that creates reactive Web Components ?? Complete documentation https://dlitejs.com ?? Introduction dlite creat

Adam Hill 20 Feb 25, 2023
✂️ React component for truncating JSX markup

React Truncate Markup React component for truncating JSX markup. Examples with code snippets CodeSandbox demo Why? Few use cases for using JS truncati

Parsable 139 Dec 24, 2022
🔱 Svelte component runs everywhere, adapter for react/vue2/vue3/svelte.

Write components once, run everywhere. Make svelte components run inside React or Vue applications. Managing support for libraries that provide UI com

Productivity Improvement Research Laboratory 112 Aug 25, 2022