
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
Jay is a lean and lightweight framework that puts the control and creativity of traditional web development with modular and scalable component architecture.
A lightweight, modular web-component library built in TypeScript. Jay manages rendering, styling, HTTP requests, and component lifecycle so you can focus on HTML, CSS, and behavior.
Via npm
npm install --save-dev jay-comp webpack webpack-cli
Via Git
git clone https://github.com/Taghunter98/jay-comps.git
cd jay-comps
npm install
npx tsc
Ensure your package.json includes:
{
"type": "module",
}
index.js
import { Comp } from "jay-comp";
import "./helloworld.js"; // Your custom components
webpack.config.cjs
const path = require("path");
module.exports = {
entry: "./index.js",
mode: "development",
output: {
filename: "bundle.js",
path: path.resolve(__dirname, "dist")
}
};
After building:
npx webpack
Include in your HTML:
<script type="module" src="./dist/bundle.js"></script>
helloworld.js
import { Comp } from "jay-comp";
class HelloWorld extends Comp {
greeting_;
beforeRender() {
this.greeting_ = "Hello Jay!";
}
createHTML() {
return `<h1 class="heading">${this.greeting_}</h1>`;
}
createCSS() {
return {
class: "heading",
colour: "#142985",
padding: [20, 40],
fontSizePt: 48,
media: {
maxWidthBp: 600,
fontSizePt: 24,
padding: [8, 16]
}
};
}
afterRender() {
this.query("h1")
.addEventListener("click", () => alert("This is my first Jay Component!"));
}
static { Comp.register(this); }
}
index.js
import { Comp } from "jay-comp";
import "./helloworld.js";
index.html
<!DOCTYPE html>
<html>
<body>
<comp-hello-world></comp-hello-world>
<script type="module" src="./dist/bundle.js"></script>
</body>
</html>
Open index.html to see your component in action.
Comp is Jay’s base class. It handles:
render()createCSS()createHTML(), createCSS(), hook())request(), submitForm())Constructor
render()render()
createHTML() and createCSS() into shadow roothook()hook()
createHTML(): stringDefine your component’s inner markup:
createHTML() {
return `<div class="container">${this.content_}</div>`;
}
createCSS(): stringDefine scoped styles via the CSS compiler:
createCSS() {
return this.css({
class: "container",
display: "flex",
padding: [10, 15],
media: {
maxWidthBp: 600,
flexDirction: "column"
}
});
}
beforeRender(): voidRun before-render logic:
beforeRender() {
if (!this.greeting_) this.greeting_ = "Hello World!"
}
afterRender(): voidRun post-render logic:
afterRender() {
this.shadowRoot
.querySelector(".container")
.addEventListener("click", () => console.log("Clicked!"));
}
static register(componentClass): voidRegisters the Comp as a custom element.
Class names convert to kebab-case and prefix comp-:
static { Comp.register(this); }
// MyButtonComp -> <comp-my-button-comp>
update(html?: string, css?: string): voidRe-render markup and/or styles at runtime:
set title(text) {
this.title_ = text;
this.update(); // Re-runs createHTML/createCSS
}
getById(id: string): HTMLElement | nullReturns an element from the Shadow DOM by its ID. Automatically strips a leading # if present.
// Lookup without '#'
const btn = this.getById<HTMLButtonElement>('submitBtn');
btn?.addEventListener('click', () => console.log('Clicked'));
// Lookup with '#'
const input = this.getById<HTMLInputElement>('#usernameInput');
if (input) input.value = 'alice';
query(sel: string): Element | nullSelects the first element matching a given CSS selector.
// Select an active list item
const item = this.query<HTMLLIElement>('ul > li.active');
// Select an input by attribute
const email = this.query<HTMLInputElement>('input[name="email"]');
queryAll(sel: string): NodeListOf<Element>Selects all elements matching a given CSS selector. Returns a live NodeList, even if no matches are found.
// Style all active items
const items = this.queryAll<HTMLLIElement>('ul > li.active');
items.forEach(li => li.style.color = 'red');
// Disable all buttons in the shadow DOM
const buttons = this.queryAll<HTMLButtonElement>('button');
buttons.forEach(btn => btn.disabled = true);
css(config: CSSConfig): stringCompiles a single config object into scoped CSS. Supports a wide range of suffix-based operators:
Bp keyword for defining breakpoints.Examples
A basic box layout:
const config1 = {
class: "box",
display: "flex",
flexDirection: "column",
padding: 10,
opacity: 0.8
};
console.log(this.css(config1));
Using arrays, percent, and media:
const config2 = {
class: "container",
colour: "white",
border: ["solid", 2, "black"],
borderRadius: [4, 8],
widthPercent: 75,
media: {
maxWidthBp: 600,
padding: [16, 32]
}
};
console.log(this.css(config2));
Pseudo-class:
const config3 = {
class: "btn",
backgroundVar: "blue100",
pseudoClass: "hover"
};
console.log(this.css(config3));
| Operator | CSS Output | Example Config | Compiled CSS Snippet |
|---|---|---|---|
| (default number) | px appended (except 0) | margin: 16 | margin: 16px; |
| Percent | % | widthPercent: 50 | width: 50%; |
| Var | var(--…) | colorVar: "blue100" | color: var(--blue100); |
| Url | url(...) | backgroundImageUrl: "hero.jpg" | background-image: url(hero.jpg); |
| Calc | calc(...) | widthCalc: "100% - 32px" | width: calc(100% - 32px); |
| Em / Rem | em / rem | paddingEm: 1.5, marginRem: 2 | padding: 1.5em;, margin: 2rem; |
| Vw / Vh / Vmin / Vmax | viewport units | heightVh: 80, gapVmax: 2 | height: 80vh;, gap: 2vmax; |
| Ch / Ex | character-based units | textIndentCh: 2, fontSizeEx: 1 | text-indent: 2ch;, font-size: 1ex; |
| Pt / Pc | print-based units | fontSizePt: 12 | font-size: 12pt; |
| In / Cm / Mm / Q | absolute/metric lengths | widthCm: 10, borderQ: 4 | width: 10cm;, border: 4q; |
| Fr | grid fraction | gridTemplateColumnsFr: [1,2] | grid-template-columns: 1fr 2fr; |
| S / Ms | time units | transitionDurationS: 0.3, delayMs: 200 | transition-duration: 0.3s;, delay: 200ms; |
| Deg / Rad / Grad / Turn | angle units | rotateDeg: 45, skewRad: 0.5 | transform: rotate(45deg);, skew(0.5rad); |
| Dpi / Dpcm / Dppx | resolution units | resolutionDpi: 300 | resolution: 300dpi; |
| Hz / KHz | frequency | audioRateHz: 60, signalKHz: 2.4 | audio-rate: 60Hz;, signal: 2.4kHz; |
| Raw strings / Keywords | passed through as-is | display: "flex" | display: flex; |
| Array shorthand | space-separated values | padding: [8,16] | padding: 8px 16px; |
| pseudoClass | pseudo-selector suffix | pseudoClass: "hover" | .my-class:hover { … } |
Breakpoint operator (Bp suffix) | media query header | media: { maxWidthBp: 600 } | @media (max-width: 600px) { … } |
request<T>(url: string, method: "GET"|"POST", data?: object): Promise<ApiResponse<T>>Perform JSON fetch with error handling.
// GET
const usersResp = await this.request<User[]>("/api/users", "GET");
if (usersResp.ok) {
console.log("Got users:", usersResp.data);
} else {
console.error("Fetch users failed:", usersResp.status, usersResp.error);
}
// POST
const loginResp = await this.request<{ token: string }>("/api/login", "POST",{ user: "alice", pass: "s3cret" });
if (loginResp.ok) {
console.log("JWT =", loginResp.data.token);
} else {
console.error("Login error:", loginResp.status, loginResp.error);
}
submitForm<T>(url: string, data: HTMLFormElement|FormData|object): Promise<ApiResponse<T>>Send multipart/form-data for uploads.
// 1) HTMLFormElement
const form = document.querySelector("form#profile")!;
const res1 = await this.submitForm<{ success: boolean }>(
"/api/profile", form
);
// 2) FormData
const fd = new FormData();
fd.append("avatar", fileInput.files[0]);
const res2 = await this.submitForm<{ url: string }>(
"/api/upload", fd
);
// 3) Plain object
const data = { name: "Alice", age: 30, newsletter: true };
const res3 = await this.submitForm<{ status: "ok" }>(
"/api/subscribe", data
);
Jay is licensed under the Apache 2.0 License. Contributions are welcome!
For issues or feedback, please open an issue or email the maintainer.
FAQs
Jay is a lean and lightweight framework that puts the control and creativity of traditional web development with modular and scalable component architecture.
The npm package jay-comp receives a total of 1 weekly downloads. As such, jay-comp popularity was classified as not popular.
We found that jay-comp demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.