1
0
mirror of https://github.com/jaandrle/deka-dom-el synced 2025-04-02 20:15:53 +02:00
Jan Andrle 4366027658
dde and docs improvements (#27)
*  🎉

*  wip

* 🔤

*  wip

*  wip

*  Refatc signals to .get/.set syntax #26

* 🐛 Better types for on*

* 🔤

* 🔤

* 🐛 coumputed signal

* 🔤  Docs UI/UX

*  🔤 UI enhancements

*  (bs) (un)min

* 🔤 adds debugging

* 🔤 ssr

* 🔤

*  bs/lint

* 🔤

* 🔤 UI

* 🔤 updates texts

* 🔤UI

*  dispatch

* 🔤 events

* 🔤 elements

* 🔤 intro

* 🐛 fixes completitions for el with components

* 🐛 wrong file(s) in git

* 🔤 logo

* 🐛 🔤 types 3ps

* 🔤 ui/ux

* 🔤

* 🔤

* 🔤 scopes

* 🔤

* 🔤 ui/ux

* 🔤

*  issignal

* 🔤 improvemens

*  irelands

* 🔤 UI/UX/wording

* 🐛 npx-hint

[Scrollable region must have keyboard access | Axe Rules | Deque University | Deque Systems](https://dequeuniversity.com/rules/axe/4.10/scrollable-region-focusable?application=axeAPI)

* 🔤 logos

*  better? dts builds

* Update README.md
2025-03-07 14:40:45 +01:00
2025-03-07 14:40:45 +01:00
2025-03-07 14:40:45 +01:00
2025-03-07 14:40:45 +01:00
2025-03-07 14:40:45 +01:00
2025-03-07 14:40:45 +01:00
2025-03-07 14:40:45 +01:00
2025-03-07 14:40:45 +01:00
2025-03-07 14:40:45 +01:00
2023-08-22 16:29:37 +02:00
2025-03-07 14:40:45 +01:00
2025-03-07 14:40:45 +01:00
2025-03-07 14:40:45 +01:00
2025-03-07 14:40:45 +01:00
2025-03-07 14:40:45 +01:00

WIP (the experimentation phase) | source code on GitHub | mirrored on Gitea

Deka DOM Elements Logo

Deka DOM Elements

Vanilla for flavouring — a full-fledged feast for large projects

…use simple DOM API by default and library tools and logic when you need them

// 🌟 Reactive component with clear separation of concerns
document.body.append(
	el(EmojiCounter, { initial: "🚀" })
);

function EmojiCounter({ initial }) {
	// ✨ State - Define reactive data
	const count = S(0);
	const emoji = S(initial);

	/** @param {HTMLOptionElement} el */
	const isSelected= el=> (el.selected= el.value===initial);
	
	// 🔄 View - UI updates automatically when signals change
	return el().append(
	el("p", {
		className: "output",
		textContent: S(() =>
		`Hello World ${emoji.get().repeat(clicks.get())}`),
	}),
	
	// 🎮 Controls - Update state on events
	el("button", { textContent: "Add Emoji" },
		on("click", () => count.set(count.get() + 1))
	),
	
	el("select", null, on("change", e => emoji.set(e.target.value)))
	.append(
		el(Option, "🎉", isSelected),
		el(Option, "🚀", isSelected),
		el(Option, "💖", isSelected),
	)
	);
}
function Option({ textContent }){
	return el("option", { value: textContent, textContent });
}

Creating reactive elements, components, and Web Components using the native IDL/JavaScript DOM API enhanced with signals/observables.

Features at a Glance

  • No build step required — use directly in browsers or Node.js
  • ☑️ Lightweight — ~10-15kB minified (original goal 10kB) with zero/minimal dependencies
  • Declarative & functional approach for clean, maintainable code
  • Optional signals with support for custom reactive implementations
  • Server-side rendering support via jsdom
  • 🔄 TypeScript support (work in progress)
  • 🔄 Enhanced Web Components support (work in progress)

Why Another Library?

This library bridges the gap between minimal solutions like van/hyperscript and more comprehensive frameworks like solid-js, offering a balanced trade-off between size, complexity, and usability.

Following functional programming principles, Deka DOM Elements starts with pure JavaScript (DOM API) and gradually adds auxiliary functions. These range from minor improvements to advanced features for building complete declarative reactive UI templates.

A key advantage: any internal function (assign, classListDeclarative, on, dispatchEvent, S, etc.) can be used independently while also working seamlessly together. This modular approach makes it easier to integrate the library into existing projects.

Getting Started

Installation

npm

# TBD
# npm install deka-dom-el

Direct Script

<script src="https://cdn.jsdelivr.net/gh/jaandrle/deka-dom-el/dist/dde-with-signals.min.js"></script>
<script type="module">
	const { el, S } = dde;
</script>

Documentation

Understanding Signals

Signals are the reactive backbone of Deka DOM Elements:

Inspiration and Alternatives

Description
A library expanding the capabilities of the native DOM API with the aim of offering the possibility of writing reactive UI templates/components declaratively directly in JavaScript.
https://jaandrle.github.io/deka-dom-el/ Readme MIT 8.1 MiB
Languages
JavaScript 99.4%
Shell 0.6%