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.

250 lines
8.9 KiB

5 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/hot-reload](https://github.com/riot/hot-reload) - Live reload plugin
  81. - [@riotjs/compiler](https://github.com/riot/compiler) - Advanced tags compiler
  82. - [@riotjs/parser](https://github.com/riot/parser) - HTML parser
  83. - [@riotjs/dom-bindings](https://github.com/riot/dom-bindings) - Expressions based template engine
  84. - [@riotjs/now](https://github.com/riot/now) - https://zeit.co/ now integration
  85. - [@riotjs/custom-elements](https://github.com/riot/custom-elements) - native custom elements implementation
  86. ### CDN hosting
  87. - [unpkg](https://unpkg.com/riot/riot.js)
  88. - [jsDelivr](https://www.jsdelivr.com/projects/riot)
  89. - [cdnjs](https://cdnjs.com/libraries/riot)
  90. ### How to contribute
  91. 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.
  92. 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.
  93. 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.
  94. Following the steps below you should be able to properly submit your patch to the project
  95. #### 1) Clone the repo and browse to the riot folder
  96. ```shell
  97. $ git clone git@github.com:riot/riot.git && cd riot
  98. ```
  99. #### 2) Set up your git branch
  100. ```shell
  101. $ git checkout -b feature/my-awesome-patch
  102. ```
  103. #### 3) Install the npm dependencies
  104. ```shell
  105. $ npm i
  106. ```
  107. #### 4) Build and test riot using the Makefile
  108. ```shell
  109. # To build and test riot
  110. $ make riot
  111. # To build without testing
  112. $ make raw
  113. ```
  114. #### 5) Pull request only against the `dev` branch making sure you have read [our pull request template](.github/PULL_REQUEST_TEMPLATE.md)
  115. #### 6) Be patient
  116. ### Credits
  117. Riot is actively maintained with :heart: by:
  118. <table>
  119. <tbody>
  120. <tr>
  121. <td valign="top">
  122. <img width="125" height="125" src="https://github.com/GianlucaGuarini.png?s=125?s=125">
  123. <br>
  124. <a href="https://github.com/GianlucaGuarini">Gianluca Guarini</a>
  125. </td>
  126. </tr>
  127. </tbody>
  128. </table>
  129. Many thanks to all smart people from all over the world who helped improving it.
  130. ## Official Website
  131. https://riot.js.org
  132. ## Backers
  133. Support us with a monthly donation and help us continue our activities. [Become a backer][support-url]
  134. [![Backers][backers-image]][support-url]
  135. ## Sponsors
  136. Become a sponsor to get your logo on our README. [Become a sponsor][support-url]
  137. [![Sponsors][sponsors-image]][support-url]
  138. ## Thanks
  139. Special thanks to Browserstack for their support
  140. <a href='https://www.browserstack.com/'>
  141. <img width='70px' src="https://cdn.worldvectorlogo.com/logos/browserstack.svg" alt="browser stack">
  142. </a>
  143. [travis-image]:https://img.shields.io/travis/riot/riot.svg?style=flat-square
  144. [travis-url]:https://travis-ci.org/riot/riot
  145. [license-image]:https://img.shields.io/badge/license-MIT-000000.svg?style=flat-square
  146. [license-url]:LICENSE.txt
  147. [npm-version-image]:https://img.shields.io/npm/v/riot.svg?style=flat-square
  148. [npm-downloads-image]:https://img.shields.io/npm/dm/riot.svg?style=flat-square
  149. [npm-url]:https://npmjs.org/package/riot
  150. [coverage-image]:https://img.shields.io/coveralls/riot/riot/dev.svg?style=flat-square
  151. [coverage-url]:https://coveralls.io/r/riot/riot?branch=dev
  152. [saucelabs-image]:https://saucelabs.com/browser-matrix/testsriotjs.svg?1
  153. [saucelabs-url]:https://saucelabs.com/u/testsriotjs
  154. [gitter-image]:https://img.shields.io/badge/GITTER-JOIN_CHAT_%E2%86%92-1dce73.svg?style=flat-square
  155. [gitter-url]:https://gitter.im/riot/riot?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
  156. [discord-url]:https://discord.gg/PagXe5Y
  157. [discord-image]:https://img.shields.io/badge/DISCORD-JOIN_CHANNEL_%E2%86%92-7289da.svg?style=flat-square
  158. [slack-ja-image]:https://img.shields.io/badge/SLACK_(ja)-JOIN_CHAT_%E2%86%92-551a8b.svg?style=flat-square
  159. [slack-ja-url]:https://riot-jp-slackin.herokuapp.com/
  160. [codeclimate-image]:https://api.codeclimate.com/v1/badges/b81ddf3c77e8189876da/maintainability
  161. [codeclimate-url]:https://codeclimate.com/github/riot/riot
  162. [donations-campaign-url]:https://pledgie.com/campaigns/31139
  163. [donations-campaign-image]:https://pledgie.com/campaigns/31139.png?skin_name=chrome
  164. [jsdelivr-image]: https://data.jsdelivr.com/v1/package/npm/riot/badge
  165. [jsdelivr-url]: https://www.jsdelivr.com/package/npm/riot
  166. [backer-url]: #backers
  167. [backer-badge]: https://opencollective.com/riot/backers/badge.svg?color=blue
  168. [sponsor-url]: #sponsors
  169. [sponsor-badge]: https://opencollective.com/riot/sponsors/badge.svg?color=blue
  170. [support-url]: https://opencollective.com/riot#support
  171. [lib-size]: https://img.badgesize.io/https://unpkg.com/riot/riot.min.js?compression=gzip
  172. [backers-image]: https://opencollective.com/riot/backers.svg
  173. [sponsors-image]: https://opencollective.com/riot/sponsors.svg