You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

251 lines
8.9 KiB

4 years ago
  1. [![Riot logo](https://riot.js.org/img/logo/riot-logo.svg)](https://riot.js.org)
  2. ## Simple and elegant component-based UI library
  3. [![Build Status][travis-image]][travis-url]
  4. [![MIT License][license-image]][license-url]
  5. [![Join the chat at https://gitter.im/riot/riot][gitter-image]][gitter-url]
  6. [![Join the discord community channel][discord-image]][discord-url]
  7. [![Join the chat (ja) at https://riot-jp-slackin.herokuapp.com/][slack-ja-image]][slack-ja-url]
  8. [![OpenCollective Backers][backer-badge]][backer-url] [![OpenCollective Sponsors][sponsor-badge]][sponsor-url]
  9. [![NPM version][npm-version-image]][npm-url]
  10. [![NPM downloads][npm-downloads-image]][npm-url]
  11. [![jsDelivr Hits][jsdelivr-image]][jsdelivr-url]
  12. [![Coverage Status][coverage-image]][coverage-url]
  13. ![Riot Size][lib-size]
  14. [![Code Quality][codeclimate-image]][codeclimate-url]
  15. [![Sauce Test Status][saucelabs-image]][saucelabs-url]
  16. ### Custom components • Concise syntax • Simple API • Tiny Size
  17. Riot brings custom components to all modern browsers. It is designed to offer you everything you wished native the web components API looked like.
  18. #### Tag definition
  19. ```html
  20. <timer>
  21. <p>Seconds Elapsed: { state.time }</p>
  22. <script>
  23. export default {
  24. tick() {
  25. this.update({ time: ++this.state.time })
  26. },
  27. onBeforeMount(props) {
  28. // create the component initial state
  29. this.state = {
  30. time: props.start
  31. }
  32. this.timer = setInterval(this.tick, 1000)
  33. },
  34. onUnmounted() {
  35. clearInterval(this.timer)
  36. }
  37. }
  38. </script>
  39. </timer>
  40. ```
  41. [Open this example on Plunker](https://riot.js.org/examples/plunker/?app=timer)
  42. #### Mounting
  43. ```javascript
  44. // mount the timer with its initial props
  45. riot.mount('timer', { start: 0 })
  46. ```
  47. #### Nesting
  48. Custom components let you build complex views with HTML.
  49. ```html
  50. <timetable>
  51. <timer start="0"></timer>
  52. <timer start="10"></timer>
  53. <timer start="20"></timer>
  54. </timetable>
  55. ```
  56. 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.
  57. ### Performant and predictable
  58. - Absolutely the smallest possible amount of DOM updates and reflows.
  59. - Fast expressions bindings instead of virtual DOM memory performance issues and drawbacks.
  60. - One way data flow: updates and unmounts are propagated downwards from parent to children.
  61. - No "magic" or "smart" reactive properties or hooks
  62. - Expressions are pre-compiled and cached for high performance.
  63. - Lifecycle methods for more control.
  64. ### Close to standards
  65. - No proprietary event system.
  66. - Future proof thanks to the javascript module syntax.
  67. - The rendered DOM can be freely manipulated with other tools.
  68. - No extra HTML root elements, `data-` attributes or fancy custom attributes.
  69. - No new syntax to learn.
  70. - Plays well with any frontend framework.
  71. ### Use your dearest language and tools
  72. - Create components with CoffeeScript, Jade, LiveScript, Typescript, ES6 or [any pre-processor](https://riot.js.org/compiler/#pre-processors) you want.
  73. - Build with [@riotjs/cli](https://github.com/riot/cli), [webpack](https://github.com/riot/webpack-loader), [Rollup](https://github.com/riot/rollup-plugin-riot), [parcel](https://github.com/riot/parcel-plugin-riot), [Browserify](https://github.com/riot/riotify).
  74. - Test with however you like, you can [load your riot tags directly in node](https://github.com/riot/ssr#render---to-render-only-markup)
  75. ### Powerful and modular ecosystem
  76. The Riot.js ecosystem is completely modular, it's designed to let you pick only the stuff you really need:
  77. - [@riotjs/cli](https://github.com/riot/cli) - CLI to compile locally your tags to javascript
  78. - [@riotjs/ssr](https://github.com/riot/ssr) - Super simple server side rendering
  79. - [@riotjs/hydrate](https://github.com/riot/hydrate) - Hydration strategy for your SPA
  80. - [@riotjs/route](https://github.com/riot/route) - Isomorphic router
  81. - [@riotjs/hot-reload](https://github.com/riot/hot-reload) - Live reload plugin
  82. - [@riotjs/compiler](https://github.com/riot/compiler) - Advanced tags compiler
  83. - [@riotjs/parser](https://github.com/riot/parser) - HTML parser
  84. - [@riotjs/dom-bindings](https://github.com/riot/dom-bindings) - Expressions based template engine
  85. - [@riotjs/now](https://github.com/riot/now) - https://zeit.co/ now integration
  86. - [@riotjs/custom-elements](https://github.com/riot/custom-elements) - native custom elements implementation
  87. ### CDN hosting
  88. - [unpkg](https://unpkg.com/riot/riot.js)
  89. - [jsDelivr](https://www.jsdelivr.com/projects/riot)
  90. - [cdnjs](https://cdnjs.com/libraries/riot)
  91. ### How to contribute
  92. 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.
  93. If you want to contribute to riot helping the project maintenance please check first the list of [open issues](https://github.com/riot/riot/issues) to understand whether there is a task where you could help.
  94. 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](Makefile). If you are on a Microsoft machine it could be harder to set up you development environment properly.
  95. Following the steps below you should be able to properly submit your patch to the project
  96. #### 1) Clone the repo and browse to the riot folder
  97. ```shell
  98. $ git clone git@github.com:riot/riot.git && cd riot
  99. ```
  100. #### 2) Set up your git branch
  101. ```shell
  102. $ git checkout -b feature/my-awesome-patch
  103. ```
  104. #### 3) Install the npm dependencies
  105. ```shell
  106. $ npm i
  107. ```
  108. #### 4) Build and test riot using the Makefile
  109. ```shell
  110. # To build and test riot
  111. $ make riot
  112. # To build without testing
  113. $ make raw
  114. ```
  115. #### 5) Pull request only against the `dev` branch making sure you have read [our pull request template](.github/PULL_REQUEST_TEMPLATE.md)
  116. #### 6) Be patient
  117. ### Credits
  118. Riot is actively maintained with :heart: by:
  119. <table>
  120. <tbody>
  121. <tr>
  122. <td valign="top">
  123. <img width="125" height="125" src="https://github.com/GianlucaGuarini.png?s=125?s=125">
  124. <br>
  125. <a href="https://github.com/GianlucaGuarini">Gianluca Guarini</a>
  126. </td>
  127. </tr>
  128. </tbody>
  129. </table>
  130. Many thanks to all smart people from all over the world who helped improving it.
  131. ## Official Website
  132. https://riot.js.org
  133. ## Backers
  134. Support us with a monthly donation and help us continue our activities. [Become a backer][support-url]
  135. [![Backers][backers-image]][support-url]
  136. ## Sponsors
  137. Become a sponsor to get your logo on our README. [Become a sponsor][support-url]
  138. [![Sponsors][sponsors-image]][support-url]
  139. ## Thanks
  140. Special thanks to Browserstack for their support
  141. <a href='https://www.browserstack.com/'>
  142. <img width='70px' src="https://cdn.worldvectorlogo.com/logos/browserstack.svg" alt="browser stack">
  143. </a>
  144. [travis-image]:https://img.shields.io/travis/riot/riot.svg?style=flat-square
  145. [travis-url]:https://travis-ci.org/riot/riot
  146. [license-image]:https://img.shields.io/badge/license-MIT-000000.svg?style=flat-square
  147. [license-url]:LICENSE.txt
  148. [npm-version-image]:https://img.shields.io/npm/v/riot.svg?style=flat-square
  149. [npm-downloads-image]:https://img.shields.io/npm/dm/riot.svg?style=flat-square
  150. [npm-url]:https://npmjs.org/package/riot
  151. [coverage-image]:https://img.shields.io/coveralls/riot/riot/dev.svg?style=flat-square
  152. [coverage-url]:https://coveralls.io/r/riot/riot?branch=dev
  153. [saucelabs-image]:https://saucelabs.com/browser-matrix/testsriotjs.svg?1
  154. [saucelabs-url]:https://saucelabs.com/u/testsriotjs
  155. [gitter-image]:https://img.shields.io/badge/GITTER-JOIN_CHAT_%E2%86%92-1dce73.svg?style=flat-square
  156. [gitter-url]:https://gitter.im/riot/riot?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
  157. [discord-url]:https://discord.gg/PagXe5Y
  158. [discord-image]:https://img.shields.io/badge/DISCORD-JOIN_CHANNEL_%E2%86%92-7289da.svg?style=flat-square
  159. [slack-ja-image]:https://img.shields.io/badge/SLACK_(ja)-JOIN_CHAT_%E2%86%92-551a8b.svg?style=flat-square
  160. [slack-ja-url]:https://riot-jp-slackin.herokuapp.com/
  161. [codeclimate-image]:https://api.codeclimate.com/v1/badges/b81ddf3c77e8189876da/maintainability
  162. [codeclimate-url]:https://codeclimate.com/github/riot/riot
  163. [donations-campaign-url]:https://pledgie.com/campaigns/31139
  164. [donations-campaign-image]:https://pledgie.com/campaigns/31139.png?skin_name=chrome
  165. [jsdelivr-image]: https://data.jsdelivr.com/v1/package/npm/riot/badge
  166. [jsdelivr-url]: https://www.jsdelivr.com/package/npm/riot
  167. [backer-url]: #backers
  168. [backer-badge]: https://opencollective.com/riot/backers/badge.svg?color=blue
  169. [sponsor-url]: #sponsors
  170. [sponsor-badge]: https://opencollective.com/riot/sponsors/badge.svg?color=blue
  171. [support-url]: https://opencollective.com/riot#support
  172. [lib-size]: https://img.badgesize.io/https://unpkg.com/riot/riot.min.js?compression=gzip
  173. [backers-image]: https://opencollective.com/riot/backers.svg
  174. [sponsors-image]: https://opencollective.com/riot/sponsors.svg