NUCLO / 12

भाषा

Practical examples। Live demos।

कोई example चुनिए और फ़ुल-स्क्रीन में खोलिए: live preview और source code साथ-साथ।

Components

4

Static और dynamic params, children, identity से match होने वाली lists और nested data, सब plain functions से। हर preview अपने mounts गिनता है।

05

Static और dynamic params

value वाला param component बनते समय बस एक बार पढ़ा जाता है। function वाला param हर update() पर दोबारा पढ़ा जाता है। दोनों ही case में component खुद सिर्फ़ एक बार चलता है, जिसे mount counter से verify कर सकते हैं।

Components
06

Child nodes और modifiers

component spread करके अपने children आगे पास करता है: builders, text, attribute objects और modifiers। conditional हिस्से when() के अंदर रहते हैं, इसलिए उन्हें wrap करने वाला component दोबारा नहीं बनता।

Components
07

List में object identity

list() किसी row को तब तक रखता है जब तक उसका item array में है। input या focus खोए बिना reorder, add और rename कीजिए। switch दिखाता है कि हर update पर objects clone करने से identity टूटने की कीमत क्या है।

Components
08

Nested data

members और उनके tasks वाली team: हर level पर एक component, nested list() calls और उन्हीं objects से function के ज़रिए निकाले गए counters। deep changes सिर्फ़ अपने nodes को patch करते हैं।

Components

API

13

हर building block के लिए एक छोटा demo, वही जो docs में भी दिखते हैं।

09

Tag builders

builder में attributes, static children और dynamic text पास होते हैं। Rename state बदलकर update() call करता है।

API
10

Components

component बस एक सादा function है। हर Counter() call का अपना अलग counter होता है।

API
11

Attributes

attribute की value function भी हो सकती है। दूसरा बटन busy बदलकर update() call करता है, और Save के disabled और aria-busy उसी के हिसाब से बदल जाते हैं।

API
12

Events

onInput और onKeyDown आम attributes ही हैं। कुछ टाइप कीजिए और clear करने के लिए Esc key दबाइए।

API
13

Lifecycle

onMount interval शुरू करता है और उसका cleanup function return करता है। unmount होते ही cleanup चलता है, इसलिए दोबारा mount होने तक timer की गिनती रुकी रहती है।

API
14

Explicit updates

count++ सिर्फ़ variable बदलता है। text तब update होता है जब इस बटन या पेज की किसी और activity से अगला update() चलता है।

API
15

Dynamic values

नाम बदलिए। static text element बनते समय ही तय हो गया था, जबकि dynamic text हर update() पर दोबारा चलता है। forceUpdate() पूरा tree दोबारा बनाता है, इसलिए static text भी update हो जाता है।

API
16

update()

हर update() सारी dynamic values चला देता है, चाहे उनका data बदला हो या नहीं। इस पेज के बाकी demos भी counter बढ़ाते हैं।

API
17

scope()

दोनों बटन cart में item जोड़ते हैं और user का नाम बदलते हैं। update('cart') सिर्फ़ उसी scope का panel update करता है।

API
18

when()

पहली true condition चुनी जाती है, और कोई भी true न हो तो .else() render होता है। नई branch शुरू से बनती है।

API
19

list()

rows object identity से match होती हैं। किसी row पर check लगाइए, फिर Reverse दबाइए: checkbox समेत वही <li> अपनी जगह से खिसकता है।

API
20

region() और into()

stacked main region और side region वाला layout बाहर से भरा जाता है। Home में कुछ लिखिए, dialog खोलकर बंद कीजिए: text वैसा ही रहता है। Article एक ही into() से दोनों regions भर देता है।

API
21

forceUpdate()

update() सिर्फ़ dynamic lang वाली line update करता है। forceUpdate() App को दोबारा call करके उसी <h1> को patch करता है। यानी explicit form सिर्फ़ इसी tree को दोबारा बनाता है, पूरे पेज को नहीं।

API

SVG

27

SVG tag builders से बने charts, animations, tools और games, जो plain data, pointer events और update() से चलते हैं।

28

Bar chart

array से बने rect। उनके y और height data के functions हैं, इसलिए update() bars को खिसका देता है।

SVG
29

Line chart

points से बना d वाला एक path, साथ में gradient से भरा area और हर point के लिए एक circle।

SVG
30

Donut chart

हर slice के लिए एक circle। stroke-dasharray उसे ring में उसका हिस्सा देता है और stroke-dashoffset तय करता है कि वह कहाँ से शुरू होगा।

SVG
31

SVG animation

SMIL के builders: animateSvg सूरज को धड़कता हुआ effect देता है और animateTransformSvg ग्रह को उसकी orbit में घुमाता है। dynamic dur speed तय करता है।

