1. Home
  2. /
  3. Riot-js
  4. /
  5. Riot.js Full Featured Counter

Riot.js Full Featured Counter - Riot-js Typing CST Test

Loading…

Riot.js Full Featured Counter — Riot-js Code

Combines step increment, max limit, auto-reset, history, auto-increment, and theme toggle.

<full-counter>
	<h2>Counter: {state.count}</h2>
	<div>History: {state.history.join(', ')}</div>
	<button onclick={() => { let n=state.count+state.step; if(n>state.max)n=0; state.count=n; state.history.push('Increment'); }}>+</button>
	<button onclick={() => { state.count-=state.step; state.history.push('Decrement'); }}>-</button>
	<button onclick={() => { state.count=0; state.history.push('Reset'); }}>Reset</button>
	<button onclick={() => state.isDark=!state.isDark}>Toggle Theme</button>

	<script>
		export default {
		state: { count: 0, history: [], isDark: false, step: 2, max: 10 },
		onMounted() {
		setInterval(() => { let n=state.count+state.step; if(n>state.max)n=0; state.count=n; state.history.push('Auto Increment'); }, 1000);
		}
		}
	</script>
</full-counter>

Riot-js Language Guide

Riot.js is a lightweight, client-side JavaScript framework for building web applications with a component-based architecture. It combines simple syntax, a virtual DOM, and reactive data binding to create maintainable, modular UI components.

Primary Use Cases

  • ▸Single-page applications
  • ▸Component libraries
  • ▸Dashboards and admin panels
  • ▸Interactive UI widgets
  • ▸Rapid prototyping with clean, modular code

Notable Features

  • ▸Small and lightweight (~10 KB gzipped)
  • ▸Component-based design
  • ▸Virtual DOM for efficient rendering
  • ▸Reactive state management
  • ▸Simple, declarative syntax

Origin & Creator

Created by Muut and first released in 2014.

Industrial Note

Riot.js is ideal for developers seeking minimalistic, performant frameworks for modular web apps without the overhead of larger frameworks like React or Angular.

More Riot-js Typing Exercises

Riot.js Counter ComponentRiot.js Counter with Step IncrementRiot.js Counter with Max LimitRiot.js Counter with Auto-ResetRiot.js Counter with HistoryRiot.js Counter with Dark Mode OnlyRiot.js Counter with Auto-IncrementRiot.js Counter with Conditional Theme

Practice Other Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypher