• Townie
    AI
  • Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
project logo

Teddy2100

EnhancedVNode

Public
Like
EnhancedVNode
Home
Code
3
README.md
logo.svg
vnode.js
Branches
1
Pull requests
Remixes
History
Environment variables
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
Code
/
Search
README.md

EnhancedVNode

A minimalist, plugin-ready hyperscript-style utility for rendering elements with style normalization, class processing, and custom behavioral plugins. Compatible with React, Preact, or any functionally similar createElement.

✨ Features

  • 🧱 Lightweight functional interface: const h = new EnhancedVNode(createElement)
  • 🎨 Normalizes class strings into Set and filters empty entries
  • 🎛️ Parses inline style into clean JS objects
  • 🧩 Plugin system for custom props, dynamic logic, or design tokens
  • 🎯 Renderer-agnostic: bring your own createElement

📦 Installation

This utility is framework-neutral. Just copy the source file into your project and wire it up:

Create val
import { createElement } from "preact"; // or import from react import EnhancedVNode from "./EnhancedVNode.js"; const h = new EnhancedVNode(createElement);

🛠️ Usage

Create val
h.plugin(props => { if (props.bg) { props.classList.add(`bg-${props.bg}`); delete props.bg; } }); const vnode = h("div", { class: "box padded", style: "color: red; padding: 1rem;", bg: "blue" });

The resulting vnode will have:

  • Normalized class string: "box padded bg-blue"
  • Inlined style converted into a class (via GooberJS)
  • Plugins applied and props cleaned up

🔌 Plugins

Plugins are just functions that receive and mutate the props object before rendering:

Create val
h.plugin(props => { if (props.opacity) { props.styleObject.opacity = parseFloat(props.opacity); delete props.opacity; } });

You can add as many as you'd like. They run sequentially.

🔍 Utilities

Create val
h.toStyleObject("color: red; padding: 1rem;") // ➜ { color: "red", padding: "1rem" }

🧪 Example Setup

Create val
import { createElement } from "preact"; import EnhancedVNode from "./EnhancedVNode.js"; const h = new EnhancedNVode(createElement); h.plugin(props => { if (props.rounded) { props.classList.add("rounded"); delete props.rounded; } }); export default h;

🧠 Philosophy

This utility embraces composability, readability, and framework flexibility. By abstracting common patterns around class and style handling, EnhancedVNode helps you build declarative UIs without tying you to one ecosystem.

Code
README.mdlogo.svgvnode.js
FeaturesVersion controlCode intelligenceCLI
Use cases
TeamsAI agentsSlackGTM
DocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Open Source Pledge
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.