SVG
32

Gauge

stroke-dashoffset से भरता arc और CSS transform से घूमती सुई। दोनों एक ही number के functions हैं।

SVG
33

Radar chart

पाँच axes पर पाँच values। shape एक path है जिसका d data से calculate होता है, इसलिए update() उसका आकार बदल देता है।

SVG
34

Heatmap

rect का grid, जिनका fill-opacity एक level के हिसाब से बदलता है। level बढ़ाने के लिए cell पर click कीजिए। titleSvg child उसका tooltip है।

SVG
35

Hover tooltip

SVG elements पर pointer events। onPointerEnter active point चुनता है और tooltip का group खिसककर उसके पास पहुँच जाता है।

SVG
36

Curve editor

cubic Bézier curve के handles drag कीजिए। onPointerDown point चुनता है, svg का onPointerMove उसे खिसकाता है और path उसी के हिसाब से बदलता है।

SVG
37

घड़ी

सुइयाँ lines हैं जिनका transform समय का function है। onMount घड़ी शुरू करता है और cleanup return करता है।

SVG
38

Icon toggles

CSS transition से cross में बदलता menu icon, और click पर शुरू होने वाले SMIL animation से उभरता दिल।

SVG
39

Live stream

timer पर दो data series बाईं ओर scroll होती हैं। एक tick जितनी duration का CSS transition motion को smooth बना देता है। किसी sample की value देखने के लिए hover कीजिए।

SVG
40

Candlestick chart

चालीस slots अपनी-अपनी candle का data पढ़ते हैं। timeframe बदलिए, average दिखाइए या छुपाइए, values देखने के लिए hover कीजिए, या live candle को update होते देखिए।

SVG
41

Bar chart race

दस bars हमेशा DOM में रहते हैं। उनकी rank translateY तय करती है, इसलिए values बदलने पर transition हर bar को उसकी row तक खिसका देता है।

SVG
42

Stacked area chart

चार stacked bands, stream और percent layout के बीच अपना आकार बदलते हैं। series छुपाने पर उसके band की thickness बस zero हो जाती है, इसलिए हर path के commands का structure वही रहता है।

SVG
43

Treemap

square जैसे boxes वाला layout जिसमें groups खोलकर अंदर जा सकते हैं। metric बदलने पर हर cell अपनी नई जगह पर खिसक जाता है, और group पर click करने पर उसके children दिखने लगते हैं।

SVG
44

Live histogram

चार distributions से लगातार samples आते रहते हैं। हर बदलाव पर bin counts दोबारा निकलते हैं, fitted bell curve mean के हिसाब से बदलता है और slider bins की संख्या तय करता है।

SVG
45

Drawing pad

pointer events से polyline बनाइए। list() हर stroke के लिए एक polyline render करता है। जो stroke बन रहा है वह हर update() पर लंबा होता जाता है।

SVG
46

Rotary knob

custom slider: pointer का angle value तय करता है, arrow keys उसे एक-एक step बदलती हैं और pathLength="100" value को stroke की लंबाई में बदल देता है।

SVG
47

Color wheel

angle से hue और center से दूरी के हिसाब से saturation चुनिए। नब्बे wedges, एक radial gradient और एक dark disc मिलकर wheel बनाते हैं।

SVG
48

Spirograph

पहिया ring के अंदर घूमता है और pen उसका path बनाता है। हर frame एक stroke को थोड़ा लंबा करता है और सिर्फ़ अपना scope() update करता है।

SVG
49

उछलती गेंदें

requestAnimationFrame loop में gravity, walls और collisions। गेंद उछालने के लिए पीछे खींचकर छोड़ दीजिए।

SVG
50

Gooey blobs

blur और color matrix filter से blobs आपस में घुल जाते हैं। circles की लड़ी pointer के पीछे-पीछे चलती है।

SVG
51

Force graph

nodes एक-दूसरे को धकेलते हैं, links खींचते हैं और layout धीरे-धीरे शांत होकर थम जाता है। nodes drag कीजिए, या नया child जोड़ने के लिए उस पर click कीजिए।

SVG
52

Brush और zoom

ऊपर वाले chart को zoom करने के लिए overview में एक range चुनिए। brush के हिसाब से बदलने वाला clipPath चुने हुए हिस्से को रंग देता है।

SVG
53

टिक-टैक-टो

computer के साथ खेलिए। when() हर mark जोड़ता है और उसके stroke का CSS animation उसे बनते हुए दिखाता है।

SVG
54

Circular text

badge के लिए text लिखिए। textPath उसे circle पर मोड़ता है और textLength उसे ठीक एक चक्कर में fit कर देता है।

SVG

Routing

6

Route tables, matching, active route, layers और loaders। nuclo-router एक अलग package है: npm install nuclo nuclo-router.

55

Routing वाला app

frame के अंदर अपने router के साथ चलता app: route table, एक outlet(), सादे links, pending state और 404। links खोलिए, फिर browser का back button इस्तेमाल कीजिए।

Routing+ nuclo-router
56

Nested routes

Docs एक layout है जिसके child routes हैं। topic उसके outlet() में render होता है और ./topic links layout के route के relative resolve होते हैं। notes लिखिए, फिर topic बदलिए: layout दोबारा नहीं बनता।

Routing+ nuclo-router
57

Route loader

post page एक load() export करता है जो page बनने से पहले चलता है। wait के दौरान router.pending देखिए। loader किसी टूटी post पर throw करे, तो Retry के साथ error state देखिए।

Routing+ nuclo-router
58

Layers

order form customer का page layer की तरह push करता है और उसके result का wait करता है। form दोबारा render नहीं होता, इसलिए उसके notes बचे रहते हैं। Save push को resolve करता है, और Cancel या back button उसे dismiss कर देता है।

Routing+ nuclo-router
59

कई routers और loading

दो routers, दो spinners। shop के layout और उसके section, दोनों में load() हैं, और दोनों एक ही router.pending के नीचे parallel चलते हैं। sidebar का अलग router बनता है लेकिन start नहीं होता। उसका अपना loading flag onNavigate से refresh होता है।

Routing+ nuclo-router
60

Pattern matching

static, :param और *rest patterns, साथ में दो parents के नीचे लगी एक section table। path लिखकर match() देखिए: यह कुछ भी load किए बिना match करता है।

Routing+ nuclo-router

Apps

15

बड़े फ़ुल-स्क्रीन programs, tabs में उनके असली source के साथ: windows वाला desktop, data grid, chat, games, editors और ऐसी libraries जो अपना state खुद संभालती हैं।

61

Page builder

सीधे page पर लिखिए। blocks का order बदलने या उन्हें layout में ले जाने के लिए grip drag कीजिए। नया block जोड़ने के लिए / दबाइए और actions के लिए right-click कीजिए। grid और flex layouts को style कीजिए, changes undo कीजिए, phone size में preview देखिए और HTML export कीजिए।

Apps
62

Algorithm stepper

engine सादा JavaScript है: generators array बदलते हैं और हर step के बाद yield करते हैं। player next() और update() call करता है। bars उन्हीं objects पर एक list() हैं, इसलिए swap सिर्फ़ दो elements को खिसकाता है।

Apps
63

Kanban board

team का board: tasks जोड़िए, लोगों को assign कीजिए, dialog में edit कीजिए, person या search से filter कीजिए, columns के बीच drag कीजिए और delete को undo कीजिए। columns और cards उन्हीं objects के सादे arrays हैं, और हर move एक splice() है। rows identity से match होती हैं, इसलिए card को drag, sort, assign या edit करने पर उसका element reuse होता है। screen पर mount count इसे verify करता है।

Apps
64

three.js inspector

ऐसी library जिसका अपना state है। panel position, color और flags सीधे three.js objects से पढ़ता है और edits भी उन्हीं पर वापस लिखता है। render loop हर frame में एक बार update() call करता है, और state की कोई अलग copy नहीं रखी जाती।

Apps
65

Infinite scroll

बिना अंत वाला feed: तेज़ fake fetch() हर नया page बनाकर एक सादे array में जोड़ता है। DOM में सिर्फ़ viewport के पास की rows रहती हैं: list() दो spacers के बीच posts.slice(start, end) render करता है, इसलिए एक लाख posts पर भी page हल्का रहता है। असली अंत पर लगा sentinel दिखने से पहले ही अगला page माँग लेता है।

Apps
66

Desktop

files, notes, terminal, calculator, timer, kanban board, finance app और calendar वाला चलता-फिरता desktop। browser में save होने वाली shared simulated disk पर folders बनाइए और organize कीजिए, notes edit कीजिए और shell commands चलाइए। calculator में सीधे keyboard से टाइप कीजिए, input पर focus करने के लिए terminal में कहीं भी click कीजिए, board पर columns के बीच cards drag कीजिए, या finance spreadsheet में हिसाब रखिए और chart बदलते देखिए। हिसाब IndexedDB में रहता है। app की windows खिसकाने, resize करने या app बदलने पर उनका state बना रहता है। चलता हुआ timer into() से taskbar tray भरता है।

Apps
67

Node graph

numbers, text और switches को math, comparison और If nodes से जोड़िए। टाइप करते ही हर value update होती है। functions भी graphs हैं: उनके Input और Output nodes हर Call के ports हैं। Call अपने ही function को भी call कर सकता है, इसलिए factorial और sum recursion से चलते हैं और If रुकने की condition देता है। engine सादा JavaScript है: हर node एक generator है जो input माँगने के लिए yield करता है। एक loop अपने stack से उन्हें चलाता है, इसलिए sum(50000) JavaScript call stack इस्तेमाल किए बिना लगभग एक सेकंड के दसवें हिस्से में पचास हज़ार calls की depth तक पहुँच जाता है। रुकने की condition न हो, तो recursion को सिर्फ़ steps की limit रोकती है। drag करने पर x और y बदलते हैं और सिर्फ़ canvas scope update होता है। run count दिखाता है कि node खिसकाने से graph नहीं चलता।

Apps
68

Data grid

10,000 सादे row objects पर बनी एक पूरी तरह काम करने वाली table। search, filter, sort और paging array पर सादे functions हैं। table body मौजूदा page पर एक list() है। identity से match होने की वजह से sorting page पर बची rows को खिसकाती है, और edit की हुई row हर जगह वही object रहती है। बनी हुई rows की गिनती इसे verify करती है।

Apps
69

Chat

तीन channels वाली chat। हर channel एक सादा object है: history, cursor, typing state, draft और scroll position। channel बदलने पर सब जस का तस रहता है, और update("chat-sidebar") सिर्फ़ unread messages के badges refresh करता है। unshift() से पुरानी history ऊपर load होती रहती है और scrollTop उतना बढ़ता है जितनी height जुड़ी। message server तक पहुँचने से पहले ही दिख जाता है। send() उसी object को patch करता है, और Retry, Edit, Delete और reactions उसकी row दोबारा नहीं बनाते। messages में code, bold text, links और @mentions दिखते हैं।

Apps
70

Live dashboard

cards अलग-अलग rate पर refresh होते हैं: 20 बार प्रति सेकंड से लेकर एक बार तक। हर card एक scope() है और उसका timer उसी card की id के साथ update() call करता है, इसलिए हर tick सिर्फ़ उसी card की values चलाता है। screen पर हर dynamic value के चलने की गिनती दिखती है। सादे update() पर switch कीजिए: घड़ी की value एक बार बदलने के लिए प्रति सेकंड लगभग सौ बार calculation होती है।

Apps
71

Pixel editor

image रंग बताने वाली 1024 strings का एक सादा array है। हर cell उसी से अपना रंग पढ़ता है। stroke array बदलता है और update() call करता है। stroke पूरा होने पर editor slice() से एक copy रख लेता है। undo, redo और history (वह भी एक list() है) का हर step पुराना array वापस रख देता है: न store, न immutable data।

Apps
72

Snake

game loop एक timer है जो सादे objects पर step() और हर tick पर एक बार update() call करता है। साँप अपने cell objects की list() है। हर tick पर पूँछ का object नया सिर बन जाता है, इसलिए एक element खिसकता है और नया नहीं बनता। बने segments की गिनती साँप के खाना खाने पर ही बढ़ती है। खाना keyframes() animation से उभरता है।

Apps
73

Step sequencer

अपनी घड़ी वाली library। Web Audio अपनी timeline पर हर note पहले से schedule करता है। pattern booleans का सादा 2D array है, जिसे grid toggle करता है और scheduler पढ़ता है, इसलिए click का असर अगली बार सुनाई देता है। जो step सुनाई दे रहा है वह बदलने पर playhead सिर्फ़ अपना scope() update करता है। पहली बार Play दबाने पर audio शुरू होता है और mount cleanup में बंद होता है, इसलिए example छोड़ते ही आवाज़ रुक जाती है।

Apps
74

Locale switcher

एक भाषा वाले app की तरह हर label एक static value है, इसलिए update() उसे दोबारा नहीं पढ़ता। cart पर click करने से सिर्फ़ quantity और total update होते हैं। भाषा बदलने पर इस tree का forceUpdate() चलता है, जो components दोबारा चलाकर उन्हीं elements को patch करता है, lang और dir समेत। currency, plurals, dates और lists Intl से format होते हैं। भाषा बदलने पर cart और टाइप किया हुआ coupon बने रहते हैं।

Apps
75

Theme editor

छोटी component library: createCss() tokens को नाम देता है और variants() उनसे buttons, badges, cards, inputs, alerts और switches बनाता है। tokens CSS variables हैं, इसलिए हर class एक बार compile होती है। हर control एक सादा theme object बदलता है और update() call करता है, जो एक style element का text दोबारा लिख देता है।

Apps