Skip to content

anubra266/ripple-jsx

Repository files navigation

Ripple JSX

JSX Runtime for Ripple JS

🎯 Usage Examples

Basic Element

const element = jsx('div', {
	className: 'greeting',
	children: 'Hello World!',
});
mount(element, { target: container });

With Event Handlers

const button = jsx('button', {
	onClick: () => alert('Clicked!'),
	className: 'btn',
	children: 'Click me',
});

Nested Elements

const component = jsx('div', {
	children: [
		jsx('h1', { children: 'Title' }),
		jsx('p', { children: 'Content' }),
		jsx('ul', {
			children: [jsx('li', { children: 'Item 1' }), jsx('li', { children: 'Item 2' })],
		}),
	],
});

SVG Elements

const svg = jsx('svg', {
	width: '100',
	height: '100',
	children: jsx('circle', {
		cx: '50',
		cy: '50',
		r: '40',
		fill: 'blue',
	}),
});

Fragment

const fragment = Fragment({
	children: [jsx('h1', { children: 'Title' }), jsx('p', { children: 'Content' }), 'Raw text'],
});

🔧 Setup for TypeScript/Babel

TypeScript (tsconfig.json)

{
	"compilerOptions": {
		"jsx": "react-jsx",
		"jsxImportSource": "ripple/jsx-runtime-custom"
	}
}

Babel (.babelrc)

{
	"presets": [
		[
			"@babel/preset-react",
			{
				"runtime": "automatic",
				"importSource": "ripple/jsx-runtime-custom"
			}
		]
	]
}

About

Runtime JSX for ripple js

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors