yeapjs / yeap Goto Github PK
View Code? Open in Web Editor NEWA magicless UI builder
License: MIT License
A magicless UI builder
License: MIT License
At the moment, to create a computed value you do to use createComputed
, try to authorize to use functions as compute in the context of yeap (HTML attribute, HTML element/text node generation) but keep function in props components and events.
import { createReactor, createComputed } from "yeap/app"
function Foo () {
const count = createReactor(0)
const count2 = createComputed(() =>count() * 2, count)
const count3 = () =>count() * 3 // usable also in the attributes
return (
<div>
<p>{count}</p>
<p>{count} * 2 = {count2}</p>
<p>{count} * 3 = {count3}</p>
<button onClick={() => count((count) =>count + 1)}>+</button>
</div>
)
}
import { createReactor } from "yeap/app"
import { define } from "yeap/web"
function MyCounter ({ start = 0, ref: element }) {
const count = createReactor(start)
return (
<div>
<p>{count}</p>
<button onClick={() => count((count) =>count + 1)}>+</button>
</div>
)
}
MyCounter.attributeTypes = {
start: Number // auto cast to number
/* cast function, use .compute if is a reactiveAttributes
start(el, v){
return +v
}
*/
}
define("my-counter", MyCounter, {
reactiveAttributes: [],
shadowed: "closed"
})
Describe the bug
After the first render call, the web component create with Yeap doesn't work
import { array, isComponent } from "yeap/children"
function App(_, c){
return array(c).filter((child) =>
isComponent(child)
)
}
In the style attribute, the styles in camelCase are ignored
function Foo() {
return (
<div
style={{
"background-color": "red", // work
backgroundColor: "blue", // keep it red
}}
>Hi !</div>
);
}
Describe the bug
when an array is update with a .map or other it does anything
Describe the bug
onMounted and onUnmounted are called only with a when
prop.
import { createEventModifier } from "yeap/app"
createEventModifier("hello", (event) =>{
console.log("hello")
})
function App(){
return <div onClick:hello={[foo, 0]}>bar</div>
}
import { createDirective } from "yeap/app"
createDirective("hello", (el, value) =>{
console.log("hello")
})
function App(){
return <div use:hello={0}>foo</div>
}
Describe the bug
When I create a component
// App.js
<Logo/>
// Logo.jsx
export const Logo = () => (
<svg width="512" height="512" viewBox="0 0 512 512" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M62.9907 92.792C57.2414 72.9029 77.5932 55.5076 96.2364 64.3758L422.326 219.49C438.013 226.953 440.798 248.178 427.573 259.482L202.045 452.249C188.82 463.553 168.389 457.409 163.552 440.673L62.9907 92.792Z" fill="#59CAFC"/>
<circle cx="72" cy="72" r="48" fill="#FF6E83" />
<path d="M278.196 87.7179C284.311 73.5143 300.783 66.9571 314.986 73.0719L410.51 114.196C424.714 120.311 431.271 136.783 425.156 150.986L384.032 246.51C377.917 260.714 361.445 267.271 347.242 261.156L251.718 220.032C237.514 213.917 230.957 197.445 237.072 183.242L278.196 87.7179Z" fill="#BEA4FF" />
<path d="M170.175 340.252C185.838 326.145 210.882 333.75 216.057 354.184L245.169 469.147C250.519 490.274 230.745 509.145 209.891 502.812L92.6579 467.215C71.8038 460.882 65.8605 434.202 82.0549 419.617L170.175 340.252Z" fill="#FFB636" />
</svg>
)
The method toFixed on number make an error (perhaps other native method on primitive types).
function Foo() {
const a = createReactor(5.11111);
return (
// Make the error
<div>{a.toFixed(2)}</div>
);
}
Allow to access to the Runtime Loop inside yeap with the internal function requestRuntimeCallback
and cancelRuntimeCallback
.
Describe the bug
too many DOM updates when a reactor is updated
Example
const a = createReactor(0)
// dom connection...
a(a => a+1) // dom update
a(a => a+1) // dom update
a(a => a+1) // dom update
a(a => a+1) // dom update
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.