jQuire
jQuery UI Reciter
This is not a serious project. It's just me fooling around with JavaScript.
Do not recommend using this for any kind of work.
Imports
import { $, _, _self, _parent, _parents } from "./index.js"
Create a component
const HelloWorld = () => [
_.world ??= "World",
$.slot[_.name="main"],
$.text["Hello " + _self.world]
]
$.add({ HelloWorld })
Rendering Content
$.render[
_.tag = document.body,
$.div[
_.Mark = 120,
$.HelloWorld[
_.world = "earth",
$.div[
_.slot = "main",
_.onclick = evt => console.log(_parents(this).mark),
$.text["🎉"+_parents.mark]
]
]
],
$.form[
_.name = "my-form",
_.onsubmit = evt => {
evt.preventDefault()
console.log("submitted")
},
$.input[_.type = "text"],
$.button[
_.type = "submit",
$.text["submit"]
]
]
]
HTML Attributes vs Data Attributes
_.type = "text"
_.Type = "text"
_.sayGreetings = "hi"
All the attributes inside of a component are treated as data attributes regardless of the case.
Data Accessors
There are three types of data access proxy objects:
- _self - access a data attribute on the current element
- _parent - access a data attribute on the immediate parent element
- _parents - access a data attribute on any one of the parent elements, including itself
$.div[
_.grandParentName = "Janice Doe"
$.div[
_.parentName = "Jane Doe"
$.span[
_.Name = "John Doe",
$.text["Hi" + _self.name],
_.onclick = evt => console.log(_self(this).name)
],
$.br[_],
$.span[
$.text["Your parent is " + _parent.parentName], $.br[_]
$.text["Your grandparent is " + _parents.grandParentName]
]
]
]
What about CSS??
Works just like normal css; no scoped styles yet :( but it's on the horizon!
$.style[`
:root {
font-size: 16px;
font-family: Roboto;
}
body {
background-color: lightgrey;
}
header {
display: grid;
justify-items: center;
align-items: center;
}
h1 {
margin: 0;
}
`]